From 1d273166064c5163a1ca2be9a8e65cb628fc3524 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 6 Oct 2010 03:09:58 +0000 Subject: Added the ability to get the disassembly instructions from the function and symbol. llvm-svn: 115734 --- lldb/source/API/SBSymbol.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'lldb/source/API/SBSymbol.cpp') diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 017df4394ca..eed84d5c608 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -9,10 +9,14 @@ #include "lldb/API/SBSymbol.h" #include "lldb/API/SBStream.h" +#include "lldb/Core/Disassembler.h" +#include "lldb/Core/Module.h" #include "lldb/Symbol/Symbol.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Target.h" using namespace lldb; - +using namespace lldb_private; SBSymbol::SBSymbol () : m_opaque_ptr (NULL) @@ -78,3 +82,30 @@ SBSymbol::GetDescription (SBStream &description) return true; } + + + +SBInstructionList +SBSymbol::GetInstructions (SBTarget target) +{ + SBInstructionList sb_instructions; + if (m_opaque_ptr) + { + ExecutionContext exe_ctx; + if (target.IsValid()) + target->CalculateExecutionContext (exe_ctx); + const AddressRange *symbol_range = m_opaque_ptr->GetAddressRangePtr(); + if (symbol_range) + { + Module *module = symbol_range->GetBaseAddress().GetModule(); + if (module) + { + sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture (), + exe_ctx, + *symbol_range)); + } + } + } + return sb_instructions; +} + -- cgit v1.2.3