forked from OSchip/llvm-project
Move the SourceManager from the Debugger to the Target. That way it can store the per-Target default Source File & Line.
Set the default Source File & line to main (if it can be found.) at startup. Selecting the current thread & or frame resets the current source file & line, and "source list" as well as the breakpoint command "break set -l <NUM>" will use the current source file. llvm-svn: 139323
This commit is contained in:
parent
7db8d697cf
commit
b7f6b2fa3c
|
@ -345,7 +345,11 @@ public:
|
|||
SourceManager &
|
||||
GetSourceManager ()
|
||||
{
|
||||
return m_source_manager;
|
||||
lldb::TargetSP selected_target = GetSelectedTarget();
|
||||
if (selected_target)
|
||||
return selected_target->GetSourceManager();
|
||||
else
|
||||
return m_source_manager;
|
||||
}
|
||||
|
||||
lldb::TargetSP
|
||||
|
@ -458,7 +462,7 @@ protected:
|
|||
TargetList m_target_list;
|
||||
PlatformList m_platform_list;
|
||||
Listener m_listener;
|
||||
SourceManager m_source_manager;
|
||||
SourceManager m_source_manager; // This is a scratch source manager that we return if we have no targets.
|
||||
std::auto_ptr<CommandInterpreter> m_command_interpreter_ap;
|
||||
|
||||
InputReaderStack m_input_reader_stack;
|
||||
|
|
|
@ -71,7 +71,9 @@ public:
|
|||
//------------------------------------------------------------------
|
||||
// Constructors and Destructors
|
||||
//------------------------------------------------------------------
|
||||
SourceManager();
|
||||
// A source manager can be made with a non-null target, in which case it can use the path remappings to find
|
||||
// source files that are not in their build locations. With no target it won't be able to do this.
|
||||
SourceManager(Target *target);
|
||||
|
||||
~SourceManager();
|
||||
|
||||
|
@ -84,16 +86,14 @@ public:
|
|||
}
|
||||
|
||||
size_t
|
||||
DisplaySourceLines (Target *target,
|
||||
const FileSpec &file,
|
||||
DisplaySourceLines (const FileSpec &file,
|
||||
uint32_t line,
|
||||
uint32_t context_before,
|
||||
uint32_t context_after,
|
||||
Stream *s);
|
||||
|
||||
size_t
|
||||
DisplaySourceLinesWithLineNumbers (Target *target,
|
||||
const FileSpec &file,
|
||||
DisplaySourceLinesWithLineNumbers (const FileSpec &file,
|
||||
uint32_t line,
|
||||
uint32_t context_before,
|
||||
uint32_t context_after,
|
||||
|
@ -114,12 +114,23 @@ public:
|
|||
DisplayMoreWithLineNumbers (Stream *s,
|
||||
const SymbolContextList *bp_locs = NULL);
|
||||
|
||||
bool
|
||||
SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line);
|
||||
|
||||
bool
|
||||
GetDefaultFileAndLine (FileSpec &file_spec, uint32_t &line);
|
||||
|
||||
bool
|
||||
DefaultFileAndLineSet ()
|
||||
{
|
||||
return (m_last_file_sp.get() != NULL);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
FileSP
|
||||
GetFile (const FileSpec &file_spec, Target *target);
|
||||
GetFile (const FileSpec &file_spec);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Classes that inherit from SourceManager can see and modify these
|
||||
//------------------------------------------------------------------
|
||||
|
@ -129,6 +140,7 @@ protected:
|
|||
uint32_t m_last_file_line;
|
||||
uint32_t m_last_file_context_before;
|
||||
uint32_t m_last_file_context_after;
|
||||
Target *m_target;
|
||||
private:
|
||||
//------------------------------------------------------------------
|
||||
// For SourceManager only
|
||||
|
|
|
@ -99,6 +99,12 @@ public:
|
|||
static bool
|
||||
ParseMethodName (const char *name, ConstString *class_name, ConstString *method_name, ConstString *base_name);
|
||||
|
||||
static bool
|
||||
IsPossibleObjCMethodName (const char *name)
|
||||
{
|
||||
return (name && (name[0] == '+' || name[0] == '-') && name[1] == '[');
|
||||
}
|
||||
|
||||
protected:
|
||||
//------------------------------------------------------------------
|
||||
// Classes that inherit from ObjCLanguageRuntime can see and modify these
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
// Mark a stack frame as the current frame
|
||||
uint32_t
|
||||
SetSelectedFrame (lldb_private::StackFrame *frame);
|
||||
|
||||
|
||||
uint32_t
|
||||
GetSelectedFrameIndex () const;
|
||||
|
||||
|
@ -56,6 +56,9 @@ public:
|
|||
void
|
||||
SetSelectedFrameByIndex (uint32_t idx);
|
||||
|
||||
void
|
||||
SetDefaultFileAndLineToSelectedFrame();
|
||||
|
||||
void
|
||||
Clear ();
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "lldb/Core/Event.h"
|
||||
#include "lldb/Core/ModuleList.h"
|
||||
#include "lldb/Core/UserSettingsController.h"
|
||||
#include "lldb/Core/SourceManager.h"
|
||||
#include "lldb/Expression/ClangPersistentVariables.h"
|
||||
#include "lldb/Interpreter/NamedOptionValue.h"
|
||||
#include "lldb/Symbol/SymbolContext.h"
|
||||
|
@ -758,6 +759,12 @@ public:
|
|||
{
|
||||
return m_platform_sp;
|
||||
}
|
||||
|
||||
SourceManager &
|
||||
GetSourceManager ()
|
||||
{
|
||||
return m_source_manager;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Target::SettingsController
|
||||
|
@ -830,6 +837,7 @@ protected:
|
|||
std::auto_ptr<ClangASTContext> m_scratch_ast_context_ap;
|
||||
ClangPersistentVariables m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser.
|
||||
|
||||
SourceManager m_source_manager;
|
||||
|
||||
typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
|
||||
StopHookCollection m_stop_hooks;
|
||||
|
|
|
@ -326,28 +326,55 @@ public:
|
|||
}
|
||||
|
||||
virtual uint32_t
|
||||
GetStackFrameCount();
|
||||
GetStackFrameCount()
|
||||
{
|
||||
return GetStackFrameList().GetNumFrames();
|
||||
}
|
||||
|
||||
virtual lldb::StackFrameSP
|
||||
GetStackFrameAtIndex (uint32_t idx);
|
||||
GetStackFrameAtIndex (uint32_t idx)
|
||||
{
|
||||
return GetStackFrameList().GetFrameAtIndex(idx);
|
||||
}
|
||||
|
||||
virtual lldb::StackFrameSP
|
||||
GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
|
||||
|
||||
virtual lldb::StackFrameSP
|
||||
GetFrameWithStackID(StackID &stack_id);
|
||||
GetFrameWithStackID(StackID &stack_id)
|
||||
{
|
||||
return GetStackFrameList().GetFrameWithStackID (stack_id);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GetSelectedFrameIndex ();
|
||||
GetSelectedFrameIndex ()
|
||||
{
|
||||
return GetStackFrameList().GetSelectedFrameIndex();
|
||||
}
|
||||
|
||||
lldb::StackFrameSP
|
||||
GetSelectedFrame ();
|
||||
GetSelectedFrame ()
|
||||
{
|
||||
return GetStackFrameAtIndex (GetStackFrameList().GetSelectedFrameIndex());
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SetSelectedFrame (lldb_private::StackFrame *frame);
|
||||
SetSelectedFrame (lldb_private::StackFrame *frame)
|
||||
{
|
||||
return GetStackFrameList().SetSelectedFrame(frame);
|
||||
}
|
||||
|
||||
void
|
||||
SetSelectedFrameByIndex (uint32_t frame_idx);
|
||||
SetSelectedFrameByIndex (uint32_t frame_idx)
|
||||
{
|
||||
GetStackFrameList().SetSelectedFrameByIndex(frame_idx);
|
||||
}
|
||||
|
||||
void
|
||||
SetDefaultFileAndLineToSelectedFrame()
|
||||
{
|
||||
GetStackFrameList().SetDefaultFileAndLineToSelectedFrame();
|
||||
}
|
||||
|
||||
virtual lldb::RegisterContextSP
|
||||
GetRegisterContext () = 0;
|
||||
|
|
|
@ -360,7 +360,7 @@ SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event,
|
|||
SBSourceManager &
|
||||
SBDebugger::GetSourceManager ()
|
||||
{
|
||||
static SourceManager g_lldb_source_manager;
|
||||
static SourceManager g_lldb_source_manager(NULL);
|
||||
static SBSourceManager g_sb_source_manager (&g_lldb_source_manager);
|
||||
return g_sb_source_manager;
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ SBSourceManager::DisplaySourceLinesWithLineNumbers
|
|||
|
||||
if (file.IsValid())
|
||||
{
|
||||
return m_opaque_ptr->DisplaySourceLinesWithLineNumbers (NULL,
|
||||
*file,
|
||||
return m_opaque_ptr->DisplaySourceLinesWithLineNumbers (*file,
|
||||
line,
|
||||
context_before,
|
||||
context_after,
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "lldb/API/SBAddress.h"
|
||||
#include "lldb/API/SBFrame.h"
|
||||
#include "lldb/API/SBSourceManager.h"
|
||||
// DONT THINK THIS IS NECESSARY: #include "lldb/API/SBSourceManager.h"
|
||||
#include "lldb/API/SBDebugger.h"
|
||||
#include "lldb/API/SBProcess.h"
|
||||
|
||||
|
|
|
@ -321,31 +321,37 @@ CommandObjectBreakpointSet::Execute
|
|||
FileSpec file;
|
||||
if (m_options.m_filename.empty())
|
||||
{
|
||||
StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame;
|
||||
if (cur_frame == NULL)
|
||||
uint32_t default_line;
|
||||
// First use the Source Manager's default file.
|
||||
// Then use the current stack frame's file.
|
||||
if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
|
||||
{
|
||||
result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame.");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
break;
|
||||
}
|
||||
else if (!cur_frame->HasDebugInformation())
|
||||
{
|
||||
result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info.");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
|
||||
if (sc.line_entry.file)
|
||||
StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame;
|
||||
if (cur_frame == NULL)
|
||||
{
|
||||
file = sc.line_entry.file;
|
||||
result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame.");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
break;
|
||||
}
|
||||
else if (!cur_frame->HasDebugInformation())
|
||||
{
|
||||
result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info.");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame.");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
break;
|
||||
const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
|
||||
if (sc.line_entry.file)
|
||||
{
|
||||
file = sc.line_entry.file;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame.");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,18 +280,23 @@ public:
|
|||
}
|
||||
|
||||
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
|
||||
|
||||
Target *target = NULL;
|
||||
|
||||
if (exe_ctx.target)
|
||||
target = exe_ctx.target;
|
||||
else
|
||||
target = m_interpreter.GetDebugger().GetSelectedTarget().get();
|
||||
|
||||
if (target == NULL)
|
||||
{
|
||||
result.AppendError ("invalid target, create a debug target using the 'target create' command");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_options.symbol_name.empty())
|
||||
{
|
||||
// Displaying the source for a symbol:
|
||||
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
|
||||
if (target == NULL)
|
||||
{
|
||||
result.AppendError ("invalid target, create a debug target using the 'target create' command");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
SymbolContextList sc_list;
|
||||
ConstString name(m_options.symbol_name.c_str());
|
||||
bool include_symbols = false;
|
||||
|
@ -418,7 +423,7 @@ public:
|
|||
char path_buf[PATH_MAX];
|
||||
start_file.GetPath(path_buf, sizeof(path_buf));
|
||||
|
||||
if (m_options.show_bp_locs && exe_ctx.target)
|
||||
if (m_options.show_bp_locs)
|
||||
{
|
||||
const bool show_inlines = true;
|
||||
m_breakpoint_locations.Reset (start_file, 0, show_inlines);
|
||||
|
@ -429,14 +434,13 @@ public:
|
|||
m_breakpoint_locations.Clear();
|
||||
|
||||
result.AppendMessageWithFormat("File: %s.\n", path_buf);
|
||||
m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (target,
|
||||
start_file,
|
||||
line_no,
|
||||
0,
|
||||
m_options.num_lines,
|
||||
"",
|
||||
&result.GetOutputStream(),
|
||||
GetBreakpointLocations ());
|
||||
target->GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file,
|
||||
line_no,
|
||||
0,
|
||||
m_options.num_lines,
|
||||
"",
|
||||
&result.GetOutputStream(),
|
||||
GetBreakpointLocations ());
|
||||
|
||||
result.SetStatus (eReturnStatusSuccessFinishResult);
|
||||
return true;
|
||||
|
@ -458,21 +462,21 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_options.show_bp_locs && exe_ctx.target)
|
||||
if (m_options.show_bp_locs)
|
||||
{
|
||||
SourceManager::FileSP last_file_sp (m_interpreter.GetDebugger().GetSourceManager().GetLastFile ());
|
||||
SourceManager::FileSP last_file_sp (target->GetSourceManager().GetLastFile ());
|
||||
if (last_file_sp)
|
||||
{
|
||||
const bool show_inlines = true;
|
||||
m_breakpoint_locations.Reset (last_file_sp->GetFileSpec(), 0, show_inlines);
|
||||
SearchFilter target_search_filter (exe_ctx.target->GetSP());
|
||||
SearchFilter target_search_filter (target->GetSP());
|
||||
target_search_filter.Search (m_breakpoint_locations);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_breakpoint_locations.Clear();
|
||||
|
||||
if (m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile(
|
||||
if (target->GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile(
|
||||
m_options.start_line, // Line to display
|
||||
0, // Lines before line to display
|
||||
m_options.num_lines, // Lines after line to display
|
||||
|
@ -488,14 +492,6 @@ public:
|
|||
else
|
||||
{
|
||||
const char *filename = m_options.file_name.c_str();
|
||||
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
|
||||
if (target == NULL)
|
||||
{
|
||||
result.AppendError ("invalid target, create a debug target using the 'target create' command");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool check_inlines = false;
|
||||
SymbolContextList sc_list;
|
||||
|
@ -571,24 +567,23 @@ public:
|
|||
{
|
||||
if (sc.comp_unit)
|
||||
{
|
||||
if (m_options.show_bp_locs && exe_ctx.target)
|
||||
if (m_options.show_bp_locs)
|
||||
{
|
||||
const bool show_inlines = true;
|
||||
m_breakpoint_locations.Reset (*sc.comp_unit, 0, show_inlines);
|
||||
SearchFilter target_search_filter (exe_ctx.target->GetSP());
|
||||
SearchFilter target_search_filter (target->GetSP());
|
||||
target_search_filter.Search (m_breakpoint_locations);
|
||||
}
|
||||
else
|
||||
m_breakpoint_locations.Clear();
|
||||
|
||||
m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (target,
|
||||
sc.comp_unit,
|
||||
m_options.start_line,
|
||||
0,
|
||||
m_options.num_lines,
|
||||
"",
|
||||
&result.GetOutputStream(),
|
||||
GetBreakpointLocations ());
|
||||
target->GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit,
|
||||
m_options.start_line,
|
||||
0,
|
||||
m_options.num_lines,
|
||||
"",
|
||||
&result.GetOutputStream(),
|
||||
GetBreakpointLocations ());
|
||||
|
||||
result.SetStatus (eReturnStatusSuccessFinishResult);
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ Debugger::Debugger () :
|
|||
m_target_list (),
|
||||
m_platform_list (),
|
||||
m_listener ("lldb.Debugger"),
|
||||
m_source_manager (),
|
||||
m_source_manager(NULL),
|
||||
m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)),
|
||||
m_input_reader_stack (),
|
||||
m_input_reader_data ()
|
||||
|
|
|
@ -369,8 +369,7 @@ Disassembler::PrintInstructions
|
|||
|
||||
if (sc.comp_unit && sc.line_entry.IsValid())
|
||||
{
|
||||
debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers (debugger.GetTargetList().GetSelectedTarget().get(),
|
||||
sc.line_entry.file,
|
||||
debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.line_entry.file,
|
||||
sc.line_entry.line,
|
||||
num_mixed_context_lines,
|
||||
num_mixed_context_lines,
|
||||
|
|
|
@ -29,12 +29,13 @@ static inline bool is_newline_char(char ch)
|
|||
//----------------------------------------------------------------------
|
||||
// SourceManager constructor
|
||||
//----------------------------------------------------------------------
|
||||
SourceManager::SourceManager() :
|
||||
SourceManager::SourceManager(Target *target) :
|
||||
m_file_cache (),
|
||||
m_last_file_sp (),
|
||||
m_last_file_line (0),
|
||||
m_last_file_context_before (0),
|
||||
m_last_file_context_after (0)
|
||||
m_last_file_context_after (10),
|
||||
m_target (target)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,6 @@ SourceManager::~SourceManager()
|
|||
size_t
|
||||
SourceManager::DisplaySourceLines
|
||||
(
|
||||
Target *target,
|
||||
const FileSpec &file_spec,
|
||||
uint32_t line,
|
||||
uint32_t context_before,
|
||||
|
@ -56,7 +56,7 @@ SourceManager::DisplaySourceLines
|
|||
Stream *s
|
||||
)
|
||||
{
|
||||
m_last_file_sp = GetFile (file_spec, target);
|
||||
m_last_file_sp = GetFile (file_spec);
|
||||
m_last_file_line = line + context_after + 1;
|
||||
m_last_file_context_before = context_before;
|
||||
m_last_file_context_after = context_after;
|
||||
|
@ -67,7 +67,7 @@ SourceManager::DisplaySourceLines
|
|||
}
|
||||
|
||||
SourceManager::FileSP
|
||||
SourceManager::GetFile (const FileSpec &file_spec, Target *target)
|
||||
SourceManager::GetFile (const FileSpec &file_spec)
|
||||
{
|
||||
FileSP file_sp;
|
||||
FileCache::iterator pos = m_file_cache.find(file_spec);
|
||||
|
@ -75,7 +75,7 @@ SourceManager::GetFile (const FileSpec &file_spec, Target *target)
|
|||
file_sp = pos->second;
|
||||
else
|
||||
{
|
||||
file_sp.reset (new File (file_spec, target));
|
||||
file_sp.reset (new File (file_spec, m_target));
|
||||
m_file_cache[file_spec] = file_sp;
|
||||
}
|
||||
return file_sp;
|
||||
|
@ -151,7 +151,6 @@ SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile
|
|||
size_t
|
||||
SourceManager::DisplaySourceLinesWithLineNumbers
|
||||
(
|
||||
Target *target,
|
||||
const FileSpec &file_spec,
|
||||
uint32_t line,
|
||||
uint32_t context_before,
|
||||
|
@ -164,7 +163,7 @@ SourceManager::DisplaySourceLinesWithLineNumbers
|
|||
bool same_as_previous = m_last_file_sp && m_last_file_sp->FileSpecMatches (file_spec);
|
||||
|
||||
if (!same_as_previous)
|
||||
m_last_file_sp = GetFile (file_spec, target);
|
||||
m_last_file_sp = GetFile (file_spec);
|
||||
|
||||
if (line == 0)
|
||||
{
|
||||
|
@ -187,6 +186,35 @@ SourceManager::DisplayMoreWithLineNumbers (Stream *s, const SymbolContextList *b
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
SourceManager::SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line)
|
||||
{
|
||||
FileSP old_file_sp = m_last_file_sp;
|
||||
m_last_file_sp = GetFile (file_spec);
|
||||
if (m_last_file_sp)
|
||||
{
|
||||
m_last_file_line = line;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_last_file_sp = old_file_sp;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
SourceManager::GetDefaultFileAndLine (FileSpec &file_spec, uint32_t &line)
|
||||
{
|
||||
if (m_last_file_sp)
|
||||
{
|
||||
file_spec = m_last_file_sp->GetFileSpec();
|
||||
line = m_last_file_line;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SourceManager::File::File(const FileSpec &file_spec, Target *target) :
|
||||
|
@ -198,7 +226,7 @@ SourceManager::File::File(const FileSpec &file_spec, Target *target) :
|
|||
{
|
||||
if (!m_mod_time.IsValid())
|
||||
{
|
||||
if (target->GetSourcePathMap().RemapPath(file_spec.GetDirectory(), m_file_spec.GetDirectory()))
|
||||
if (target && target->GetSourcePathMap().RemapPath(file_spec.GetDirectory(), m_file_spec.GetDirectory()))
|
||||
m_mod_time = file_spec.GetModificationTime();
|
||||
}
|
||||
|
||||
|
|
|
@ -792,22 +792,27 @@ DWARFCompileUnit::Index
|
|||
{
|
||||
if (name)
|
||||
{
|
||||
ConstString objc_class_name;
|
||||
ConstString objc_method_name;
|
||||
ConstString objc_base_name;
|
||||
if (ObjCLanguageRuntime::ParseMethodName (name,
|
||||
&objc_class_name,
|
||||
&objc_method_name,
|
||||
&objc_base_name))
|
||||
// Note, this check is also done in ParseMethodName, but since this is a hot loop, we do the
|
||||
// simple inlined check outside the call.
|
||||
if (ObjCLanguageRuntime::IsPossibleObjCMethodName(name))
|
||||
{
|
||||
objc_class_selectors.Insert(objc_class_name, die_info);
|
||||
|
||||
func_selectors.Insert (objc_method_name, die_info);
|
||||
|
||||
if (!objc_base_name.IsEmpty())
|
||||
ConstString objc_class_name;
|
||||
ConstString objc_method_name;
|
||||
ConstString objc_base_name;
|
||||
if (ObjCLanguageRuntime::ParseMethodName (name,
|
||||
&objc_class_name,
|
||||
&objc_method_name,
|
||||
&objc_base_name))
|
||||
{
|
||||
func_basenames.Insert (objc_base_name, die_info);
|
||||
func_fullnames.Insert (objc_base_name, die_info);
|
||||
objc_class_selectors.Insert(objc_class_name, die_info);
|
||||
|
||||
func_selectors.Insert (objc_method_name, die_info);
|
||||
|
||||
if (!objc_base_name.IsEmpty())
|
||||
{
|
||||
func_basenames.Insert (objc_base_name, die_info);
|
||||
func_fullnames.Insert (objc_base_name, die_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we have a mangled name, then the DW_AT_name attribute
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include "lldb/Symbol/SymbolVendor.h"
|
||||
#include "lldb/Symbol/VariableList.h"
|
||||
|
||||
#include "lldb/Target/ObjCLanguageRuntime.h"
|
||||
|
||||
#include "DWARFCompileUnit.h"
|
||||
#include "DWARFDebugAbbrev.h"
|
||||
#include "DWARFDebugAranges.h"
|
||||
|
@ -3789,7 +3791,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
|
|||
bool type_handled = false;
|
||||
if (tag == DW_TAG_subprogram)
|
||||
{
|
||||
if (type_name_cstr[1] == '[' && (type_name_cstr[0] == '-' || type_name_cstr[0] == '+'))
|
||||
if (ObjCLanguageRuntime::IsPossibleObjCMethodName (type_name_cstr))
|
||||
{
|
||||
// We need to find the DW_TAG_class_type or
|
||||
// DW_TAG_struct_type by name so we can add this
|
||||
|
|
|
@ -111,7 +111,7 @@ ObjCLanguageRuntime::ParseMethodName (const char *name,
|
|||
if (method_name) { method_name->Clear(); }
|
||||
if (base_name) { base_name->Clear(); }
|
||||
|
||||
if (name && (name[0] == '-' || name[0] == '+') && name[1] == '[')
|
||||
if (IsPossibleObjCMethodName (name))
|
||||
{
|
||||
int name_len = strlen (name);
|
||||
// Objective C methods must have at least:
|
||||
|
|
|
@ -1282,8 +1282,7 @@ StackFrame::GetStatus (Stream& strm,
|
|||
if (m_sc.comp_unit && m_sc.line_entry.IsValid())
|
||||
{
|
||||
Target &target = GetThread().GetProcess().GetTarget();
|
||||
target.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (
|
||||
&target,
|
||||
target.GetSourceManager().DisplaySourceLinesWithLineNumbers (
|
||||
m_sc.line_entry.file,
|
||||
m_sc.line_entry.line,
|
||||
3,
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/Core/StreamFile.h"
|
||||
#include "lldb/Core/SourceManager.h"
|
||||
#include "lldb/Symbol/Block.h"
|
||||
#include "lldb/Symbol/Function.h"
|
||||
#include "lldb/Symbol/Symbol.h"
|
||||
#include "lldb/Target/Process.h"
|
||||
#include "lldb/Target/RegisterContext.h"
|
||||
#include "lldb/Target/StackFrame.h"
|
||||
#include "lldb/Target/Target.h"
|
||||
#include "lldb/Target/Thread.h"
|
||||
#include "lldb/Target/Unwind.h"
|
||||
|
||||
|
@ -401,15 +404,16 @@ StackFrameList::SetSelectedFrame (lldb_private::StackFrame *frame)
|
|||
const_iterator pos;
|
||||
const_iterator begin = m_frames.begin();
|
||||
const_iterator end = m_frames.end();
|
||||
m_selected_frame_idx = 0;
|
||||
for (pos = begin; pos != end; ++pos)
|
||||
{
|
||||
if (pos->get() == frame)
|
||||
{
|
||||
m_selected_frame_idx = std::distance (begin, pos);
|
||||
return m_selected_frame_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_selected_frame_idx = 0;
|
||||
SetDefaultFileAndLineToSelectedFrame();
|
||||
return m_selected_frame_idx;
|
||||
}
|
||||
|
||||
|
@ -419,6 +423,22 @@ StackFrameList::SetSelectedFrameByIndex (uint32_t idx)
|
|||
{
|
||||
Mutex::Locker locker (m_mutex);
|
||||
m_selected_frame_idx = idx;
|
||||
SetDefaultFileAndLineToSelectedFrame();
|
||||
}
|
||||
|
||||
void
|
||||
StackFrameList::SetDefaultFileAndLineToSelectedFrame()
|
||||
{
|
||||
if (m_thread.GetID() == m_thread.GetProcess().GetThreadList().GetSelectedThread()->GetID())
|
||||
{
|
||||
StackFrameSP frame_sp = m_frames[m_selected_frame_idx];
|
||||
if (frame_sp)
|
||||
{
|
||||
SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
|
||||
if (sc.line_entry.file)
|
||||
m_thread.GetProcess().GetTarget().GetSourceManager().SetDefaultFileAndLine (sc.line_entry.file, sc.line_entry.line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The thread has been run, reset the number stack frames to zero so we can
|
||||
|
|
|
@ -59,6 +59,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat
|
|||
m_image_search_paths (ImageSearchPathsChanged, this),
|
||||
m_scratch_ast_context_ap (NULL),
|
||||
m_persistent_variables (),
|
||||
m_source_manager(this),
|
||||
m_stop_hooks (),
|
||||
m_stop_hook_next_id (0),
|
||||
m_suppress_stop_hooks (false)
|
||||
|
@ -469,6 +470,26 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
|
|||
|
||||
FileSpecList dependent_files;
|
||||
ObjectFile *executable_objfile = executable_sp->GetObjectFile();
|
||||
// Let's find the file & line for main and set the default source file from there.
|
||||
if (!m_source_manager.DefaultFileAndLineSet())
|
||||
{
|
||||
SymbolContextList sc_list;
|
||||
uint32_t num_matches;
|
||||
ConstString main_name("main");
|
||||
bool symbols_okay = false; // Force it to be a debug symbol.
|
||||
bool append = false;
|
||||
num_matches = executable_sp->FindFunctions (main_name, eFunctionNameTypeBase, symbols_okay, append, sc_list);
|
||||
for (uint32_t idx = 0; idx < num_matches; idx++)
|
||||
{
|
||||
SymbolContext sc;
|
||||
sc_list.GetContextAtIndex(idx, sc);
|
||||
if (sc.line_entry.file)
|
||||
{
|
||||
m_source_manager.SetDefaultFileAndLine(sc.line_entry.file, sc.line_entry.line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (executable_objfile)
|
||||
{
|
||||
|
|
|
@ -925,15 +925,6 @@ Thread::GetStackFrameList ()
|
|||
return *m_curr_frames_sp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t
|
||||
Thread::GetStackFrameCount()
|
||||
{
|
||||
return GetStackFrameList().GetNumFrames();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Thread::ClearStackFrames ()
|
||||
{
|
||||
|
@ -942,49 +933,12 @@ Thread::ClearStackFrames ()
|
|||
m_curr_frames_sp.reset();
|
||||
}
|
||||
|
||||
lldb::StackFrameSP
|
||||
Thread::GetStackFrameAtIndex (uint32_t idx)
|
||||
{
|
||||
return GetStackFrameList().GetFrameAtIndex(idx);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Thread::GetSelectedFrameIndex ()
|
||||
{
|
||||
return GetStackFrameList().GetSelectedFrameIndex();
|
||||
}
|
||||
|
||||
lldb::StackFrameSP
|
||||
Thread::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
|
||||
{
|
||||
return GetStackFrameList().GetFrameWithConcreteFrameIndex (unwind_idx);
|
||||
}
|
||||
|
||||
lldb::StackFrameSP
|
||||
Thread::GetFrameWithStackID(StackID &stack_id)
|
||||
{
|
||||
return GetStackFrameList().GetFrameWithStackID (stack_id);
|
||||
}
|
||||
|
||||
|
||||
lldb::StackFrameSP
|
||||
Thread::GetSelectedFrame ()
|
||||
{
|
||||
return GetStackFrameAtIndex (GetStackFrameList().GetSelectedFrameIndex());
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Thread::SetSelectedFrame (lldb_private::StackFrame *frame)
|
||||
{
|
||||
return GetStackFrameList().SetSelectedFrame(frame);
|
||||
}
|
||||
|
||||
void
|
||||
Thread::SetSelectedFrameByIndex (uint32_t idx)
|
||||
{
|
||||
GetStackFrameList().SetSelectedFrameByIndex(idx);
|
||||
}
|
||||
|
||||
void
|
||||
Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
|
||||
{
|
||||
|
|
|
@ -558,8 +558,12 @@ bool
|
|||
ThreadList::SetSelectedThreadByID (lldb::tid_t tid)
|
||||
{
|
||||
Mutex::Locker locker(m_threads_mutex);
|
||||
if (FindThreadByID(tid).get())
|
||||
ThreadSP selected_thread_sp(FindThreadByID(tid));
|
||||
if (selected_thread_sp)
|
||||
{
|
||||
m_selected_tid = tid;
|
||||
selected_thread_sp->SetDefaultFileAndLineToSelectedFrame();
|
||||
}
|
||||
else
|
||||
m_selected_tid = LLDB_INVALID_THREAD_ID;
|
||||
|
||||
|
@ -570,9 +574,12 @@ bool
|
|||
ThreadList::SetSelectedThreadByIndexID (uint32_t index_id)
|
||||
{
|
||||
Mutex::Locker locker(m_threads_mutex);
|
||||
ThreadSP thread_sp (FindThreadByIndexID(index_id));
|
||||
if (thread_sp.get())
|
||||
m_selected_tid = thread_sp->GetID();
|
||||
ThreadSP selected_thread_sp (FindThreadByIndexID(index_id));
|
||||
if (selected_thread_sp.get())
|
||||
{
|
||||
m_selected_tid = selected_thread_sp->GetID();
|
||||
selected_thread_sp->SetDefaultFileAndLineToSelectedFrame();
|
||||
}
|
||||
else
|
||||
m_selected_tid = LLDB_INVALID_THREAD_ID;
|
||||
|
||||
|
|
|
@ -40,8 +40,9 @@ class BreakpointCommandTestCase(TestBase):
|
|||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# Add two breakpoints on the same line.
|
||||
self.expect("breakpoint set -f main.c -l %d" % self.line,
|
||||
# Add two breakpoints on the same line. The first time we don't specify the file,
|
||||
# since the default file is the one containing main:
|
||||
self.expect("breakpoint set -l %d" % self.line,
|
||||
BREAKPOINT_CREATED,
|
||||
startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" %
|
||||
self.line)
|
||||
|
|
Loading…
Reference in New Issue