From 96a518af35401f86a9a42c0f2c6d90bfeb11ddee Mon Sep 17 00:00:00 2001 From: xuxingliang Date: Mon, 23 Sep 2024 11:01:06 +0800 Subject: [PATCH] tools/gdb: fix elf file with special character Make sure file name is surrounded by \" Signed-off-by: xuxingliang --- tools/gdb/nuttxgdb/gcore.py | 4 ++-- tools/gdb/nuttxgdb/macros.py | 2 +- tools/gdb/nuttxgdb/utils.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/gdb/nuttxgdb/gcore.py b/tools/gdb/nuttxgdb/gcore.py index f15a436b1a6..532d6da7c1e 100644 --- a/tools/gdb/nuttxgdb/gcore.py +++ b/tools/gdb/nuttxgdb/gcore.py @@ -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}") diff --git a/tools/gdb/nuttxgdb/macros.py b/tools/gdb/nuttxgdb/macros.py index 6ce8f917feb..bf7b960eb31 100644 --- a/tools/gdb/nuttxgdb/macros.py +++ b/tools/gdb/nuttxgdb/macros.py @@ -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: diff --git a/tools/gdb/nuttxgdb/utils.py b/tools/gdb/nuttxgdb/utils.py index 985c89d0b49..740012e5353 100644 --- a/tools/gdb/nuttxgdb/utils.py +++ b/tools/gdb/nuttxgdb/utils.py @@ -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 = {}