Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Xavier Roirand <roirand@adacore.com>
To: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org
Cc: brobecker@adacore.com
Subject: Re: [RFA v2] (x86) Fix watchpoint using hardware breakpoint for some distro
Date: Tue, 27 Mar 2018 13:19:00 -0000	[thread overview]
Message-ID: <e9826842-3939-21c8-ced6-2eeb0805104c@adacore.com> (raw)
In-Reply-To: <38205bbb-35c0-c512-0d2c-df0fe9596b4f@redhat.com>

Hello,

> Earlier you said that TRAP_HWBKPT was the only case that was different
> from current kernels, but turns out that's not accurate.  And now
> I'm left wondering what do those kernels report for the other cases
> you haven't confirmed yet, like hw breakpoints, software breakpoints,
> and regular single steps.  We need a complete picture to figure out
> what the best fix is.
> 

Here's a more complete picture:

Ubuntu 16.04

| what                                     | si_code     | value |
|------------------------------------------+-------------|-------|
| software breakpoints (int3)              | SI_KERNEL   |  0x80 |
| single-steps                             | TRAP_TRACE  |     2 |
| single-stepping a syscall                | TRAP_BRKPT  |     1 |
| user sent SIGTRAP                        | 0           |     0 |
| exec SIGTRAP (when no PTRACE_EVENT_EXEC) | 0           |     0 |
| hardware breakpoints/watchpoints         | TRAP_HWBKPT |     4 |

CentOs 5.11

| what                                     | si_code     | value |
|------------------------------------------+-------------|-------|
| software breakpoints (int3)              | SI_KERNEL   |  0x80 |
| single-steps                             | TRAP_TRACE  |     2 |
| single-stepping a syscall                | TRAP_BRKPT  |     1 |
| user sent SIGTRAP                        | 0           |     0 |
| exec SIGTRAP (when no PTRACE_EVENT_EXEC) | 0           |     0 |
| hardware breakpoints/watchpoints         | TRAP_HWBKPT |     1 |


>> E.g., if hw breakpoints and watchpoints report the same si_code,
>> how do hw breakpoints work with your patch?
>>

In handle_signal_stop function, there's a check done in order to see if 
there's a breakpoint/watchpoint/catchpoint/etc which handle this stop 
event and check if there's a breakpoint/watchpoint/catchpoint where the 
inferior is stopped:

   /* See if there is a breakpoint/watchpoint/catchpoint/etc. that
      handles this event.  */
   ecs->event_thread->control.stop_bpstat
     = bpstat_stop_status (get_current_regcache ()->aspace (),
                           stop_pc, ecs->ptid, &ecs->ws);

Do you think that having a fix handling both cases in save_stop_reason 
would be better (hardware breakpoint & watchpoint) ?

           else
             {
               if (hardware_breakpoint_inserted_here_p (regcache->aspace 
(), pc))
                 lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
               else
                 check_stopped_by_watchpoint (lp);
             }

Rather than my initial proposal:

           else
             {
                 check_stopped_by_watchpoint (lp);
             }

Regards

> Thanks,
> Pedro Alves
> 


      reply	other threads:[~2018-03-27 13:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-16 14:07 [RFA] " Xavier Roirand
2018-03-19 14:29 ` Pedro Alves
2018-03-20 14:28   ` [RFA v2] " Xavier Roirand
     [not found]     ` <c0d80d21-9f0e-c6b0-caaf-7b6246e83807@redhat.com>
2018-03-21 16:17       ` Xavier Roirand
2018-03-26 11:38         ` Pedro Alves
2018-03-27 13:19           ` Xavier Roirand [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=e9826842-3939-21c8-ced6-2eeb0805104c@adacore.com \
    --to=roirand@adacore.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@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