[RFC] Watchpoint on an unloaded shared library(3)
Joel Brobecker
brobecker@adacore.com
Wed Sep 23 22:34:00 GMT 2009
Emi,
I'm quoting the important pieces of your email to refresh both our
memories about the issue at hand:
The problem occurs when watching a variable that lives inside a shared
library, after the shared library gets unmapped.
> b->exp for software watchpoints would be updated when a new shared
> library is loaded and the user enables disabled ones, but not when a
> shared library is unloaded. So fetch_watchpoint_value (b->exp,....)
> would refer to symtabs which is already freed after the shared
> library is unloaded.
>
> For breakpoints, we use disable_breakpoints_in_unloaded_shlib to check
> if the breakpoints refer to the unloaded library. And we should call
> update_watchpoint for each watchpoints to check if the expression
> they refer to is to be removed. But actually calling update_watchpoint
> in disable_breakpoints_in_unloaded_shlib does not work, because we
> remove the symtabs of the unloaded library after we notify that the
> shared library is unloaded:
[...]
> However, when the symtabs for the shared library is automatically
> loaded, we notify the observers of load of a shared library *before*
> loading its symtabs (Note that observer_notify_solib_load is called in
> update_solib_list):
[...]
> So I think it is more consistent to remove auto-loaded symbols for an
> unloaded shared library before notifying the unload. I also confirmed
> that the other observers for solib_unloaded do not expect that symtabs
> for that library still exist.
I am very uncomfortable with the idea of unloading the objfiles and
then calling the observers with the so_list struct of the SO that
got unloaded. This struct contains a pointer to the objfile which
we just freed!
I wish there was an easy to do the same as what we do for breakpoints,
but watchpoints are a little more complicated. So here is what I suggest
instead: Let's create a new observer called solib_unloaded_post, and
send a notification after the SO has been unloaded. We should update
the documentation for the solib_unloaded notification that this event
is triggered *before* the library's symbols are unloaded. In fact,
I will do that immediately.
--
Joel
More information about the Gdb-patches
mailing list