OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/disassembler.h" | 5 #include "src/disassembler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 EmbeddedVector<char, 128> v8_buffer_; | 35 EmbeddedVector<char, 128> v8_buffer_; |
36 }; | 36 }; |
37 | 37 |
38 | 38 |
39 const char* V8NameConverter::NameOfAddress(byte* pc) const { | 39 const char* V8NameConverter::NameOfAddress(byte* pc) const { |
40 const char* name = | 40 const char* name = |
41 code_ == NULL ? NULL : code_->GetIsolate()->builtins()->Lookup(pc); | 41 code_ == NULL ? NULL : code_->GetIsolate()->builtins()->Lookup(pc); |
42 | 42 |
43 if (name != NULL) { | 43 if (name != NULL) { |
44 SNPrintF(v8_buffer_, "%s (%p)", name, static_cast<void*>(pc)); | 44 SNPrintF(v8_buffer_, "%p (%s)", static_cast<void*>(pc), name); |
45 return v8_buffer_.start(); | 45 return v8_buffer_.start(); |
46 } | 46 } |
47 | 47 |
48 if (code_ != NULL) { | 48 if (code_ != NULL) { |
49 int offs = static_cast<int>(pc - code_->instruction_start()); | 49 int offs = static_cast<int>(pc - code_->instruction_start()); |
50 // print as code offset, if it seems reasonable | 50 // print as code offset, if it seems reasonable |
51 if (0 <= offs && offs < code_->instruction_size()) { | 51 if (0 <= offs && offs < code_->instruction_size()) { |
52 SNPrintF(v8_buffer_, "%d (%p)", offs, static_cast<void*>(pc)); | 52 SNPrintF(v8_buffer_, "%p <+0x%x>", static_cast<void*>(pc), offs); |
53 return v8_buffer_.start(); | 53 return v8_buffer_.start(); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 return disasm::NameConverter::NameOfAddress(pc); | 57 return disasm::NameConverter::NameOfAddress(pc); |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 const char* V8NameConverter::NameInCode(byte* addr) const { | 61 const char* V8NameConverter::NameInCode(byte* addr) const { |
62 // The V8NameConverter is used for well known code, so we can "safely" | 62 // The V8NameConverter is used for well known code, so we can "safely" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 // Comments. | 147 // Comments. |
148 for (int i = 0; i < comments.length(); i++) { | 148 for (int i = 0; i < comments.length(); i++) { |
149 out.AddFormatted(" %s", comments[i]); | 149 out.AddFormatted(" %s", comments[i]); |
150 DumpBuffer(os, &out); | 150 DumpBuffer(os, &out); |
151 } | 151 } |
152 | 152 |
153 // Instruction address and instruction offset. | 153 // Instruction address and instruction offset. |
154 out.AddFormatted("%p %4" V8PRIdPTRDIFF " ", static_cast<void*>(prev_pc), | 154 out.AddFormatted("%p %4" V8PRIxPTRDIFF " ", static_cast<void*>(prev_pc), |
155 prev_pc - begin); | 155 prev_pc - begin); |
156 | 156 |
157 // Instruction. | 157 // Instruction. |
158 out.AddFormatted("%s", decode_buffer.start()); | 158 out.AddFormatted("%s", decode_buffer.start()); |
159 | 159 |
160 // Print all the reloc info for this instruction which are not comments. | 160 // Print all the reloc info for this instruction which are not comments. |
161 for (int i = 0; i < pcs.length(); i++) { | 161 for (int i = 0; i < pcs.length(); i++) { |
162 // Put together the reloc info | 162 // Put together the reloc info |
163 RelocInfo relocinfo(pcs[i], rmodes[i], datas[i], converter.code()); | 163 RelocInfo relocinfo(pcs[i], rmodes[i], datas[i], converter.code()); |
164 | 164 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, | 283 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, |
284 byte* end, Code* code) { | 284 byte* end, Code* code) { |
285 return 0; | 285 return 0; |
286 } | 286 } |
287 | 287 |
288 #endif // ENABLE_DISASSEMBLER | 288 #endif // ENABLE_DISASSEMBLER |
289 | 289 |
290 } // namespace internal | 290 } // namespace internal |
291 } // namespace v8 | 291 } // namespace v8 |
OLD | NEW |