mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-15 14:36:45 +00:00
feat(debugging): move gdbinit generation to CMake
This feature is useful for 3rd-party software to run GDB with predefined options that described in project_description.json file allow to pass custom options to "idf.py gdb": --gdb-commands: command line arguments for gdb. (without changes) -ex: pass command to gdb. -x: pass gdbinit file to gdb. Alias for old --gdbinit command
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
from typing import List
|
||||
|
||||
|
||||
@@ -20,12 +21,18 @@ GDB_SUBSTITUTE_PATH_FMT = 'set substitute-path {} {}\n'
|
||||
|
||||
|
||||
def write_gdbinit(build_dir: str, folders: List[str]) -> None:
|
||||
gdb_init_filepath = os.path.join(build_dir, 'prefix_map_gdbinit')
|
||||
gdbinit_dir = os.path.join(build_dir, 'gdbinit')
|
||||
gdbinit_filepath = os.path.join(gdbinit_dir, 'prefix_map')
|
||||
|
||||
with open(gdb_init_filepath, 'w') as fw:
|
||||
if not os.path.exists(gdbinit_dir):
|
||||
os.mkdir(gdbinit_dir)
|
||||
|
||||
with open(gdbinit_filepath, 'w') as fw:
|
||||
for folder in folders:
|
||||
fw.write(f'{GDB_SUBSTITUTE_PATH_FMT.format(component_name(folder), folder)}')
|
||||
|
||||
shutil.copy(gdbinit_filepath, os.path.join(build_dir, 'prefix_map_gdbinit'))
|
||||
|
||||
|
||||
def main(build_dir: str, folders: List[str]) -> None:
|
||||
write_gdbinit(build_dir, folders)
|
||||
@@ -34,7 +41,7 @@ def main(build_dir: str, folders: List[str]) -> None:
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='print the debug-prefix-map and write to '
|
||||
'$BUILD_DIR/prefix_map_gdbinit file')
|
||||
'$BUILD_DIR/gdbinit/prefix_map file')
|
||||
|
||||
parser.add_argument('build_dir',
|
||||
help='build dir')
|
||||
|
Reference in New Issue
Block a user