From c013648617cb82fba0d6353296ce4dcdbc00b930 Mon Sep 17 00:00:00 2001 From: xuxingliang Date: Sat, 28 Sep 2024 09:47:13 +0800 Subject: [PATCH] tools/gdb: improve nxgcore speed Let GDB to read from ELF for readonly data. Disable this feature by nxgcore --no-trust-readonly. Signed-off-by: xuxingliang --- tools/gdb/nuttxgdb/gcore.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tools/gdb/nuttxgdb/gcore.py b/tools/gdb/nuttxgdb/gcore.py index 532d6da7c1e..3a303762870 100644 --- a/tools/gdb/nuttxgdb/gcore.py +++ b/tools/gdb/nuttxgdb/gcore.py @@ -43,6 +43,21 @@ def parse_args(args): help="Select the appropriate architecture for the objcopy tool", type=str, ) + + parser.add_argument( + "--trust-readonly", + help="Trust readonly section from elf, bypass read from device.", + action="store_true", + default=True, + ) + + parser.add_argument( + "--no-trust-readonly", + help="Do not trust readonly section from elf, read from device.", + action="store_false", + dest="trust_readonly", + ) + parser.add_argument( "-r", "--memrange", @@ -129,7 +144,16 @@ class NXGcore(gdb.Command): os.remove(section) gdb.execute(f"file {tmpfile.name}") - gdb.execute(f'gcore "{corefile}"') + + if args.trust_readonly: + gdb.execute("set trust-readonly-sections on") + + gdb.execute(f"gcore {corefile}") + + if args.trust_readonly: + # Restore trust-readonly-sections to default off state + gdb.execute("set trust-readonly-sections off") + gdb.execute(f'file "{elffile}"') tmpfile.close()