1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 """ GDB Python customization auto-loader for libxul """
9 from os
.path
import abspath
, dirname
, exists
11 # Add the toplevel objdir to the gdb source search path.
13 # In development builds, $objdir/dist/bin/libxul.so is a symlink to
14 # $objdir/toolkit/library/build/libxul.so, and the latter path is what gdb uses
15 # to search for gdb scripts.
17 # For artifact builds, libxul.so will be a regular file in $objdir/dist/bin.
20 libxul_dir
= dirname(__file__
)
22 for relpath
in ("../../..", "../.."):
23 objdir
= abspath(libxul_dir
+ "/" + relpath
)
24 if exists(objdir
+ "/build/.gdbinit"):
27 gdb
.write("Warning: Gecko objdir not found\n")
29 if objdir
is not None:
30 m
= re
.search(r
"[\w ]+: (.*)", gdb
.execute("show dir", False, True))
31 if m
and objdir
not in m
.group(1).split(":"):
32 gdb
.execute("set dir {}:{}".format(objdir
, m
.group(1)))
34 # When running from a random directory, the toplevel Gecko .gdbinit may
35 # not have been loaded. Load it now.
36 gdb
.execute("source -s build/.gdbinit.loader")