Avoid duplicated .gdbinit loads by RUNRUBY_USE_GDB=true

If we use out-of-source build and have `${BUILD_DIR}/run.gdb` (by
`make run.gdb`), `${SOURCE_DIR}/.gdbinit` is loaded twice because
`run.gdb` loads `${SOURCE_DIR}/.gdbinit`.

If we have `run.gdb`, we don't need `-x ${SOURCE_DIR}/.gdbinit`.

There is one more problem for `${BUILD_DIR}/run.gdb` and
`${SOURCE_DIR}/.gdbinit`. `source -s misc/gdb.py` in
`${SOURCE_DIR}/.gdbinit` is failed when we use out-of-source build and
`${BUILD_DIR}/run.gdb` because `${SOURCE_DIR}` isn't included in
search path of `source`. If we have `directory $(srcdir)` in
`${BUILD_DIR}/run.gdb`, `source -s misc/gdb.py` works in
`${SOURCE_DIR}/.gdbinit` that is loaded from `${BUILD_DIR}/run.gdb`.
This commit is contained in:
Sutou Kouhei authored and Sutou Kouhei committed 2026-07-21 05:49:49 +09:00
1 parent 0bb123e4de
commit 46bcd7e58c
2 files changed
+6 -3
Notes: git 2026-07-20 20:50:20 +00:00

No files matched your search

+3 -2
View File
@@ -1469,8 +1469,9 @@ run.gdb:
echo '# handle SIGINT nostop' >> run.gdb
echo '# handle SIGPIPE nostop' >> run.gdb
echo '# b rb_longjmp' >> run.gdb
echo source $(srcdir)/breakpoints.gdb >> run.gdb
echo source $(srcdir)/.gdbinit >> run.gdb
echo directory $(srcdir) >> run.gdb
echo source -s breakpoints.gdb >> run.gdb
echo source -s .gdbinit >> run.gdb
echo 'set $$_exitcode = -999' >> run.gdb
echo run >> run.gdb
echo 'if $$_exitcode != -999' >> run.gdb
+3 -1
View File
@@ -163,10 +163,12 @@ ENV.update env
if debugger
case debugger
when :gdb
debugger = %W'gdb -x #{srcdir}/.gdbinit'
debugger = %W'gdb'
if File.exist?(gdb = 'run.gdb') or
File.exist?(gdb = File.join(abs_archdir, 'run.gdb'))
debugger.push('-x', gdb)
else
debugger.push('-x', "#{srcdir}/.gdbinit")
end
debugger << '--args'
when :lldb