blob: b03b2af391bda092e98c90a23b94e81f43d3b319 [file] [log] [blame]
Sean Callanan95e5c632012-02-17 00:53:45 +00001//===-- DisassemblerLLVMC.cpp -----------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "DisassemblerLLVMC.h"
11
12#include "llvm-c/Disassembler.h"
13#include "llvm/Support/TargetSelect.h"
14
15#include "lldb/Core/Address.h"
16#include "lldb/Core/DataExtractor.h"
17#include "lldb/Core/Stream.h"
18#include "lldb/Symbol/SymbolContext.h"
19#include "lldb/Target/ExecutionContext.h"
20#include "lldb/Target/Process.h"
21#include "lldb/Target/RegisterContext.h"
22#include "lldb/Target/Target.h"
23#include "lldb/Target/StackFrame.h"
24
25#include <regex.h>
26
27using namespace lldb;
28using namespace lldb_private;
29
30class InstructionLLVMC : public lldb_private::Instruction
31{
32public:
33 InstructionLLVMC (DisassemblerLLVMC &disasm,
34 const lldb_private::Address &address,
Greg Claytonc8e0c242012-04-13 00:07:34 +000035 AddressClass addr_class) :
Sean Callanan95e5c632012-02-17 00:53:45 +000036 Instruction(address, addr_class),
Sean Callanan95e5c632012-02-17 00:53:45 +000037 m_is_valid(false),
Bill Wendlinge6eeef02012-04-06 00:09:59 +000038 m_disasm(disasm),
Sean Callanan7e6d4e52012-08-01 18:50:59 +000039 m_disasm_sp(disasm.shared_from_this()),
Sean Callanan7725a462012-03-02 23:22:53 +000040 m_does_branch(eLazyBoolCalculate)
Sean Callanan95e5c632012-02-17 00:53:45 +000041 {
42 }
43
44 virtual
45 ~InstructionLLVMC ()
46 {
47 }
48
49 static void
50 PadToWidth (lldb_private::StreamString &ss,
51 int new_width)
52 {
53 int old_width = ss.GetSize();
54
55 if (old_width < new_width)
56 {
57 ss.Printf("%*s", new_width - old_width, "");
58 }
59 }
Sean Callanan95e5c632012-02-17 00:53:45 +000060
Sean Callanan95e5c632012-02-17 00:53:45 +000061 virtual bool
62 DoesBranch () const
63 {
Sean Callanan7725a462012-03-02 23:22:53 +000064 return m_does_branch == eLazyBoolYes;
Sean Callanan95e5c632012-02-17 00:53:45 +000065 }
66
67 virtual size_t
68 Decode (const lldb_private::Disassembler &disassembler,
69 const lldb_private::DataExtractor &data,
70 uint32_t data_offset)
71 {
Greg Claytonba812f42012-05-10 02:52:23 +000072 // All we have to do is read the opcode which can be easy for some
73 // architetures
74 bool got_op = false;
75 const ArchSpec &arch = m_disasm.GetArchitecture();
Sean Callanan95e5c632012-02-17 00:53:45 +000076
Greg Claytonba812f42012-05-10 02:52:23 +000077 const uint32_t min_op_byte_size = arch.GetMinimumOpcodeByteSize();
78 const uint32_t max_op_byte_size = arch.GetMaximumOpcodeByteSize();
79 if (min_op_byte_size == max_op_byte_size)
80 {
81 // Fixed size instructions, just read that amount of data.
82 if (!data.ValidOffsetForDataOfSize(data_offset, min_op_byte_size))
83 return false;
84
85 switch (min_op_byte_size)
86 {
87 case 1:
88 m_opcode.SetOpcode8 (data.GetU8 (&data_offset));
89 got_op = true;
90 break;
91
92 case 2:
93 m_opcode.SetOpcode16 (data.GetU16 (&data_offset));
94 got_op = true;
95 break;
96
97 case 4:
98 m_opcode.SetOpcode32 (data.GetU32 (&data_offset));
99 got_op = true;
100 break;
101
102 case 8:
103 m_opcode.SetOpcode64 (data.GetU64 (&data_offset));
104 got_op = true;
105 break;
106
107 default:
108 m_opcode.SetOpcodeBytes(data.PeekData(data_offset, min_op_byte_size), min_op_byte_size);
109 got_op = true;
110 break;
111 }
112 }
113 if (!got_op)
114 {
115 ::LLVMDisasmContextRef disasm_context = m_disasm.m_disasm_context;
116
117 bool is_altnernate_isa = false;
118 if (m_disasm.m_alternate_disasm_context)
119 {
120 const AddressClass address_class = GetAddressClass ();
121
122 if (address_class == eAddressClassCodeAlternateISA)
123 {
124 disasm_context = m_disasm.m_alternate_disasm_context;
125 is_altnernate_isa = true;
126 }
127 }
128 const llvm::Triple::ArchType machine = arch.GetMachine();
129 if (machine == llvm::Triple::arm || machine == llvm::Triple::thumb)
130 {
131 if (machine == llvm::Triple::thumb || is_altnernate_isa)
132 {
Sean Callanan5c97c2f2012-08-06 23:42:52 +0000133 uint16_t thumb_opcode = data.GetU16(&data_offset);
Greg Claytonba812f42012-05-10 02:52:23 +0000134 if ((thumb_opcode & 0xe000) != 0xe000 || ((thumb_opcode & 0x1800u) == 0))
135 {
136 m_opcode.SetOpcode16 (thumb_opcode);
Sean Callanan5c97c2f2012-08-06 23:42:52 +0000137 m_is_valid = true;
Greg Claytonba812f42012-05-10 02:52:23 +0000138 }
139 else
140 {
Sean Callanan5c97c2f2012-08-06 23:42:52 +0000141 data_offset -= 2;
142 m_opcode.SetOpcode16_2 (data.GetU32(&data_offset));
Greg Claytonba812f42012-05-10 02:52:23 +0000143 m_is_valid = true;
144 }
145 }
146 else
147 {
148 m_opcode.SetOpcode32 (data.GetU32(&data_offset));
Sean Callanan5c97c2f2012-08-06 23:42:52 +0000149 m_is_valid = true;
Greg Claytonba812f42012-05-10 02:52:23 +0000150 }
151 }
152 else
153 {
154 // The opcode isn't evenly sized, so we need to actually use the llvm
155 // disassembler to parse it and get the size.
156 char out_string[512];
157 m_disasm.Lock(this, NULL);
158 uint8_t *opcode_data = const_cast<uint8_t *>(data.PeekData (data_offset, 1));
159 const size_t opcode_data_len = data.GetByteSize() - data_offset;
160 const addr_t pc = m_address.GetFileAddress();
161 const size_t inst_size = ::LLVMDisasmInstruction (disasm_context,
162 opcode_data,
163 opcode_data_len,
164 pc, // PC value
165 out_string,
166 sizeof(out_string));
167 // The address lookup function could have caused us to fill in our comment
168 m_comment.clear();
169 m_disasm.Unlock();
170 if (inst_size == 0)
171 m_opcode.Clear();
172 else
173 {
174 m_opcode.SetOpcodeBytes(opcode_data, inst_size);
175 m_is_valid = true;
176 }
177 }
178 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000179 return m_opcode.GetByteSize();
180 }
181
182 void
Greg Claytonba812f42012-05-10 02:52:23 +0000183 AppendComment (std::string &description)
Sean Callanan95e5c632012-02-17 00:53:45 +0000184 {
Greg Claytonba812f42012-05-10 02:52:23 +0000185 if (m_comment.empty())
186 m_comment.swap (description);
Sean Callanan95e5c632012-02-17 00:53:45 +0000187 else
Greg Claytonba812f42012-05-10 02:52:23 +0000188 {
189 m_comment.append(", ");
190 m_comment.append(description);
191 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000192 }
193
194 virtual void
Greg Claytonba812f42012-05-10 02:52:23 +0000195 CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext *exe_ctx)
Sean Callanan95e5c632012-02-17 00:53:45 +0000196 {
Greg Claytonba812f42012-05-10 02:52:23 +0000197 DataExtractor data;
198 const AddressClass address_class = GetAddressClass ();
199
200 if (m_opcode.GetData(data, address_class))
201 {
202 char out_string[512];
203
204 ::LLVMDisasmContextRef disasm_context;
205
206 if (address_class == eAddressClassCodeAlternateISA)
207 disasm_context = m_disasm.m_alternate_disasm_context;
208 else
209 disasm_context = m_disasm.m_disasm_context;
210
211 lldb::addr_t pc = LLDB_INVALID_ADDRESS;
212
213 if (exe_ctx)
214 {
215 Target *target = exe_ctx->GetTargetPtr();
216 if (target)
217 pc = m_address.GetLoadAddress(target);
218 }
219
220 if (pc == LLDB_INVALID_ADDRESS)
221 pc = m_address.GetFileAddress();
222
223 m_disasm.Lock(this, exe_ctx);
224 uint8_t *opcode_data = const_cast<uint8_t *>(data.PeekData (0, 1));
225 const size_t opcode_data_len = data.GetByteSize();
226 size_t inst_size = ::LLVMDisasmInstruction (disasm_context,
227 opcode_data,
228 opcode_data_len,
229 pc,
230 out_string,
231 sizeof(out_string));
232
233 m_disasm.Unlock();
234
235 if (inst_size == 0)
236 {
237 m_comment.assign ("unknown opcode");
238 inst_size = m_opcode.GetByteSize();
239 StreamString mnemonic_strm;
240 uint32_t offset = 0;
241 switch (inst_size)
242 {
243 case 1:
244 {
245 const uint8_t uval8 = data.GetU8 (&offset);
246 m_opcode.SetOpcode8 (uval8);
247 m_opcode_name.assign (".byte");
248 mnemonic_strm.Printf("0x%2.2x", uval8);
249 }
250 break;
251 case 2:
252 {
253 const uint16_t uval16 = data.GetU16(&offset);
254 m_opcode.SetOpcode16(uval16);
255 m_opcode_name.assign (".short");
256 mnemonic_strm.Printf("0x%4.4x", uval16);
257 }
258 break;
259 case 4:
260 {
261 const uint32_t uval32 = data.GetU32(&offset);
262 m_opcode.SetOpcode32(uval32);
263 m_opcode_name.assign (".long");
264 mnemonic_strm.Printf("0x%8.8x", uval32);
265 }
266 break;
267 case 8:
268 {
269 const uint64_t uval64 = data.GetU64(&offset);
270 m_opcode.SetOpcode64(uval64);
271 m_opcode_name.assign (".quad");
272 mnemonic_strm.Printf("0x%16.16llx", uval64);
273 }
274 break;
275 default:
276 if (inst_size == 0)
277 return;
278 else
279 {
280 const uint8_t *bytes = data.PeekData(offset, inst_size);
281 if (bytes == NULL)
282 return;
283 m_opcode_name.assign (".byte");
284 m_opcode.SetOpcodeBytes(bytes, inst_size);
285 mnemonic_strm.Printf("0x%2.2x", bytes[0]);
286 for (uint32_t i=1; i<inst_size; ++i)
287 mnemonic_strm.Printf(" 0x%2.2x", bytes[i]);
288 }
289 break;
290 }
291 m_mnemocics.swap(mnemonic_strm.GetString());
292 return;
293 }
294 else
295 {
296 if (m_does_branch == eLazyBoolCalculate)
297 {
298 if (StringRepresentsBranch (out_string, strlen(out_string)))
299 m_does_branch = eLazyBoolYes;
300 else
301 m_does_branch = eLazyBoolNo;
302 }
303 }
304
305 if (!s_regex_compiled)
306 {
307 ::regcomp(&s_regex, "[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
308 s_regex_compiled = true;
309 }
310
311 ::regmatch_t matches[3];
312
313 if (!::regexec(&s_regex, out_string, sizeof(matches) / sizeof(::regmatch_t), matches, 0))
314 {
315 if (matches[1].rm_so != -1)
316 m_opcode_name.assign(out_string + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so);
317 if (matches[2].rm_so != -1)
318 m_mnemocics.assign(out_string + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so);
319 }
320 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000321 }
322
323 bool
324 IsValid ()
325 {
326 return m_is_valid;
327 }
328
329 size_t
330 GetByteSize ()
331 {
332 return m_opcode.GetByteSize();
333 }
334protected:
Sean Callanan95e5c632012-02-17 00:53:45 +0000335
Sean Callanan7725a462012-03-02 23:22:53 +0000336 bool StringRepresentsBranch (const char *data, size_t size)
337 {
338 const char *cursor = data;
339
340 bool inWhitespace = true;
341
342 while (inWhitespace && cursor < data + size)
343 {
344 switch (*cursor)
345 {
346 default:
347 inWhitespace = false;
348 break;
349 case ' ':
350 break;
351 case '\t':
352 break;
353 }
354
355 if (inWhitespace)
356 ++cursor;
357 }
358
359 if (cursor >= data + size)
360 return false;
361
362 llvm::Triple::ArchType arch = m_disasm.GetArchitecture().GetMachine();
363
364 switch (arch)
365 {
366 default:
367 return false;
368 case llvm::Triple::x86:
369 case llvm::Triple::x86_64:
370 switch (cursor[0])
371 {
372 default:
373 return false;
374 case 'j':
375 return true;
376 case 'c':
377 if (cursor[1] == 'a' &&
378 cursor[2] == 'l' &&
379 cursor[3] == 'l')
380 return true;
381 else
382 return false;
383 }
384 case llvm::Triple::arm:
385 case llvm::Triple::thumb:
386 switch (cursor[0])
387 {
388 default:
389 return false;
390 case 'b':
391 {
392 switch (cursor[1])
393 {
394 default:
Sean Callanan7725a462012-03-02 23:22:53 +0000395 return true;
Sean Callanan62ecb9b2012-04-10 21:51:12 +0000396 case 'f':
397 case 'i':
398 case 'k':
399 return false;
Sean Callanan7725a462012-03-02 23:22:53 +0000400 }
Sean Callanan7725a462012-03-02 23:22:53 +0000401 }
402 case 'c':
403 {
404 switch (cursor[1])
405 {
406 default:
407 return false;
408 case 'b':
409 return true;
410 }
411 }
412 }
413 }
414
415 return false;
416 }
417
Sean Callanan95e5c632012-02-17 00:53:45 +0000418 bool m_is_valid;
419 DisassemblerLLVMC &m_disasm;
Sean Callanan7e6d4e52012-08-01 18:50:59 +0000420 DisassemblerSP m_disasm_sp; // for ownership
Sean Callanan7725a462012-03-02 23:22:53 +0000421 LazyBool m_does_branch;
Sean Callanan95e5c632012-02-17 00:53:45 +0000422
423 static bool s_regex_compiled;
424 static ::regex_t s_regex;
425};
426
427bool InstructionLLVMC::s_regex_compiled = false;
428::regex_t InstructionLLVMC::s_regex;
429
430Disassembler *
431DisassemblerLLVMC::CreateInstance (const ArchSpec &arch)
432{
433 std::auto_ptr<DisassemblerLLVMC> disasm_ap (new DisassemblerLLVMC(arch));
434
435 if (disasm_ap.get() && disasm_ap->IsValid())
436 return disasm_ap.release();
437
438 return NULL;
439}
440
441DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch) :
442 Disassembler(arch),
Greg Claytonba812f42012-05-10 02:52:23 +0000443 m_exe_ctx (NULL),
444 m_inst (NULL),
445 m_disasm_context (NULL),
446 m_alternate_disasm_context (NULL)
Sean Callanan95e5c632012-02-17 00:53:45 +0000447{
448 m_disasm_context = ::LLVMCreateDisasm(arch.GetTriple().getTriple().c_str(),
449 (void*)this,
450 /*TagType=*/1,
Sean Callanan6f298a62012-02-23 23:43:28 +0000451 NULL,
Sean Callanan95e5c632012-02-17 00:53:45 +0000452 DisassemblerLLVMC::SymbolLookupCallback);
453
454 if (arch.GetTriple().getArch() == llvm::Triple::arm)
455 {
Greg Claytonba812f42012-05-10 02:52:23 +0000456 ArchSpec thumb_arch(arch);
457 thumb_arch.GetTriple().setArchName(llvm::StringRef("thumbv7"));
458 std::string thumb_triple(thumb_arch.GetTriple().getTriple());
459
460 m_alternate_disasm_context = ::LLVMCreateDisasm(thumb_triple.c_str(),
Sean Callanan95e5c632012-02-17 00:53:45 +0000461 (void*)this,
462 /*TagType=*/1,
Sean Callanan6f298a62012-02-23 23:43:28 +0000463 NULL,
Sean Callanan95e5c632012-02-17 00:53:45 +0000464 DisassemblerLLVMC::SymbolLookupCallback);
465 }
466}
467
468DisassemblerLLVMC::~DisassemblerLLVMC()
469{
Sean Callanan2b54db72012-04-06 17:59:49 +0000470 if (m_disasm_context)
471 {
472 ::LLVMDisasmDispose(m_disasm_context);
473 m_disasm_context = NULL;
474 }
475 if (m_alternate_disasm_context)
476 {
477 ::LLVMDisasmDispose(m_alternate_disasm_context);
478 m_alternate_disasm_context = NULL;
479 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000480}
481
482size_t
483DisassemblerLLVMC::DecodeInstructions (const Address &base_addr,
484 const DataExtractor& data,
485 uint32_t data_offset,
486 uint32_t num_instructions,
487 bool append)
488{
489 if (!append)
490 m_instruction_list.Clear();
491
492 if (!IsValid())
493 return 0;
494
495 uint32_t data_cursor = data_offset;
Greg Claytonba812f42012-05-10 02:52:23 +0000496 const size_t data_byte_size = data.GetByteSize();
Sean Callanan95e5c632012-02-17 00:53:45 +0000497 uint32_t instructions_parsed = 0;
Greg Claytonba812f42012-05-10 02:52:23 +0000498 Address inst_addr(base_addr);
Sean Callanan95e5c632012-02-17 00:53:45 +0000499
Greg Claytonba812f42012-05-10 02:52:23 +0000500 while (data_cursor < data_byte_size && instructions_parsed < num_instructions)
Sean Callanan95e5c632012-02-17 00:53:45 +0000501 {
Sean Callanan95e5c632012-02-17 00:53:45 +0000502
Greg Claytonba812f42012-05-10 02:52:23 +0000503 AddressClass address_class = eAddressClassCode;
Sean Callanan95e5c632012-02-17 00:53:45 +0000504
505 if (m_alternate_disasm_context)
Greg Claytonba812f42012-05-10 02:52:23 +0000506 address_class = inst_addr.GetAddressClass ();
Sean Callanan95e5c632012-02-17 00:53:45 +0000507
508 InstructionSP inst_sp(new InstructionLLVMC(*this,
Greg Claytonba812f42012-05-10 02:52:23 +0000509 inst_addr,
Sean Callanan95e5c632012-02-17 00:53:45 +0000510 address_class));
511
512 if (!inst_sp)
Greg Claytonba812f42012-05-10 02:52:23 +0000513 break;
514
Sean Callanan95e5c632012-02-17 00:53:45 +0000515 uint32_t inst_size = inst_sp->Decode(*this, data, data_cursor);
516
Greg Claytonba812f42012-05-10 02:52:23 +0000517 if (inst_size == 0)
518 break;
519
Sean Callanan95e5c632012-02-17 00:53:45 +0000520 m_instruction_list.Append(inst_sp);
Sean Callanan95e5c632012-02-17 00:53:45 +0000521 data_cursor += inst_size;
Greg Claytonba812f42012-05-10 02:52:23 +0000522 inst_addr.Slide(inst_size);
Sean Callanan95e5c632012-02-17 00:53:45 +0000523 instructions_parsed++;
524 }
525
526 return data_cursor - data_offset;
527}
528
529void
530DisassemblerLLVMC::Initialize()
531{
532 PluginManager::RegisterPlugin (GetPluginNameStatic(),
533 GetPluginDescriptionStatic(),
534 CreateInstance);
535
536 llvm::InitializeAllTargetInfos();
537 llvm::InitializeAllTargetMCs();
538 llvm::InitializeAllAsmParsers();
539 llvm::InitializeAllDisassemblers();
540}
541
542void
543DisassemblerLLVMC::Terminate()
544{
545 PluginManager::UnregisterPlugin (CreateInstance);
546}
547
548
549const char *
550DisassemblerLLVMC::GetPluginNameStatic()
551{
Greg Claytonf8712de2012-03-22 00:49:15 +0000552 return "llvm-mc";
Sean Callanan95e5c632012-02-17 00:53:45 +0000553}
554
555const char *
556DisassemblerLLVMC::GetPluginDescriptionStatic()
557{
Greg Claytonf8712de2012-03-22 00:49:15 +0000558 return "Disassembler that uses LLVM MC to disassemble i386, x86_64 and ARM.";
Sean Callanan95e5c632012-02-17 00:53:45 +0000559}
560
Greg Claytonba812f42012-05-10 02:52:23 +0000561int DisassemblerLLVMC::OpInfoCallback (void *disassembler,
562 uint64_t pc,
563 uint64_t offset,
564 uint64_t size,
565 int tag_type,
566 void *tag_bug)
Sean Callanan95e5c632012-02-17 00:53:45 +0000567{
Greg Claytonba812f42012-05-10 02:52:23 +0000568 return static_cast<DisassemblerLLVMC*>(disassembler)->OpInfo (pc,
569 offset,
570 size,
571 tag_type,
572 tag_bug);
Sean Callanan95e5c632012-02-17 00:53:45 +0000573}
574
Greg Claytonba812f42012-05-10 02:52:23 +0000575const char *DisassemblerLLVMC::SymbolLookupCallback (void *disassembler,
576 uint64_t value,
577 uint64_t *type,
578 uint64_t pc,
579 const char **name)
Sean Callanan95e5c632012-02-17 00:53:45 +0000580{
Greg Claytonba812f42012-05-10 02:52:23 +0000581 return static_cast<DisassemblerLLVMC*>(disassembler)->SymbolLookup(value,
582 type,
583 pc,
584 name);
Sean Callanan95e5c632012-02-17 00:53:45 +0000585}
586
587int DisassemblerLLVMC::OpInfo (uint64_t PC,
588 uint64_t Offset,
589 uint64_t Size,
Greg Claytonba812f42012-05-10 02:52:23 +0000590 int tag_type,
591 void *tag_bug)
Sean Callanan95e5c632012-02-17 00:53:45 +0000592{
Greg Claytonba812f42012-05-10 02:52:23 +0000593 switch (tag_type)
Sean Callanan95e5c632012-02-17 00:53:45 +0000594 {
595 default:
596 break;
597 case 1:
Greg Claytonba812f42012-05-10 02:52:23 +0000598 bzero (tag_bug, sizeof(::LLVMOpInfo1));
Sean Callanan95e5c632012-02-17 00:53:45 +0000599 break;
600 }
601 return 0;
602}
603
Greg Claytonba812f42012-05-10 02:52:23 +0000604const char *DisassemblerLLVMC::SymbolLookup (uint64_t value,
605 uint64_t *type_ptr,
606 uint64_t pc,
607 const char **name)
Sean Callanan95e5c632012-02-17 00:53:45 +0000608{
Greg Claytonba812f42012-05-10 02:52:23 +0000609 if (*type_ptr)
610 {
611 if (m_exe_ctx && m_inst)
612 {
613 //std::string remove_this_prior_to_checkin;
614 Address reference_address;
Sean Callanan95e5c632012-02-17 00:53:45 +0000615
Greg Claytonba812f42012-05-10 02:52:23 +0000616 Target *target = m_exe_ctx ? m_exe_ctx->GetTargetPtr() : NULL;
617
618 if (target && !target->GetSectionLoadList().IsEmpty())
619 target->GetSectionLoadList().ResolveLoadAddress(value, reference_address);
620 else
621 {
622 ModuleSP module_sp(m_inst->GetAddress().GetModule());
623 if (module_sp)
624 module_sp->ResolveFileAddress(value, reference_address);
625 }
626
Sean Callanan6f298a62012-02-23 23:43:28 +0000627 if (reference_address.IsValid() && reference_address.GetSection())
Sean Callanan95e5c632012-02-17 00:53:45 +0000628 {
Sean Callanan95e5c632012-02-17 00:53:45 +0000629 StreamString ss;
630
Sean Callanan6f298a62012-02-23 23:43:28 +0000631 reference_address.Dump (&ss,
632 target,
633 Address::DumpStyleResolvedDescriptionNoModule,
634 Address::DumpStyleSectionNameOffset);
Sean Callanan95e5c632012-02-17 00:53:45 +0000635
Sean Callanan745af462012-03-22 20:04:23 +0000636 if (!ss.GetString().empty())
Greg Claytonba812f42012-05-10 02:52:23 +0000637 {
638 //remove_this_prior_to_checkin = ss.GetString();
639 //if (*type_ptr)
640 m_inst->AppendComment(ss.GetString());
641 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000642 }
Greg Claytonba812f42012-05-10 02:52:23 +0000643 //printf ("DisassemblerLLVMC::SymbolLookup (value=0x%16.16llx, type=%llu, pc=0x%16.16llx, name=\"%s\") m_exe_ctx=%p, m_inst=%p\n", value, *type_ptr, pc, remove_this_prior_to_checkin.c_str(), m_exe_ctx, m_inst);
Sean Callanan95e5c632012-02-17 00:53:45 +0000644 }
645 }
Greg Claytonba812f42012-05-10 02:52:23 +0000646
647 *type_ptr = LLVMDisassembler_ReferenceType_InOut_None;
648 *name = NULL;
649 return NULL;
Sean Callanan95e5c632012-02-17 00:53:45 +0000650}
651
652//------------------------------------------------------------------
653// PluginInterface protocol
654//------------------------------------------------------------------
655const char *
656DisassemblerLLVMC::GetPluginName()
657{
658 return "DisassemblerLLVMC";
659}
660
661const char *
662DisassemblerLLVMC::GetShortPluginName()
663{
664 return GetPluginNameStatic();
665}
666
667uint32_t
668DisassemblerLLVMC::GetPluginVersion()
669{
670 return 1;
671}
672