Added more functionality to the public API to allow for better
symbolication. Also improved the SBInstruction API to allow
access to the instruction opcode name, mnemonics, comment and
instruction data.
Added the ability to edit SBLineEntry objects (change the file,
line and column), and also allow SBSymbolContext objects to be
modified (set module, comp unit, function, block, line entry
or symbol).
The SymbolContext and SBSymbolContext can now generate inlined
call stack infomration for symbolication much easier using the
SymbolContext::GetParentInlinedFrameInfo(...) and
SBSymbolContext::GetParentInlinedFrameInfo(...) methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140518 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBBlock.cpp b/source/API/SBBlock.cpp
index 860f9b9..bc7392c 100644
--- a/source/API/SBBlock.cpp
+++ b/source/API/SBBlock.cpp
@@ -8,8 +8,10 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBBlock.h"
+#include "lldb/API/SBAddress.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBStream.h"
+#include "lldb/Core/AddressRange.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -127,6 +129,15 @@
return sb_block;
}
+lldb::SBBlock
+SBBlock::GetContainingInlinedBlock ()
+{
+ SBBlock sb_block;
+ if (m_opaque_ptr)
+ sb_block.m_opaque_ptr = m_opaque_ptr->GetContainingInlinedBlock ();
+ return sb_block;
+}
+
SBBlock
SBBlock::GetSibling ()
{
@@ -145,8 +156,8 @@
return sb_block;
}
-const lldb_private::Block *
-SBBlock::get () const
+lldb_private::Block *
+SBBlock::get ()
{
return m_opaque_ptr;
}
@@ -181,3 +192,59 @@
return true;
}
+
+uint32_t
+SBBlock::GetNumRanges ()
+{
+ if (m_opaque_ptr)
+ return m_opaque_ptr->GetNumRanges();
+ return 0;
+}
+
+lldb::SBAddress
+SBBlock::GetRangeStartAddress (uint32_t idx)
+{
+ lldb::SBAddress sb_addr;
+ if (m_opaque_ptr)
+ {
+ AddressRange range;
+ if (m_opaque_ptr->GetRangeAtIndex(idx, range))
+ {
+ sb_addr.ref() = range.GetBaseAddress();
+ }
+ }
+ return sb_addr;
+}
+
+lldb::SBAddress
+SBBlock::GetRangeEndAddress (uint32_t idx)
+{
+ lldb::SBAddress sb_addr;
+ if (m_opaque_ptr)
+ {
+ AddressRange range;
+ if (m_opaque_ptr->GetRangeAtIndex(idx, range))
+ {
+ sb_addr.ref() = range.GetBaseAddress();
+ sb_addr.ref().Slide(range.GetByteSize());
+ }
+ }
+ return sb_addr;
+}
+
+uint32_t
+SBBlock::GetRangeIndexForBlockAddress (lldb::SBAddress block_addr)
+{
+ if (m_opaque_ptr && block_addr.IsValid())
+ {
+ uint32_t range_idx = UINT32_MAX;
+ AddressRange range;
+ if (m_opaque_ptr->GetRangeContainingAddress (block_addr.ref(), range, &range_idx))
+ {
+ return range_idx;
+ }
+ }
+
+ return UINT32_MAX;
+}
+
diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp
index 58723e5..1590362 100644
--- a/source/API/SBCompileUnit.cpp
+++ b/source/API/SBCompileUnit.cpp
@@ -173,8 +173,8 @@
return *m_opaque_ptr;
}
-const lldb_private::CompileUnit *
-SBCompileUnit::get () const
+lldb_private::CompileUnit *
+SBCompileUnit::get ()
{
return m_opaque_ptr;
}
diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp
index 0be59af..d708aa0 100644
--- a/source/API/SBInstruction.cpp
+++ b/source/API/SBInstruction.cpp
@@ -16,6 +16,7 @@
#include "lldb/API/SBTarget.h"
#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/StreamFile.h"
@@ -67,6 +68,60 @@
return sb_addr;
}
+const char *
+SBInstruction::GetOpcodeName(SBTarget target)
+{
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker;
+ ExecutionContext exe_ctx;
+ if (target.IsValid())
+ {
+ api_locker.Reset (target->GetAPIMutex().GetMutex());
+ target->CalculateExecutionContext (exe_ctx);
+ exe_ctx.SetProcessSP(target->GetProcessSP());
+ }
+ return m_opaque_sp->GetOpcodeName(exe_ctx.GetBestExecutionContextScope());
+ }
+ return NULL;
+}
+
+const char *
+SBInstruction::GetMnemonics(SBTarget target)
+{
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker;
+ ExecutionContext exe_ctx;
+ if (target.IsValid())
+ {
+ api_locker.Reset (target->GetAPIMutex().GetMutex());
+ target->CalculateExecutionContext (exe_ctx);
+ exe_ctx.SetProcessSP(target->GetProcessSP());
+ }
+ return m_opaque_sp->GetMnemonics(exe_ctx.GetBestExecutionContextScope());
+ }
+ return NULL;
+}
+
+const char *
+SBInstruction::GetComment(SBTarget target)
+{
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker;
+ ExecutionContext exe_ctx;
+ if (target.IsValid())
+ {
+ api_locker.Reset (target->GetAPIMutex().GetMutex());
+ target->CalculateExecutionContext (exe_ctx);
+ exe_ctx.SetProcessSP(target->GetProcessSP());
+ }
+ return m_opaque_sp->GetComment(exe_ctx.GetBestExecutionContextScope());
+ }
+ return NULL;
+}
+
size_t
SBInstruction::GetByteSize ()
{
@@ -75,6 +130,32 @@
return 0;
}
+SBData
+SBInstruction::GetData (SBTarget target)
+{
+ lldb::SBData sb_data;
+ if (m_opaque_sp)
+ {
+ const Opcode &opcode = m_opaque_sp->GetOpcode();
+ const void *opcode_data = opcode.GetOpcodeBytes();
+ const uint32_t opcode_data_size = opcode.GetByteSize();
+ if (opcode_data && opcode_data_size > 0)
+ {
+ ByteOrder data_byte_order = opcode.GetDataByteOrder();
+ if (data_byte_order == eByteOrderInvalid)
+ data_byte_order = target->GetArchitecture().GetByteOrder();
+ DataBufferSP data_buffer_sp (new DataBufferHeap (opcode_data, opcode_data_size));
+ DataExtractorSP data_extractor_sp (new DataExtractor (data_buffer_sp,
+ data_byte_order,
+ target.IsValid() ? target->GetArchitecture().GetAddressByteSize() : sizeof(void*)));
+ sb_data.SetOpaque (data_extractor_sp);
+ }
+ }
+ return sb_data;
+}
+
+
+
bool
SBInstruction::DoesBranch ()
{
diff --git a/source/API/SBLineEntry.cpp b/source/API/SBLineEntry.cpp
index 3567a38..6915f58 100644
--- a/source/API/SBLineEntry.cpp
+++ b/source/API/SBLineEntry.cpp
@@ -28,33 +28,33 @@
m_opaque_ap ()
{
if (rhs.IsValid())
- m_opaque_ap.reset (new lldb_private::LineEntry (*rhs));
+ ref() = rhs.ref();
}
-
-
SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) :
m_opaque_ap ()
{
if (lldb_object_ptr)
- m_opaque_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr));
+ ref() = *lldb_object_ptr;
}
const SBLineEntry &
SBLineEntry::operator = (const SBLineEntry &rhs)
{
- if (this != &rhs && rhs.IsValid())
- m_opaque_ap.reset (new lldb_private::LineEntry(*rhs));
+ if (this != &rhs)
+ {
+ if (rhs.IsValid())
+ ref() = rhs.ref();
+ else
+ m_opaque_ap.reset();
+ }
return *this;
}
void
SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref)
{
- if (m_opaque_ap.get())
- (*m_opaque_ap.get()) = lldb_object_ref;
- else
- m_opaque_ap.reset (new lldb_private::LineEntry (lldb_object_ref));
+ ref() = lldb_object_ref;
}
@@ -156,6 +156,28 @@
return 0;
}
+void
+SBLineEntry::SetFileSpec (lldb::SBFileSpec filespec)
+{
+ if (filespec.IsValid())
+ ref().file = filespec.ref();
+ else
+ ref().file.Clear();
+}
+void
+SBLineEntry::SetLine (uint32_t line)
+{
+ ref().line = line;
+}
+
+void
+SBLineEntry::SetColumn (uint32_t column)
+{
+ ref().line = column;
+}
+
+
+
bool
SBLineEntry::operator == (const SBLineEntry &rhs) const
{
@@ -186,8 +208,16 @@
return m_opaque_ap.get();
}
+lldb_private::LineEntry &
+SBLineEntry::ref()
+{
+ if (m_opaque_ap.get() == NULL)
+ m_opaque_ap.reset (new lldb_private::LineEntry ());
+ return *m_opaque_ap;
+}
+
const lldb_private::LineEntry &
-SBLineEntry::operator*() const
+SBLineEntry::ref() const
{
return *m_opaque_ap;
}
diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp
index 76c607f..c2b70fb 100644
--- a/source/API/SBSymbolContext.cpp
+++ b/source/API/SBSymbolContext.cpp
@@ -10,6 +10,7 @@
#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -173,6 +174,46 @@
return sb_symbol;
}
+void
+SBSymbolContext::SetModule (lldb::SBModule module)
+{
+ ref().module_sp = module.get_sp();
+}
+
+void
+SBSymbolContext::SetCompileUnit (lldb::SBCompileUnit compile_unit)
+{
+ ref().comp_unit = compile_unit.get();
+}
+
+void
+SBSymbolContext::SetFunction (lldb::SBFunction function)
+{
+ ref().function = function.get();
+}
+
+void
+SBSymbolContext::SetBlock (lldb::SBBlock block)
+{
+ ref().block = block.get();
+}
+
+void
+SBSymbolContext::SetLineEntry (lldb::SBLineEntry line_entry)
+{
+ if (line_entry.IsValid())
+ ref().line_entry = line_entry.ref();
+ else
+ ref().line_entry.Clear();
+}
+
+void
+SBSymbolContext::SetSymbol (lldb::SBSymbol symbol)
+{
+ ref().symbol = symbol.get();
+}
+
+
lldb_private::SymbolContext*
SBSymbolContext::operator->() const
{
@@ -223,3 +264,18 @@
return true;
}
+
+SBSymbolContext
+SBSymbolContext::GetParentInlinedFrameInfo (const SBAddress &curr_frame_pc,
+ bool is_concrete_frame,
+ SBAddress &parent_frame_addr) const
+{
+ SBSymbolContext sb_sc;
+ if (m_opaque_ap.get() && curr_frame_pc.IsValid())
+ {
+ if (m_opaque_ap->GetParentInlinedFrameInfo (curr_frame_pc.ref(), is_concrete_frame, sb_sc.ref(), parent_frame_addr.ref()))
+ return sb_sc;
+ }
+ return SBSymbolContext();
+}
+
diff --git a/source/Core/Opcode.cpp b/source/Core/Opcode.cpp
index b765bf7..489a61a 100644
--- a/source/Core/Opcode.cpp
+++ b/source/Core/Opcode.cpp
@@ -14,6 +14,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Stream.h"
+#include "lldb/Host/Endian.h"
using namespace lldb;
using namespace lldb_private;
@@ -62,3 +63,19 @@
return bytes_written;
}
+lldb::ByteOrder
+Opcode::GetDataByteOrder () const
+{
+ switch (m_type)
+ {
+ case Opcode::eTypeInvalid: break;
+ case Opcode::eType8:
+ case Opcode::eType16:
+ case Opcode::eType32:
+ case Opcode::eType64: return lldb::endian::InlHostByteOrder();
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return eByteOrderInvalid;
+}
+
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index a8c423f..610271d 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -99,13 +99,15 @@
s->Printf("%s ", str.c_str());
}
static void
-AddSymbolicInfo(const ExecutionContext *exe_ctx, ExecutionContextScope *exe_scope,
- StreamString &comment, uint64_t operand_value, const Address &inst_addr)
+AddSymbolicInfo (ExecutionContextScope *exe_scope,
+ StreamString &comment,
+ uint64_t operand_value,
+ const Address &inst_addr)
{
Address so_addr;
Target *target = NULL;
- if (exe_ctx)
- target = exe_ctx->GetTargetPtr();
+ if (exe_scope)
+ target = exe_scope->CalculateTarget();
if (target && !target->GetSectionLoadList().IsEmpty())
{
if (target->GetSectionLoadList().ResolveLoadAddress(operand_value, so_addr))
@@ -225,12 +227,16 @@
if (numTokens != -1 && !raw)
{
addr_t base_addr = LLDB_INVALID_ADDRESS;
-
+ uint32_t addr_nibble_size = 8;
Target *target = NULL;
if (exe_ctx)
target = exe_ctx->GetTargetPtr();
- if (target && !target->GetSectionLoadList().IsEmpty())
- base_addr = GetAddress().GetLoadAddress (target);
+ if (target)
+ {
+ if (!target->GetSectionLoadList().IsEmpty())
+ base_addr = GetAddress().GetLoadAddress (target);
+ addr_nibble_size = target->GetArchitecture().GetAddressByteSize() * 2;
+ }
if (base_addr == LLDB_INVALID_ADDRESS)
base_addr = GetAddress().GetFileAddress ();
@@ -314,16 +320,16 @@
{
if (EDInstIsBranch(m_inst))
{
- operands.Printf("0x%llx ", operand_value);
+ operands.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
show_token = false;
}
else
{
// Put the address value into the comment
- comment.Printf("0x%llx ", operand_value);
+ comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
}
- AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress());
+ AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress());
} // EDEvaluateOperand
} // EDOperandIsMemory
} // EDGetOperand
@@ -351,8 +357,8 @@
if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) {
uint64_t operand_value = PC + atoi(++pos);
// Put the address value into the operands.
- operands.Printf("0x%llx ", operand_value);
- AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress());
+ operands.Printf("0x%8.8llx ", operand_value);
+ AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress());
}
}
// Yet more workaround for "bl #..." and "blx #...".
@@ -369,12 +375,12 @@
}
uint64_t operand_value = PC + atoi(++pos);
// Put the address value into the comment.
- comment.Printf("0x%llx ", operand_value);
+ comment.Printf("0x%8.8llx ", operand_value);
// And the original token string into the operands.
llvm::StringRef Str(pos - 1);
RStrip(Str, '\n');
operands.PutCString(Str.str().c_str());
- AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress());
+ AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress());
}
}
// END of workaround.
@@ -423,6 +429,144 @@
}
}
+void
+InstructionLLVM::CalculateOpcodeName (ExecutionContextScope *exe_scope)
+{
+ const int num_tokens = EDNumTokens(m_inst);
+ if (num_tokens > 0)
+ {
+ const char *token_cstr = NULL;
+ int currentOpIndex = -1;
+ StreamString comment;
+ uint32_t addr_nibble_size = 8;
+ addr_t base_addr = LLDB_INVALID_ADDRESS;
+ Target *target = NULL;
+ if (exe_scope)
+ target = exe_scope->CalculateTarget();
+ if (target && !target->GetSectionLoadList().IsEmpty())
+ base_addr = GetAddress().GetLoadAddress (target);
+ if (base_addr == LLDB_INVALID_ADDRESS)
+ base_addr = GetAddress().GetFileAddress ();
+ addr_nibble_size = target->GetArchitecture().GetAddressByteSize() * 2;
+
+ lldb::addr_t PC = base_addr + EDInstByteSize(m_inst);
+
+ // When executing an ARM instruction, PC reads as the address of the
+ // current instruction plus 8. And for Thumb, it is plus 4.
+ if (m_arch_type == llvm::Triple::arm)
+ PC = base_addr + 8;
+ else if (m_arch_type == llvm::Triple::thumb)
+ PC = base_addr + 4;
+
+ RegisterReaderArg rra(PC, m_disassembler);
+
+ for (int token_idx = 0; token_idx < num_tokens; ++token_idx)
+ {
+ EDTokenRef token;
+ if (EDGetToken(&token, m_inst, token_idx))
+ break;
+
+ if (EDTokenIsOpcode(token) == 1)
+ {
+ if (EDGetTokenString(&token_cstr, token) == 0) // 0 on success
+ {
+ if (token_cstr)
+ m_opcode_name.assign(token_cstr);
+ }
+ }
+ else
+ {
+ int operandIndex = EDOperandIndexForToken(token);
+
+ if (operandIndex >= 0)
+ {
+ if (operandIndex != currentOpIndex)
+ {
+ currentOpIndex = operandIndex;
+ EDOperandRef operand;
+
+ if (!EDGetOperand(&operand, m_inst, currentOpIndex))
+ {
+ if (EDOperandIsMemory(operand))
+ {
+ uint64_t operand_value;
+
+ if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, &rra))
+ {
+ comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
+ AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress());
+ }
+ }
+ }
+ }
+ }
+ if (m_mnemocics.empty() && EDTokenIsWhitespace (token) == 1)
+ continue;
+ if (EDGetTokenString (&token_cstr, token))
+ break;
+ m_mnemocics.append (token_cstr);
+ }
+ }
+ // FIXME!!!
+ // Workaround for llvm::tB's operands not properly parsed by ARMAsmParser.
+ if (m_arch_type == llvm::Triple::thumb && m_opcode_name.compare("b") == 0)
+ {
+ const char *inst_str;
+ const char *pos = NULL;
+ comment.Clear();
+ if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL)
+ {
+ uint64_t operand_value = PC + atoi(++pos);
+ // Put the address value into the operands.
+ comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
+ AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress());
+ }
+ }
+ // Yet more workaround for "bl #..." and "blx #...".
+ if ((m_arch_type == llvm::Triple::arm || m_arch_type == llvm::Triple::thumb) &&
+ (m_opcode_name.compare("bl") == 0 || m_opcode_name.compare("blx") == 0))
+ {
+ const char *inst_str;
+ const char *pos = NULL;
+ comment.Clear();
+ if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL)
+ {
+ if (m_arch_type == llvm::Triple::thumb && m_opcode_name.compare("blx") == 0)
+ {
+ // A8.6.23 BLX (immediate)
+ // Target Address = Align(PC,4) + offset value
+ PC = AlignPC(PC);
+ }
+ uint64_t operand_value = PC + atoi(++pos);
+ // Put the address value into the comment.
+ comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
+ // And the original token string into the operands.
+// llvm::StringRef Str(pos - 1);
+// RStrip(Str, '\n');
+// operands.PutCString(Str.str().c_str());
+ AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress());
+ }
+ }
+ // END of workaround.
+
+ m_comment.swap (comment.GetString());
+ }
+}
+
+void
+InstructionLLVM::CalculateMnemonics(ExecutionContextScope *exe_scope)
+{
+ // Do all of the work in CalculateOpcodeName()
+ CalculateOpcodeName (exe_scope);
+}
+
+void
+InstructionLLVM::CalculateComment(ExecutionContextScope *exe_scope)
+{
+ // Do all of the work in CalculateOpcodeName()
+ CalculateOpcodeName (exe_scope);
+}
+
bool
InstructionLLVM::DoesBranch() const
{
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
index 0d2d920..b9ab490 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
@@ -43,6 +43,15 @@
const lldb_private::DataExtractor &data,
uint32_t data_offset);
+ virtual void
+ CalculateOpcodeName (lldb_private::ExecutionContextScope *exe_scope);
+
+ virtual void
+ CalculateMnemonics (lldb_private::ExecutionContextScope *exe_scope);
+
+ virtual void
+ CalculateComment (lldb_private::ExecutionContextScope *exe_scope);
+
protected:
EDDisassemblerRef m_disassembler;
EDInstRef m_inst;
diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp
index d1e4d40..6676279 100644
--- a/source/Symbol/Block.cpp
+++ b/source/Symbol/Block.cpp
@@ -367,7 +367,7 @@
bool
-Block::GetRangeContainingAddress (const Address& addr, AddressRange &range)
+Block::GetRangeContainingAddress (const Address& addr, AddressRange &range, uint32_t *range_idx_ptr)
{
Function *function = CalculateSymbolContextFunction();
if (function)
@@ -387,11 +387,15 @@
range.GetBaseAddress() = func_range.GetBaseAddress();
range.GetBaseAddress().SetOffset(func_offset + m_ranges[range_idx].GetBaseAddress());
range.SetByteSize(m_ranges[range_idx].GetByteSize());
+ if (range_idx_ptr)
+ *range_idx_ptr = range_idx;
return true;
}
}
}
}
+ if (range_idx_ptr)
+ *range_idx_ptr = UINT32_MAX;
range.Clear();
return false;
}
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index 45a5f52..c7b2fb2 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -487,6 +487,95 @@
return return_value;
}
+bool
+SymbolContext::GetParentInlinedFrameInfo (const Address &curr_frame_pc,
+ bool is_concrete_frame,
+ SymbolContext &next_frame_sc,
+ Address &inlined_frame_addr) const
+{
+ next_frame_sc.Clear();
+ inlined_frame_addr.Clear();
+
+ if (block)
+ {
+ bool concrete_has_inlines = false;
+ Block *curr_inlined_block = NULL;
+ Block *next_inlined_block = NULL;
+ //const addr_t curr_frame_file_addr = curr_frame_pc.GetFileAddress();
+ if (is_concrete_frame)
+ {
+ curr_inlined_block = block->GetContainingInlinedBlock();
+ if (curr_inlined_block)
+ {
+ concrete_has_inlines = true;
+ next_inlined_block = curr_inlined_block->GetInlinedParent();
+ }
+ }
+ else
+ {
+ curr_inlined_block = block;
+ next_inlined_block = block->GetInlinedParent();
+ }
+
+ if (next_inlined_block)
+ {
+ next_inlined_block->CalculateSymbolContext (&next_frame_sc);
+
+ AddressRange range;
+ bool got_range = curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range);
+ assert (got_range);
+ const InlineFunctionInfo* inline_info = next_inlined_block->GetInlinedFunctionInfo();
+ if (inline_info)
+ {
+ inlined_frame_addr = range.GetBaseAddress();
+ next_frame_sc.line_entry.range.GetBaseAddress() = inlined_frame_addr;
+ next_frame_sc.line_entry.file = inline_info->GetCallSite().GetFile();
+ next_frame_sc.line_entry.line = inline_info->GetCallSite().GetLine();
+ next_frame_sc.line_entry.column = inline_info->GetCallSite().GetColumn();
+ return true;
+ }
+ }
+ else if (is_concrete_frame && !concrete_has_inlines)
+ {
+ // This is the symbol context for the frame that was found using the
+ // PC value and there are no inlined blocks so there are no inlined
+ // parent frames.
+ return false;
+ }
+ else
+ {
+ // We have had inlined frames before and now we are at the function
+ // instance that called the inlined frames.
+ // The SymbolContext object should contain a previous inline symbol
+ // context which we need to use to get the file, line and column info
+ const InlineFunctionInfo* inline_info = curr_inlined_block->GetInlinedFunctionInfo();
+ if (inline_info)
+ {
+ Block *parent_block = curr_inlined_block->GetParent();
+ if (parent_block)
+ {
+ parent_block->CalculateSymbolContext (&next_frame_sc);
+
+ AddressRange range;
+ if (curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range))
+ {
+ inlined_frame_addr = range.GetBaseAddress();
+ //const addr_t range_file_file_addr = inlined_frame_addr.GetFileAddress();
+ next_frame_sc.line_entry.range.GetBaseAddress() = inlined_frame_addr;
+ next_frame_sc.line_entry.file = inline_info->GetCallSite().GetFile();
+ next_frame_sc.line_entry.line = inline_info->GetCallSite().GetLine();
+ next_frame_sc.line_entry.column = inline_info->GetCallSite().GetColumn();
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+
//----------------------------------------------------------------------
//
// SymbolContextSpecifier
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index f8e1c6f..0d25879 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -39,15 +39,12 @@
#define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1)
#define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1)
-StackFrame::StackFrame
-(
- user_id_t frame_idx,
- user_id_t unwind_frame_index,
- Thread &thread,
- addr_t cfa,
- addr_t pc,
- const SymbolContext *sc_ptr
-) :
+StackFrame::StackFrame (user_id_t frame_idx,
+ user_id_t unwind_frame_index,
+ Thread &thread,
+ addr_t cfa,
+ addr_t pc,
+ const SymbolContext *sc_ptr) :
m_thread (thread),
m_frame_index (frame_idx),
m_concrete_frame_index (unwind_frame_index),
@@ -69,16 +66,13 @@
}
}
-StackFrame::StackFrame
-(
- user_id_t frame_idx,
- user_id_t unwind_frame_index,
- Thread &thread,
- const RegisterContextSP ®_context_sp,
- addr_t cfa,
- addr_t pc,
- const SymbolContext *sc_ptr
-) :
+StackFrame::StackFrame (user_id_t frame_idx,
+ user_id_t unwind_frame_index,
+ Thread &thread,
+ const RegisterContextSP ®_context_sp,
+ addr_t cfa,
+ addr_t pc,
+ const SymbolContext *sc_ptr) :
m_thread (thread),
m_frame_index (frame_idx),
m_concrete_frame_index (unwind_frame_index),
@@ -106,16 +100,13 @@
}
}
-StackFrame::StackFrame
-(
- user_id_t frame_idx,
- user_id_t unwind_frame_index,
- Thread &thread,
- const RegisterContextSP ®_context_sp,
- addr_t cfa,
- const Address& pc_addr,
- const SymbolContext *sc_ptr
-) :
+StackFrame::StackFrame (user_id_t frame_idx,
+ user_id_t unwind_frame_index,
+ Thread &thread,
+ const RegisterContextSP ®_context_sp,
+ addr_t cfa,
+ const Address& pc_addr,
+ const SymbolContext *sc_ptr) :
m_thread (thread),
m_frame_index (frame_idx),
m_concrete_frame_index (unwind_frame_index),