diff options
author | Greg Clayton <gclayton@apple.com> | 2010-08-24 00:45:41 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-08-24 00:45:41 +0000 |
commit | 1b72fcb7d1105f500749c2643b34e0bddcf9c0e3 (patch) | |
tree | 5ee15de3b20c05e0a6cae5b92bba14dee2e1de78 /lldb/source/Symbol | |
parent | 02db8f64155e880cfc4ab519edb3381876787ab3 (diff) | |
download | bcm5719-llvm-1b72fcb7d1105f500749c2643b34e0bddcf9c0e3.tar.gz bcm5719-llvm-1b72fcb7d1105f500749c2643b34e0bddcf9c0e3.zip |
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
Diffstat (limited to 'lldb/source/Symbol')
-rw-r--r-- | lldb/source/Symbol/Block.cpp | 62 | ||||
-rw-r--r-- | lldb/source/Symbol/Function.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Symbol/SymbolContext.cpp | 40 |
3 files changed, 108 insertions, 4 deletions
diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp index 28da776d567..8256aa7e199 100644 --- a/lldb/source/Symbol/Block.cpp +++ b/lldb/source/Symbol/Block.cpp @@ -225,6 +225,52 @@ Block::GetParent () const return NULL; } +Block * +Block::GetInlinedParent () const +{ + Block *parent_block = GetParent (); + if (parent_block) + { + if (parent_block->InlinedFunctionInfo()) + return parent_block; + else + return parent_block->GetInlinedParent(); + } + return NULL; +} + + +bool +Block::GetRangeContainingAddress (const Address& addr, AddressRange &range) +{ + SymbolContext sc; + CalculateSymbolContext(&sc); + if (sc.function) + { + const AddressRange &func_range = sc.function->GetAddressRange(); + if (addr.GetSection() == func_range.GetBaseAddress().GetSection()) + { + const addr_t addr_offset = addr.GetOffset(); + const addr_t func_offset = func_range.GetBaseAddress().GetOffset(); + if (addr_offset >= func_offset && addr_offset < func_offset + func_range.GetByteSize()) + { + addr_t offset = addr_offset - func_offset; + + uint32_t range_idx = VMRange::FindRangeIndexThatContainsValue (m_ranges, offset); + if (range_idx < m_ranges.size()) + { + range.GetBaseAddress() = func_range.GetBaseAddress(); + range.GetBaseAddress().SetOffset(func_offset + m_ranges[range_idx].GetBaseAddress()); + range.SetByteSize(m_ranges[range_idx].GetByteSize()); + return true; + } + } + } + } + range.Clear(); + return false; +} + void Block::AddRange(addr_t start_offset, addr_t end_offset) { @@ -330,22 +376,32 @@ Block::GetVariableList (bool get_child_variables, bool can_create) } uint32_t -Block::AppendVariables (bool can_create, bool get_parent_variables, VariableList *variable_list) +Block::AppendVariables +( + bool can_create, + bool get_parent_variables, + bool stop_if_block_is_inlined_function, + VariableList *variable_list +) { uint32_t num_variables_added = 0; VariableListSP variable_list_sp(GetVariableList(false, can_create)); + bool is_inlined_function = InlinedFunctionInfo() != NULL; if (variable_list_sp.get()) { num_variables_added = variable_list_sp->GetSize(); variable_list->AddVariables(variable_list_sp.get()); } - + if (get_parent_variables) { + if (stop_if_block_is_inlined_function && is_inlined_function) + return num_variables_added; + Block* parent_block = GetParent(); if (parent_block) - num_variables_added += parent_block->AppendVariables (can_create, get_parent_variables, variable_list); + num_variables_added += parent_block->AppendVariables (can_create, get_parent_variables, stop_if_block_is_inlined_function, variable_list); } return num_variables_added; } diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 73a09eae24f..5f9adbbbe12 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -148,6 +148,16 @@ InlineFunctionInfo::DumpStopContext (Stream *s) const s->PutCString (m_name.AsCString()); } + +const ConstString & +InlineFunctionInfo::GetName () const +{ + if (m_mangled) + return m_mangled.GetName(); + return m_name; +} + + Declaration & InlineFunctionInfo::GetCallSite () { diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index 268caf200a8..db0bccb726e 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -114,7 +114,8 @@ SymbolContext::DumpStopContext Stream *s, ExecutionContextScope *exe_scope, const Address &addr, - bool show_module + bool show_module, + bool show_inlined_frames ) const { if (show_module && module_sp) @@ -127,6 +128,30 @@ SymbolContext::DumpStopContext if (function->GetMangled().GetName()) function->GetMangled().GetName().Dump(s); + + if (show_inlined_frames && block) + { + InlineFunctionInfo *inline_info = block->InlinedFunctionInfo(); + if (inline_info == NULL) + { + Block *parent_inline_block = block->GetInlinedParent(); + if (parent_inline_block) + inline_info = parent_inline_block->InlinedFunctionInfo(); + } + + if (inline_info) + { + s->PutCString(" [inlined] "); + inline_info->GetName().Dump(s); + + if (line_entry.IsValid()) + { + s->PutCString(" at "); + line_entry.DumpStopContext(s); + } + return; + } + } const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset(); if (function_offset) s->Printf(" + %llu", function_offset); @@ -237,6 +262,19 @@ SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Process * } } +uint32_t +SymbolContext::GetResolvedMask () const +{ + uint32_t resolved_mask = 0; + if (target_sp) resolved_mask |= eSymbolContextTarget; + if (module_sp) resolved_mask |= eSymbolContextModule; + if (comp_unit) resolved_mask |= eSymbolContextCompUnit; + if (function) resolved_mask |= eSymbolContextFunction; + if (block) resolved_mask |= eSymbolContextBlock; + if (line_entry.IsValid()) resolved_mask |= eSymbolContextLineEntry; + if (symbol) resolved_mask |= eSymbolContextSymbol; + return resolved_mask; +} void |