| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 // A Disassembler object is used to disassemble a block of code instruction by | 28 // A Disassembler object is used to disassemble a block of code instruction by |
| 29 // instruction. The default implementation of the NameConverter object can be | 29 // instruction. The default implementation of the NameConverter object can be |
| 30 // overriden to modify register names or to do symbol lookup on addresses. | 30 // overriden to modify register names or to do symbol lookup on addresses. |
| 31 // | 31 // |
| 32 // The example below will disassemble a block of code and print it to stdout. | 32 // The example below will disassemble a block of code and print it to stdout. |
| 33 // | 33 // |
| 34 // NameConverter converter; | 34 // NameConverter converter; |
| 35 // Disassembler d(converter); | 35 // Disassembler d(converter); |
| 36 // for (byte* pc = begin; pc < end;) { | 36 // for (byte* pc = begin; pc < end;) { |
| 37 // char buffer[128]; | 37 // v8::internal::EmbeddedVector<char, 256> buffer; |
| 38 // buffer[0] = '\0'; | |
| 39 // byte* prev_pc = pc; | 38 // byte* prev_pc = pc; |
| 40 // pc += d.InstructionDecode(buffer, sizeof buffer, pc); | 39 // pc += d.InstructionDecode(buffer, pc); |
| 41 // printf("%p %08x %s\n", | 40 // printf("%p %08x %s\n", |
| 42 // prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer); | 41 // prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer); |
| 43 // } | 42 // } |
| 44 // | 43 // |
| 45 // The Disassembler class also has a convenience method to disassemble a block | 44 // The Disassembler class also has a convenience method to disassemble a block |
| 46 // of code into a FILE*, meaning that the above functionality could also be | 45 // of code into a FILE*, meaning that the above functionality could also be |
| 47 // achieved by just calling Disassembler::Disassemble(stdout, begin, end); | 46 // achieved by just calling Disassembler::Disassemble(stdout, begin, end); |
| 48 | 47 |
| 49 | 48 |
| 50 #include <assert.h> | 49 #include <assert.h> |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 buffer[0] = '\0'; | 1302 buffer[0] = '\0'; |
| 1304 byte* prev_pc = pc; | 1303 byte* prev_pc = pc; |
| 1305 pc += d.InstructionDecode(buffer, pc); | 1304 pc += d.InstructionDecode(buffer, pc); |
| 1306 fprintf(f, "%p %08x %s\n", | 1305 fprintf(f, "%p %08x %s\n", |
| 1307 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1306 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
| 1308 } | 1307 } |
| 1309 } | 1308 } |
| 1310 | 1309 |
| 1311 | 1310 |
| 1312 } // namespace disasm | 1311 } // namespace disasm |
| OLD | NEW |