Bug 960300 - Put a .lldbinit in the objdir and in dist/bin/, which load the .lldbinit in topsrcdir. r=glandium
authorCameron McCormack <cam@mcc.id.au>
Tue, 21 Jan 2014 14:47:05 +1100
changeset 170157 148382c24e1cd062d8a037f441cf9e9cc6dcfa4b
parent 170148 febe9b4bf753f9eaf3d2aba54c21e7c909ee92e8
child 170158 ce3e8f10d4d857e911bc9d3973837d0c90e337b7
push idunknown
push userunknown
push dateunknown
reviewersglandium
bugs960300
milestone29.0a1
Bug 960300 - Put a .lldbinit in the objdir and in dist/bin/, which load the .lldbinit in topsrcdir. r=glandium
.lldbinit
build/.lldbinit.in
build/Makefile.in
--- a/.lldbinit
+++ b/.lldbinit
@@ -1,30 +1,31 @@
 # .lldbinit file for debugging Mozilla
 
 # -----------------------------------------------------------------------------
 # For documentation on all of the commands and type summaries defined here
 # and in the accompanying Python scripts, see python/lldbutils/README.txt.
 # -----------------------------------------------------------------------------
 
+# Import the module that defines complex Gecko debugging commands.  This assumes
+# you are either running lldb from the top level source directory, the objdir,
+# or the dist/bin directory.  (.lldbinit files in the objdir and dist/bin set
+# topsrcdir appropriately.)
+script topsrcdir = topsrcdir if locals().has_key("topsrcdir") else "."; sys.path.append(os.path.join(topsrcdir, "python/lldbutils")); import lldbutils; lldbutils.init()
+
 # Mozilla's use of UNIFIED_SOURCES to include multiple source files into a
 # single compiled file breaks lldb breakpoint setting. This works around that.
 # See http://lldb.llvm.org/troubleshooting.html for more info.
 settings set target.inline-breakpoint-strategy always
 
 # Show the dynamic type of an object when using "expr".  This, for example,
 # will show a variable declared as "nsIFrame *" that points to an nsBlockFrame
 # object as being of type "nsBlockFrame *" rather than "nsIFrame *".
 settings set target.prefer-dynamic-value run-target
 
-# Import the module that defines complex Gecko debugging commands.  Rather
-# than do any kind of searching, this assumes that you are running lldb from
-# the top level source directory.
-script sys.path.append('python/lldbutils'); import lldbutils; lldbutils.init()
-
 # Show the string value in atoms.
 type summary add nsIAtom --summary-string "${var.mString}"
 
 # Show the value of text nodes.
 type summary add nsTextNode --summary-string "${var.mText}"
 
 # Dump the current JS stack.
 command alias js expr DumpJSStack()
new file mode 100644
--- /dev/null
+++ b/build/.lldbinit.in
@@ -0,0 +1,2 @@
+#filter substitution
+script topsrcdir = "@topsrcdir@"; lldb.debugger.HandleCommand("command source -s true '%s'" % os.path.join(topsrcdir, ".lldbinit"))
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -42,24 +42,28 @@ endif
 
 # Put a useful .gdbinit in the bin directory, to be picked up automatically
 # by GDB when we debug executables there.
 # NOTE: Keep .gdbinit in the topsrcdir for people who run gdb from the topsrcdir.
 GDBINIT_FILES := $(topsrcdir)/.gdbinit
 GDBINIT_DEST = $(FINAL_TARGET)
 INSTALL_TARGETS += GDBINIT
 
-# Put a useful .lldbinit in the bin directory, to be picked up automatically
-# by LLDB when we debug executables using that directory as the current working
-# directory.
-# NOTE: Keep .lldbinit in the topsrcdir for people who run LLDB from the
-# topsrcdir rather than the bin directory.
-LLDBINIT_FILES := $(topsrcdir)/.lldbinit
-LLDBINIT_DEST = $(FINAL_TARGET)
-INSTALL_TARGETS += LLDBINIT
+# Put a .lldbinit in the bin directory and the objdir, to be picked up
+# automatically by LLDB when we debug executables using either of those two
+# directories as the current working directory.  The .lldbinit file will
+# load $(topsrcdir)/.lldbinit, which is where the actual debugging commands are.
+LLDBINIT_OBJDIR := .lldbinit.in
+LLDBINIT_OBJDIR_PATH = $(DEPTH)
+LLDBINIT_OBJDIR_FLAGS += -Dtopsrcdir=$(abspath $(topsrcdir))
+PP_TARGETS += LLDBINIT_OBJDIR
+
+LLDBINIT_FINAL_TARGET_FILES := $(DEPTH)/.lldbinit
+LLDBINIT_FINAL_TARGET_DEST = $(FINAL_TARGET)
+INSTALL_TARGETS += LLDBINIT_FINAL_TARGET
 
 include $(topsrcdir)/config/rules.mk
 
 # we install to _leaktest/
 TARGET_DEPTH = ..
 include $(srcdir)/automation-build.mk
 
 _LEAKTEST_DIR = $(DEPTH)/_leaktest