summaryrefslogtreecommitdiffstats
path: root/lldb/source/API
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBFunction.cpp32
-rw-r--r--lldb/source/API/SBInstruction.cpp100
-rw-r--r--lldb/source/API/SBInstructionList.cpp45
-rw-r--r--lldb/source/API/SBProcess.cpp14
-rw-r--r--lldb/source/API/SBSymbol.cpp33
-rw-r--r--lldb/source/API/SBThread.cpp6
6 files changed, 179 insertions, 51 deletions
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index 38e349bd3f9..f1426e787cd 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -10,10 +10,15 @@
#include "lldb/API/SBFunction.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
-
+using namespace lldb_private;
SBFunction::SBFunction () :
m_opaque_ptr (NULL)
@@ -77,3 +82,28 @@ SBFunction::GetDescription (SBStream &description)
return true;
}
+
+SBInstructionList
+SBFunction::GetInstructions (SBTarget target)
+{
+ SBInstructionList sb_instructions;
+ if (m_opaque_ptr)
+ {
+ ExecutionContext exe_ctx;
+ if (target.IsValid())
+ {
+ target->CalculateExecutionContext (exe_ctx);
+ exe_ctx.process = target->GetProcessSP().get();
+ }
+ Module *module = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule();
+ if (module)
+ {
+ sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture(),
+ exe_ctx,
+ m_opaque_ptr->GetAddressRange()));
+ }
+ }
+ return sb_instructions;
+}
+
+
diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp
index 181b6b0c5e9..13d68a1cd34 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -9,58 +9,78 @@
#include "lldb/API/SBInstruction.h"
+#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBInstruction.h"
+#include "lldb/API/SBStream.h"
+
#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/StreamFile.h"
using namespace lldb;
using namespace lldb_private;
-//SBInstruction::SBInstruction (lldb_private::Disassembler::Instruction *lldb_insn) :
-// m_opaque_sp (lldb_insn);
-//{
-//}
-
SBInstruction::SBInstruction ()
{
}
+SBInstruction::SBInstruction (const lldb::InstructionSP& inst_sp) :
+ m_opaque_sp (inst_sp)
+{
+}
+
SBInstruction::~SBInstruction ()
{
}
-//bool
-//SBInstruction::IsValid()
-//{
-// return (m_opaque_sp.get() != NULL);
-//}
+bool
+SBInstruction::IsValid()
+{
+ return (m_opaque_sp.get() != NULL);
+}
+
+SBAddress
+SBInstruction::GetAddress()
+{
+ SBAddress sb_addr;
+ if (m_opaque_sp && m_opaque_sp->GetAddress().IsValid())
+ sb_addr.SetAddress(&m_opaque_sp->GetAddress());
+ return sb_addr;
+}
+
+size_t
+SBInstruction::GetByteSize ()
+{
+ if (m_opaque_sp)
+ return m_opaque_sp->GetByteSize();
+ return 0;
+}
-//size_t
-//SBInstruction::GetByteSize ()
-//{
-// if (IsValid())
-// {
-// return m_opaque_sp->GetByteSize();
-// }
-// return 0;
-//}
+bool
+SBInstruction::DoesBranch ()
+{
+ if (m_opaque_sp)
+ return m_opaque_sp->DoesBranch ();
+ return false;
+}
-//void
-//SBInstruction::SetByteSize (size_T byte_size)
-//{
-// if (IsValid ())
-// {
-// m_opaque_sp->SetByteSize (byte_size);
-// }
-//}
+void
+SBInstruction::SetOpaque (const lldb::InstructionSP &inst_sp)
+{
+ m_opaque_sp = inst_sp;
+}
-//bool
-//SBInstruction::DoesBranch ()
-//{
-// if (IsValid ())
-// {
-// return m_opaque_sp->DoesBranch ();
-// }
-// return false;
-//}
+bool
+SBInstruction::GetDescription (lldb::SBStream &s)
+{
+ if (m_opaque_sp)
+ {
+ // Use the "ref()" instead of the "get()" accessor in case the SBStream
+ // didn't have a stream already created, one will get created...
+ m_opaque_sp->Dump (&s.ref(), true, NULL, 0, NULL, false);
+ return true;
+ }
+ return false;
+}
void
SBInstruction::Print (FILE *out)
@@ -68,7 +88,9 @@ SBInstruction::Print (FILE *out)
if (out == NULL)
return;
- //StreamFile out_strem (out);
-
- //m_opaque_sp->Dump (out, LLDB_INVALID_ADDRESS, NULL, 0);
+ if (m_opaque_sp)
+ {
+ StreamFile out_stream (out);
+ m_opaque_sp->Dump (&out_stream, true, NULL, 0, NULL, false);
+ }
}
diff --git a/lldb/source/API/SBInstructionList.cpp b/lldb/source/API/SBInstructionList.cpp
index d34e9d100a9..b27ddfa5011 100644
--- a/lldb/source/API/SBInstructionList.cpp
+++ b/lldb/source/API/SBInstructionList.cpp
@@ -9,11 +9,16 @@
#include "lldb/API/SBInstructionList.h"
#include "lldb/API/SBInstruction.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/Stream.h"
using namespace lldb;
+using namespace lldb_private;
-SBInstructionList::SBInstructionList ()
+SBInstructionList::SBInstructionList () :
+ m_opaque_sp()
{
}
@@ -24,6 +29,8 @@ SBInstructionList::~SBInstructionList ()
size_t
SBInstructionList::GetSize ()
{
+ if (m_opaque_sp)
+ return m_opaque_sp->GetInstructionList().GetSize();
return 0;
}
@@ -31,12 +38,15 @@ SBInstruction
SBInstructionList::GetInstructionAtIndex (uint32_t idx)
{
SBInstruction inst;
+ if (m_opaque_sp && idx < m_opaque_sp->GetInstructionList().GetSize())
+ inst.SetOpaque (m_opaque_sp->GetInstructionList().GetInstructionAtIndex (idx));
return inst;
}
void
SBInstructionList::Clear ()
{
+ m_opaque_sp.reset();
}
void
@@ -45,9 +55,42 @@ SBInstructionList::AppendInstruction (SBInstruction insn)
}
void
+SBInstructionList::SetDisassembler (const lldb::DisassemblerSP &opaque_sp)
+{
+ m_opaque_sp = opaque_sp;
+}
+
+void
SBInstructionList::Print (FILE *out)
{
if (out == NULL)
return;
}
+
+bool
+SBInstructionList::GetDescription (lldb::SBStream &description)
+{
+ if (m_opaque_sp)
+ {
+ size_t num_instructions = GetSize ();
+ if (num_instructions)
+ {
+ // Call the ref() to make sure a stream is created if one deesn't
+ // exist already inside description...
+ Stream &sref = description.ref();
+ for (size_t i=0; i<num_instructions; ++i)
+ {
+ Instruction *inst = m_opaque_sp->GetInstructionList().GetInstructionAtIndex (i).get();
+ if (inst == NULL)
+ break;
+ inst->Dump (&sref, true, NULL, 0, NULL, false);
+ sref.EOL();
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index 2d6e6b03a92..1a72f589c6a 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -474,11 +474,17 @@ SBProcess::GetDescription (SBStream &description)
{
char path[PATH_MAX];
GetTarget().GetExecutable().GetPath (path, sizeof(path));
- description.Printf ("Process {pid: %d, executable %s\n", (int) GetProcessID(), path);
- description.Printf (" instance name: %s, state: %s, thread cnt: %d}",
- m_opaque_sp->GetInstanceName().AsCString(),
+ Module *exe_module = m_opaque_sp->GetTarget().GetExecutableModule ().get();
+ const char *exe_name = NULL;
+ if (exe_module)
+ exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
+
+ description.Printf ("Process {pid: %d, state: %s, threads: %d%s%s}",
+ m_opaque_sp->GetID(),
SBDebugger::StateAsCString (GetState()),
- GetNumThreads());
+ GetNumThreads(),
+ exe_name ? ", executable: " : "",
+ exe_name ? exe_name : "");
}
else
description.Printf ("No value");
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;
+}
+
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 216fa127816..7bf7dd29542 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -418,11 +418,7 @@ bool
SBThread::GetDescription (SBStream &description)
{
if (m_opaque_sp)
- {
- m_opaque_sp->DumpUsingSettingsFormat (description.ref(), LLDB_INVALID_INDEX32);
- description.Printf (" %d frames, (instance name: %s)", GetNumFrames(),
- m_opaque_sp->GetInstanceName().AsCString());
- }
+ m_opaque_sp->DumpUsingSettingsFormat (description.ref(), 0);
else
description.Printf ("No value");
OpenPOWER on IntegriCloud