public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Differences in MI Breakpoint Notification for GDB CLI and MI Command
@ 2023-05-09 15:29 bilal
  2023-05-09 18:26 ` Simon Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: bilal @ 2023-05-09 15:29 UTC (permalink / raw)
  To: gdb-patches

Hi expert,

I have noticed differences in the MI breakpoint notification when creating a breakpoint from the GDB CLI command versus using the MI command


If I create a software breakpoint for a read-only memory location using the GDB CLI command, GDB immediately notifies the MI client of a breakpoint modification by changing it to a hardware breakpoint.
i.e
$ ./arm-none-eabi-gdb -q /tmp/test --interpreter mi3 -ex "mem 0x0 0x100000 ro nocache" 
=thread-group-added,id="i1"
~"Reading symbols from /tmp/test...\n"
(gdb) 
b main
&"b main\n"
~"Breakpoint 1 at 0x254\n"
=breakpoint-created,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000254",at="<main+12>",thread-groups=["i1"],times="0",original-location="main"}
=breakpoint-modified,bkpt={number="1",type="hw breakpoint",disp="keep",enabled="y",addr="0x00000254",at="<main+12>",thread-groups=["i1"],times="0",original-location="main"}
~"Note: automatically using hardware breakpoints for read-only addresses.\n"
^done
(gdb)


However, there is no such notification if I use the MI break-insert command instead of the CLI command.
i.e
$ ./arm-none-eabi-gdb -q /tmp/test --interpreter mi3 -ex "mem 0x0 0x100000 ro nocache" 
=thread-group-added,id="i1"
~"Reading symbols from /tmp/test...\n"
(gdb) 
-break-insert main
~"Note: automatically using hardware breakpoints for read-only addresses.\n"
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000254",at="<main+12>",thread-groups=["i1"],times="0",original-location="main"}
(gdb)


GDB only emits a modified notification when a breakpoint is hit, and an MI client, such as CDT, needs to re-install the breakpoint as a hardware breakpoint while the program is running and being debugged. Therefore, the IDE must first interrupt the program and then re-install the modified breakpoint. 

Could anyone explain why GDB does not emit an MI breakpoint notification when the breakpoint is first inserted?


Thanks
-Bilal
    

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

* Re: Differences in MI Breakpoint Notification for GDB CLI and MI Command
  2023-05-09 15:29 Differences in MI Breakpoint Notification for GDB CLI and MI Command bilal
@ 2023-05-09 18:26 ` Simon Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2023-05-09 18:26 UTC (permalink / raw)
  To: bilal, gdb-patches

On 5/9/23 11:29, bilal--- via Gdb-patches wrote:
> Hi expert,
> 
> I have noticed differences in the MI breakpoint notification when creating a breakpoint from the GDB CLI command versus using the MI command
> 
> 
> If I create a software breakpoint for a read-only memory location using the GDB CLI command, GDB immediately notifies the MI client of a breakpoint modification by changing it to a hardware breakpoint.
> i.e
> $ ./arm-none-eabi-gdb -q /tmp/test --interpreter mi3 -ex "mem 0x0 0x100000 ro nocache" 
> =thread-group-added,id="i1"
> ~"Reading symbols from /tmp/test...\n"
> (gdb) 
> b main
> &"b main\n"
> ~"Breakpoint 1 at 0x254\n"
> =breakpoint-created,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000254",at="<main+12>",thread-groups=["i1"],times="0",original-location="main"}
> =breakpoint-modified,bkpt={number="1",type="hw breakpoint",disp="keep",enabled="y",addr="0x00000254",at="<main+12>",thread-groups=["i1"],times="0",original-location="main"}
> ~"Note: automatically using hardware breakpoints for read-only addresses.\n"
> ^done
> (gdb)
> 
> 
> However, there is no such notification if I use the MI break-insert command instead of the CLI command.
> i.e
> $ ./arm-none-eabi-gdb -q /tmp/test --interpreter mi3 -ex "mem 0x0 0x100000 ro nocache" 
> =thread-group-added,id="i1"
> ~"Reading symbols from /tmp/test...\n"
> (gdb) 
> -break-insert main
> ~"Note: automatically using hardware breakpoints for read-only addresses.\n"
> ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000254",at="<main+12>",thread-groups=["i1"],times="0",original-location="main"}
> (gdb)
> 
> 
> GDB only emits a modified notification when a breakpoint is hit, and an MI client, such as CDT, needs to re-install the breakpoint as a hardware breakpoint while the program is running and being debugged. Therefore, the IDE must first interrupt the program and then re-install the modified breakpoint. 
> 
> Could anyone explain why GDB does not emit an MI breakpoint notification when the breakpoint is first inserted?

I'm guessing that it's because all MI notifications (the things starting
with =_) are muted during the execution of the -break-insert command.
The reason being that the client doesn't need to get notified of the
breakpoint creation for its own -break-insert command.

At first glance, it looks like a bug, the ^done response should probably
say type="hw breakpoint".

Simon

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

end of thread, other threads:[~2023-05-09 18:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-09 15:29 Differences in MI Breakpoint Notification for GDB CLI and MI Command bilal
2023-05-09 18:26 ` Simon Marchi

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