2010-06-09 00:52:24 +08:00
|
|
|
|
//===-- StackFrame.cpp ------------------------------------------*- C++ -*-===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
|
// C++ Includes
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
|
// Project includes
|
2016-02-19 02:52:47 +08:00
|
|
|
|
#include "lldb/Target/StackFrame.h"
|
2010-10-04 09:05:56 +08:00
|
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
#include "lldb/Core/Disassembler.h"
|
2015-02-05 06:00:53 +08:00
|
|
|
|
#include "lldb/Core/FormatEntity.h"
|
2016-03-16 05:50:51 +08:00
|
|
|
|
#include "lldb/Core/Mangled.h"
|
|
|
|
|
#include "lldb/Core/Module.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
#include "lldb/Core/Value.h"
|
2010-09-02 10:59:18 +08:00
|
|
|
|
#include "lldb/Core/ValueObjectVariable.h"
|
2010-12-15 13:08:08 +08:00
|
|
|
|
#include "lldb/Core/ValueObjectConstResult.h"
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 12:48:36 +08:00
|
|
|
|
#include "lldb/Core/ValueObjectMemory.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
#include "lldb/Symbol/Function.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
|
#include "lldb/Symbol/Symbol.h"
|
|
|
|
|
#include "lldb/Symbol/SymbolContextScope.h"
|
2015-11-20 06:28:58 +08:00
|
|
|
|
#include "lldb/Symbol/Type.h"
|
2010-09-02 10:59:18 +08:00
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 12:48:36 +08:00
|
|
|
|
#include "lldb/Target/ABI.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
// The first bits in the flags are reserved for the SymbolContext::Scope bits
|
|
|
|
|
// so we know if we have tried to look up information in our internal symbol
|
|
|
|
|
// context (m_sc) already.
|
2010-08-31 02:11:35 +08:00
|
|
|
|
#define RESOLVED_FRAME_CODE_ADDR (uint32_t(eSymbolContextEverything + 1))
|
2010-09-03 05:44:10 +08:00
|
|
|
|
#define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_CODE_ADDR << 1)
|
2010-08-31 02:11:35 +08:00
|
|
|
|
#define GOT_FRAME_BASE (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1)
|
|
|
|
|
#define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1)
|
2010-11-01 12:38:59 +08:00
|
|
|
|
#define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
2016-05-19 13:13:57 +08:00
|
|
|
|
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index, addr_t cfa,
|
|
|
|
|
bool cfa_is_valid, addr_t pc, uint32_t stop_id, bool stop_id_is_valid, bool is_history_frame,
|
|
|
|
|
const SymbolContext *sc_ptr)
|
|
|
|
|
: m_thread_wp(thread_sp),
|
|
|
|
|
m_frame_index(frame_idx),
|
|
|
|
|
m_concrete_frame_index(unwind_frame_index),
|
|
|
|
|
m_reg_context_sp(),
|
|
|
|
|
m_id(pc, cfa, nullptr),
|
|
|
|
|
m_frame_code_addr(pc),
|
|
|
|
|
m_sc(),
|
|
|
|
|
m_flags(),
|
|
|
|
|
m_frame_base(),
|
|
|
|
|
m_frame_base_error(),
|
|
|
|
|
m_cfa_is_valid(cfa_is_valid),
|
|
|
|
|
m_stop_id(stop_id),
|
|
|
|
|
m_stop_id_is_valid(stop_id_is_valid),
|
|
|
|
|
m_is_history_frame(is_history_frame),
|
|
|
|
|
m_variable_list_sp(),
|
|
|
|
|
m_variable_list_value_objects(),
|
|
|
|
|
m_disassembly(),
|
|
|
|
|
m_mutex()
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2013-11-04 19:02:52 +08:00
|
|
|
|
// If we don't have a CFA value, use the frame index for our StackID so that recursive
|
|
|
|
|
// functions properly aren't confused with one another on a history stack.
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (m_is_history_frame && !m_cfa_is_valid)
|
2013-11-04 19:02:52 +08:00
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
m_id.SetCFA(m_frame_index);
|
2013-11-04 19:02:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (sc_ptr != nullptr)
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
|
m_sc = *sc_ptr;
|
2016-05-19 13:13:57 +08:00
|
|
|
|
m_flags.Set(m_sc.GetResolvedMask());
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 13:13:57 +08:00
|
|
|
|
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index,
|
|
|
|
|
const RegisterContextSP ®_context_sp, addr_t cfa, addr_t pc, const SymbolContext *sc_ptr)
|
|
|
|
|
: m_thread_wp(thread_sp),
|
|
|
|
|
m_frame_index(frame_idx),
|
|
|
|
|
m_concrete_frame_index(unwind_frame_index),
|
|
|
|
|
m_reg_context_sp(reg_context_sp),
|
|
|
|
|
m_id(pc, cfa, nullptr),
|
|
|
|
|
m_frame_code_addr(pc),
|
|
|
|
|
m_sc(),
|
|
|
|
|
m_flags(),
|
|
|
|
|
m_frame_base(),
|
|
|
|
|
m_frame_base_error(),
|
|
|
|
|
m_cfa_is_valid(true),
|
|
|
|
|
m_stop_id(0),
|
|
|
|
|
m_stop_id_is_valid(false),
|
|
|
|
|
m_is_history_frame(false),
|
|
|
|
|
m_variable_list_sp(),
|
|
|
|
|
m_variable_list_value_objects(),
|
|
|
|
|
m_disassembly(),
|
|
|
|
|
m_mutex()
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (sc_ptr != nullptr)
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
|
m_sc = *sc_ptr;
|
2016-05-19 13:13:57 +08:00
|
|
|
|
m_flags.Set(m_sc.GetResolvedMask());
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
}
|
2016-05-19 13:13:57 +08:00
|
|
|
|
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
if (reg_context_sp && !m_sc.target_sp)
|
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
m_sc.target_sp = reg_context_sp->CalculateTarget();
|
|
|
|
|
if (m_sc.target_sp)
|
2016-05-19 13:13:57 +08:00
|
|
|
|
m_flags.Set(eSymbolContextTarget);
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 13:13:57 +08:00
|
|
|
|
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index,
|
|
|
|
|
const RegisterContextSP ®_context_sp, addr_t cfa, const Address &pc_addr,
|
|
|
|
|
const SymbolContext *sc_ptr)
|
|
|
|
|
: m_thread_wp(thread_sp),
|
|
|
|
|
m_frame_index(frame_idx),
|
|
|
|
|
m_concrete_frame_index(unwind_frame_index),
|
|
|
|
|
m_reg_context_sp(reg_context_sp),
|
|
|
|
|
m_id(pc_addr.GetLoadAddress(thread_sp->CalculateTarget().get()), cfa, nullptr),
|
|
|
|
|
m_frame_code_addr(pc_addr),
|
|
|
|
|
m_sc(),
|
|
|
|
|
m_flags(),
|
|
|
|
|
m_frame_base(),
|
|
|
|
|
m_frame_base_error(),
|
|
|
|
|
m_cfa_is_valid(true),
|
|
|
|
|
m_stop_id(0),
|
|
|
|
|
m_stop_id_is_valid(false),
|
|
|
|
|
m_is_history_frame(false),
|
|
|
|
|
m_variable_list_sp(),
|
|
|
|
|
m_variable_list_value_objects(),
|
|
|
|
|
m_disassembly(),
|
|
|
|
|
m_mutex()
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (sc_ptr != nullptr)
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
{
|
|
|
|
|
m_sc = *sc_ptr;
|
2016-05-19 13:13:57 +08:00
|
|
|
|
m_flags.Set(m_sc.GetResolvedMask());
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
}
|
2016-05-19 13:13:57 +08:00
|
|
|
|
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (!m_sc.target_sp && reg_context_sp)
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
m_sc.target_sp = reg_context_sp->CalculateTarget();
|
|
|
|
|
if (m_sc.target_sp)
|
2016-05-19 13:13:57 +08:00
|
|
|
|
m_flags.Set(eSymbolContextTarget);
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
}
|
2016-05-19 13:13:57 +08:00
|
|
|
|
|
|
|
|
|
ModuleSP pc_module_sp(pc_addr.GetModule());
|
2012-02-24 09:59:29 +08:00
|
|
|
|
if (!m_sc.module_sp || m_sc.module_sp != pc_module_sp)
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
|
if (pc_module_sp)
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
|
m_sc.module_sp = pc_module_sp;
|
2016-05-19 13:13:57 +08:00
|
|
|
|
m_flags.Set(eSymbolContextModule);
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
}
|
2010-09-13 12:34:30 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_sc.module_sp.reset();
|
|
|
|
|
}
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-19 02:52:47 +08:00
|
|
|
|
StackFrame::~StackFrame() = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
StackID&
|
|
|
|
|
StackFrame::GetStackID()
|
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-09-03 05:44:10 +08:00
|
|
|
|
// Make sure we have resolved the StackID object's symbol context scope if
|
|
|
|
|
// we already haven't looked it up.
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
2010-08-31 02:11:35 +08:00
|
|
|
|
if (m_flags.IsClear (RESOLVED_FRAME_ID_SYMBOL_SCOPE))
|
|
|
|
|
{
|
2010-09-04 01:10:42 +08:00
|
|
|
|
if (m_id.GetSymbolContextScope ())
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2010-09-07 12:20:48 +08:00
|
|
|
|
// We already have a symbol context scope, we just don't have our
|
|
|
|
|
// flag bit set.
|
2010-08-31 02:11:35 +08:00
|
|
|
|
m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
|
2010-08-25 05:05:24 +08:00
|
|
|
|
}
|
2010-08-31 02:11:35 +08:00
|
|
|
|
else
|
2010-08-25 05:05:24 +08:00
|
|
|
|
{
|
2010-09-07 12:20:48 +08:00
|
|
|
|
// Calculate the frame block and use this for the stack ID symbol
|
|
|
|
|
// context scope if we have one.
|
|
|
|
|
SymbolContextScope *scope = GetFrameBlock ();
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (scope == nullptr)
|
2010-08-31 02:11:35 +08:00
|
|
|
|
{
|
2010-09-07 12:20:48 +08:00
|
|
|
|
// We don't have a block, so use the symbol
|
|
|
|
|
if (m_flags.IsClear (eSymbolContextSymbol))
|
|
|
|
|
GetSymbolContext (eSymbolContextSymbol);
|
|
|
|
|
|
2016-02-19 02:52:47 +08:00
|
|
|
|
// It is ok if m_sc.symbol is nullptr here
|
2010-09-07 12:20:48 +08:00
|
|
|
|
scope = m_sc.symbol;
|
2010-08-31 02:11:35 +08:00
|
|
|
|
}
|
2010-09-07 12:20:48 +08:00
|
|
|
|
// Set the symbol context scope (the accessor will set the
|
|
|
|
|
// RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags).
|
|
|
|
|
SetSymbolContextScope (scope);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return m_id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-01 09:02:41 +08:00
|
|
|
|
uint32_t
|
|
|
|
|
StackFrame::GetFrameIndex () const
|
|
|
|
|
{
|
|
|
|
|
ThreadSP thread_sp = GetThread();
|
|
|
|
|
if (thread_sp)
|
2013-11-04 17:33:30 +08:00
|
|
|
|
return thread_sp->GetStackFrameList()->GetVisibleStackFrameIndex(m_frame_index);
|
2012-09-01 09:02:41 +08:00
|
|
|
|
else
|
|
|
|
|
return m_frame_index;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-31 02:11:35 +08:00
|
|
|
|
void
|
|
|
|
|
StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope)
|
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-08-31 02:11:35 +08:00
|
|
|
|
m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
|
|
|
|
|
m_id.SetSymbolContextScope (symbol_scope);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-06 12:07:21 +08:00
|
|
|
|
const Address&
|
2010-08-25 05:05:24 +08:00
|
|
|
|
StackFrame::GetFrameCodeAddress()
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-08-31 02:11:35 +08:00
|
|
|
|
if (m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR) && !m_frame_code_addr.IsSectionOffset())
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2010-08-31 02:11:35 +08:00
|
|
|
|
m_flags.Set (RESOLVED_FRAME_CODE_ADDR);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
// Resolve the PC into a temporary address because if ResolveLoadAddress
|
|
|
|
|
// fails to resolve the address, it will clear the address object...
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ThreadSP thread_sp (GetThread());
|
|
|
|
|
if (thread_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
TargetSP target_sp (thread_sp->CalculateTarget());
|
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2015-09-07 17:58:09 +08:00
|
|
|
|
if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get(), eAddressClassCode))
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
|
ModuleSP module_sp (m_frame_code_addr.GetModule());
|
|
|
|
|
if (module_sp)
|
2012-02-18 13:35:26 +08:00
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
|
m_sc.module_sp = module_sp;
|
|
|
|
|
m_flags.Set(eSymbolContextModule);
|
2012-02-18 13:35:26 +08:00
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-08-27 06:05:43 +08:00
|
|
|
|
return m_frame_code_addr;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 19:02:52 +08:00
|
|
|
|
bool
|
2010-06-09 00:52:24 +08:00
|
|
|
|
StackFrame::ChangePC (addr_t pc)
|
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2013-11-04 19:02:52 +08:00
|
|
|
|
// We can't change the pc value of a history stack frame - it is immutable.
|
|
|
|
|
if (m_is_history_frame)
|
|
|
|
|
return false;
|
2012-02-24 09:59:29 +08:00
|
|
|
|
m_frame_code_addr.SetRawAddress(pc);
|
2013-02-23 12:12:47 +08:00
|
|
|
|
m_sc.Clear(false);
|
2010-10-27 11:32:59 +08:00
|
|
|
|
m_flags.Reset(0);
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ThreadSP thread_sp (GetThread());
|
|
|
|
|
if (thread_sp)
|
|
|
|
|
thread_sp->ClearStackFrames ();
|
2013-11-04 19:02:52 +08:00
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
StackFrame::Disassemble ()
|
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
if (m_disassembly.GetSize() == 0)
|
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
|
if (target)
|
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
const char *plugin_name = nullptr;
|
|
|
|
|
const char *flavor = nullptr;
|
2012-02-18 13:35:26 +08:00
|
|
|
|
Disassembler::Disassemble (target->GetDebugger(),
|
|
|
|
|
target->GetArchitecture(),
|
2013-03-02 08:26:47 +08:00
|
|
|
|
plugin_name,
|
|
|
|
|
flavor,
|
2012-02-18 13:35:26 +08:00
|
|
|
|
exe_ctx,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
m_disassembly);
|
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
if (m_disassembly.GetSize() == 0)
|
2016-02-19 02:52:47 +08:00
|
|
|
|
return nullptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
return m_disassembly.GetData();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-07 12:20:48 +08:00
|
|
|
|
Block *
|
|
|
|
|
StackFrame::GetFrameBlock ()
|
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (m_sc.block == nullptr && m_flags.IsClear(eSymbolContextBlock))
|
2010-09-07 12:20:48 +08:00
|
|
|
|
GetSymbolContext (eSymbolContextBlock);
|
|
|
|
|
|
|
|
|
|
if (m_sc.block)
|
|
|
|
|
{
|
|
|
|
|
Block *inline_block = m_sc.block->GetContainingInlinedBlock();
|
|
|
|
|
if (inline_block)
|
|
|
|
|
{
|
|
|
|
|
// Use the block with the inlined function info
|
|
|
|
|
// as the frame block we want this frame to have only the variables
|
|
|
|
|
// for the inlined function and its non-inlined block child blocks.
|
|
|
|
|
return inline_block;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-07-19 23:28:02 +08:00
|
|
|
|
// This block is not contained within any inlined function blocks
|
2010-09-07 12:20:48 +08:00
|
|
|
|
// with so we want to use the top most function block.
|
|
|
|
|
return &m_sc.function->GetBlock (false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-19 02:52:47 +08:00
|
|
|
|
return nullptr;
|
2010-09-07 12:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
// Get the symbol context if we already haven't done so by resolving the
|
|
|
|
|
// PC address as much as possible. This way when we pass around a
|
|
|
|
|
// StackFrame object, everyone will have as much information as
|
|
|
|
|
// possible and no one will ever have to look things up manually.
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
const SymbolContext&
|
|
|
|
|
StackFrame::GetSymbolContext (uint32_t resolve_scope)
|
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
// Copy our internal symbol context into "sc".
|
2010-10-27 11:32:59 +08:00
|
|
|
|
if ((m_flags.Get() & resolve_scope) != resolve_scope)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2012-11-29 08:53:06 +08:00
|
|
|
|
uint32_t resolved = 0;
|
|
|
|
|
|
|
|
|
|
// If the target was requested add that:
|
|
|
|
|
if (!m_sc.target_sp)
|
|
|
|
|
{
|
|
|
|
|
m_sc.target_sp = CalculateTarget();
|
|
|
|
|
if (m_sc.target_sp)
|
|
|
|
|
resolved |= eSymbolContextTarget;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 02:05:41 +08:00
|
|
|
|
// Resolve our PC to section offset if we haven't already done so
|
2010-06-09 00:52:24 +08:00
|
|
|
|
// and if we don't have a module. The resolved address section will
|
|
|
|
|
// contain the module to which it belongs
|
2010-08-31 02:11:35 +08:00
|
|
|
|
if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR))
|
2010-08-25 05:05:24 +08:00
|
|
|
|
GetFrameCodeAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
// If this is not frame zero, then we need to subtract 1 from the PC
|
|
|
|
|
// value when doing address lookups since the PC will be on the
|
|
|
|
|
// instruction following the function call instruction...
|
|
|
|
|
|
2010-08-25 05:05:24 +08:00
|
|
|
|
Address lookup_addr(GetFrameCodeAddress());
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
if (m_frame_index > 0 && lookup_addr.IsValid())
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
|
|
|
|
addr_t offset = lookup_addr.GetOffset();
|
|
|
|
|
if (offset > 0)
|
2014-11-08 13:38:17 +08:00
|
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
|
lookup_addr.SetOffset(offset - 1);
|
2014-11-08 13:38:17 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// lookup_addr is the start of a section. We need
|
|
|
|
|
// do the math on the actual load address and re-compute
|
|
|
|
|
// the section. We're working with a 'noreturn' function
|
|
|
|
|
// at the end of a section.
|
|
|
|
|
ThreadSP thread_sp (GetThread());
|
|
|
|
|
if (thread_sp)
|
|
|
|
|
{
|
|
|
|
|
TargetSP target_sp (thread_sp->CalculateTarget());
|
|
|
|
|
if (target_sp)
|
|
|
|
|
{
|
|
|
|
|
addr_t addr_minus_one = lookup_addr.GetLoadAddress(target_sp.get()) - 1;
|
|
|
|
|
lookup_addr.SetLoadAddress (addr_minus_one, target_sp.get());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lookup_addr.SetOffset(offset - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_sc.module_sp)
|
|
|
|
|
{
|
|
|
|
|
// We have something in our stack frame symbol context, lets check
|
|
|
|
|
// if we haven't already tried to lookup one of those things. If we
|
|
|
|
|
// haven't then we will do the query.
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
|
|
|
|
|
uint32_t actual_resolve_scope = 0;
|
|
|
|
|
|
|
|
|
|
if (resolve_scope & eSymbolContextCompUnit)
|
|
|
|
|
{
|
|
|
|
|
if (m_flags.IsClear (eSymbolContextCompUnit))
|
|
|
|
|
{
|
|
|
|
|
if (m_sc.comp_unit)
|
2010-08-25 05:05:24 +08:00
|
|
|
|
resolved |= eSymbolContextCompUnit;
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
else
|
|
|
|
|
actual_resolve_scope |= eSymbolContextCompUnit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (resolve_scope & eSymbolContextFunction)
|
|
|
|
|
{
|
|
|
|
|
if (m_flags.IsClear (eSymbolContextFunction))
|
|
|
|
|
{
|
|
|
|
|
if (m_sc.function)
|
2010-08-25 05:05:24 +08:00
|
|
|
|
resolved |= eSymbolContextFunction;
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
else
|
|
|
|
|
actual_resolve_scope |= eSymbolContextFunction;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (resolve_scope & eSymbolContextBlock)
|
|
|
|
|
{
|
|
|
|
|
if (m_flags.IsClear (eSymbolContextBlock))
|
|
|
|
|
{
|
|
|
|
|
if (m_sc.block)
|
2010-08-25 05:05:24 +08:00
|
|
|
|
resolved |= eSymbolContextBlock;
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
else
|
|
|
|
|
actual_resolve_scope |= eSymbolContextBlock;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (resolve_scope & eSymbolContextSymbol)
|
|
|
|
|
{
|
|
|
|
|
if (m_flags.IsClear (eSymbolContextSymbol))
|
|
|
|
|
{
|
|
|
|
|
if (m_sc.symbol)
|
2010-08-25 05:05:24 +08:00
|
|
|
|
resolved |= eSymbolContextSymbol;
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
else
|
|
|
|
|
actual_resolve_scope |= eSymbolContextSymbol;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (resolve_scope & eSymbolContextLineEntry)
|
|
|
|
|
{
|
|
|
|
|
if (m_flags.IsClear (eSymbolContextLineEntry))
|
|
|
|
|
{
|
|
|
|
|
if (m_sc.line_entry.IsValid())
|
2010-08-25 05:05:24 +08:00
|
|
|
|
resolved |= eSymbolContextLineEntry;
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
else
|
|
|
|
|
actual_resolve_scope |= eSymbolContextLineEntry;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (actual_resolve_scope)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
|
|
|
|
// We might be resolving less information than what is already
|
|
|
|
|
// in our current symbol context so resolve into a temporary
|
|
|
|
|
// symbol context "sc" so we don't clear out data we have
|
|
|
|
|
// already found in "m_sc"
|
|
|
|
|
SymbolContext sc;
|
|
|
|
|
// Set flags that indicate what we have tried to resolve
|
2010-08-25 05:05:24 +08:00
|
|
|
|
resolved |= m_sc.module_sp->ResolveSymbolContextForAddress (lookup_addr, actual_resolve_scope, sc);
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
// Only replace what we didn't already have as we may have
|
|
|
|
|
// information for an inlined function scope that won't match
|
|
|
|
|
// what a standard lookup by address would match
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if ((resolved & eSymbolContextCompUnit) && m_sc.comp_unit == nullptr)
|
2010-08-25 05:05:24 +08:00
|
|
|
|
m_sc.comp_unit = sc.comp_unit;
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if ((resolved & eSymbolContextFunction) && m_sc.function == nullptr)
|
2010-08-25 05:05:24 +08:00
|
|
|
|
m_sc.function = sc.function;
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if ((resolved & eSymbolContextBlock) && m_sc.block == nullptr)
|
2010-08-25 05:05:24 +08:00
|
|
|
|
m_sc.block = sc.block;
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if ((resolved & eSymbolContextSymbol) && m_sc.symbol == nullptr)
|
2010-08-25 05:05:24 +08:00
|
|
|
|
m_sc.symbol = sc.symbol;
|
2012-11-29 08:53:06 +08:00
|
|
|
|
if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid())
|
|
|
|
|
{
|
2010-08-25 05:05:24 +08:00
|
|
|
|
m_sc.line_entry = sc.line_entry;
|
2016-05-12 06:46:53 +08:00
|
|
|
|
m_sc.line_entry.ApplyFileMappings(m_sc.target_sp);
|
2012-11-29 08:53:06 +08:00
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// If we don't have a module, then we can't have the compile unit,
|
|
|
|
|
// function, block, line entry or symbol, so we can safely call
|
|
|
|
|
// ResolveSymbolContextForAddress with our symbol context member m_sc.
|
2010-08-25 05:05:24 +08:00
|
|
|
|
if (m_sc.target_sp)
|
2013-02-22 04:54:33 +08:00
|
|
|
|
{
|
2012-11-29 08:53:06 +08:00
|
|
|
|
resolved |= m_sc.target_sp->GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc);
|
2013-02-22 04:54:33 +08:00
|
|
|
|
}
|
2010-08-25 05:05:24 +08:00
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
// Update our internal flags so we remember what we have tried to locate so
|
|
|
|
|
// we don't have to keep trying when more calls to this function are made.
|
2010-08-25 05:05:24 +08:00
|
|
|
|
// We might have dug up more information that was requested (for example
|
|
|
|
|
// if we were asked to only get the block, we will have gotten the
|
|
|
|
|
// compile unit, and function) so set any additional bits that we resolved
|
|
|
|
|
m_flags.Set (resolve_scope | resolved);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the symbol context with everything that was possible to resolve
|
|
|
|
|
// resolved.
|
|
|
|
|
return m_sc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VariableList *
|
2010-09-02 10:59:18 +08:00
|
|
|
|
StackFrame::GetVariableList (bool get_file_globals)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
if (m_flags.IsClear(RESOLVED_VARIABLES))
|
|
|
|
|
{
|
|
|
|
|
m_flags.Set(RESOLVED_VARIABLES);
|
|
|
|
|
|
2010-09-07 12:20:48 +08:00
|
|
|
|
Block *frame_block = GetFrameBlock();
|
|
|
|
|
|
|
|
|
|
if (frame_block)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2010-09-07 12:20:48 +08:00
|
|
|
|
const bool get_child_variables = true;
|
|
|
|
|
const bool can_create = true;
|
2011-06-18 06:10:16 +08:00
|
|
|
|
const bool stop_if_child_block_is_inlined_function = true;
|
|
|
|
|
m_variable_list_sp.reset(new VariableList());
|
2016-02-25 20:23:37 +08:00
|
|
|
|
frame_block->AppendBlockVariables(can_create,
|
|
|
|
|
get_child_variables,
|
|
|
|
|
stop_if_child_block_is_inlined_function,
|
2016-04-26 05:54:10 +08:00
|
|
|
|
[this](Variable* v) { return true; },
|
2016-02-25 20:23:37 +08:00
|
|
|
|
m_variable_list_sp.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
2010-11-01 12:38:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_flags.IsClear(RESOLVED_GLOBAL_VARIABLES) &&
|
|
|
|
|
get_file_globals)
|
|
|
|
|
{
|
|
|
|
|
m_flags.Set(RESOLVED_GLOBAL_VARIABLES);
|
|
|
|
|
|
|
|
|
|
if (m_flags.IsClear (eSymbolContextCompUnit))
|
|
|
|
|
GetSymbolContext (eSymbolContextCompUnit);
|
2010-09-02 10:59:18 +08:00
|
|
|
|
|
2010-11-01 12:38:59 +08:00
|
|
|
|
if (m_sc.comp_unit)
|
2010-09-02 10:59:18 +08:00
|
|
|
|
{
|
2010-11-01 12:38:59 +08:00
|
|
|
|
VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
|
|
|
|
|
if (m_variable_list_sp)
|
|
|
|
|
m_variable_list_sp->AddVariables (global_variable_list_sp.get());
|
|
|
|
|
else
|
|
|
|
|
m_variable_list_sp = global_variable_list_sp;
|
2010-09-02 10:59:18 +08:00
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
2010-11-01 12:38:59 +08:00
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
return m_variable_list_sp.get();
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-03 07:35:43 +08:00
|
|
|
|
VariableListSP
|
2016-04-26 08:29:59 +08:00
|
|
|
|
StackFrame::GetInScopeVariableList (bool get_file_globals, bool must_have_valid_location)
|
2011-08-03 07:35:43 +08:00
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2013-11-04 19:02:52 +08:00
|
|
|
|
// We can't fetch variable information for a history stack frame.
|
|
|
|
|
if (m_is_history_frame)
|
|
|
|
|
return VariableListSP();
|
|
|
|
|
|
2011-08-03 07:35:43 +08:00
|
|
|
|
VariableListSP var_list_sp(new VariableList);
|
|
|
|
|
GetSymbolContext (eSymbolContextCompUnit | eSymbolContextBlock);
|
|
|
|
|
|
|
|
|
|
if (m_sc.block)
|
|
|
|
|
{
|
|
|
|
|
const bool can_create = true;
|
|
|
|
|
const bool get_parent_variables = true;
|
|
|
|
|
const bool stop_if_block_is_inlined_function = true;
|
|
|
|
|
m_sc.block->AppendVariables (can_create,
|
|
|
|
|
get_parent_variables,
|
|
|
|
|
stop_if_block_is_inlined_function,
|
2016-04-26 08:29:59 +08:00
|
|
|
|
[this, must_have_valid_location](Variable* v)
|
|
|
|
|
{
|
|
|
|
|
return v->IsInScope(this) && (!must_have_valid_location || v->LocationIsValidForFrame(this));
|
|
|
|
|
},
|
2011-08-03 07:35:43 +08:00
|
|
|
|
var_list_sp.get());
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-03 07:49:41 +08:00
|
|
|
|
if (m_sc.comp_unit && get_file_globals)
|
2011-08-03 07:35:43 +08:00
|
|
|
|
{
|
|
|
|
|
VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
|
|
|
|
|
if (global_variable_list_sp)
|
|
|
|
|
var_list_sp->AddVariables (global_variable_list_sp.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return var_list_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
|
ValueObjectSP
|
2012-07-14 08:53:55 +08:00
|
|
|
|
StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
|
2011-09-17 16:33:22 +08:00
|
|
|
|
DynamicValueType use_dynamic,
|
2011-05-04 11:43:18 +08:00
|
|
|
|
uint32_t options,
|
2011-09-17 16:33:22 +08:00
|
|
|
|
VariableSP &var_sp,
|
2011-05-04 11:43:18 +08:00
|
|
|
|
Error &error)
|
2010-12-14 10:59:59 +08:00
|
|
|
|
{
|
2013-11-04 19:02:52 +08:00
|
|
|
|
// We can't fetch variable information for a history stack frame.
|
|
|
|
|
if (m_is_history_frame)
|
|
|
|
|
return ValueObjectSP();
|
2010-12-15 13:08:08 +08:00
|
|
|
|
|
|
|
|
|
if (var_expr_cstr && var_expr_cstr[0])
|
2010-12-14 10:59:59 +08:00
|
|
|
|
{
|
2011-01-21 03:27:18 +08:00
|
|
|
|
const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0;
|
|
|
|
|
const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0;
|
2011-08-09 09:04:56 +08:00
|
|
|
|
const bool no_synth_child = (options & eExpressionPathOptionsNoSyntheticChildren) != 0;
|
2011-08-20 05:56:10 +08:00
|
|
|
|
//const bool no_synth_array = (options & eExpressionPathOptionsNoSyntheticArrayRange) != 0;
|
2010-12-15 13:08:08 +08:00
|
|
|
|
error.Clear();
|
|
|
|
|
bool deref = false;
|
|
|
|
|
bool address_of = false;
|
|
|
|
|
ValueObjectSP valobj_sp;
|
|
|
|
|
const bool get_file_globals = true;
|
2011-08-03 07:35:43 +08:00
|
|
|
|
// When looking up a variable for an expression, we need only consider the
|
|
|
|
|
// variables that are in scope.
|
|
|
|
|
VariableListSP var_list_sp (GetInScopeVariableList (get_file_globals));
|
|
|
|
|
VariableList *variable_list = var_list_sp.get();
|
2010-12-15 13:08:08 +08:00
|
|
|
|
|
|
|
|
|
if (variable_list)
|
2010-12-14 10:59:59 +08:00
|
|
|
|
{
|
2010-12-15 13:08:08 +08:00
|
|
|
|
// If first character is a '*', then show pointer contents
|
|
|
|
|
const char *var_expr = var_expr_cstr;
|
|
|
|
|
if (var_expr[0] == '*')
|
|
|
|
|
{
|
|
|
|
|
deref = true;
|
|
|
|
|
var_expr++; // Skip the '*'
|
|
|
|
|
}
|
|
|
|
|
else if (var_expr[0] == '&')
|
|
|
|
|
{
|
|
|
|
|
address_of = true;
|
|
|
|
|
var_expr++; // Skip the '&'
|
|
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
|
std::string var_path (var_expr);
|
|
|
|
|
size_t separator_idx = var_path.find_first_of(".-[=+~|&^%#@!/?,<>{}");
|
|
|
|
|
StreamString var_expr_path_strm;
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
|
ConstString name_const_string;
|
|
|
|
|
if (separator_idx == std::string::npos)
|
|
|
|
|
name_const_string.SetCString (var_path.c_str());
|
|
|
|
|
else
|
|
|
|
|
name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
2015-08-19 06:46:57 +08:00
|
|
|
|
var_sp = variable_list->FindVariable(name_const_string, false);
|
2012-07-14 08:53:55 +08:00
|
|
|
|
|
|
|
|
|
bool synthetically_added_instance_object = false;
|
|
|
|
|
|
|
|
|
|
if (var_sp)
|
|
|
|
|
{
|
|
|
|
|
var_path.erase (0, name_const_string.GetLength ());
|
|
|
|
|
}
|
2015-11-20 06:28:58 +08:00
|
|
|
|
|
|
|
|
|
if (!var_sp && (options & eExpressionPathOptionsAllowDirectIVarAccess))
|
2012-07-14 08:53:55 +08:00
|
|
|
|
{
|
|
|
|
|
// Check for direct ivars access which helps us with implicit
|
|
|
|
|
// access to ivars with the "this->" or "self->"
|
|
|
|
|
GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock);
|
|
|
|
|
lldb::LanguageType method_language = eLanguageTypeUnknown;
|
|
|
|
|
bool is_instance_method = false;
|
|
|
|
|
ConstString method_object_name;
|
|
|
|
|
if (m_sc.GetFunctionMethodInfo (method_language, is_instance_method, method_object_name))
|
|
|
|
|
{
|
|
|
|
|
if (is_instance_method && method_object_name)
|
|
|
|
|
{
|
|
|
|
|
var_sp = variable_list->FindVariable(method_object_name);
|
|
|
|
|
if (var_sp)
|
|
|
|
|
{
|
|
|
|
|
separator_idx = 0;
|
|
|
|
|
var_path.insert(0, "->");
|
|
|
|
|
synthetically_added_instance_object = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-20 06:28:58 +08:00
|
|
|
|
|
|
|
|
|
if (!var_sp && (options & eExpressionPathOptionsInspectAnonymousUnions))
|
|
|
|
|
{
|
|
|
|
|
// Check if any anonymous unions are there which contain a variable with the name we need
|
|
|
|
|
for (size_t i = 0;
|
|
|
|
|
i < variable_list->GetSize();
|
|
|
|
|
i++)
|
|
|
|
|
{
|
|
|
|
|
if (VariableSP variable_sp = variable_list->GetVariableAtIndex(i))
|
|
|
|
|
{
|
|
|
|
|
if (variable_sp->GetName().IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
if (Type *var_type = variable_sp->GetType())
|
|
|
|
|
{
|
|
|
|
|
if (var_type->GetForwardCompilerType().IsAnonymousType())
|
|
|
|
|
{
|
|
|
|
|
valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
|
|
|
|
|
if (!valobj_sp)
|
|
|
|
|
return valobj_sp;
|
|
|
|
|
valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string, true);
|
|
|
|
|
if (valobj_sp)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-14 08:53:55 +08:00
|
|
|
|
|
2015-11-20 06:28:58 +08:00
|
|
|
|
if (var_sp && !valobj_sp)
|
2010-12-14 10:59:59 +08:00
|
|
|
|
{
|
2011-05-04 11:43:18 +08:00
|
|
|
|
valobj_sp = GetValueObjectForFrameVariable (var_sp, use_dynamic);
|
2011-04-16 08:01:13 +08:00
|
|
|
|
if (!valobj_sp)
|
|
|
|
|
return valobj_sp;
|
2015-11-20 06:28:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (valobj_sp)
|
|
|
|
|
{
|
2010-12-15 13:08:08 +08:00
|
|
|
|
// We are dumping at least one child
|
|
|
|
|
while (separator_idx != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
// Calculate the next separator index ahead of time
|
|
|
|
|
ValueObjectSP child_valobj_sp;
|
|
|
|
|
const char separator_type = var_path[0];
|
|
|
|
|
switch (separator_type)
|
2010-12-14 10:59:59 +08:00
|
|
|
|
{
|
2010-12-15 13:08:08 +08:00
|
|
|
|
case '-':
|
|
|
|
|
if (var_path.size() >= 2 && var_path[1] != '>')
|
2010-12-14 10:59:59 +08:00
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
|
2011-01-21 03:27:18 +08:00
|
|
|
|
if (no_fragile_ivar)
|
|
|
|
|
{
|
|
|
|
|
// Make sure we aren't trying to deref an objective
|
|
|
|
|
// C ivar if this is not allowed
|
2016-02-19 02:52:47 +08:00
|
|
|
|
const uint32_t pointer_type_flags = valobj_sp->GetCompilerType().GetTypeInfo(nullptr);
|
2014-10-22 04:52:14 +08:00
|
|
|
|
if ((pointer_type_flags & eTypeIsObjC) &&
|
|
|
|
|
(pointer_type_flags & eTypeIsPointer))
|
2011-01-21 03:27:18 +08:00
|
|
|
|
{
|
|
|
|
|
// This was an objective C object pointer and
|
|
|
|
|
// it was requested we skip any fragile ivars
|
|
|
|
|
// so return nothing here
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
var_path.erase (0, 1); // Remove the '-'
|
2016-02-16 12:14:33 +08:00
|
|
|
|
LLVM_FALLTHROUGH;
|
2010-12-15 13:08:08 +08:00
|
|
|
|
case '.':
|
2010-12-14 10:59:59 +08:00
|
|
|
|
{
|
2010-12-15 13:08:08 +08:00
|
|
|
|
const bool expr_is_ptr = var_path[0] == '>';
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
|
var_path.erase (0, 1); // Remove the '.' or '>'
|
|
|
|
|
separator_idx = var_path.find_first_of(".-[");
|
|
|
|
|
ConstString child_name;
|
|
|
|
|
if (separator_idx == std::string::npos)
|
|
|
|
|
child_name.SetCString (var_path.c_str());
|
2010-12-14 10:59:59 +08:00
|
|
|
|
else
|
2010-12-15 13:08:08 +08:00
|
|
|
|
child_name.SetCStringWithLength(var_path.c_str(), separator_idx);
|
|
|
|
|
|
|
|
|
|
if (check_ptr_vs_member)
|
2010-12-14 10:59:59 +08:00
|
|
|
|
{
|
2010-12-15 13:08:08 +08:00
|
|
|
|
// We either have a pointer type and need to verify
|
|
|
|
|
// valobj_sp is a pointer, or we have a member of a
|
|
|
|
|
// class/union/struct being accessed with the . syntax
|
|
|
|
|
// and need to verify we don't have a pointer.
|
|
|
|
|
const bool actual_is_ptr = valobj_sp->IsPointerType ();
|
|
|
|
|
|
|
|
|
|
if (actual_is_ptr != expr_is_ptr)
|
|
|
|
|
{
|
|
|
|
|
// Incorrect use of "." with a pointer, or "->" with
|
|
|
|
|
// a class/union/struct instance or reference.
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2010-12-15 13:08:08 +08:00
|
|
|
|
if (actual_is_ptr)
|
|
|
|
|
error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?",
|
|
|
|
|
var_expr_path_strm.GetString().c_str(),
|
|
|
|
|
child_name.GetCString(),
|
|
|
|
|
var_expr_path_strm.GetString().c_str(),
|
|
|
|
|
var_path.c_str());
|
|
|
|
|
else
|
|
|
|
|
error.SetErrorStringWithFormat ("\"%s\" is not a pointer and -> was used to attempt to access \"%s\". Did you mean \"%s.%s\"?",
|
|
|
|
|
var_expr_path_strm.GetString().c_str(),
|
|
|
|
|
child_name.GetCString(),
|
|
|
|
|
var_expr_path_strm.GetString().c_str(),
|
|
|
|
|
var_path.c_str());
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true);
|
2010-12-14 10:59:59 +08:00
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (!no_synth_child)
|
2012-03-20 06:58:49 +08:00
|
|
|
|
{
|
|
|
|
|
child_valobj_sp = valobj_sp->GetSyntheticValue();
|
|
|
|
|
if (child_valobj_sp)
|
|
|
|
|
child_valobj_sp = child_valobj_sp->GetChildMemberWithName (child_name, true);
|
|
|
|
|
}
|
2011-08-12 01:08:01 +08:00
|
|
|
|
|
|
|
|
|
if (no_synth_child || !child_valobj_sp)
|
2010-12-15 13:08:08 +08:00
|
|
|
|
{
|
2011-08-12 01:08:01 +08:00
|
|
|
|
// No child member with name "child_name"
|
2012-07-14 08:53:55 +08:00
|
|
|
|
if (synthetically_added_instance_object)
|
2011-08-12 01:08:01 +08:00
|
|
|
|
{
|
2012-07-14 08:53:55 +08:00
|
|
|
|
// We added a "this->" or "self->" to the beginning of the expression
|
|
|
|
|
// and this is the first pointer ivar access, so just return the normal
|
|
|
|
|
// error
|
|
|
|
|
error.SetErrorStringWithFormat("no variable or instance variable named '%s' found in this frame",
|
|
|
|
|
name_const_string.GetCString());
|
2011-08-12 01:08:01 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-07-14 08:53:55 +08:00
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
|
|
|
|
if (child_name)
|
|
|
|
|
{
|
|
|
|
|
error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"",
|
|
|
|
|
child_name.GetCString(),
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"",
|
|
|
|
|
var_expr_path_strm.GetString().c_str(),
|
|
|
|
|
var_expr_cstr);
|
|
|
|
|
}
|
2011-08-12 01:08:01 +08:00
|
|
|
|
}
|
|
|
|
|
return ValueObjectSP();
|
2010-12-15 13:08:08 +08:00
|
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
}
|
2012-07-14 08:53:55 +08:00
|
|
|
|
synthetically_added_instance_object = false;
|
2010-12-15 13:08:08 +08:00
|
|
|
|
// Remove the child name from the path
|
|
|
|
|
var_path.erase(0, child_name.GetLength());
|
2011-09-17 16:33:22 +08:00
|
|
|
|
if (use_dynamic != eNoDynamicValues)
|
2011-04-16 08:01:13 +08:00
|
|
|
|
{
|
2011-05-04 11:43:18 +08:00
|
|
|
|
ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
|
2011-04-16 08:01:13 +08:00
|
|
|
|
if (dynamic_value_sp)
|
|
|
|
|
child_valobj_sp = dynamic_value_sp;
|
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
|
case '[':
|
|
|
|
|
// Array member access, or treating pointer as an array
|
|
|
|
|
if (var_path.size() > 2) // Need at least two brackets and a number
|
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
char *end = nullptr;
|
2011-01-26 07:55:37 +08:00
|
|
|
|
long child_index = ::strtol (&var_path[1], &end, 0);
|
2011-07-06 10:13:41 +08:00
|
|
|
|
if (end && *end == ']'
|
|
|
|
|
&& *(end-1) != '[') // this code forces an error in the case of arr[]. as bitfield[] is not a good syntax we're good to go
|
2010-12-15 13:08:08 +08:00
|
|
|
|
{
|
2015-08-25 07:46:31 +08:00
|
|
|
|
if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
// what we have is *ptr[low]. the most similar C++ syntax is to deref ptr
|
|
|
|
|
// and extract bit low out of it. reading array item low
|
|
|
|
|
// would be done by saying ptr[low], without a deref * sign
|
|
|
|
|
Error error;
|
|
|
|
|
ValueObjectSP temp(valobj_sp->Dereference(error));
|
|
|
|
|
if (error.Fail())
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
|
|
|
|
error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"",
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
valobj_sp = temp;
|
|
|
|
|
deref = false;
|
|
|
|
|
}
|
2015-08-25 07:46:31 +08:00
|
|
|
|
else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
// what we have is *arr[low]. the most similar C++ syntax is to get arr[0]
|
|
|
|
|
// (an operation that is equivalent to deref-ing arr)
|
|
|
|
|
// and extract bit low out of it. reading array item low
|
|
|
|
|
// would be done by saying arr[low], without a deref * sign
|
|
|
|
|
Error error;
|
|
|
|
|
ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true));
|
|
|
|
|
if (error.Fail())
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
|
|
|
|
error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"",
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
valobj_sp = temp;
|
|
|
|
|
deref = false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-06 10:33:54 +08:00
|
|
|
|
bool is_incomplete_array = false;
|
2010-12-15 13:08:08 +08:00
|
|
|
|
if (valobj_sp->IsPointerType ())
|
|
|
|
|
{
|
2012-03-08 10:39:03 +08:00
|
|
|
|
bool is_objc_pointer = true;
|
|
|
|
|
|
2015-08-25 07:46:31 +08:00
|
|
|
|
if (valobj_sp->GetCompilerType().GetMinimumLanguage() != eLanguageTypeObjC)
|
2012-03-08 10:39:03 +08:00
|
|
|
|
is_objc_pointer = false;
|
2015-08-25 07:46:31 +08:00
|
|
|
|
else if (!valobj_sp->GetCompilerType().IsPointerType())
|
2012-03-08 10:39:03 +08:00
|
|
|
|
is_objc_pointer = false;
|
|
|
|
|
|
|
|
|
|
if (no_synth_child && is_objc_pointer)
|
2010-12-15 13:08:08 +08:00
|
|
|
|
{
|
2012-03-08 10:39:03 +08:00
|
|
|
|
error.SetErrorStringWithFormat("\"(%s) %s\" is an Objective-C pointer, and cannot be subscripted",
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
else if (is_objc_pointer)
|
|
|
|
|
{
|
2011-08-09 09:04:56 +08:00
|
|
|
|
// dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children
|
2012-03-20 06:58:49 +08:00
|
|
|
|
ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (!synthetic /* no synthetic */
|
2011-08-09 09:04:56 +08:00
|
|
|
|
|| synthetic == valobj_sp) /* synthetic is the same as the original object */
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
|
|
|
|
error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
2014-04-02 11:51:35 +08:00
|
|
|
|
else if (static_cast<uint32_t>(child_index) >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
|
2011-08-09 09:04:56 +08:00
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2011-09-20 08:26:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
|
2011-08-09 09:04:56 +08:00
|
|
|
|
child_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
|
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2011-09-20 08:26:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
|
2011-08-09 09:04:56 +08:00
|
|
|
|
child_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-02-27 07:55:39 +08:00
|
|
|
|
child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true);
|
2011-08-09 09:04:56 +08:00
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2011-09-20 08:26:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("failed to use pointer as array for index %ld for \"(%s) %s\"",
|
2011-08-09 09:04:56 +08:00
|
|
|
|
child_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-19 02:52:47 +08:00
|
|
|
|
else if (valobj_sp->GetCompilerType().IsArrayType(nullptr, nullptr, &is_incomplete_array))
|
2010-12-15 13:08:08 +08:00
|
|
|
|
{
|
2011-04-16 08:01:13 +08:00
|
|
|
|
// Pass false to dynamic_value here so we can tell the difference between
|
|
|
|
|
// no dynamic value and no member of this type...
|
2010-12-15 13:08:08 +08:00
|
|
|
|
child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true);
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (!child_valobj_sp && (is_incomplete_array || !no_synth_child))
|
2012-12-06 10:33:54 +08:00
|
|
|
|
child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true);
|
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2011-09-20 08:26:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
|
2010-12-15 13:08:08 +08:00
|
|
|
|
child_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-25 07:46:31 +08:00
|
|
|
|
else if (valobj_sp->GetCompilerType().IsScalarType())
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
// this is a bitfield asking to display just one bit
|
|
|
|
|
child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, child_index, true);
|
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2011-09-20 08:26:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"",
|
2011-07-06 10:13:41 +08:00
|
|
|
|
child_index, child_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2012-03-20 06:58:49 +08:00
|
|
|
|
ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
|
2011-08-09 09:04:56 +08:00
|
|
|
|
if (no_synth_child /* synthetic is forbidden */ ||
|
2016-02-19 02:52:47 +08:00
|
|
|
|
!synthetic /* no synthetic */
|
2011-08-09 09:04:56 +08:00
|
|
|
|
|| synthetic == valobj_sp) /* synthetic is the same as the original object */
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
|
|
|
|
error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
2014-04-02 11:51:35 +08:00
|
|
|
|
else if (static_cast<uint32_t>(child_index) >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
|
2011-08-09 09:04:56 +08:00
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2011-09-20 08:26:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
|
2011-08-09 09:04:56 +08:00
|
|
|
|
child_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
|
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2011-09-20 08:26:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
|
2011-08-09 09:04:56 +08:00
|
|
|
|
child_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
// Invalid array index...
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Erase the array member specification '[%i]' where
|
|
|
|
|
// %i is the array index
|
|
|
|
|
var_path.erase(0, (end - var_path.c_str()) + 1);
|
|
|
|
|
separator_idx = var_path.find_first_of(".-[");
|
2011-09-17 16:33:22 +08:00
|
|
|
|
if (use_dynamic != eNoDynamicValues)
|
2011-04-16 08:01:13 +08:00
|
|
|
|
{
|
2011-05-04 11:43:18 +08:00
|
|
|
|
ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
|
2011-04-16 08:01:13 +08:00
|
|
|
|
if (dynamic_value_sp)
|
|
|
|
|
child_valobj_sp = dynamic_value_sp;
|
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
// Break out early from the switch since we were
|
|
|
|
|
// able to find the child member
|
|
|
|
|
break;
|
|
|
|
|
}
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
|
else if (end && *end == '-')
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
// this is most probably a BitField, let's take a look
|
2016-02-19 02:52:47 +08:00
|
|
|
|
char *real_end = nullptr;
|
2011-07-06 10:13:41 +08:00
|
|
|
|
long final_index = ::strtol (end+1, &real_end, 0);
|
2011-08-20 05:13:46 +08:00
|
|
|
|
bool expand_bitfield = true;
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
|
if (real_end && *real_end == ']')
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
// if the format given is [high-low], swap range
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
|
if (child_index > final_index)
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
long temp = child_index;
|
|
|
|
|
child_index = final_index;
|
|
|
|
|
final_index = temp;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 07:46:31 +08:00
|
|
|
|
if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
// what we have is *ptr[low-high]. the most similar C++ syntax is to deref ptr
|
|
|
|
|
// and extract bits low thru high out of it. reading array items low thru high
|
|
|
|
|
// would be done by saying ptr[low-high], without a deref * sign
|
|
|
|
|
Error error;
|
|
|
|
|
ValueObjectSP temp(valobj_sp->Dereference(error));
|
|
|
|
|
if (error.Fail())
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
|
|
|
|
error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"",
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
valobj_sp = temp;
|
|
|
|
|
deref = false;
|
|
|
|
|
}
|
2015-08-25 07:46:31 +08:00
|
|
|
|
else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
// what we have is *arr[low-high]. the most similar C++ syntax is to get arr[0]
|
|
|
|
|
// (an operation that is equivalent to deref-ing arr)
|
|
|
|
|
// and extract bits low thru high out of it. reading array items low thru high
|
|
|
|
|
// would be done by saying arr[low-high], without a deref * sign
|
|
|
|
|
Error error;
|
|
|
|
|
ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true));
|
|
|
|
|
if (error.Fail())
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
|
|
|
|
error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"",
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
valobj_sp = temp;
|
|
|
|
|
deref = false;
|
|
|
|
|
}
|
2011-08-20 05:13:46 +08:00
|
|
|
|
/*else if (valobj_sp->IsArrayType() || valobj_sp->IsPointerType())
|
|
|
|
|
{
|
|
|
|
|
child_valobj_sp = valobj_sp->GetSyntheticArrayRangeChild(child_index, final_index, true);
|
|
|
|
|
expand_bitfield = false;
|
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
|
|
|
|
error.SetErrorStringWithFormat ("array range %i-%i is not valid for \"(%s) %s\"",
|
|
|
|
|
child_index, final_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
|
|
|
|
}*/
|
2011-07-06 10:13:41 +08:00
|
|
|
|
|
2011-08-20 05:13:46 +08:00
|
|
|
|
if (expand_bitfield)
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
2011-08-20 05:13:46 +08:00
|
|
|
|
child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true);
|
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2011-09-20 08:26:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"",
|
2011-08-20 05:13:46 +08:00
|
|
|
|
child_index, final_index,
|
|
|
|
|
valobj_sp->GetTypeName().AsCString("<invalid type>"),
|
|
|
|
|
var_expr_path_strm.GetString().c_str());
|
|
|
|
|
}
|
2011-07-06 10:13:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!child_valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
// Invalid bitfield range...
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Erase the bitfield member specification '[%i-%i]' where
|
|
|
|
|
// %i is the index
|
|
|
|
|
var_path.erase(0, (real_end - var_path.c_str()) + 1);
|
|
|
|
|
separator_idx = var_path.find_first_of(".-[");
|
2011-09-17 16:33:22 +08:00
|
|
|
|
if (use_dynamic != eNoDynamicValues)
|
2011-07-06 10:13:41 +08:00
|
|
|
|
{
|
|
|
|
|
ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
|
|
|
|
|
if (dynamic_value_sp)
|
|
|
|
|
child_valobj_sp = dynamic_value_sp;
|
|
|
|
|
}
|
|
|
|
|
// Break out early from the switch since we were
|
|
|
|
|
// able to find the child member
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error.SetErrorStringWithFormat("invalid square bracket encountered after \"%s\" in \"%s\"",
|
|
|
|
|
var_expr_path_strm.GetString().c_str(),
|
|
|
|
|
var_path.c_str());
|
2010-12-14 10:59:59 +08:00
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
return ValueObjectSP();
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
|
default:
|
|
|
|
|
// Failure...
|
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
valobj_sp->GetExpressionPath (var_expr_path_strm, false);
|
2010-12-15 13:08:08 +08:00
|
|
|
|
error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"",
|
|
|
|
|
separator_type,
|
|
|
|
|
var_expr_path_strm.GetString().c_str(),
|
|
|
|
|
var_path.c_str());
|
|
|
|
|
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
|
if (child_valobj_sp)
|
|
|
|
|
valobj_sp = child_valobj_sp;
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
|
if (var_path.empty())
|
|
|
|
|
break;
|
2010-12-14 10:59:59 +08:00
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
if (valobj_sp)
|
2010-12-14 10:59:59 +08:00
|
|
|
|
{
|
2010-12-15 13:08:08 +08:00
|
|
|
|
if (deref)
|
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
|
ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error));
|
2010-12-15 13:08:08 +08:00
|
|
|
|
valobj_sp = deref_valobj_sp;
|
|
|
|
|
}
|
|
|
|
|
else if (address_of)
|
|
|
|
|
{
|
|
|
|
|
ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf(error));
|
|
|
|
|
valobj_sp = address_of_valobj_sp;
|
|
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
return valobj_sp;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-04 11:43:18 +08:00
|
|
|
|
error.SetErrorStringWithFormat("no variable named '%s' found in this frame",
|
|
|
|
|
name_const_string.GetCString());
|
2010-12-14 10:59:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-15 13:08:08 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error.SetErrorStringWithFormat("invalid variable path '%s'", var_expr_cstr);
|
|
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
|
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (!m_cfa_is_valid)
|
2013-11-04 19:02:52 +08:00
|
|
|
|
{
|
|
|
|
|
m_frame_base_error.SetErrorString("No frame base available for this historical stack frame.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
if (m_flags.IsClear(GOT_FRAME_BASE))
|
|
|
|
|
{
|
|
|
|
|
if (m_sc.function)
|
|
|
|
|
{
|
|
|
|
|
m_frame_base.Clear();
|
|
|
|
|
m_frame_base_error.Clear();
|
|
|
|
|
|
|
|
|
|
m_flags.Set(GOT_FRAME_BASE);
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
Value expr_value;
|
2010-09-14 10:20:48 +08:00
|
|
|
|
addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
|
if (m_sc.function->GetFrameBaseExpression().IsLocationList())
|
2012-02-18 13:35:26 +08:00
|
|
|
|
loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.GetTargetPtr());
|
2010-09-14 10:20:48 +08:00
|
|
|
|
|
2016-02-26 22:21:10 +08:00
|
|
|
|
if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
loclist_base_addr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
expr_value,
|
|
|
|
|
&m_frame_base_error) == false)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
|
|
|
|
// We should really have an error if evaluate returns, but in case
|
|
|
|
|
// we don't, lets set the error to something at least.
|
|
|
|
|
if (m_frame_base_error.Success())
|
|
|
|
|
m_frame_base_error.SetErrorString("Evaluation of the frame base expression failed.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-12 06:46:58 +08:00
|
|
|
|
m_frame_base = expr_value.ResolveValue(&exe_ctx);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_frame_base_error.SetErrorString ("No function in symbol context.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_frame_base_error.Success())
|
|
|
|
|
frame_base = m_frame_base;
|
|
|
|
|
|
|
|
|
|
if (error_ptr)
|
|
|
|
|
*error_ptr = m_frame_base_error;
|
|
|
|
|
return m_frame_base_error.Success();
|
|
|
|
|
}
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 12:48:36 +08:00
|
|
|
|
DWARFExpression *
|
|
|
|
|
StackFrame::GetFrameBaseExpression(Error *error_ptr)
|
|
|
|
|
{
|
|
|
|
|
if (!m_sc.function)
|
|
|
|
|
{
|
|
|
|
|
if (error_ptr)
|
|
|
|
|
{
|
|
|
|
|
error_ptr->SetErrorString ("No function in symbol context.");
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &m_sc.function->GetFrameBaseExpression();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-07 06:15:06 +08:00
|
|
|
|
RegisterContextSP
|
2010-06-09 00:52:24 +08:00
|
|
|
|
StackFrame::GetRegisterContext ()
|
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2011-01-07 06:15:06 +08:00
|
|
|
|
if (!m_reg_context_sp)
|
2012-02-18 13:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
ThreadSP thread_sp (GetThread());
|
|
|
|
|
if (thread_sp)
|
|
|
|
|
m_reg_context_sp = thread_sp->CreateRegisterContextForFrame (this);
|
|
|
|
|
}
|
2011-01-07 06:15:06 +08:00
|
|
|
|
return m_reg_context_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
StackFrame::HasDebugInformation ()
|
|
|
|
|
{
|
2010-08-25 05:05:24 +08:00
|
|
|
|
GetSymbolContext (eSymbolContextLineEntry);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
return m_sc.line_entry.IsValid();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-02 10:59:18 +08:00
|
|
|
|
ValueObjectSP
|
2011-09-17 16:33:22 +08:00
|
|
|
|
StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-09-02 10:59:18 +08:00
|
|
|
|
ValueObjectSP valobj_sp;
|
2013-11-04 19:02:52 +08:00
|
|
|
|
if (m_is_history_frame)
|
|
|
|
|
{
|
|
|
|
|
return valobj_sp;
|
|
|
|
|
}
|
2010-09-02 10:59:18 +08:00
|
|
|
|
VariableList *var_list = GetVariableList (true);
|
|
|
|
|
if (var_list)
|
|
|
|
|
{
|
|
|
|
|
// Make sure the variable is a frame variable
|
|
|
|
|
const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get());
|
|
|
|
|
const uint32_t num_variables = var_list->GetSize();
|
|
|
|
|
if (var_idx < num_variables)
|
|
|
|
|
{
|
|
|
|
|
valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx);
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (!valobj_sp)
|
2010-09-02 10:59:18 +08:00
|
|
|
|
{
|
|
|
|
|
if (m_variable_list_value_objects.GetSize() < num_variables)
|
|
|
|
|
m_variable_list_value_objects.Resize(num_variables);
|
2011-04-23 07:53:53 +08:00
|
|
|
|
valobj_sp = ValueObjectVariable::Create (this, variable_sp);
|
2010-09-02 10:59:18 +08:00
|
|
|
|
m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-17 16:33:22 +08:00
|
|
|
|
if (use_dynamic != eNoDynamicValues && valobj_sp)
|
2011-04-16 08:01:13 +08:00
|
|
|
|
{
|
2011-05-04 11:43:18 +08:00
|
|
|
|
ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (use_dynamic);
|
2011-04-16 08:01:13 +08:00
|
|
|
|
if (dynamic_sp)
|
|
|
|
|
return dynamic_sp;
|
|
|
|
|
}
|
2010-09-02 10:59:18 +08:00
|
|
|
|
return valobj_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueObjectSP
|
2011-09-17 16:33:22 +08:00
|
|
|
|
StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
|
2010-09-02 10:59:18 +08:00
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2013-11-04 19:02:52 +08:00
|
|
|
|
if (m_is_history_frame)
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
|
2010-09-02 10:59:18 +08:00
|
|
|
|
// Check to make sure we aren't already tracking this variable?
|
2011-04-16 08:01:13 +08:00
|
|
|
|
ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic));
|
2010-09-02 10:59:18 +08:00
|
|
|
|
if (!valobj_sp)
|
|
|
|
|
{
|
|
|
|
|
// We aren't already tracking this global
|
|
|
|
|
VariableList *var_list = GetVariableList (true);
|
|
|
|
|
// If this frame has no variables, create a new list
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (var_list == nullptr)
|
2010-09-02 10:59:18 +08:00
|
|
|
|
m_variable_list_sp.reset (new VariableList());
|
|
|
|
|
|
|
|
|
|
// Add the global/static variable to this frame
|
|
|
|
|
m_variable_list_sp->AddVariable (variable_sp);
|
|
|
|
|
|
|
|
|
|
// Now make a value object for it so we can track its changes
|
2011-04-16 08:01:13 +08:00
|
|
|
|
valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
|
2010-09-02 10:59:18 +08:00
|
|
|
|
}
|
|
|
|
|
return valobj_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-27 04:44:45 +08:00
|
|
|
|
bool
|
|
|
|
|
StackFrame::IsInlined ()
|
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (m_sc.block == nullptr)
|
2010-08-31 02:11:35 +08:00
|
|
|
|
GetSymbolContext (eSymbolContextBlock);
|
|
|
|
|
if (m_sc.block)
|
2016-02-19 02:52:47 +08:00
|
|
|
|
return m_sc.block->GetContainingInlinedBlock() != nullptr;
|
2010-08-31 02:11:35 +08:00
|
|
|
|
return false;
|
2010-08-27 04:44:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-04 09:02:30 +08:00
|
|
|
|
lldb::LanguageType
|
|
|
|
|
StackFrame::GetLanguage ()
|
|
|
|
|
{
|
|
|
|
|
CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
|
|
|
|
|
if (cu)
|
|
|
|
|
return cu->GetLanguage();
|
|
|
|
|
return lldb::eLanguageTypeUnknown;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 05:50:51 +08:00
|
|
|
|
lldb::LanguageType
|
|
|
|
|
StackFrame::GuessLanguage ()
|
|
|
|
|
{
|
|
|
|
|
LanguageType lang_type = GetLanguage();
|
|
|
|
|
|
|
|
|
|
if (lang_type == eLanguageTypeUnknown)
|
|
|
|
|
{
|
|
|
|
|
Function *f = GetSymbolContext(eSymbolContextFunction).function;
|
|
|
|
|
if (f)
|
|
|
|
|
{
|
|
|
|
|
lang_type = f->GetMangled().GuessLanguage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lang_type;
|
|
|
|
|
}
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 12:48:36 +08:00
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
std::pair<const Instruction::Operand *, int64_t>
|
|
|
|
|
GetBaseExplainingValue(const Instruction::Operand &operand,
|
|
|
|
|
RegisterContext ®ister_context,
|
|
|
|
|
lldb::addr_t value)
|
|
|
|
|
{
|
|
|
|
|
switch(operand.m_type)
|
|
|
|
|
{
|
|
|
|
|
case Instruction::Operand::Type::Dereference:
|
|
|
|
|
case Instruction::Operand::Type::Immediate:
|
|
|
|
|
case Instruction::Operand::Type::Invalid:
|
|
|
|
|
case Instruction::Operand::Type::Product:
|
|
|
|
|
// These are not currently interesting
|
|
|
|
|
return std::make_pair(nullptr, 0);
|
|
|
|
|
case Instruction::Operand::Type::Sum:
|
|
|
|
|
{
|
|
|
|
|
const Instruction::Operand *immediate_child = nullptr;
|
|
|
|
|
const Instruction::Operand *variable_child = nullptr;
|
|
|
|
|
if (operand.m_children[0].m_type == Instruction::Operand::Type::Immediate)
|
|
|
|
|
{
|
|
|
|
|
immediate_child = &operand.m_children[0];
|
|
|
|
|
variable_child = &operand.m_children[1];
|
|
|
|
|
}
|
|
|
|
|
else if (operand.m_children[1].m_type == Instruction::Operand::Type::Immediate)
|
|
|
|
|
{
|
|
|
|
|
immediate_child = &operand.m_children[1];
|
|
|
|
|
variable_child = &operand.m_children[0];
|
|
|
|
|
}
|
|
|
|
|
if (!immediate_child)
|
|
|
|
|
{
|
|
|
|
|
return std::make_pair(nullptr, 0);
|
|
|
|
|
}
|
|
|
|
|
lldb::addr_t adjusted_value = value;
|
|
|
|
|
if (immediate_child->m_negative)
|
|
|
|
|
{
|
|
|
|
|
adjusted_value += immediate_child->m_immediate;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
adjusted_value -= immediate_child->m_immediate;
|
|
|
|
|
}
|
|
|
|
|
std::pair<const Instruction::Operand *, int64_t> base_and_offset = GetBaseExplainingValue(*variable_child, register_context, adjusted_value);
|
|
|
|
|
if (!base_and_offset.first)
|
|
|
|
|
{
|
|
|
|
|
return std::make_pair(nullptr, 0);
|
|
|
|
|
}
|
|
|
|
|
if (immediate_child->m_negative)
|
|
|
|
|
{
|
|
|
|
|
base_and_offset.second -= immediate_child->m_immediate;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
base_and_offset.second += immediate_child->m_immediate;
|
|
|
|
|
}
|
|
|
|
|
return base_and_offset;
|
|
|
|
|
}
|
|
|
|
|
case Instruction::Operand::Type::Register:
|
|
|
|
|
{
|
|
|
|
|
const RegisterInfo *info = register_context.GetRegisterInfoByName(operand.m_register.AsCString());
|
|
|
|
|
if (!info)
|
|
|
|
|
{
|
|
|
|
|
return std::make_pair(nullptr, 0);
|
|
|
|
|
}
|
|
|
|
|
RegisterValue reg_value;
|
|
|
|
|
if (!register_context.ReadRegister(info, reg_value))
|
|
|
|
|
{
|
|
|
|
|
return std::make_pair(nullptr, 0);
|
|
|
|
|
}
|
|
|
|
|
if (reg_value.GetAsUInt64() == value)
|
|
|
|
|
{
|
|
|
|
|
return std::make_pair(&operand, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return std::make_pair(nullptr, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::pair<const Instruction::Operand *, int64_t>
|
|
|
|
|
GetBaseExplainingDereference(const Instruction::Operand &operand,
|
|
|
|
|
RegisterContext ®ister_context,
|
|
|
|
|
lldb::addr_t addr)
|
|
|
|
|
{
|
|
|
|
|
if (operand.m_type == Instruction::Operand::Type::Dereference)
|
|
|
|
|
{
|
|
|
|
|
return GetBaseExplainingValue(operand.m_children[0],
|
|
|
|
|
register_context,
|
|
|
|
|
addr);
|
|
|
|
|
}
|
|
|
|
|
return std::make_pair(nullptr, 0);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
lldb::ValueObjectSP
|
|
|
|
|
StackFrame::GuessValueForAddress(lldb::addr_t addr)
|
|
|
|
|
{
|
|
|
|
|
TargetSP target_sp = CalculateTarget();
|
|
|
|
|
|
|
|
|
|
const ArchSpec &target_arch = target_sp->GetArchitecture();
|
|
|
|
|
|
|
|
|
|
AddressRange pc_range;
|
|
|
|
|
pc_range.GetBaseAddress() = GetFrameCodeAddress();
|
|
|
|
|
pc_range.SetByteSize(target_arch.GetMaximumOpcodeByteSize());
|
|
|
|
|
|
|
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
|
|
|
|
|
|
|
|
|
const char *plugin_name = nullptr;
|
|
|
|
|
const char *flavor = nullptr;
|
|
|
|
|
const bool prefer_file_cache = false;
|
|
|
|
|
|
|
|
|
|
DisassemblerSP disassembler_sp = Disassembler::DisassembleRange (target_arch,
|
|
|
|
|
plugin_name,
|
|
|
|
|
flavor,
|
|
|
|
|
exe_ctx,
|
|
|
|
|
pc_range,
|
|
|
|
|
prefer_file_cache);
|
|
|
|
|
|
|
|
|
|
if (!disassembler_sp->GetInstructionList().GetSize())
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InstructionSP instruction_sp = disassembler_sp->GetInstructionList().GetInstructionAtIndex(0);
|
|
|
|
|
|
|
|
|
|
llvm::SmallVector<Instruction::Operand, 3> operands;
|
|
|
|
|
|
|
|
|
|
if (!instruction_sp->ParseOperands(operands))
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegisterContextSP register_context_sp = GetRegisterContext();
|
|
|
|
|
|
|
|
|
|
if (!register_context_sp)
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const Instruction::Operand &operand : operands)
|
|
|
|
|
{
|
|
|
|
|
std::pair<const Instruction::Operand *, int64_t>
|
|
|
|
|
base_and_offset = GetBaseExplainingDereference(operand, *register_context_sp, addr);
|
|
|
|
|
|
|
|
|
|
if (!base_and_offset.first)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (base_and_offset.first->m_type)
|
|
|
|
|
{
|
|
|
|
|
case Instruction::Operand::Type::Immediate:
|
|
|
|
|
{
|
|
|
|
|
lldb_private::Address addr;
|
|
|
|
|
if (target_sp->ResolveLoadAddress(base_and_offset.first->m_immediate + base_and_offset.second, addr))
|
|
|
|
|
{
|
|
|
|
|
TypeSystem *c_type_system = target_sp->GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC);
|
|
|
|
|
if (!c_type_system)
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CompilerType void_ptr_type = c_type_system->GetBasicTypeFromAST(lldb::BasicType::eBasicTypeChar).GetPointerType();
|
|
|
|
|
return ValueObjectMemory::Create(this, "", addr, void_ptr_type);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Instruction::Operand::Type::Register:
|
|
|
|
|
{
|
|
|
|
|
return GuessValueForRegisterAndOffset(base_and_offset.first->m_register, base_and_offset.second);
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
ValueObjectSP
|
|
|
|
|
GetValueForOffset(StackFrame &frame, ValueObjectSP &parent, int64_t offset)
|
|
|
|
|
{
|
|
|
|
|
if (offset < 0 || offset >= parent->GetByteSize())
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (parent->IsPointerOrReferenceType())
|
|
|
|
|
{
|
|
|
|
|
return parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int ci = 0, ce = parent->GetNumChildren(); ci != ce; ++ci)
|
|
|
|
|
{
|
|
|
|
|
const bool can_create = true;
|
|
|
|
|
ValueObjectSP child_sp = parent->GetChildAtIndex(ci, can_create);
|
|
|
|
|
|
|
|
|
|
if (!child_sp)
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t child_offset = child_sp->GetByteOffset();
|
|
|
|
|
int64_t child_size = child_sp->GetByteSize();
|
|
|
|
|
|
|
|
|
|
if (offset >= child_offset &&
|
|
|
|
|
offset < (child_offset + child_size))
|
|
|
|
|
{
|
|
|
|
|
return GetValueForOffset(frame, child_sp, offset - child_offset);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (offset == 0)
|
|
|
|
|
{
|
|
|
|
|
return parent;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueObjectSP
|
|
|
|
|
GetValueForDereferincingOffset(StackFrame &frame, ValueObjectSP &base, int64_t offset)
|
|
|
|
|
{
|
|
|
|
|
// base is a pointer to something
|
|
|
|
|
// offset is the thing to add to the pointer
|
|
|
|
|
// We return the most sensible ValueObject for the result of *(base+offset)
|
|
|
|
|
|
|
|
|
|
if (!base->IsPointerOrReferenceType())
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Error error;
|
|
|
|
|
ValueObjectSP pointee = base->Dereference(error);
|
|
|
|
|
|
|
|
|
|
if (offset >= pointee->GetByteSize())
|
|
|
|
|
{
|
|
|
|
|
int64_t index = offset / pointee->GetByteSize();
|
|
|
|
|
offset = offset % pointee->GetByteSize();
|
|
|
|
|
const bool can_create = true;
|
|
|
|
|
pointee = base->GetSyntheticArrayMember(index, can_create);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!pointee || error.Fail())
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return GetValueForOffset(frame, pointee, offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
/// Attempt to reconstruct the ValueObject for the address contained in a
|
|
|
|
|
/// given register plus an offset.
|
|
|
|
|
///
|
|
|
|
|
/// @params [in] frame
|
|
|
|
|
/// The current stack frame.
|
|
|
|
|
///
|
|
|
|
|
/// @params [in] reg
|
|
|
|
|
/// The register.
|
|
|
|
|
///
|
|
|
|
|
/// @params [in] offset
|
|
|
|
|
/// The offset from the register.
|
|
|
|
|
///
|
|
|
|
|
/// @param [in] disassembler
|
|
|
|
|
/// A disassembler containing instructions valid up to the current PC.
|
|
|
|
|
///
|
|
|
|
|
/// @param [in] variables
|
|
|
|
|
/// The variable list from the current frame,
|
|
|
|
|
///
|
|
|
|
|
/// @param [in] pc
|
|
|
|
|
/// The program counter for the instruction considered the 'user'.
|
|
|
|
|
///
|
|
|
|
|
/// @return
|
|
|
|
|
/// A string describing the base for the ExpressionPath. This could be a
|
|
|
|
|
/// variable, a register value, an argument, or a function return value.
|
|
|
|
|
/// The ValueObject if found. If valid, it has a valid ExpressionPath.
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
lldb::ValueObjectSP
|
|
|
|
|
DoGuessValueAt(StackFrame &frame, ConstString reg, int64_t offset, Disassembler &disassembler, VariableList &variables, const Address &pc)
|
|
|
|
|
{
|
|
|
|
|
// Example of operation for Intel:
|
|
|
|
|
//
|
|
|
|
|
// +14: movq -0x8(%rbp), %rdi
|
|
|
|
|
// +18: movq 0x8(%rdi), %rdi
|
|
|
|
|
// +22: addl 0x4(%rdi), %eax
|
|
|
|
|
//
|
|
|
|
|
// f, a pointer to a struct, is known to be at -0x8(%rbp).
|
|
|
|
|
//
|
|
|
|
|
// DoGuessValueAt(frame, rdi, 4, dis, vars, 0x22) finds the instruction at +18 that assigns to rdi, and calls itself recursively for that dereference
|
|
|
|
|
// DoGuessValueAt(frame, rdi, 8, dis, vars, 0x18) finds the instruction at +14 that assigns to rdi, and calls itself recursively for that derefernece
|
|
|
|
|
// DoGuessValueAt(frame, rbp, -8, dis, vars, 0x14) finds "f" in the variable list.
|
|
|
|
|
// Returns a ValueObject for f. (That's what was stored at rbp-8 at +14)
|
|
|
|
|
// Returns a ValueObject for *(f+8) or f->b (That's what was stored at rdi+8 at +18)
|
|
|
|
|
// Returns a ValueObject for *(f->b+4) or f->b->a (That's what was stored at rdi+4 at +22)
|
|
|
|
|
|
|
|
|
|
// First, check the variable list to see if anything is at the specified location.
|
|
|
|
|
for (size_t vi = 0, ve = variables.GetSize(); vi != ve; ++vi)
|
|
|
|
|
{
|
|
|
|
|
VariableSP var_sp = variables.GetVariableAtIndex(vi);
|
|
|
|
|
DWARFExpression &dwarf_expression = var_sp->LocationExpression();
|
|
|
|
|
|
|
|
|
|
const RegisterInfo *expression_reg;
|
|
|
|
|
int64_t expression_offset;
|
|
|
|
|
ExecutionContext exe_ctx;
|
|
|
|
|
|
|
|
|
|
if (dwarf_expression.IsDereferenceOfRegister(frame, expression_reg, expression_offset))
|
|
|
|
|
{
|
|
|
|
|
if ((reg == ConstString(expression_reg->name) ||
|
|
|
|
|
reg == ConstString(expression_reg->alt_name)) &&
|
|
|
|
|
expression_offset == offset)
|
|
|
|
|
{
|
|
|
|
|
return frame.GetValueObjectForFrameVariable(var_sp, eNoDynamicValues);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_in_return_register = false;
|
|
|
|
|
ABISP abi_sp = frame.CalculateProcess()->GetABI();
|
|
|
|
|
RegisterInfo return_register_info;
|
|
|
|
|
|
|
|
|
|
if (abi_sp)
|
|
|
|
|
{
|
|
|
|
|
const char *return_register_name;
|
|
|
|
|
const RegisterInfo *reg_info = nullptr;
|
|
|
|
|
if (abi_sp->GetPointerReturnRegister(return_register_name) &&
|
|
|
|
|
reg == ConstString(return_register_name) &&
|
|
|
|
|
(reg_info = frame.GetRegisterContext()->GetRegisterInfoByName(return_register_name)))
|
|
|
|
|
{
|
|
|
|
|
is_in_return_register = true;
|
|
|
|
|
return_register_info = *reg_info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t current_inst = disassembler.GetInstructionList().GetIndexOfInstructionAtAddress(pc);
|
|
|
|
|
if (current_inst == UINT32_MAX)
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueObjectSP source_path;
|
|
|
|
|
|
|
|
|
|
for (uint32_t ii = current_inst - 1; ii != (uint32_t)-1; --ii)
|
|
|
|
|
{
|
|
|
|
|
// This is not an exact algorithm, and it sacrifices accuracy for generality.
|
|
|
|
|
// Recognizing "mov" and "ld" instructions –– and which are their source and
|
|
|
|
|
// destination operands -- is something the disassembler should do for us.
|
|
|
|
|
InstructionSP instruction_sp = disassembler.GetInstructionList().GetInstructionAtIndex(ii);
|
|
|
|
|
|
|
|
|
|
if (is_in_return_register && instruction_sp->IsCall())
|
|
|
|
|
{
|
|
|
|
|
llvm::SmallVector<Instruction::Operand, 1> operands;
|
|
|
|
|
if (!instruction_sp->ParseOperands(operands) || operands.size() != 1)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (operands[0].m_type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
case Instruction::Operand::Type::Immediate:
|
|
|
|
|
{
|
|
|
|
|
SymbolContext sc;
|
|
|
|
|
Address load_address;
|
|
|
|
|
if (!frame.CalculateTarget()->ResolveLoadAddress(operands[0].m_immediate, load_address))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
frame.CalculateTarget()->GetImages().ResolveSymbolContextForAddress(load_address, eSymbolContextFunction, sc);
|
|
|
|
|
if (!sc.function)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
CompilerType function_type = sc.function->GetCompilerType();
|
|
|
|
|
if (!function_type.IsFunctionType())
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
CompilerType return_type = function_type.GetFunctionReturnType();
|
|
|
|
|
RegisterValue return_value;
|
|
|
|
|
if (!frame.GetRegisterContext()->ReadRegister(&return_register_info, return_value))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
std::string name_str(sc.function->GetName().AsCString("<unknown function>"));
|
|
|
|
|
name_str.append("()");
|
|
|
|
|
Address return_value_address(return_value.GetAsUInt64());
|
|
|
|
|
ValueObjectSP return_value_sp = ValueObjectMemory::Create(&frame, name_str.c_str(), return_value_address, return_type);
|
|
|
|
|
return GetValueForDereferincingOffset(frame, return_value_sp, offset);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llvm::SmallVector<Instruction::Operand, 2> operands;
|
|
|
|
|
if (!instruction_sp->ParseOperands(operands) || operands.size() != 2)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Instruction::Operand *register_operand = nullptr;
|
|
|
|
|
Instruction::Operand *origin_operand = nullptr;
|
|
|
|
|
if (operands[0].m_type == Instruction::Operand::Type::Register &&
|
|
|
|
|
operands[0].m_clobbered == true &&
|
|
|
|
|
operands[0].m_register == reg)
|
|
|
|
|
{
|
|
|
|
|
register_operand = &operands[0];
|
|
|
|
|
origin_operand = &operands[1];
|
|
|
|
|
}
|
|
|
|
|
else if (operands[1].m_type == Instruction::Operand::Type::Register &&
|
|
|
|
|
operands[1].m_clobbered == true &&
|
|
|
|
|
operands[1].m_register == reg)
|
|
|
|
|
{
|
|
|
|
|
register_operand = &operands[1];
|
|
|
|
|
origin_operand = &operands[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We have an origin operand. Can we track its value down?
|
|
|
|
|
switch (origin_operand->m_type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
case Instruction::Operand::Type::Register:
|
|
|
|
|
source_path = DoGuessValueAt(frame, origin_operand->m_register, 0, disassembler, variables, instruction_sp->GetAddress());
|
|
|
|
|
break;
|
|
|
|
|
case Instruction::Operand::Type::Dereference:
|
|
|
|
|
{
|
|
|
|
|
const Instruction::Operand &pointer = origin_operand->m_children[0];
|
|
|
|
|
switch (pointer.m_type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
case Instruction::Operand::Type::Register:
|
|
|
|
|
source_path = DoGuessValueAt(frame, pointer.m_register, 0, disassembler, variables, instruction_sp->GetAddress());
|
|
|
|
|
if (source_path)
|
|
|
|
|
{
|
|
|
|
|
Error err;
|
|
|
|
|
source_path = source_path->Dereference(err);
|
|
|
|
|
if (!err.Success())
|
|
|
|
|
{
|
|
|
|
|
source_path.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Instruction::Operand::Type::Sum:
|
|
|
|
|
{
|
|
|
|
|
const Instruction::Operand *origin_register = nullptr;
|
|
|
|
|
const Instruction::Operand *origin_offset = nullptr;
|
|
|
|
|
if (pointer.m_children.size() != 2)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (pointer.m_children[0].m_type == Instruction::Operand::Type::Register &&
|
|
|
|
|
pointer.m_children[1].m_type == Instruction::Operand::Type::Immediate)
|
|
|
|
|
{
|
|
|
|
|
origin_register = &pointer.m_children[0];
|
|
|
|
|
origin_offset = &pointer.m_children[1];
|
|
|
|
|
}
|
|
|
|
|
else if (pointer.m_children[1].m_type == Instruction::Operand::Type::Register &&
|
|
|
|
|
pointer.m_children[0].m_type == Instruction::Operand::Type::Immediate)
|
|
|
|
|
{
|
|
|
|
|
origin_register = &pointer.m_children[1];
|
|
|
|
|
origin_offset = &pointer.m_children[0];
|
|
|
|
|
}
|
|
|
|
|
if (!origin_register)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
int64_t signed_origin_offset = origin_offset->m_negative ? -((int64_t)origin_offset->m_immediate) : origin_offset->m_immediate;
|
|
|
|
|
source_path = DoGuessValueAt(frame, origin_register->m_register, signed_origin_offset, disassembler, variables, instruction_sp->GetAddress());
|
|
|
|
|
if (!source_path)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
source_path = GetValueForDereferincingOffset(frame, source_path, offset);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (source_path)
|
|
|
|
|
{
|
|
|
|
|
return source_path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::ValueObjectSP
|
|
|
|
|
StackFrame::GuessValueForRegisterAndOffset(ConstString reg, int64_t offset)
|
|
|
|
|
{
|
|
|
|
|
TargetSP target_sp = CalculateTarget();
|
|
|
|
|
|
|
|
|
|
const ArchSpec &target_arch = target_sp->GetArchitecture();
|
|
|
|
|
|
|
|
|
|
Block *frame_block = GetFrameBlock();
|
|
|
|
|
|
|
|
|
|
if (!frame_block)
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Function *function = frame_block->CalculateSymbolContextFunction();
|
|
|
|
|
if (!function)
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AddressRange pc_range = function->GetAddressRange();
|
|
|
|
|
|
|
|
|
|
if (GetFrameCodeAddress().GetFileAddress() < pc_range.GetBaseAddress().GetFileAddress() ||
|
|
|
|
|
GetFrameCodeAddress().GetFileAddress() - pc_range.GetBaseAddress().GetFileAddress() >= pc_range.GetByteSize())
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
|
|
|
|
|
|
|
|
|
const char *plugin_name = nullptr;
|
|
|
|
|
const char *flavor = nullptr;
|
|
|
|
|
const bool prefer_file_cache = false;
|
|
|
|
|
DisassemblerSP disassembler_sp = Disassembler::DisassembleRange (target_arch,
|
|
|
|
|
plugin_name,
|
|
|
|
|
flavor,
|
|
|
|
|
exe_ctx,
|
|
|
|
|
pc_range,
|
|
|
|
|
prefer_file_cache);
|
|
|
|
|
|
|
|
|
|
if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize())
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool get_file_globals = false;
|
|
|
|
|
VariableList *variables = GetVariableList(get_file_globals);
|
|
|
|
|
|
|
|
|
|
if (!variables)
|
|
|
|
|
{
|
|
|
|
|
return ValueObjectSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DoGuessValueAt(*this, reg, offset, *disassembler_sp, *variables, GetFrameCodeAddress());
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 13:35:26 +08:00
|
|
|
|
TargetSP
|
2010-06-09 00:52:24 +08:00
|
|
|
|
StackFrame::CalculateTarget ()
|
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
TargetSP target_sp;
|
|
|
|
|
ThreadSP thread_sp(GetThread());
|
|
|
|
|
if (thread_sp)
|
|
|
|
|
{
|
|
|
|
|
ProcessSP process_sp (thread_sp->CalculateProcess());
|
|
|
|
|
if (process_sp)
|
|
|
|
|
target_sp = process_sp->CalculateTarget();
|
|
|
|
|
}
|
|
|
|
|
return target_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ProcessSP
|
2010-06-09 00:52:24 +08:00
|
|
|
|
StackFrame::CalculateProcess ()
|
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ProcessSP process_sp;
|
|
|
|
|
ThreadSP thread_sp(GetThread());
|
|
|
|
|
if (thread_sp)
|
|
|
|
|
process_sp = thread_sp->CalculateProcess();
|
|
|
|
|
return process_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ThreadSP
|
2010-06-09 00:52:24 +08:00
|
|
|
|
StackFrame::CalculateThread ()
|
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
return GetThread();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 17:33:30 +08:00
|
|
|
|
StackFrameSP
|
|
|
|
|
StackFrame::CalculateStackFrame ()
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
return shared_from_this();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-10-04 09:05:56 +08:00
|
|
|
|
StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
exe_ctx.SetContext (shared_from_this());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-04 09:05:56 +08:00
|
|
|
|
void
|
2013-10-19 01:38:31 +08:00
|
|
|
|
StackFrame::DumpUsingSettingsFormat (Stream *strm, const char *frame_marker)
|
2010-10-04 09:05:56 +08:00
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (strm == nullptr)
|
2010-10-04 09:05:56 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
GetSymbolContext(eSymbolContextEverything);
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
2010-10-04 09:05:56 +08:00
|
|
|
|
StreamString s;
|
2013-10-19 01:38:31 +08:00
|
|
|
|
|
|
|
|
|
if (frame_marker)
|
|
|
|
|
s.PutCString(frame_marker);
|
|
|
|
|
|
2016-02-19 02:52:47 +08:00
|
|
|
|
const FormatEntity::Entry *frame_format = nullptr;
|
2012-02-18 13:35:26 +08:00
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
|
if (target)
|
|
|
|
|
frame_format = target->GetDebugger().GetFrameFormat();
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (frame_format && FormatEntity::Format(*frame_format, s, &m_sc, &exe_ctx, nullptr, nullptr, false, false))
|
2010-10-04 09:05:56 +08:00
|
|
|
|
{
|
|
|
|
|
strm->Write(s.GetData(), s.GetSize());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Dump (strm, true, false);
|
|
|
|
|
strm->EOL();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
void
|
2010-09-03 05:44:10 +08:00
|
|
|
|
StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (strm == nullptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (show_frame_index)
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
strm->Printf("frame #%u: ", m_frame_index);
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
2012-11-30 05:49:15 +08:00
|
|
|
|
strm->Printf("0x%0*" PRIx64 " ",
|
2012-02-18 13:35:26 +08:00
|
|
|
|
target ? (target->GetArchitecture().GetAddressByteSize() * 2) : 16,
|
|
|
|
|
GetFrameCodeAddress().GetLoadAddress(target));
|
2010-08-25 05:05:24 +08:00
|
|
|
|
GetSymbolContext(eSymbolContextEverything);
|
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
2010-08-24 08:45:41 +08:00
|
|
|
|
const bool show_module = true;
|
|
|
|
|
const bool show_inline = true;
|
2014-10-11 07:07:36 +08:00
|
|
|
|
const bool show_function_arguments = true;
|
2015-02-14 07:24:21 +08:00
|
|
|
|
const bool show_function_name = true;
|
2012-02-18 13:35:26 +08:00
|
|
|
|
m_sc.DumpStopContext (strm,
|
|
|
|
|
exe_ctx.GetBestExecutionContextScope(),
|
|
|
|
|
GetFrameCodeAddress(),
|
|
|
|
|
show_fullpaths,
|
|
|
|
|
show_module,
|
2014-10-11 07:07:36 +08:00
|
|
|
|
show_inline,
|
2015-02-14 07:24:21 +08:00
|
|
|
|
show_function_arguments,
|
|
|
|
|
show_function_name);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-28 02:24:16 +08:00
|
|
|
|
void
|
2013-11-04 17:33:30 +08:00
|
|
|
|
StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame)
|
2010-08-28 02:24:16 +08:00
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-08-31 02:11:35 +08:00
|
|
|
|
assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing
|
2013-11-04 17:33:30 +08:00
|
|
|
|
m_variable_list_sp = prev_frame.m_variable_list_sp;
|
|
|
|
|
m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects);
|
|
|
|
|
if (!m_disassembly.GetString().empty())
|
|
|
|
|
m_disassembly.GetString().swap (m_disassembly.GetString());
|
2010-08-28 02:24:16 +08:00
|
|
|
|
}
|
2010-08-28 05:47:54 +08:00
|
|
|
|
|
2010-08-31 02:11:35 +08:00
|
|
|
|
void
|
2013-11-04 17:33:30 +08:00
|
|
|
|
StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame)
|
2010-08-31 02:11:35 +08:00
|
|
|
|
{
|
2016-05-19 13:13:57 +08:00
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-09-04 01:10:42 +08:00
|
|
|
|
assert (GetStackID() == curr_frame.GetStackID()); // TODO: remove this after some testing
|
2013-11-04 17:33:30 +08:00
|
|
|
|
m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value
|
|
|
|
|
assert (GetThread() == curr_frame.GetThread());
|
|
|
|
|
m_frame_index = curr_frame.m_frame_index;
|
|
|
|
|
m_concrete_frame_index = curr_frame.m_concrete_frame_index;
|
|
|
|
|
m_reg_context_sp = curr_frame.m_reg_context_sp;
|
|
|
|
|
m_frame_code_addr = curr_frame.m_frame_code_addr;
|
2016-02-19 02:52:47 +08:00
|
|
|
|
assert (!m_sc.target_sp || !curr_frame.m_sc.target_sp || m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get());
|
|
|
|
|
assert (!m_sc.module_sp || !curr_frame.m_sc.module_sp || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get());
|
|
|
|
|
assert (m_sc.comp_unit == nullptr || curr_frame.m_sc.comp_unit == nullptr || m_sc.comp_unit == curr_frame.m_sc.comp_unit);
|
|
|
|
|
assert (m_sc.function == nullptr || curr_frame.m_sc.function == nullptr || m_sc.function == curr_frame.m_sc.function);
|
2013-11-04 17:33:30 +08:00
|
|
|
|
m_sc = curr_frame.m_sc;
|
|
|
|
|
m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything);
|
|
|
|
|
m_flags.Set (m_sc.GetResolvedMask());
|
|
|
|
|
m_frame_base.Clear();
|
|
|
|
|
m_frame_base_error.Clear();
|
2010-08-31 02:11:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 17:33:30 +08:00
|
|
|
|
bool
|
|
|
|
|
StackFrame::HasCachedData () const
|
|
|
|
|
{
|
2016-02-19 02:52:47 +08:00
|
|
|
|
if (m_variable_list_sp)
|
2013-11-04 17:33:30 +08:00
|
|
|
|
return true;
|
|
|
|
|
if (m_variable_list_value_objects.GetSize() > 0)
|
|
|
|
|
return true;
|
|
|
|
|
if (!m_disassembly.GetString().empty())
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
|
bool
|
|
|
|
|
StackFrame::GetStatus (Stream& strm,
|
|
|
|
|
bool show_frame_info,
|
2013-10-19 01:38:31 +08:00
|
|
|
|
bool show_source,
|
|
|
|
|
const char *frame_marker)
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
|
{
|
2012-07-12 04:33:48 +08:00
|
|
|
|
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
|
if (show_frame_info)
|
|
|
|
|
{
|
|
|
|
|
strm.Indent();
|
2013-10-19 01:38:31 +08:00
|
|
|
|
DumpUsingSettingsFormat (&strm, frame_marker);
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (show_source)
|
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
2015-12-03 12:56:16 +08:00
|
|
|
|
bool have_source = false, have_debuginfo = false;
|
2012-08-23 01:17:09 +08:00
|
|
|
|
Debugger::StopDisassemblyType disasm_display = Debugger::eStopDisassemblyTypeNever;
|
2012-02-18 13:35:26 +08:00
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
2012-07-12 04:33:48 +08:00
|
|
|
|
if (target)
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
|
{
|
2012-07-12 04:33:48 +08:00
|
|
|
|
Debugger &debugger = target->GetDebugger();
|
|
|
|
|
const uint32_t source_lines_before = debugger.GetStopSourceLineCount(true);
|
|
|
|
|
const uint32_t source_lines_after = debugger.GetStopSourceLineCount(false);
|
|
|
|
|
disasm_display = debugger.GetStopDisassemblyDisplay ();
|
2011-11-22 05:44:34 +08:00
|
|
|
|
|
2014-07-08 04:47:24 +08:00
|
|
|
|
GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
|
|
|
|
|
if (m_sc.comp_unit && m_sc.line_entry.IsValid())
|
2011-11-22 05:44:34 +08:00
|
|
|
|
{
|
2015-12-03 12:56:16 +08:00
|
|
|
|
have_debuginfo = true;
|
2014-07-08 04:47:24 +08:00
|
|
|
|
if (source_lines_before > 0 || source_lines_after > 0)
|
2011-11-22 05:44:34 +08:00
|
|
|
|
{
|
2015-12-03 12:56:16 +08:00
|
|
|
|
size_t num_lines = target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
|
2012-07-12 04:33:48 +08:00
|
|
|
|
m_sc.line_entry.line,
|
|
|
|
|
source_lines_before,
|
|
|
|
|
source_lines_after,
|
|
|
|
|
"->",
|
2013-04-29 17:59:31 +08:00
|
|
|
|
&strm);
|
2015-12-03 12:56:16 +08:00
|
|
|
|
if (num_lines != 0)
|
|
|
|
|
have_source = true;
|
|
|
|
|
// TODO: Give here a one time warning if source file is missing.
|
2011-11-22 05:44:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-12 04:33:48 +08:00
|
|
|
|
switch (disasm_display)
|
2011-11-22 05:44:34 +08:00
|
|
|
|
{
|
2012-08-23 01:17:09 +08:00
|
|
|
|
case Debugger::eStopDisassemblyTypeNever:
|
2012-07-12 04:33:48 +08:00
|
|
|
|
break;
|
2015-12-03 12:56:16 +08:00
|
|
|
|
|
|
|
|
|
case Debugger::eStopDisassemblyTypeNoDebugInfo:
|
|
|
|
|
if (have_debuginfo)
|
|
|
|
|
break;
|
2016-02-16 12:14:33 +08:00
|
|
|
|
LLVM_FALLTHROUGH;
|
2015-12-03 12:56:16 +08:00
|
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
|
case Debugger::eStopDisassemblyTypeNoSource:
|
2012-07-12 04:33:48 +08:00
|
|
|
|
if (have_source)
|
|
|
|
|
break;
|
2016-02-16 12:14:33 +08:00
|
|
|
|
LLVM_FALLTHROUGH;
|
2015-12-03 12:56:16 +08:00
|
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
|
case Debugger::eStopDisassemblyTypeAlways:
|
2012-07-12 04:33:48 +08:00
|
|
|
|
if (target)
|
2011-11-22 05:44:34 +08:00
|
|
|
|
{
|
2012-07-12 04:33:48 +08:00
|
|
|
|
const uint32_t disasm_lines = debugger.GetDisassemblyLineCount();
|
|
|
|
|
if (disasm_lines > 0)
|
|
|
|
|
{
|
|
|
|
|
const ArchSpec &target_arch = target->GetArchitecture();
|
|
|
|
|
AddressRange pc_range;
|
|
|
|
|
pc_range.GetBaseAddress() = GetFrameCodeAddress();
|
|
|
|
|
pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize());
|
2016-02-19 02:52:47 +08:00
|
|
|
|
const char *plugin_name = nullptr;
|
|
|
|
|
const char *flavor = nullptr;
|
2012-07-12 04:33:48 +08:00
|
|
|
|
Disassembler::Disassemble (target->GetDebugger(),
|
|
|
|
|
target_arch,
|
2013-03-02 08:26:47 +08:00
|
|
|
|
plugin_name,
|
|
|
|
|
flavor,
|
2012-07-12 04:33:48 +08:00
|
|
|
|
exe_ctx,
|
|
|
|
|
pc_range,
|
|
|
|
|
disasm_lines,
|
|
|
|
|
0,
|
|
|
|
|
Disassembler::eOptionMarkPCAddress,
|
|
|
|
|
strm);
|
|
|
|
|
}
|
2011-11-22 05:44:34 +08:00
|
|
|
|
}
|
2012-07-12 04:33:48 +08:00
|
|
|
|
break;
|
2011-11-22 05:44:34 +08:00
|
|
|
|
}
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|