OLD | NEW |
1 /* Copyright (c) 2007, Google Inc. | 1 /* Copyright (c) 2007, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 18 matching lines...) Expand all Loading... |
29 * | 29 * |
30 * --- | 30 * --- |
31 * Author: Joi Sigurdsson | 31 * Author: Joi Sigurdsson |
32 * | 32 * |
33 * Definition of MiniDisassembler. | 33 * Definition of MiniDisassembler. |
34 */ | 34 */ |
35 | 35 |
36 #ifndef GOOGLE_PERFTOOLS_MINI_DISASSEMBLER_H_ | 36 #ifndef GOOGLE_PERFTOOLS_MINI_DISASSEMBLER_H_ |
37 #define GOOGLE_PERFTOOLS_MINI_DISASSEMBLER_H_ | 37 #define GOOGLE_PERFTOOLS_MINI_DISASSEMBLER_H_ |
38 | 38 |
39 #include "config.h" | |
40 #include <windows.h> | 39 #include <windows.h> |
41 #include "mini_disassembler_types.h" | 40 #include "mini_disassembler_types.h" |
42 | 41 |
43 // compatibility shim | 42 // compatibility shim |
44 #include "base/logging.h" | 43 #include "base/logging.h" |
45 #define SIDESTEP_ASSERT(cond) RAW_DCHECK(cond, #cond) | 44 #define SIDESTEP_ASSERT(cond) RAW_DCHECK(cond, #cond) |
46 #define SIDESTEP_LOG(msg) RAW_VLOG(1, msg) | 45 #define SIDESTEP_LOG(msg) RAW_VLOG(1, msg) |
47 | 46 |
48 namespace sidestep { | 47 namespace sidestep { |
49 | 48 |
(...skipping 18 matching lines...) Expand all Loading... |
68 // already has enough instructions to replace with the absolute jump | 67 // already has enough instructions to replace with the absolute jump |
69 // to the patching code. | 68 // to the patching code. |
70 // | 69 // |
71 // The usage is quite simple; just create a MiniDisassembler and use its | 70 // The usage is quite simple; just create a MiniDisassembler and use its |
72 // Disassemble() method. | 71 // Disassemble() method. |
73 // | 72 // |
74 // If you would like to extend this disassembler, please refer to the | 73 // If you would like to extend this disassembler, please refer to the |
75 // IA-32 Intel® Architecture Software Developers Manual Volume 2: | 74 // IA-32 Intel® Architecture Software Developers Manual Volume 2: |
76 // Instruction Set Reference for information about operand decoding | 75 // Instruction Set Reference for information about operand decoding |
77 // etc. | 76 // etc. |
78 class PERFTOOLS_DLL_DECL MiniDisassembler { | 77 class MiniDisassembler { |
79 public: | 78 public: |
80 | 79 |
81 // Creates a new instance and sets defaults. | 80 // Creates a new instance and sets defaults. |
82 // | 81 // |
83 // @param operand_default_32_bits If true, the default operand size is | 82 // @param operand_default_32_bits If true, the default operand size is |
84 // set to 32 bits, which is the default under Win32. Otherwise it is 16 bits. | 83 // set to 32 bits, which is the default under Win32. Otherwise it is 16 bits. |
85 // @param address_default_32_bits If true, the default address size is | 84 // @param address_default_32_bits If true, the default address size is |
86 // set to 32 bits, which is the default under Win32. Otherwise it is 16 bits. | 85 // set to 32 bits, which is the default under Win32. Otherwise it is 16 bits. |
87 MiniDisassembler(bool operand_default_32_bits, | 86 MiniDisassembler(bool operand_default_32_bits, |
88 bool address_default_32_bits); | 87 bool address_default_32_bits); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 158 |
160 // Default operand size is 32 bits if true, 16 bits if false. | 159 // Default operand size is 32 bits if true, 16 bits if false. |
161 bool operand_default_is_32_bits_; | 160 bool operand_default_is_32_bits_; |
162 | 161 |
163 // Current address size is 32 bits if true, 16 bits if false. | 162 // Current address size is 32 bits if true, 16 bits if false. |
164 bool address_is_32_bits_; | 163 bool address_is_32_bits_; |
165 | 164 |
166 // Default address size is 32 bits if true, 16 bits if false. | 165 // Default address size is 32 bits if true, 16 bits if false. |
167 bool address_default_is_32_bits_; | 166 bool address_default_is_32_bits_; |
168 | 167 |
169 // Determines if 64 bit operands are supported (x64). | |
170 bool operand_default_support_64_bits_; | |
171 | |
172 // Current operand size is 64 bits if true, 32 bits if false. | |
173 bool operand_is_64_bits_; | |
174 | |
175 // Huge big opcode table based on the IA-32 manual, defined | 168 // Huge big opcode table based on the IA-32 manual, defined |
176 // in Ia32OpcodeMap.cc | 169 // in Ia32OpcodeMap.cc |
177 static const OpcodeTable s_ia32_opcode_map_[]; | 170 static const OpcodeTable s_ia32_opcode_map_[]; |
178 | 171 |
179 // Somewhat smaller table to help with decoding ModR/M bytes | 172 // Somewhat smaller table to help with decoding ModR/M bytes |
180 // when 16-bit addressing mode is being used. Defined in | 173 // when 16-bit addressing mode is being used. Defined in |
181 // Ia32ModrmMap.cc | 174 // Ia32ModrmMap.cc |
182 static const ModrmEntry s_ia16_modrm_map_[]; | 175 static const ModrmEntry s_ia16_modrm_map_[]; |
183 | 176 |
184 // Somewhat smaller table to help with decoding ModR/M bytes | 177 // Somewhat smaller table to help with decoding ModR/M bytes |
185 // when 32-bit addressing mode is being used. Defined in | 178 // when 32-bit addressing mode is being used. Defined in |
186 // Ia32ModrmMap.cc | 179 // Ia32ModrmMap.cc |
187 static const ModrmEntry s_ia32_modrm_map_[]; | 180 static const ModrmEntry s_ia32_modrm_map_[]; |
188 | 181 |
189 // Indicators of whether we got certain prefixes that certain | 182 // Indicators of whether we got certain prefixes that certain |
190 // silly Intel instructions depend on in nonstandard ways for | 183 // silly Intel instructions depend on in nonstandard ways for |
191 // their behaviors. | 184 // their behaviors. |
192 bool got_f2_prefix_, got_f3_prefix_, got_66_prefix_; | 185 bool got_f2_prefix_, got_f3_prefix_, got_66_prefix_; |
193 }; | 186 }; |
194 | 187 |
195 }; // namespace sidestep | 188 }; // namespace sidestep |
196 | 189 |
197 #endif // GOOGLE_PERFTOOLS_MINI_DISASSEMBLER_H_ | 190 #endif // GOOGLE_PERFTOOLS_MINI_DISASSEMBLER_H_ |
OLD | NEW |