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.
pull/10990/head
Xavier Claessens 2 years ago
parent 3e7433086c
commit bc2f1fb2f3
  1. 15
      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): except (FileExistsError, shutil.SameFileError):
pass 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'): if not shutil.which('gdb'):
return return
bdir = privatedir.parent 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') gdbinit_path.write_text(gdbinit_line, encoding='utf-8')
first_time = True first_time = True
if first_time: 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: def run(options: argparse.Namespace) -> int:
privatedir = Path(options.builddir) / 'meson-private' privatedir = Path(options.builddir) / 'meson-private'
@ -142,7 +151,7 @@ def run(options: argparse.Namespace) -> int:
return 0 return 0
install_data = minstall.load_install_data(str(privatedir / 'install.dat')) 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) setup_vsenv(b.need_vsenv)

Loading…
Cancel
Save