Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tudor-Stefan Magirescu <tudor.magirescu@gmail.com>
To: gdb-patches@sourceware.org
Cc: tudor.magirescu@gmail.com
Subject: [PATCH v2 0/2] Fix auto-load script loading after safe-path is widened
Date: Thu,  3 Sep 2026 11:21:59 +0200	[thread overview]
Message-ID: <20260903092201.663063-1-tudor.magirescu@gmail.com> (raw)
In-Reply-To: <20260901140602.3287196-1-tudor.magirescu@gmail.com>

GDB's safe-path mechanism makes it inconvenient to work with scripts
embedded in .debug_gdb_scripts sections.  Once a script is blocked, GDB
never retries loading it even if the safe-path is widened.  This occurs
because the hash table entry inserted for the first declined load prevents
any further attempt.  Working around this requires reloading the binary
via the file command or restarting GDB entirely.

Patch 1 fixes the hash table issue.  For shared library scripts, which
are re-examined on each run of the inferior, a re-run after widening the
safe-path is sufficient.  Scripts embedded in the main executable still
require a reload via file or a GDB restart, since their objfile is not
reloaded for a re-run.

Patch 2 further addresses the problem by changing add-auto-load-safe-path
to immediately retry previously blocked scripts.  This allows the user to
load a rejected script without exiting the current GDB session or
re-running the inferior.

Changes since v1:
  - Change the return type of maybe_add_script_file and
    maybe_add_script_text to bool, making it return whether the script
    was previously loaded.
  - Add Patch 2 (add-auto-load-safe-path immediate retry).

Tudor-Stefan Magirescu (2):
  [gdb] Fix auto-load script re-execution on subsequent runs
  [gdb] Retry blocked auto-load scripts when safe-path is widened

 gdb/auto-load.c                               | 130 +++++++-----
 gdb/auto-load.h                               |  13 +-
 gdb/extension.c                               |   7 +-
 gdb/extension.h                               |   3 +-
 ...ers-in-newobjfile-event-objfile.so-gdb.py} |   0
 ...s-in-newobjfile-event-dotdebug-filename.py |  43 ++++
 ...-newobjfile-event-lib-dotdebug-filename.cc |  39 ++++
 ...s-in-newobjfile-event-lib-dotdebug-text.cc |  49 +++++
 ...inters-in-newobjfile-event-lib-objfile.cc} |   0
 ...ed-pretty-printers-in-newobjfile-event.exp | 187 +++++++++++++-----
 10 files changed, 361 insertions(+), 110 deletions(-)
 rename gdb/testsuite/gdb.python/{libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py => libpy-autoloaded-pretty-printers-in-newobjfile-event-objfile.so-gdb.py} (100%)
 create mode 100644 gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-dotdebug-filename.py
 create mode 100644 gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib-dotdebug-filename.cc
 create mode 100644 gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib-dotdebug-text.cc
 rename gdb/testsuite/gdb.python/{py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc => py-autoloaded-pretty-printers-in-newobjfile-event-lib-objfile.cc} (100%)

-- 
2.43.0


  reply	other threads:[~2026-09-03  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 14:06 [PATCH] [gdb] Fix auto-load script re-execution on subsequent runs Tudor-Stefan Magirescu
2026-09-03  9:21 ` Tudor-Stefan Magirescu [this message]
2026-09-03  9:22   ` [PATCH v2 1/2] " Tudor-Stefan Magirescu
2026-09-03  9:22   ` [PATCH v2 2/2] [gdb] Retry blocked auto-load scripts when safe-path is widened Tudor-Stefan Magirescu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260903092201.663063-1-tudor.magirescu@gmail.com \
    --to=tudor.magirescu@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox