Re: [PATCH 7/7] Reset Windows hardware breakpoints on executable's entry point

Pedro Alves
2020-05-31T15:54:23Z

On 5/27/20 4:39 PM, Hannes Domani via Gdb-patches wrote:
> Am Mittwoch, 27. Mai 2020, 16:48:16 MESZ hat Pedro Alves <palves@redhat.com> Folgendes geschrieben:

>> The answer at <https://stackoverflow.com/questions/5925542/how-can-i-set-break-point-on-my-function-and-list-its-source>,
>> seems to confirm it:
>>
>>    "If you debugger sets some registry values right now, those changes would not
>>      matter, because OS will override all register values while starting executing
>>      process. "
>>
>> Interestingly, it also says:
>>
>>    "Workaround is simple -- first make a single step using t instruction, then you
>>      can use hardware breakpoints as you like."
>>
>> Which makes it sounds like a single-step is all it takes to get to the entry point.
>> That may make it easier to implement this inside do_initial_windows_stuff,
>> including doing the same thing in gdbserver.
>
> I just tried:

...

> So after a nexti the hardware breakpoint still didn't work, because at this
> point it's far before the overwriting of the context.
>

OK, thanks for trying it out.

> Or did you mean this different?

No, I was misled by the comments in stackoverflow, which are clearly incorrect.

Meanwhile I found this, which explains this mechanism in more detail:

http://www.nynaeve.net/?p=81

> Anyways, since there is a simple workaround to make the hardware breakpoints
> work (just use "start"), it doesn't matter much to me if this gets fixed.
I think that it's nice to make this work transparently; I was just
exploring the best way to do so. Let me take another look at the patch.

Thanks,
Pedro Alves