Skip to content

Commit

Permalink
[Driver] Add command line option to allow loading local lldbinit file.
Browse files Browse the repository at this point in the history
This patch adds a command line flag that allows lldb to load local
lldbinit files.

Differential revision: https://reviews.llvm.org/D61578

llvm-svn: 360172
  • Loading branch information
JDevlieghere authored and MrSidims committed May 24, 2019
1 parent 16977d6 commit 880c80d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lldb/lit/Driver/LocalLLDBInit.test
@@ -1,9 +1,12 @@
# RUN: mkdir -p %t.root
# RUN: mkdir -p %t.home
# RUN: cp %S/Inputs/.lldbinit %t.root
# RUN: cd %t.root
# RUN: %lldb-init -o 'settings show frame-format' 2>&1 | FileCheck %s --check-prefix=INIT --check-prefix=CHECK
# RUN: env HOME=%t.home %lldb-init -o 'settings show frame-format' 2>&1 | FileCheck %s --check-prefix=WARNINIT --check-prefix=CHECK
# RUN: env HOME=%t.home %lldb-init -local-lldbinit -o 'settings show frame-format' 2>&1 | FileCheck %s --check-prefix=ALLOWINIT --check-prefix=NOINIT
# RUN: %lldb -o 'settings show frame-format' 2>&1 | FileCheck %s --check-prefix=NOINIT --check-prefix=CHECK

# INIT: There is a .lldbinit file in the current directory which is not being read.
# WARNINIT: There is a .lldbinit file in the current directory which is not being read.
# NOINIT-NOT: There is a .lldbinit file in the current directory which is not being read.
# CHECK-NOT: bogus
# ALLOWINIT: bogus
5 changes: 5 additions & 0 deletions lldb/tools/driver/Driver.cpp
Expand Up @@ -222,6 +222,11 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
m_debugger.SkipAppInitFiles(true);
}

if (args.hasArg(OPT_local_lldbinit)) {
lldb::SBDebugger::SetInternalVariable("target.load-cwd-lldbinit", "true",
m_debugger.GetInstanceName());
}

if (args.hasArg(OPT_no_use_colors)) {
m_debugger.SetUseColor(false);
}
Expand Down
3 changes: 3 additions & 0 deletions lldb/tools/driver/Options.td
Expand Up @@ -95,6 +95,9 @@ def: Flag<["-"], "x">,
Alias<no_lldbinit>,
HelpText<"Alias for --no-lldbinit">,
Group<grp_command>;
def local_lldbinit: F<"local-lldbinit">,
HelpText<"Allow the debugger to parse the .lldbinit files in the current working directory, unless --no-lldbinit is passed.">,
Group<grp_command>;

def batch: F<"batch">,
HelpText<"Tells the debugger to run the commands from -s, -S, -o & -O, and then quit.">,
Expand Down

0 comments on commit 880c80d

Please sign in to comment.