This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: bug fix for gdb 16039 ( patch resent according Sergion's suggestion)
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: "Dave.Tian" <xhengdf at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 15 Oct 2013 13:56:59 -0300
- Subject: Re: bug fix for gdb 16039 ( patch resent according Sergion's suggestion)
- Authentication-results: sourceware.org; auth=none
- References: <CAKjgB1PbTgbJDGUuDuydRdcPXfa_V3=msZOkTiNrZtr1bSu8+g at mail dot gmail dot com>
On Monday, October 14 2013, Dave Tian wrote:
> 1 description: gdb bug 16039 created by me
>
> Title: gdb next" command stop working when shared library unloaded
> Root Cause: there is "libc++" static linked into the shared library,
> and since gdb insert internal breakpoints on
> std::terminate/longjump/..
> so after dlclose, the memory address is invalid,
> remove_breakpoints/insert_breakpoints failed with EIO error.
>
> Fix: disable the internal breakpoints when dlclose hit.
>
> 2 ChangeLog:
>
> PR gdb/16039
> * breakpoint.c (set_longjmp_breakpoint): Check if breakpoint's
> location address is not in an unloaded shared library.
> (disable_breakpoints_in_unloaded_shlib):
> disable the internal breakpoints in the hook function of shared
> library unload.
Still not there yet. Please, take a look at the link I sent, and also
at the file gdb/ChangeLog to see how the entries are written. You
should format it with TABs instead of spaces, mention new functions,
etc.
> 3 Patch diffs:
>
> --- breakpoint.c.bak 2013-10-12 01:15:09.044081000 -0700
> +++ breakpoint.c 2013-10-13 22:56:54.905407000 -0700
> @@ -1118,6 +1118,15 @@ is_tracepoint (const struct breakpoint *
> return is_tracepoint_type (b->type);
> }
>
> +static int
> +is_internal_breakpoint (const struct breakpoint *b)
> +{
> + return (b->type == bp_longjmp_master
> + || b->type == bp_std_terminate_master
> + || b->type == bp_exception_master
> + || b->type == bp_exception);
> +}
This new function needs a comment on top of it. And I think this
function is incomplete. If its job is to check for internal
breakpoints, then I guess it should be expanded to check for all types
of internal breakpoints.
> +
> /* A helper function that validates that COMMANDS are valid for a
> breakpoint. This function will throw an exception if a problem is
> found. */
> @@ -7147,8 +7156,8 @@ set_longjmp_breakpoint (struct thread_in
> clones of those and enable them for the requested thread. */
> ALL_BREAKPOINTS_SAFE (b, b_tmp)
> if (b->pspace == current_program_space
> - && (b->type == bp_longjmp_master
> - || b->type == bp_exception_master))
> + && ((b->type == bp_longjmp_master
> + || b->type == bp_exception_master) && !b->loc->shlib_disabled))
> {
> enum bptype type = b->type == bp_longjmp_master ? bp_longjmp : bp_exception;
> struct breakpoint *clone;
> @@ -7463,7 +7472,8 @@ disable_breakpoints_in_unloaded_shlib (s
> || b->type == bp_hardware_breakpoint)
> && (loc->loc_type == bp_loc_hardware_breakpoint
> || loc->loc_type == bp_loc_software_breakpoint))
> - || is_tracepoint (b))
> + || is_tracepoint (b)
> + || is_internal_breakpoint (b))
> && solib_contains_address_p (solib, loc->address))
> {
> loc->shlib_disabled = 1;
>
Thanks. You might want to wait for a maintainer to review this patch as
well.
--
Sergio