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 <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang
2024-09-28 09:47:13 +08:00
committed by Xiang Xiao
parent 3a2d4584c7
commit c013648617
+25 -1
View File
@@ -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()