Add a version of SBDebugger::Create which allows us to specify whether to source

in the init files or not.

llvm-svn: 137541
This commit is contained in:
Jim Ingham 2011-08-13 00:22:20 +00:00
parent 60726fab78
commit 06942690b1
3 changed files with 34 additions and 1 deletions

View File

@ -25,9 +25,13 @@ public:
static void
Terminate();
// Deprecated, use the one that takes a source_init_files bool.
static lldb::SBDebugger
Create();
static lldb::SBDebugger
Create(bool source_init_files);
static void
Destroy (lldb::SBDebugger &debugger);

View File

@ -70,6 +70,12 @@ SBDebugger::Clear ()
SBDebugger
SBDebugger::Create()
{
return SBDebugger::Create(true);
}
SBDebugger
SBDebugger::Create(bool source_init_files)
{
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -83,6 +89,19 @@ SBDebugger::Create()
log->Printf ("SBDebugger::Create () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData());
}
SBCommandInterpreter interp = debugger.GetCommandInterpreter();
if (source_init_files)
{
interp.get()->SkipLLDBInitFiles(false);
interp.get()->SkipAppInitFiles (false);
SBCommandReturnObject result;
interp.SourceInitFileInHomeDirectory(result);
}
else
{
interp.get()->SkipLLDBInitFiles(true);
interp.get()->SkipAppInitFiles (true);
}
return debugger;
}

View File

@ -83,7 +83,7 @@ static OptionDefinition g_options[] =
Driver::Driver () :
SBBroadcaster ("Driver"),
m_debugger (SBDebugger::Create()),
m_debugger (SBDebugger::Create(false)),
m_editline_pty (),
m_editline_slave_fh (NULL),
m_editline_reader (),
@ -478,6 +478,15 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
}
}
// This is kind of a pain, but since we make the debugger in the Driver's constructor, we can't
// know at that point whether we should read in init files yet. So we don't read them in in the
// Driver constructor, then set the flags back to "read them in" here, and then if we see the
// "-n" flag, we'll turn it off again. Finally we have to read them in by hand later in the
// main loop.
m_debugger.SkipLLDBInitFiles (false);
m_debugger.SkipAppInitFiles (false);
// Prepare for & make calls to getopt_long.
#if __GLIBC__
optind = 0;
@ -542,6 +551,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
case 'n':
m_debugger.SkipLLDBInitFiles (true);
m_debugger.SkipAppInitFiles (true);
break;
case 'f':