public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: cole945@gmail.com (Wei-cheng Wang)
Cc: gdb-patches@sourceware.org, cole945@gmail.com
Subject: Re: [PATCH 1/2] Re-check fastpoint after reloading symbols.
Date: Thu, 27 Aug 2015 18:13:00 -0000	[thread overview]
Message-ID: <20150827181255.B2A0C39FA@oc7340732750.ibm.com> (raw)
In-Reply-To: <1440091938-42453-1-git-send-email-cole945@gmail.com> from "Wei-cheng Wang" at Aug 21, 2015 01:32:17 AM

Wei-cheng Wang wrote:

> Check fast tracepoints after symbols have been re-loaded.
> For example, a pending tracepoint just becomes available after
> a new shared object being loaded.  We didn't check it before,
> because we have no idea where it is.
> 
> If the target rejects the tracepoint, an error is throw in
> check_fast_tracepoint_sals, and we will disable the breakpoint.
> 
> The checking is deliberately put after the loop for adding location
> to breakpoint, so users can check the address for the tracepoint
> with `info trace'.  Otherwise, it will simply show <PENDING> instead
> of the address.
> 
> (gdb) info trace
> Num     Type            Disp Enb Address            What
> 1       fast tracepoint keep n   0x00003fffb7f507dc <pendfunc+20>
>                                  ^^^^^^^^^^^^^^^^^^

This makes sense to me.

However, we now have allowed a disabled breakpoint with an invalid
address in the list.  If the user simply enables the breakpoint now
and continues, we will run into the same internal error as before ...

So we probably ought to add the same check to enable_breakpoint.

> -  /* If there's no new locations, and all existing locations are
> -     pending, don't do anything.  This optimizes the common case where
> -     all locations are in the same shared library, that was unloaded.
> -     We'd like to retain the location, so that when the library is
> -     loaded again, we don't loose the enabled/disabled status of the
> -     individual locations.  */
> -  if (all_locations_are_pending (existing_locations) && sals.nelts == 0)
> -    return;

I don't understand why you're moving this piece of code down.  This just
seems to disable the optimization mentioned in the comment ...

> +  if (b->type == bp_fast_tracepoint)
> +    {
> +      TRY
> +	{
> +	  check_fast_tracepoint_sals (get_current_arch(), &sals);
This should use b->gdbarch instead of get_current_arch().

> +	}
> +      CATCH (e, RETURN_MASK_ERROR)
> +	{
> +	  b->enable_state = bp_disabled;
> +	  throw_exception (e);
> +	}
> +      END_CATCH
> +    }
> +
>    /* If possible, carry over 'disable' status from existing
>       breakpoints.  */

Hmm.  I think the check still needs to be moved further down.

Note that if there are other breakpoints, the have been re-set by the
loop above.  For those other breakpoints, we still should do the
actions done in the rest of this routine:
- carry over disable status
- notify observers
- update global location list

But if you run into an error during check_fast_tracepoint_sals,
you throw an exception, which skips all this code.  That's not
a good idea ...

I think we should move the check to the very end of the routine.
(In fact, we then might move it up into the caller, i.e. to the
end of tracepoint_re_set.)

Also, some test that all this works as expected would be good.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

      parent reply	other threads:[~2015-08-27 18:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-23 16:17 Wei-cheng Wang
2015-08-23 16:17 ` [PATCH 2/2] Determine the iteration count based on wallclock instead of user+system time Wei-cheng Wang
2015-08-27 18:14   ` Ulrich Weigand
2016-02-18 18:48   ` Marcin Kościelnicki
2016-02-18 18:56     ` Ulrich Weigand
2016-02-18 19:26       ` Marcin Kościelnicki
2015-08-27 18:13 ` Ulrich Weigand [this message]

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=20150827181255.B2A0C39FA@oc7340732750.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=cole945@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).