public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Luis Machado <lgustavo@codesourcery.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix problems with finishing a dummy function call on simulators.
Date: Wed, 17 Jun 2015 12:41:00 -0000	[thread overview]
Message-ID: <55816AD5.6020605@redhat.com> (raw)
In-Reply-To: <55805F52.20805@codesourcery.com>

On 06/09/2015 07:22 PM, Luis Machado wrote:
> Both the above and the mail sound like workaround ideas. You mentioned
> even more special casing in the mail. It is the amount of special casing
> that i'm afraid of.

I was actually proposing to remove the special casing.  :-)

On 06/16/2015 06:39 PM, Luis Machado wrote:

> I gave the strategy of not marking permanent breakpoints/locations as 
> inserted a try, and it fixes the simulator problems i've been seeing 
> with the permanent breakpoint locations.

Thanks.

> 
> One strange side effect of this change on my local machine (x86-64) is 
> that gdb.threads/attach-many-short-lived-threads.exp gives me PASS 
> instead of FAIL when always-inserted mode is ON. I didn't investigate 
> this further though. 

You mean you _always_ get a FAIL before your patch?  This test sometimes
FAILs for an unknown reason, but it's racy -- it should be passing most of
the time.

> Is it known that this testcase is affected by 
> permanent breakpoint locations?

No.

> Is this patch what you had in mind?

Yep.  Close, but also remove the bp_call_dummy check in
bp_loc_is_permanent, and merge in its comment, like ...

> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index eb3df02..768ce59 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -7440,15 +7440,16 @@ make_breakpoint_permanent (struct breakpoint *b)
>    struct bp_location *bl;
>
>    /* By definition, permanent breakpoints are already present in the
> -     code.  Mark all locations as inserted.  For now,
> -     make_breakpoint_permanent is called in just one place, so it's
> -     hard to say if it's reasonable to have permanent breakpoint with
> -     multiple locations or not, but it's easy to implement.  */
> +     code.  For now, make_breakpoint_permanent is called in just one place, so
> +     it's hard to say if it's reasonable to have permanent breakpoint with
> +     multiple locations or not, but it's easy to implement.
> +
> +     Permanent breakpoints are not marked as inserted so we allow other
> +     non-permanent locations at the same address to be inserted on top
> +     of it.  This is required due to some targets, simulators mostly, not
> +     dealing properly with hardwired breakpoints in the code.  */

... this:

    /* While by definition, permanent breakpoints are already present in the
       code, we don't mark the location as inserted.  Normally one would expect
       that GDB could rely on that breakpoint instruction to stop the program, thus
       removing the need to insert its own breakpoint, except that executing the
       breakpoint instruction can kill the target instead of reporting a SIGTRAP.
       E.g., on SPARC, when interrupts are disabled, executing the instruction
       resets the CPU, so QEMU 2.0.0 for SPARC correspondingly dies
       with "Trap 0x02 while interrupts disabled, Error state".  Letting the
       breakpoint be inserted normally results in QEMU knowing about the GDB
       breakpoint, and thus trap before the breakpoint instruction is executed.
       (If GDB later needs to continue execution past the permanent breakpoint,
       it manually increments the PC, thus avoiding executing the breakpoint
       instruction.)

>    for (bl = b->loc; bl; bl = bl->next)
> -    {
> -      bl->permanent = 1;
> -      bl->inserted = 1;
> -    }
> +    bl->permanent = 1;
>  }
>

Actually, make_breakpoint_permanent is dead and should be deleted.  The
last remaining caller is finally gone - it was one of the old Unix ports
we removed.  So the comment should be moved to add_location_to_breakpoint
instead.

Thanks,
Pedro Alves

  reply	other threads:[~2015-06-17 12:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09 15:01 Luis Machado
2015-06-09 17:51 ` Pedro Alves
2015-06-09 18:10   ` Luis Machado
2015-06-09 18:13     ` Pedro Alves
2015-06-09 18:22       ` Luis Machado
2015-06-09 18:34       ` Luis Machado
2015-06-16 17:39   ` Luis Machado
2015-06-17 12:41     ` Pedro Alves [this message]
2015-06-17 13:26       ` Luis Machado
2015-06-17 13:43         ` Pedro Alves
2015-06-17 20:16           ` Luis Machado
2015-07-06 15:06             ` Pedro Alves
2015-07-06 15:33               ` Luis Machado
2015-07-06 16:15                 ` Pedro Alves
2015-07-06 16:18                   ` Luis Machado
2015-07-06 18:34                   ` Luis Machado
2015-07-06 19:07                     ` Pedro Alves
2015-07-06 19:11                       ` Luis Machado

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=55816AD5.6020605@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lgustavo@codesourcery.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).