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
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 00192a5..a236d71 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -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)
{