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