tools/gdb: fix elf file with special character

Make sure file name is surrounded by \"

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang 2024-09-23 11:01:06 +08:00 • committed by Xiang Xiao
parent 6d0d4458cd
commit 96a518af35
3 changed files with 4 additions and 4 deletions

View file

@ -129,8 +129,8 @@ class NXGcore(gdb.Command):
os.remove(section)
gdb.execute(f"file {tmpfile.name}")
gdb.execute(f"gcore {corefile}")
gdb.execute(f"file {elffile}")
gdb.execute(f'gcore "{corefile}"')
gdb.execute(f'file "{elffile}"')
tmpfile.close()
print(f"Please run gdbserver.py to parse {corefile}")

View file

@ -135,7 +135,7 @@ def fetch_macro_info(file):
cache = path.join(path.dirname(path.abspath(file)), f"{hash}.macro")
if not path.isfile(cache):
start = time.time()
os.system(f"readelf -wm {file} > {cache}")
os.system(f'readelf -wm "{file}" > "{cache}"')
print(f"readelf took {time.time() - start:.1f} seconds")
print(f"Cache macro info to {cache}")
else:

View file

@ -196,7 +196,7 @@ def get_symbol_value(name, locspec="nx_start", cacheable=True):
# in order to use the list command to set the scope.
if len(gdb.inferiors()) == 1:
gdb.execute(
f"add-inferior -exec {gdb.objfiles()[0].filename} -no-connection",
f'add-inferior -exec "{gdb.objfiles()[0].filename}" -no-connection',
to_string=True,
)
g_symbol_cache = {}