public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Why are  these two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() called multiple times
@ 2023-05-31  9:12 hilbert
  2023-05-31 15:57 ` John Baldwin
  0 siblings, 1 reply; 5+ messages in thread
From: hilbert @ 2023-05-31  9:12 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

Hi,

         I just inserted a breakpoint, shouldn't the two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() be used only once?

There is only one breakpoint, why both functions default_memory_insert_breakpoint() and default_memory_remove_breakpoint() are called before stopping and after stopping (after the continue command), why?


Thank you very much.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why are these two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() called multiple times
  2023-05-31  9:12 Why are these two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() called multiple times hilbert
@ 2023-05-31 15:57 ` John Baldwin
  2023-06-01  1:50   ` hilbert
  0 siblings, 1 reply; 5+ messages in thread
From: John Baldwin @ 2023-05-31 15:57 UTC (permalink / raw)
  To: hilbert, gdb

On 5/31/23 2:12 AM, hilbert via Gdb wrote:
> Hi,
> 
>           I just inserted a breakpoint, shouldn't the two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() be used only once?
> 
> There is only one breakpoint, why both functions default_memory_insert_breakpoint() and default_memory_remove_breakpoint() are called before stopping and after stopping (after the continue command), why?

GDB inserts some of its own internal breakpoints.  For example,
in the runtime linker/loader there is a special symbol GDB sets
a breakpoint on so it can be notified about shared libraries being
loaded or unloaded.  If you are using libthread_db on a target it
may install internal breakpoints to detect thread creation and
thread exit as well.

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re:Re: Why are these two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() called multiple times
  2023-05-31 15:57 ` John Baldwin
@ 2023-06-01  1:50   ` hilbert
  2023-06-01 17:09     ` John Baldwin
  0 siblings, 1 reply; 5+ messages in thread
From: hilbert @ 2023-06-01  1:50 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]

 @John Baldwin 



Thank you very much for your answer;




I have another question, very confused.I don't understand the mechanism of register caching.

The register cache is initialized at the very beginning, when will it be updated later?

Will it be automatically updated later?




In the infrun.c/displaced_step_prepare() , it can accurately read the original_pc, which is the pc at the breakpoint position.
The instruction replaced by the breakpoint can be obtained through this original_pc;








Thank you very much.











At 2023-05-31 23:57:52, "John Baldwin" <jhb@FreeBSD.org> wrote:
>On 5/31/23 2:12 AM, hilbert via Gdb wrote:
>> Hi,
>> 
>>           I just inserted a breakpoint, shouldn't the two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() be used only once?
>> 
>> There is only one breakpoint, why both functions default_memory_insert_breakpoint() and default_memory_remove_breakpoint() are called before stopping and after stopping (after the continue command), why?
>
>GDB inserts some of its own internal breakpoints.  For example,
>in the runtime linker/loader there is a special symbol GDB sets
>a breakpoint on so it can be notified about shared libraries being
>loaded or unloaded.  If you are using libthread_db on a target it
>may install internal breakpoints to detect thread creation and
>thread exit as well.
>
>-- 
>John Baldwin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why are these two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() called multiple times
  2023-06-01  1:50   ` hilbert
@ 2023-06-01 17:09     ` John Baldwin
  2023-06-02  2:09       ` hilbert
  0 siblings, 1 reply; 5+ messages in thread
From: John Baldwin @ 2023-06-01 17:09 UTC (permalink / raw)
  To: hilbert; +Cc: gdb

On 5/31/23 6:50 PM, hilbert wrote:
>   @John Baldwin
> 
> 
> 
> Thank you very much for your answer;
> 
> 
> 
> 
> I have another question, very confused.I don't understand the mechanism of register caching.
> 
> The register cache is initialized at the very beginning, when will it be updated later?
> 
> Will it be automatically updated later?

My understanding is that the cache for a given thread is flushed on each stop of that thread,
so the cache is only active in terms of preventing multiple ptrace() calls or multiple
requests to the remote target while a user is examining a thread during a single stop.

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re:Re: Why are these two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() called multiple times
  2023-06-01 17:09     ` John Baldwin
@ 2023-06-02  2:09       ` hilbert
  0 siblings, 0 replies; 5+ messages in thread
From: hilbert @ 2023-06-02  2:09 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]



 @John Baldwin 

Got it.

Thank you so much














At 2023-06-02 01:09:40, "John Baldwin" <jhb@FreeBSD.org> wrote:
>On 5/31/23 6:50 PM, hilbert wrote:
>>   @John Baldwin
>> 
>> 
>> 
>> Thank you very much for your answer;
>> 
>> 
>> 
>> 
>> I have another question, very confused.I don't understand the mechanism of register caching.
>> 
>> The register cache is initialized at the very beginning, when will it be updated later?
>> 
>> Will it be automatically updated later?
>
>My understanding is that the cache for a given thread is flushed on each stop of that thread,
>so the cache is only active in terms of preventing multiple ptrace() calls or multiple
>requests to the remote target while a user is examining a thread during a single stop.
>
>-- 
>John Baldwin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-02  2:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31  9:12 Why are these two methods default_memory_insert_breakpoint() and default_memory_remove_breakpoint() called multiple times hilbert
2023-05-31 15:57 ` John Baldwin
2023-06-01  1:50   ` hilbert
2023-06-01 17:09     ` John Baldwin
2023-06-02  2:09       ` hilbert

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).