gdb: relax requirement for the map_failed stap probe to be present
From glibc 2.35 and later, the "map_failed" stap probe is no longer
included in glibc. The removal of the probe looks like an accident,
but it was caused by a glibc commit which meant that the "map_failed"
probe could no longer be reached; the compiler then helpfully
optimised out the probe.
In GDB, in solib-svr4.c, we have a list of probes that we look for
related to the shared library loading detection. If any of these
probes are missing then GDB will fall back to the non-probe based
mechanism for detecting shared library loading. The "map_failed"
probe is include in the list of required probes.
This means that on glibc 2.35 (or later) systems, GDB is going to
always fall back to the non-probes based mechanism for detecting
shared library loading.
I raised a glibc bug to discuss this issue:
https://sourceware.org/bugzilla/show_bug.cgi?id=29818
But, whatever the ultimate decision from the glibc team, given there
are version of glibc in the wild without the "map_failed" probe, we
probably should update GDB to handle this situation.
The "map_failed" probe is already a little strange, very early
versions of glibc didn't include this probe, so, in some cases, if
this probe is missing GDB is happy to ignore it. This is fine, the
action associated with this probe inside GDB is DO_NOTHING, this means
the probe isn't actually required in order for GDB to correctly detect
the loading of shared libraries.
In this commit I propose changing the rules so that any probe whose
action is DO_NOTHING, is optional.
There is one possible downside to this change, and that concerns 'set
stop-on-solib-events on'. If a probe is removed from glibc, but the
old style breakpoint based mechanism is still in place within glibc
for that same event, then GDB will stop when using the old style
non-probe based mechanism, but not when using the probes based
mechanism.
For the map_failed case this is not a problem, both the map_failed
probe, and the call to the old style breakpoint location were
optimised out, and so neither event (probes based, or breakpoint
based) will trigger. This would only become an issue if glibc removed
a probe, but left the breakpoint in place (this would almost certainly
be a bug in glibc).
For now, I'm proposing that we just don't worry about this. Because
some probes have actions that are not DO_NOTHING, then we know the
user will always seem _some_ stops when a shared library is
loaded/unloaded, and (I'm guessing), in most cases, that's all they
care about. I figure when someone complains then we can figure out
what the right solution is then.
With this commit in place, then, when using a glibc 2.35 or later
system, GDB will once again use the stap probes for shared library
detection.
Reviewed-By: Lancelot SIX <lancelot.six@amd.com>