Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Hannes Domani <ssbssa@yahoo.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH 7/7] Reset Windows hardware breakpoints on executable's entry point
Date: Wed, 27 May 2020 13:07:08 +0100	[thread overview]
Message-ID: <ef68f25b-da7c-6dbd-247a-389e4e35508b@redhat.com> (raw)
In-Reply-To: <20200525185659.59346-8-ssbssa@yahoo.de>

On 5/25/20 7:56 PM, Hannes Domani via Gdb-patches wrote:
> Fixes these testsuite fails on Windows (actually more, but the others are
> cascading failures):
> FAIL: gdb.base/hbreak2.exp: hardware breakpoint insertion (the program exited)
> FAIL: gdb.base/hbreak2.exp: run until function breakpoint (the program exited)
> FAIL: gdb.base/hbreak2.exp: run to factorial(6) (the program exited)
> FAIL: gdb.base/hbreak2.exp: run until hardware function breakpoint, optimized file (the program exited)
> 
> The problem happens if you only have hardware breakpoints active when
> (re-)starting the program:
> 
> (gdb) start
> Temporary breakpoint 1 at 0x401650: file C:/src/repos/binutils-gdb.git/gdb/tests
> uite/gdb.base/break.c, line 43.
> Starting program: C:\gdb\build64\gdb-git\gdb\testsuite\outputs\gdb.base\hbreak2\
> hbreak2.exe
> 
> Temporary breakpoint 1, main (argc=1, argv=0x7e2120, envp=0x7e2900)
>     at C:/src/repos/binutils-gdb.git/gdb/testsuite/gdb.base/break.c:43
> 43          if (argc == 12345) {  /* an unlikely value < 2^16, in case uninited
> */ /* set breakpoint 6 here */
> (gdb) hb factorial
> Hardware assisted breakpoint 2 at 0x401703: file C:/src/repos/binutils-gdb.git/g
> db/testsuite/gdb.base/break.c, line 63.
> (gdb) r
> The program being debugged has been started already.
> Start it from the beginning? (y or n) y
> Starting program: C:\gdb\build64\gdb-git\gdb\testsuite\outputs\gdb.base\hbreak2\
> hbreak2.exe
> 720
> [Inferior 1 (process 7836) exited normally]
> 
> But if you stopped just once before reaching the hardware breakpoint, it
> works fine:
> 
> (gdb) start
> Temporary breakpoint 3 at 0x401650: file C:/src/repos/binutils-gdb.git/gdb/tests
> uite/gdb.base/break.c, line 43.
> Starting program: C:\gdb\build64\gdb-git\gdb\testsuite\outputs\gdb.base\hbreak2\
> hbreak2.exe
> 
> Temporary breakpoint 3, main (argc=1, argv=0x322120, envp=0x322900)
>     at C:/src/repos/binutils-gdb.git/gdb/testsuite/gdb.base/break.c:43
> 43          if (argc == 12345) {  /* an unlikely value < 2^16, in case uninited
> */ /* set breakpoint 6 here */
> (gdb) c
> Continuing.
> 
> Breakpoint 2, factorial (value=6)
>     at C:/src/repos/binutils-gdb.git/gdb/testsuite/gdb.base/break.c:63
> 63        if (value > 1) {  /* set breakpoint 7 here */
> 
> I found out that cdb writes this error when trying to do the same:
> 
> Unable to set breakpoint error
> The system resets thread contexts after the process
> breakpoint so hardware breakpoints cannot be set.
> Go to the executable's entry point and set it then.
> 
> So all the hardware breakpoints that were set before (or rather, their
> debug register information) are practically lost when the process entry
> point is reached.
> 
> This patch creates an internal breakpoint on the process entry point, which
> when it is reached, resets all active hardware breakpoints, and continues
> execution.

Eh, I always assumed that the initial breakpoint the Windows debug API emits
during process initialization _was_ the entry point.  Where does the PC
point at when the initial breakpoint is reached?

You can use "starti" to check that.  "starti" spawns the process with
target_create_inferior, and then just does not run any other instruction,
It presents the stop where target_create_inferior left the process, which
is supposedly the process's entry point.

If Windows indeed resets the thread context after the initial
process breakpoint, then it sounds like we also lose any change to
the registers you make after "starti".

E.g., if you do "starti" + "p $rax = 0xabc" + "stepi", or something like
that.

It it sounding to me like we should be running to the entry point
in the initialization loop, from within do_initial_windows_stuff?

Thanks,
Pedro Alves



  reply	other threads:[~2020-05-27 12:07 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200525185659.59346-1-ssbssa.ref@yahoo.de>
2020-05-25 18:56 ` Windows testsuite failures Hannes Domani
2020-05-25 18:56   ` [PATCH 1/7] Fix function argument and return value locations Hannes Domani
2020-05-25 21:02     ` Simon Marchi
2020-05-25 21:32       ` Hannes Domani
2020-05-25 22:14         ` Simon Marchi
2020-05-25 23:03           ` Hannes Domani
2020-05-26 16:14             ` Simon Marchi
2020-05-26 20:43         ` Tom Tromey
2020-05-25 18:56   ` [PATCH 2/7] Handle Windows drives in auto-load script paths Hannes Domani
2020-05-26 16:04     ` Jon Turney
2020-05-26 16:31       ` Hannes Domani
2020-05-26 16:05     ` Christian Biesinger
2020-05-26 16:25       ` Hannes Domani
2020-05-26 16:31         ` Christian Biesinger
2020-05-26 16:40           ` Hannes Domani
2020-05-26 16:42             ` Christian Biesinger
2020-05-26 17:14               ` Hannes Domani
2020-05-25 18:56   ` [PATCH 3/7] Handle Windows drives in rbreak paths Hannes Domani
2020-05-25 18:56   ` [PATCH 4/7] Use errno value of first openp failure Hannes Domani
2020-05-26 20:37     ` Tom Tromey
2020-05-25 18:56   ` [PATCH 5/7] Close file handle of empty history file Hannes Domani
2020-05-26 16:37     ` Christian Biesinger
2020-05-26 17:42       ` Hannes Domani
2020-05-27 14:33         ` Tom Tromey
2020-05-27 17:37           ` Hannes Domani
2020-05-27 18:27             ` Christian Biesinger
2020-05-25 18:56   ` [PATCH 6/7] Move exit_status_set_internal_vars out of GLOBAL_CURDIR Hannes Domani
2020-05-26 20:45     ` Tom Tromey
2020-05-27 17:50       ` Hannes Domani
2020-05-25 18:56   ` [PATCH 7/7] Reset Windows hardware breakpoints on executable's entry point Hannes Domani
2020-05-27 12:07     ` Pedro Alves [this message]
2020-05-27 14:48       ` Pedro Alves
2020-05-27 15:39         ` Hannes Domani
2020-05-31 15:54           ` Pedro Alves
2020-05-31 16:37     ` Pedro Alves
2020-06-07 12:56       ` Hannes Domani
2020-07-08 17:43         ` Hannes Domani
2020-10-09 18:22         ` Pedro Alves
2020-10-09 18:51           ` Hannes Domani via Gdb-patches
2020-10-12 11:13             ` Pedro Alves
2020-10-12 17:21       ` Tom Tromey
2020-10-12 17:22         ` Tom Tromey
2020-05-28 18:15   ` Windows testsuite failures Christian Biesinger
2020-05-28 18:37     ` Hannes Domani

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=ef68f25b-da7c-6dbd-247a-389e4e35508b@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ssbssa@yahoo.de \
    /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