aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2011-10-07 22:16:04 +0000
committerJim Ingham <jingham@apple.com>2011-10-07 22:16:04 +0000
commitca804bfc09bdc53065e11081c8cb42a5e67fc613 (patch)
treefd6573e0740352395eec4dcf701e01de8f983851 /source
parent8384612bdbaf624b75363c46548f5d538eaef666 (diff)
downloadlldb-ca804bfc09bdc53065e11081c8cb42a5e67fc613.tar.gz
Don't look up main to find the default source file till somebody actually asks for it.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@141422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source')
-rw-r--r--source/Core/SourceManager.cpp33
-rw-r--r--source/Target/Target.cpp20
2 files changed, 33 insertions, 20 deletions
diff --git a/source/Core/SourceManager.cpp b/source/Core/SourceManager.cpp
index 6b0670f31..743f2d116 100644
--- a/source/Core/SourceManager.cpp
+++ b/source/Core/SourceManager.cpp
@@ -35,6 +35,7 @@ SourceManager::SourceManager(Target &target) :
m_last_file_line (0),
m_last_file_context_before (0),
m_last_file_context_after (10),
+ m_default_set(false),
m_target (&target),
m_debugger(NULL)
{
@@ -46,6 +47,7 @@ SourceManager::SourceManager(Debugger &debugger) :
m_last_file_line (0),
m_last_file_context_before (0),
m_last_file_context_after (10),
+ m_default_set(false),
m_target (NULL),
m_debugger (&debugger)
{
@@ -206,6 +208,8 @@ SourceManager::SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line)
{
FileSP old_file_sp = m_last_file_sp;
m_last_file_sp = GetFile (file_spec);
+
+ m_default_set = true;
if (m_last_file_sp)
{
m_last_file_line = line;
@@ -227,6 +231,35 @@ SourceManager::GetDefaultFileAndLine (FileSpec &file_spec, uint32_t &line)
line = m_last_file_line;
return true;
}
+ else if (!m_default_set)
+ {
+ // If nobody has set the default file and line then try here. If there's no executable, then we
+ // will try again later when there is one. Otherwise, if we can't find it we won't look again,
+ // somebody will have to set it (for instance when we stop somewhere...)
+ Module *executable_ptr = m_target->GetExecutableModulePointer();
+ if (executable_ptr)
+ {
+ 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_ptr->FindFunctions (main_name, lldb::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)
+ {
+ SetDefaultFileAndLine(sc.line_entry.file, sc.line_entry.line);
+ break;
+ }
+ }
+ return GetDefaultFileAndLine (file_spec, line);
+ }
+ else
+ return false;
+ }
else
return false;
}
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 036a0180b..0cb1617f4 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -811,26 +811,6 @@ 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 && get_dependent_files)
{