js-gdb.py (777B)
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/. 4 5 """GDB Python customization auto-loader for JS shell binary""" 6 7 # This script will be installed into $objdir/dist/bin. Add $objdir to gdb's 8 # source search path and load in the Gecko+JS init file. 9 10 import os 11 import re 12 from os.path import abspath, dirname 13 14 import gdb 15 16 devel_objdir = abspath(os.path.join(dirname(__file__), "..", "..")) 17 m = re.search(r"[\w ]+: (.*)", gdb.execute("show directories", False, True)) 18 if m and devel_objdir not in m.group(1).split(":"): 19 gdb.execute(f"set directories {devel_objdir}:{m.group(1)}") 20 21 gdb.execute("source -s build/.gdbinit.loader")