Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Dave.Tian" <xhengdf@gmail.com>
To: gdb-patches@sourceware.org
Cc: sergiodj@redhat.com, "Dave.Tian" <xhengdf@gmail.com>
Subject: [PATCH] bug fix for gdb 16039
Date: Wed, 16 Oct 2013 02:18:00 -0000	[thread overview]
Message-ID: <CAKjgB1NmhyvBFfBF2HgQc-9KP0OMPMb9fNXJAe3QxejdD3-X1g@mail.gmail.com> (raw)

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:

2013-10-16  Tian Ye  <xhengdf@gmail.com>

	PR gdb/16039
	* breakpoint.c (is_removable_in_unloaded_shlib): New.
	(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.

3 Patch Diffs:

--- breakpoint.c.bak	2013-10-12 01:15:09.044081000 -0700
+++ breakpoint.c	2013-10-15 18:50:59.842116000 -0700
@@ -1118,6 +1118,17 @@ is_tracepoint (const struct breakpoint *
   return is_tracepoint_type (b->type);
 }

+/* Breakpoints should be disable when shlib unload.  */
+
+static int
+is_removable_in_unloaded_shlib(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);
+}
+
 /* 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 +7158,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 +7474,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_removable_in_unloaded_shlib(b))
 	&& solib_contains_address_p (solib, loc->address))
       {
 	loc->shlib_disabled = 1;


             reply	other threads:[~2013-10-16  2:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16  2:18 Dave.Tian [this message]
2013-10-16  3:31 ` Sergio Durigan Junior
2013-10-16  6:44   ` Dave.Tian
2013-10-17 20:25     ` Tom Tromey
2013-10-19  4:38     ` Sergio Durigan Junior
2013-10-21  4:29       ` Dave.Tian
2013-10-28 23:33         ` Sergio Durigan Junior

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=CAKjgB1NmhyvBFfBF2HgQc-9KP0OMPMb9fNXJAe3QxejdD3-X1g@mail.gmail.com \
    --to=xhengdf@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@redhat.com \
    /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