mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
tools/gdb: register NuttX commands when loading the first elf file
Make sure elf exists before registering our commands. If no elf at the moment, register event to GDB to get notified when user adds the first object file. Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
+23
-9
@@ -34,13 +34,27 @@ sys.path.insert(1, python_dir)
|
||||
py_files = glob.glob(f"{python_dir}/*.py")
|
||||
py_files.remove(os.path.abspath(__file__))
|
||||
|
||||
gdb.execute("set pagination off")
|
||||
gdb.write("set pagination off\n")
|
||||
gdb.execute("set python print-stack full")
|
||||
gdb.write("set python print-stack full\n")
|
||||
for py_file in py_files:
|
||||
gdb.execute(f"source {py_file}")
|
||||
gdb.write(f"source {py_file}\n")
|
||||
|
||||
gdb.execute('handle SIGUSR1 "nostop" "pass" "noprint"')
|
||||
gdb.write('"handle SIGUSR1 "nostop" "pass" "noprint"\n')
|
||||
def register_commands(event):
|
||||
if getattr(register_commands, "registered", False):
|
||||
return
|
||||
|
||||
register_commands.registered = True
|
||||
|
||||
gdb.write("Registering NuttX GDB commands...\n")
|
||||
gdb.execute("set pagination off")
|
||||
gdb.write("set pagination off\n")
|
||||
gdb.execute("set python print-stack full")
|
||||
gdb.write("set python print-stack full\n")
|
||||
for py_file in py_files:
|
||||
gdb.execute(f"source {py_file}")
|
||||
gdb.write(f"source {py_file}\n")
|
||||
|
||||
gdb.execute('handle SIGUSR1 "nostop" "pass" "noprint"')
|
||||
gdb.write('"handle SIGUSR1 "nostop" "pass" "noprint"\n')
|
||||
|
||||
|
||||
if len(gdb.objfiles()) == 0:
|
||||
gdb.events.new_objfile.connect(register_commands)
|
||||
else:
|
||||
register_commands(None)
|
||||
|
||||
Reference in New Issue
Block a user