blob: a5284f11c8e9327bf1387c2fd510a8f50ae6017a [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 {
133 uint32_t thumb_opcode = data.GetU16(&data_offset);
134 if ((thumb_opcode & 0xe000) != 0xe000 || ((thumb_opcode & 0x1800u) == 0))
135 {
136 m_opcode.SetOpcode16 (thumb_opcode);
137 }
138 else
139 {
140 thumb_opcode <<= 16;
141 thumb_opcode |= data.GetU16(&data_offset);
142 m_opcode.SetOpcode32 (thumb_opcode);
143 m_is_valid = true;
144 }
145 }
146 else
147 {
148 m_opcode.SetOpcode32 (data.GetU32(&data_offset));
149 }
150 }
151 else
152 {
153 // The opcode isn't evenly sized, so we need to actually use the llvm
154 // disassembler to parse it and get the size.
155 char out_string[512];
156 m_disasm.Lock(this, NULL);
157 uint8_t *opcode_data = const_cast<uint8_t *>(data.PeekData (data_offset, 1));
158 const size_t opcode_data_len = data.GetByteSize() - data_offset;
159 const addr_t pc = m_address.GetFileAddress();
160 const size_t inst_size = ::LLVMDisasmInstruction (disasm_context,
161 opcode_data,
162 opcode_data_len,
163 pc, // PC value
164 out_string,
165 sizeof(out_string));
166 // The address lookup function could have caused us to fill in our comment
167 m_comment.clear();
168 m_disasm.Unlock();
169 if (inst_size == 0)
170 m_opcode.Clear();
171 else
172 {
173 m_opcode.SetOpcodeBytes(opcode_data, inst_size);
174 m_is_valid = true;
175 }
176 }
177 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000178 return m_opcode.GetByteSize();
179 }
180
181 void
Greg Claytonba812f42012-05-10 02:52:23 +0000182 AppendComment (std::string &description)
Sean Callanan95e5c632012-02-17 00:53:45 +0000183 {
Greg Claytonba812f42012-05-10 02:52:23 +0000184 if (m_comment.empty())
185 m_comment.swap (description);
Sean Callanan95e5c632012-02-17 00:53:45 +0000186 else
Greg Claytonba812f42012-05-10 02:52:23 +0000187 {
188 m_comment.append(", ");
189 m_comment.append(description);
190 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000191 }
192
193 virtual void
Greg Claytonba812f42012-05-10 02:52:23 +0000194 CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext *exe_ctx)
Sean Callanan95e5c632012-02-17 00:53:45 +0000195 {
Greg Claytonba812f42012-05-10 02:52:23 +0000196 DataExtractor data;
197 const AddressClass address_class = GetAddressClass ();
198
199 if (m_opcode.GetData(data, address_class))
200 {
201 char out_string[512];
202
203 ::LLVMDisasmContextRef disasm_context;
204
205 if (address_class == eAddressClassCodeAlternateISA)
206 disasm_context = m_disasm.m_alternate_disasm_context;
207 else
208 disasm_context = m_disasm.m_disasm_context;
209
210 lldb::addr_t pc = LLDB_INVALID_ADDRESS;
211
212 if (exe_ctx)
213 {
214 Target *target = exe_ctx->GetTargetPtr();
215 if (target)
216 pc = m_address.GetLoadAddress(target);
217 }
218
219 if (pc == LLDB_INVALID_ADDRESS)
220 pc = m_address.GetFileAddress();
221
222 m_disasm.Lock(this, exe_ctx);
223 uint8_t *opcode_data = const_cast<uint8_t *>(data.PeekData (0, 1));
224 const size_t opcode_data_len = data.GetByteSize();
225 size_t inst_size = ::LLVMDisasmInstruction (disasm_context,
226 opcode_data,
227 opcode_data_len,
228 pc,
229 out_string,
230 sizeof(out_string));
231
232 m_disasm.Unlock();
233
234 if (inst_size == 0)
235 {
236 m_comment.assign ("unknown opcode");
237 inst_size = m_opcode.GetByteSize();
238 StreamString mnemonic_strm;
239 uint32_t offset = 0;
240 switch (inst_size)
241 {
242 case 1:
243 {
244 const uint8_t uval8 = data.GetU8 (&offset);
245 m_opcode.SetOpcode8 (uval8);
246 m_opcode_name.assign (".byte");
247 mnemonic_strm.Printf("0x%2.2x", uval8);
248 }
249 break;
250 case 2:
251 {
252 const uint16_t uval16 = data.GetU16(&offset);
253 m_opcode.SetOpcode16(uval16);
254 m_opcode_name.assign (".short");
255 mnemonic_strm.Printf("0x%4.4x", uval16);
256 }
257 break;
258 case 4:
259 {
260 const uint32_t uval32 = data.GetU32(&offset);
261 m_opcode.SetOpcode32(uval32);
262 m_opcode_name.assign (".long");
263 mnemonic_strm.Printf("0x%8.8x", uval32);
264 }
265 break;
266 case 8:
267 {
268 const uint64_t uval64 = data.GetU64(&offset);
269 m_opcode.SetOpcode64(uval64);
270 m_opcode_name.assign (".quad");
271 mnemonic_strm.Printf("0x%16.16llx", uval64);
272 }
273 break;
274 default:
275 if (inst_size == 0)
276 return;
277 else
278 {
279 const uint8_t *bytes = data.PeekData(offset, inst_size);
280 if (bytes == NULL)
281 return;
282 m_opcode_name.assign (".byte");
283 m_opcode.SetOpcodeBytes(bytes, inst_size);
284 mnemonic_strm.Printf("0x%2.2x", bytes[0]);
285 for (uint32_t i=1; i<inst_size; ++i)
286 mnemonic_strm.Printf(" 0x%2.2x", bytes[i]);
287 }
288 break;
289 }
290 m_mnemocics.swap(mnemonic_strm.GetString());
291 return;
292 }
293 else
294 {
295 if (m_does_branch == eLazyBoolCalculate)
296 {
297 if (StringRepresentsBranch (out_string, strlen(out_string)))
298 m_does_branch = eLazyBoolYes;
299 else
300 m_does_branch = eLazyBoolNo;
301 }
302 }
303
304 if (!s_regex_compiled)
305 {
306 ::regcomp(&s_regex, "[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
307 s_regex_compiled = true;
308 }
309
310 ::regmatch_t matches[3];
311
312 if (!::regexec(&s_regex, out_string, sizeof(matches) / sizeof(::regmatch_t), matches, 0))
313 {
314 if (matches[1].rm_so != -1)
315 m_opcode_name.assign(out_string + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so);
316 if (matches[2].rm_so != -1)
317 m_mnemocics.assign(out_string + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so);
318 }
319 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000320 }
321
322 bool
323 IsValid ()
324 {
325 return m_is_valid;
326 }
327
328 size_t
329 GetByteSize ()
330 {
331 return m_opcode.GetByteSize();
332 }
333protected:
Sean Callanan95e5c632012-02-17 00:53:45 +0000334
Sean Callanan7725a462012-03-02 23:22:53 +0000335 bool StringRepresentsBranch (const char *data, size_t size)
336 {
337 const char *cursor = data;
338
339 bool inWhitespace = true;
340
341 while (inWhitespace && cursor < data + size)
342 {
343 switch (*cursor)
344 {
345 default:
346 inWhitespace = false;
347 break;
348 case ' ':
349 break;
350 case '\t':
351 break;
352 }
353
354 if (inWhitespace)
355 ++cursor;
356 }
357
358 if (cursor >= data + size)
359 return false;
360
361 llvm::Triple::ArchType arch = m_disasm.GetArchitecture().GetMachine();
362
363 switch (arch)
364 {
365 default:
366 return false;
367 case llvm::Triple::x86:
368 case llvm::Triple::x86_64:
369 switch (cursor[0])
370 {
371 default:
372 return false;
373 case 'j':
374 return true;
375 case 'c':
376 if (cursor[1] == 'a' &&
377 cursor[2] == 'l' &&
378 cursor[3] == 'l')
379 return true;
380 else
381 return false;
382 }
383 case llvm::Triple::arm:
384 case llvm::Triple::thumb:
385 switch (cursor[0])
386 {
387 default:
388 return false;
389 case 'b':
390 {
391 switch (cursor[1])
392 {
393 default:
Sean Callanan7725a462012-03-02 23:22:53 +0000394 return true;
Sean Callanan62ecb9b2012-04-10 21:51:12 +0000395 case 'f':
396 case 'i':
397 case 'k':
398 return false;
Sean Callanan7725a462012-03-02 23:22:53 +0000399 }
Sean Callanan7725a462012-03-02 23:22:53 +0000400 }
401 case 'c':
402 {
403 switch (cursor[1])
404 {
405 default:
406 return false;
407 case 'b':
408 return true;
409 }
410 }
411 }
412 }
413
414 return false;
415 }
416
Sean Callanan95e5c632012-02-17 00:53:45 +0000417 bool m_is_valid;
418 DisassemblerLLVMC &m_disasm;
Sean Callanan7e6d4e52012-08-01 18:50:59 +0000419 DisassemblerSP m_disasm_sp; // for ownership
Sean Callanan7725a462012-03-02 23:22:53 +0000420 LazyBool m_does_branch;
Sean Callanan95e5c632012-02-17 00:53:45 +0000421
422 static bool s_regex_compiled;
423 static ::regex_t s_regex;
424};
425
426bool InstructionLLVMC::s_regex_compiled = false;
427::regex_t InstructionLLVMC::s_regex;
428
429Disassembler *
430DisassemblerLLVMC::CreateInstance (const ArchSpec &arch)
431{
432 std::auto_ptr<DisassemblerLLVMC> disasm_ap (new DisassemblerLLVMC(arch));
433
434 if (disasm_ap.get() && disasm_ap->IsValid())
435 return disasm_ap.release();
436
437 return NULL;
438}
439
440DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch) :
441 Disassembler(arch),
Greg Claytonba812f42012-05-10 02:52:23 +0000442 m_exe_ctx (NULL),
443 m_inst (NULL),
444 m_disasm_context (NULL),
445 m_alternate_disasm_context (NULL)
Sean Callanan95e5c632012-02-17 00:53:45 +0000446{
447 m_disasm_context = ::LLVMCreateDisasm(arch.GetTriple().getTriple().c_str(),
448 (void*)this,
449 /*TagType=*/1,
Sean Callanan6f298a62012-02-23 23:43:28 +0000450 NULL,
Sean Callanan95e5c632012-02-17 00:53:45 +0000451 DisassemblerLLVMC::SymbolLookupCallback);
452
453 if (arch.GetTriple().getArch() == llvm::Triple::arm)
454 {
Greg Claytonba812f42012-05-10 02:52:23 +0000455 ArchSpec thumb_arch(arch);
456 thumb_arch.GetTriple().setArchName(llvm::StringRef("thumbv7"));
457 std::string thumb_triple(thumb_arch.GetTriple().getTriple());
458
459 m_alternate_disasm_context = ::LLVMCreateDisasm(thumb_triple.c_str(),
Sean Callanan95e5c632012-02-17 00:53:45 +0000460 (void*)this,
461 /*TagType=*/1,
Sean Callanan6f298a62012-02-23 23:43:28 +0000462 NULL,
Sean Callanan95e5c632012-02-17 00:53:45 +0000463 DisassemblerLLVMC::SymbolLookupCallback);
464 }
465}
466
467DisassemblerLLVMC::~DisassemblerLLVMC()
468{
Sean Callanan2b54db72012-04-06 17:59:49 +0000469 if (m_disasm_context)
470 {
471 ::LLVMDisasmDispose(m_disasm_context);
472 m_disasm_context = NULL;
473 }
474 if (m_alternate_disasm_context)
475 {
476 ::LLVMDisasmDispose(m_alternate_disasm_context);
477 m_alternate_disasm_context = NULL;
478 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000479}
480
481size_t
482DisassemblerLLVMC::DecodeInstructions (const Address &base_addr,
483 const DataExtractor& data,
484 uint32_t data_offset,
485 uint32_t num_instructions,
486 bool append)
487{
488 if (!append)
489 m_instruction_list.Clear();
490
491 if (!IsValid())
492 return 0;
493
494 uint32_t data_cursor = data_offset;
Greg Claytonba812f42012-05-10 02:52:23 +0000495 const size_t data_byte_size = data.GetByteSize();
Sean Callanan95e5c632012-02-17 00:53:45 +0000496 uint32_t instructions_parsed = 0;
Greg Claytonba812f42012-05-10 02:52:23 +0000497 Address inst_addr(base_addr);
Sean Callanan95e5c632012-02-17 00:53:45 +0000498
Greg Claytonba812f42012-05-10 02:52:23 +0000499 while (data_cursor < data_byte_size && instructions_parsed < num_instructions)
Sean Callanan95e5c632012-02-17 00:53:45 +0000500 {
Sean Callanan95e5c632012-02-17 00:53:45 +0000501
Greg Claytonba812f42012-05-10 02:52:23 +0000502 AddressClass address_class = eAddressClassCode;
Sean Callanan95e5c632012-02-17 00:53:45 +0000503
504 if (m_alternate_disasm_context)
Greg Claytonba812f42012-05-10 02:52:23 +0000505 address_class = inst_addr.GetAddressClass ();
Sean Callanan95e5c632012-02-17 00:53:45 +0000506
507 InstructionSP inst_sp(new InstructionLLVMC(*this,
Greg Claytonba812f42012-05-10 02:52:23 +0000508 inst_addr,
Sean Callanan95e5c632012-02-17 00:53:45 +0000509 address_class));
510
511 if (!inst_sp)
Greg Claytonba812f42012-05-10 02:52:23 +0000512 break;
513
Sean Callanan95e5c632012-02-17 00:53:45 +0000514 uint32_t inst_size = inst_sp->Decode(*this, data, data_cursor);
515
Greg Claytonba812f42012-05-10 02:52:23 +0000516 if (inst_size == 0)
517 break;
518
Sean Callanan95e5c632012-02-17 00:53:45 +0000519 m_instruction_list.Append(inst_sp);
Sean Callanan95e5c632012-02-17 00:53:45 +0000520 data_cursor += inst_size;
Greg Claytonba812f42012-05-10 02:52:23 +0000521 inst_addr.Slide(inst_size);
Sean Callanan95e5c632012-02-17 00:53:45 +0000522 instructions_parsed++;
523 }
524
525 return data_cursor - data_offset;
526}
527
528void
529DisassemblerLLVMC::Initialize()
530{
531 PluginManager::RegisterPlugin (GetPluginNameStatic(),
532 GetPluginDescriptionStatic(),
533 CreateInstance);
534
535 llvm::InitializeAllTargetInfos();
536 llvm::InitializeAllTargetMCs();
537 llvm::InitializeAllAsmParsers();
538 llvm::InitializeAllDisassemblers();
539}
540
541void
542DisassemblerLLVMC::Terminate()
543{
544 PluginManager::UnregisterPlugin (CreateInstance);
545}
546
547
548const char *
549DisassemblerLLVMC::GetPluginNameStatic()
550{
Greg Claytonf8712de2012-03-22 00:49:15 +0000551 return "llvm-mc";
Sean Callanan95e5c632012-02-17 00:53:45 +0000552}
553
554const char *
555DisassemblerLLVMC::GetPluginDescriptionStatic()
556{
Greg Claytonf8712de2012-03-22 00:49:15 +0000557 return "Disassembler that uses LLVM MC to disassemble i386, x86_64 and ARM.";
Sean Callanan95e5c632012-02-17 00:53:45 +0000558}
559
Greg Claytonba812f42012-05-10 02:52:23 +0000560int DisassemblerLLVMC::OpInfoCallback (void *disassembler,
561 uint64_t pc,
562 uint64_t offset,
563 uint64_t size,
564 int tag_type,
565 void *tag_bug)
Sean Callanan95e5c632012-02-17 00:53:45 +0000566{
Greg Claytonba812f42012-05-10 02:52:23 +0000567 return static_cast<DisassemblerLLVMC*>(disassembler)->OpInfo (pc,
568 offset,
569 size,
570 tag_type,
571 tag_bug);
Sean Callanan95e5c632012-02-17 00:53:45 +0000572}
573
Greg Claytonba812f42012-05-10 02:52:23 +0000574const char *DisassemblerLLVMC::SymbolLookupCallback (void *disassembler,
575 uint64_t value,
576 uint64_t *type,
577 uint64_t pc,
578 const char **name)
Sean Callanan95e5c632012-02-17 00:53:45 +0000579{
Greg Claytonba812f42012-05-10 02:52:23 +0000580 return static_cast<DisassemblerLLVMC*>(disassembler)->SymbolLookup(value,
581 type,
582 pc,
583 name);
Sean Callanan95e5c632012-02-17 00:53:45 +0000584}
585
586int DisassemblerLLVMC::OpInfo (uint64_t PC,
587 uint64_t Offset,
588 uint64_t Size,
Greg Claytonba812f42012-05-10 02:52:23 +0000589 int tag_type,
590 void *tag_bug)
Sean Callanan95e5c632012-02-17 00:53:45 +0000591{
Greg Claytonba812f42012-05-10 02:52:23 +0000592 switch (tag_type)
Sean Callanan95e5c632012-02-17 00:53:45 +0000593 {
594 default:
595 break;
596 case 1:
Greg Claytonba812f42012-05-10 02:52:23 +0000597 bzero (tag_bug, sizeof(::LLVMOpInfo1));
Sean Callanan95e5c632012-02-17 00:53:45 +0000598 break;
599 }
600 return 0;
601}
602
Greg Claytonba812f42012-05-10 02:52:23 +0000603const char *DisassemblerLLVMC::SymbolLookup (uint64_t value,
604 uint64_t *type_ptr,
605 uint64_t pc,
606 const char **name)
Sean Callanan95e5c632012-02-17 00:53:45 +0000607{
Greg Claytonba812f42012-05-10 02:52:23 +0000608 if (*type_ptr)
609 {
610 if (m_exe_ctx && m_inst)
611 {
612 //std::string remove_this_prior_to_checkin;
613 Address reference_address;
Sean Callanan95e5c632012-02-17 00:53:45 +0000614
Greg Claytonba812f42012-05-10 02:52:23 +0000615 Target *target = m_exe_ctx ? m_exe_ctx->GetTargetPtr() : NULL;
616
617 if (target && !target->GetSectionLoadList().IsEmpty())
618 target->GetSectionLoadList().ResolveLoadAddress(value, reference_address);
619 else
620 {
621 ModuleSP module_sp(m_inst->GetAddress().GetModule());
622 if (module_sp)
623 module_sp->ResolveFileAddress(value, reference_address);
624 }
625
Sean Callanan6f298a62012-02-23 23:43:28 +0000626 if (reference_address.IsValid() && reference_address.GetSection())
Sean Callanan95e5c632012-02-17 00:53:45 +0000627 {
Sean Callanan95e5c632012-02-17 00:53:45 +0000628 StreamString ss;
629
Sean Callanan6f298a62012-02-23 23:43:28 +0000630 reference_address.Dump (&ss,
631 target,
632 Address::DumpStyleResolvedDescriptionNoModule,
633 Address::DumpStyleSectionNameOffset);
Sean Callanan95e5c632012-02-17 00:53:45 +0000634
Sean Callanan745af462012-03-22 20:04:23 +0000635 if (!ss.GetString().empty())
Greg Claytonba812f42012-05-10 02:52:23 +0000636 {
637 //remove_this_prior_to_checkin = ss.GetString();
638 //if (*type_ptr)
639 m_inst->AppendComment(ss.GetString());
640 }
Sean Callanan95e5c632012-02-17 00:53:45 +0000641 }
Greg Claytonba812f42012-05-10 02:52:23 +0000642 //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 +0000643 }
644 }
Greg Claytonba812f42012-05-10 02:52:23 +0000645
646 *type_ptr = LLVMDisassembler_ReferenceType_InOut_None;
647 *name = NULL;
648 return NULL;
Sean Callanan95e5c632012-02-17 00:53:45 +0000649}
650
651//------------------------------------------------------------------
652// PluginInterface protocol
653//------------------------------------------------------------------
654const char *
655DisassemblerLLVMC::GetPluginName()
656{
657 return "DisassemblerLLVMC";
658}
659
660const char *
661DisassemblerLLVMC::GetShortPluginName()
662{
663 return GetPluginNameStatic();
664}
665
666uint32_t
667DisassemblerLLVMC::GetPluginVersion()
668{
669 return 1;
670}
671