From bc2f1fb2f3e4e3601a262facc16313e1852926f0 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 3 Nov 2022 10:02:33 -0400 Subject: [PATCH] devenv: Add more info how to get gdb scripts working Now that top builddir is not the default workdir any more, the .gdbinit file we write there won't be loaded automatically unless user cd there, or use --init-command. There is also a global setting that user has to set to allow automatically loading .gdbinit file. --- mesonbuild/mdevenv.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mesonbuild/mdevenv.py b/mesonbuild/mdevenv.py index 6223b14e1..7f9b04ede 100644 --- a/mesonbuild/mdevenv.py +++ b/mesonbuild/mdevenv.py @@ -92,7 +92,7 @@ def add_gdb_auto_load(autoload_path: Path, gdb_helper: str, fname: Path) -> None except (FileExistsError, shutil.SameFileError): pass -def write_gdb_script(privatedir: Path, install_data: 'InstallData') -> None: +def write_gdb_script(privatedir: Path, install_data: 'InstallData', workdir: Path) -> None: if not shutil.which('gdb'): return bdir = privatedir.parent @@ -122,7 +122,16 @@ def write_gdb_script(privatedir: Path, install_data: 'InstallData') -> None: gdbinit_path.write_text(gdbinit_line, encoding='utf-8') first_time = True if first_time: - mlog.log('Meson detected GDB helpers and added config in', mlog.bold(str(gdbinit_path))) + gdbinit_path = gdbinit_path.resolve() + workdir_path = workdir.resolve() + rel_path = gdbinit_path.relative_to(workdir_path) + mlog.log('Meson detected GDB helpers and added config in', mlog.bold(str(rel_path))) + mlog.log('To load it automatically you might need to:') + mlog.log(' - Add', mlog.bold(f'add-auto-load-safe-path {gdbinit_path.parent}'), + 'in', mlog.bold('~/.gdbinit')) + if gdbinit_path.parent != workdir_path: + mlog.log(' - Change current workdir to', mlog.bold(str(rel_path.parent)), + 'or use', mlog.bold(f'--init-command {rel_path}')) def run(options: argparse.Namespace) -> int: privatedir = Path(options.builddir) / 'meson-private' @@ -142,7 +151,7 @@ def run(options: argparse.Namespace) -> int: return 0 install_data = minstall.load_install_data(str(privatedir / 'install.dat')) - write_gdb_script(privatedir, install_data) + write_gdb_script(privatedir, install_data, workdir) setup_vsenv(b.need_vsenv)