[Lldb-commits] [lldb] r139323 - in /lldb/trunk: include/lldb/Core/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Plugins/SymbolFile/DWARF/ source/Target/ test/functionalities/breakpoint/breakpoint_command/
Jim Ingham
jingham at apple.com
Thu Sep 8 15:13:50 PDT 2011
Author: jingham
Date: Thu Sep 8 17:13:49 2011
New Revision: 139323
URL: http://llvm.org/viewvc/llvm-project?rev=139323&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Core/SourceManager.h
lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
lldb/trunk/include/lldb/Target/StackFrameList.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBSourceManager.cpp
lldb/trunk/source/API/SBThread.cpp
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Commands/CommandObjectSource.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/Disassembler.cpp
lldb/trunk/source/Core/SourceManager.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/source/Target/StackFrameList.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/source/Target/ThreadList.cpp
lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Thu Sep 8 17:13:49 2011
@@ -345,7 +345,11 @@
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 @@
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;
Modified: lldb/trunk/include/lldb/Core/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SourceManager.h?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/SourceManager.h (original)
+++ lldb/trunk/include/lldb/Core/SourceManager.h Thu Sep 8 17:13:49 2011
@@ -71,7 +71,9 @@
//------------------------------------------------------------------
// 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 @@
}
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 @@
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 @@
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
Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Thu Sep 8 17:13:49 2011
@@ -99,6 +99,12 @@
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
Modified: lldb/trunk/include/lldb/Target/StackFrameList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrameList.h?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrameList.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrameList.h Thu Sep 8 17:13:49 2011
@@ -48,7 +48,7 @@
// Mark a stack frame as the current frame
uint32_t
SetSelectedFrame (lldb_private::StackFrame *frame);
-
+
uint32_t
GetSelectedFrameIndex () const;
@@ -57,6 +57,9 @@
SetSelectedFrameByIndex (uint32_t idx);
void
+ SetDefaultFileAndLineToSelectedFrame();
+
+ void
Clear ();
void
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Thu Sep 8 17:13:49 2011
@@ -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 @@
{
return m_platform_sp;
}
+
+ SourceManager &
+ GetSourceManager ()
+ {
+ return m_source_manager;
+ }
//------------------------------------------------------------------
// Target::SettingsController
@@ -830,6 +837,7 @@
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;
Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Thu Sep 8 17:13:49 2011
@@ -326,28 +326,55 @@
}
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;
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Thu Sep 8 17:13:49 2011
@@ -360,7 +360,7 @@
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;
}
Modified: lldb/trunk/source/API/SBSourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSourceManager.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSourceManager.cpp (original)
+++ lldb/trunk/source/API/SBSourceManager.cpp Thu Sep 8 17:13:49 2011
@@ -61,8 +61,7 @@
if (file.IsValid())
{
- return m_opaque_ptr->DisplaySourceLinesWithLineNumbers (NULL,
- *file,
+ return m_opaque_ptr->DisplaySourceLinesWithLineNumbers (*file,
line,
context_before,
context_after,
Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Thu Sep 8 17:13:49 2011
@@ -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"
Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Thu Sep 8 17:13:49 2011
@@ -321,32 +321,38 @@
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
+ else if (!cur_frame->HasDebugInformation())
{
- result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame.");
+ 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)
+ {
+ 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;
+ }
+ }
}
}
else
Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.cpp Thu Sep 8 17:13:49 2011
@@ -280,18 +280,23 @@
}
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 @@
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 @@
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 @@
}
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 @@
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 @@
{
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);
}
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Sep 8 17:13:49 2011
@@ -237,7 +237,7 @@
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 ()
Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Thu Sep 8 17:13:49 2011
@@ -369,8 +369,7 @@
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,
Modified: lldb/trunk/source/Core/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Core/SourceManager.cpp (original)
+++ lldb/trunk/source/Core/SourceManager.cpp Thu Sep 8 17:13:49 2011
@@ -29,12 +29,13 @@
//----------------------------------------------------------------------
// 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 @@
size_t
SourceManager::DisplaySourceLines
(
- Target *target,
const FileSpec &file_spec,
uint32_t line,
uint32_t context_before,
@@ -56,7 +56,7 @@
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::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 @@
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 @@
size_t
SourceManager::DisplaySourceLinesWithLineNumbers
(
- Target *target,
const FileSpec &file_spec,
uint32_t line,
uint32_t context_before,
@@ -164,7 +163,7 @@
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 @@
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 @@
{
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();
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Sep 8 17:13:49 2011
@@ -792,22 +792,27 @@
{
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
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 8 17:13:49 2011
@@ -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 @@
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
Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Thu Sep 8 17:13:49 2011
@@ -111,7 +111,7 @@
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:
Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Thu Sep 8 17:13:49 2011
@@ -1282,8 +1282,7 @@
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,
Modified: lldb/trunk/source/Target/StackFrameList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrameList.cpp (original)
+++ lldb/trunk/source/Target/StackFrameList.cpp Thu Sep 8 17:13:49 2011
@@ -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 @@
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 @@
{
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
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Sep 8 17:13:49 2011
@@ -59,6 +59,7 @@
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 @@
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)
{
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Thu Sep 8 17:13:49 2011
@@ -925,15 +925,6 @@
return *m_curr_frames_sp;
}
-
-
-uint32_t
-Thread::GetStackFrameCount()
-{
- return GetStackFrameList().GetNumFrames();
-}
-
-
void
Thread::ClearStackFrames ()
{
@@ -943,48 +934,11 @@
}
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)
{
Modified: lldb/trunk/source/Target/ThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadList.cpp (original)
+++ lldb/trunk/source/Target/ThreadList.cpp Thu Sep 8 17:13:49 2011
@@ -558,8 +558,12 @@
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 @@
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;
Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py?rev=139323&r1=139322&r2=139323&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py (original)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py Thu Sep 8 17:13:49 2011
@@ -40,8 +40,9 @@
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)
More information about the lldb-commits
mailing list