diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index d05bb9fc572c5e1833976ab69f82753c35aab661..820760213bec9a07fb62170bfd33ca3991a4d04d 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -41,6 +41,9 @@ public: void SetAsync (bool b); + void + SkipLLDBInitFiles (bool b); + void SetInputFileHandle (FILE *f, bool transfer_ownership); diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 7c967bdf2b6ee40e9b1ea2004f968ff1b7a5bed6..2251280869b2f7286448685985b0b12edb92e2e5 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -202,6 +202,12 @@ public: ScriptInterpreter * GetScriptInterpreter (); + void + SkipLLDBInitFiles (bool skip_lldbinit_files) + { + m_skip_lldbinit_files = skip_lldbinit_files; + } + bool GetSynchronous (); @@ -239,6 +245,7 @@ private: Debugger &m_debugger; // The debugger session that this interpreter is associated with bool m_synchronous_execution; + bool m_skip_lldbinit_files; CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten). CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands CommandObject::CommandMap m_user_dict; // Stores user-defined commands diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index d29a9f76303fd816e7fbd28b987c282cde4bef68..6a68e3bf34e136fd56946b90b9c35dbdb6e62871 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -10,11 +10,6 @@ #include "lldb/API/SBDebugger.h" #include "lldb/lldb-include.h" -#include "lldb/Interpreter/Args.h" -#include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/TargetList.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBBroadcaster.h" @@ -29,6 +24,12 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/State.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/TargetList.h" using namespace lldb; using namespace lldb_private; @@ -82,6 +83,13 @@ SBDebugger::SetAsync (bool b) m_opaque_sp->SetAsyncExecution(b); } +void +SBDebugger::SkipLLDBInitFiles (bool b) +{ + if (m_opaque_sp) + m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles (b); +} + // Shouldn't really be settable after initialization as this could cause lots of problems; don't want users // trying to switch modes in the middle of a debugging session. void diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index a648581cb811ff5dcd6ed9b3ffbeecd95b2e45fa..e7cf0a8bb95a08ad45ed6b8958e4d09090b05bd0 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -309,78 +309,79 @@ CommandObjectBreakpointSet::Execute switch (break_type) { case eSetTypeFileAndLine: // Breakpoint by source position - { - FileSpec file; - if (m_options.m_filename.empty()) { - StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; - if (cur_frame == NULL) - { - 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 + FileSpec file; + if (m_options.m_filename.empty()) { - const SymbolContext &context = cur_frame->GetSymbolContext(true); - if (context.line_entry.file) + StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; + if (cur_frame == NULL) { - file = context.line_entry.file; - } - else if (context.comp_unit != NULL) - { file = context.comp_unit; + 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 &context = cur_frame->GetSymbolContext(true); + if (context.line_entry.file) + { + file = context.line_entry.file; + } + else if (context.comp_unit != NULL) + { file = context.comp_unit; + } + 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 + { + file.SetFile(m_options.m_filename.c_str()); } - } - else - { - file.SetFile(m_options.m_filename.c_str()); - } - if (use_module) - { - for (int i = 0; i < num_modules; ++i) + if (use_module) { - module.SetFile(m_options.m_modules[i].c_str()); - bp = target->CreateBreakpoint (&module, - file, - m_options.m_line_num, - m_options.m_ignore_inlines).get(); - if (bp) - { - StreamString &output_stream = result.GetOutputStream(); - output_stream.Printf ("Breakpoint created: "); - bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); - output_stream.EOL(); - result.SetStatus (eReturnStatusSuccessFinishResult); - } - else + for (int i = 0; i < num_modules; ++i) { - result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", - m_options.m_modules[i].c_str()); - result.SetStatus (eReturnStatusFailed); + module.SetFile(m_options.m_modules[i].c_str()); + bp = target->CreateBreakpoint (&module, + file, + m_options.m_line_num, + m_options.m_ignore_inlines).get(); + if (bp) + { + StreamString &output_stream = result.GetOutputStream(); + output_stream.Printf ("Breakpoint created: "); + bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); + output_stream.EOL(); + result.SetStatus (eReturnStatusSuccessFinishResult); + } + else + { + result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", + m_options.m_modules[i].c_str()); + result.SetStatus (eReturnStatusFailed); + } } } + else + bp = target->CreateBreakpoint (NULL, + file, + m_options.m_line_num, + m_options.m_ignore_inlines).get(); } - else - bp = target->CreateBreakpoint (NULL, - file, - m_options.m_line_num, - m_options.m_ignore_inlines).get(); - } - break; + break; + case eSetTypeAddress: // Breakpoint by address bp = target->CreateBreakpoint (m_options.m_load_addr, false).get(); break; diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index f0704f767c4f21585371cc1d57c2958f55ccbeee..64bdfcd5b80ec32d3da897cd2eaeae6a51c668f1 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -59,7 +59,8 @@ CommandInterpreter::CommandInterpreter ) : Broadcaster ("CommandInterpreter"), m_debugger (debugger), - m_synchronous_execution (synchronous_execution) + m_synchronous_execution (synchronous_execution), + m_skip_lldbinit_files (false) { const char *dbg_name = debugger.GetInstanceName().AsCString(); std::string lang_name = ScriptInterpreter::LanguageToString (script_language); @@ -1060,6 +1061,10 @@ CommandInterpreter::GetOptionArgumentPosition (const char *in_string) void CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result) { + // Don't parse any .lldbinit files if we were asked not to + if (m_skip_lldbinit_files) + return; + const char *init_file_path = in_cwd ? "./.lldbinit" : "~/.lldbinit"; FileSpec init_file (init_file_path); // If the file exists, tell HandleCommand to 'source' it; this will do the actual broadcasting diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 842d67df4001a61f4129eb553c0bbc8fbf23793e..b3b1081b5c56a79409f2e8b639793d020ccd87da 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -75,6 +75,9 @@ static lldb::OptionDefinition g_options[] = { LLDB_OPT_SET_ALL, false, "editor", 'e', no_argument, NULL, NULL, eArgTypeNone, "Tells the debugger to open source files using the host's \"external editor\" mechanism." }, + { LLDB_OPT_SET_ALL, false, "no-lldbinit", 'n', no_argument, NULL, NULL, eArgTypeNone, + "Do not automatically parse any '.lldbinit' files." }, + // { LLDB_OPT_SET_4, true, "crash-log", 'c', required_argument, NULL, NULL, eArgTypeFilename, // "Load executable images from a crash log for symbolication." }, @@ -554,10 +557,15 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) case 'c': m_option_data.m_crash_log = optarg; break; + case 'e': m_option_data.m_use_external_editor = true; break; - + + case 'n': + m_debugger.SkipLLDBInitFiles (true); + break; + case 'f': { SBFileSpec file(optarg);