Bug 7161 - "clear" command removes internal breakpoints
Summary: "clear" command removes internal breakpoints
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: cli (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 13.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-05-27 23:18 UTC by phred
Modified: 2022-04-18 14:52 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description phred 2001-05-28 06:18:00 UTC
[Converted from Gnats 56]

The "clear" command will merrily delete gdb's special
internal breakpoints.

In particular, if the user sets a normal breakpoint at a 
place where gdb also happens to have an internal breakpoint
and types "clear" when gdb hits the normal breakpoint, then
the internal breakpoint goes away, too.

Release:
gdb 5.0

Environment:
Stock Red Hat Linux 7.1

How-To-Repeat:
[wuzzy:~] 12) gcc -g hello.c
 
[wuzzy:~] 13) gdb a.out
GNU gdb 5.0rh-5 Red Hat Linux 7.1
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) br main
Breakpoint 1 at 0x8048466: file hello.c, line 4.
(gdb) ru
Starting program: /home/phred/a.out
 
Breakpoint 1, main (argc=1, argv=0xbffff91c) at hello.c:4
4           printf( "Hello, world!\n" );
(gdb) maintenance info breakpoints
Num Type           Disp Enb Address    What
1   breakpoint     keep y   0x08048466 in main at hello.c:4
        breakpoint already hit 1 time
-2  shlib events   keep y   0x4000e4f0 <_dl_debug_state>
        breakpoint already hit 3 times
-7  longjmp        keep n   0x400116d0 <longjmp>
-8  longjmp        keep n   0x40053444 <__libc_siglongjmp>
-9  longjmp        keep n   0x40053444 <__libc_siglongjmp>
-10 longjmp resume keep n   0x00000000
(gdb) clear *0x4000e4f0
Deleted breakpoint -2
(gdb) clear *0x400116d0
Deleted breakpoint -7
(gdb) clear *0x40053444
Deleted breakpoints -9 -8
(gdb)
Comment 1 phred 2001-05-28 06:18:00 UTC
Fix:
The clear_command() function should check whether a 
breakpoint is an internal breakpoint before deleting it.

Someone might want to add a "maintenance clear" command that
can remove internal breakpoints.
Comment 2 Tom Tromey 2018-09-15 18:49:13 UTC
Amazingly, still a bug.
Comment 3 Enze Li 2022-04-18 12:15:32 UTC
I'm trying to fix this issue.

FTR, patch posted here: 
[v1] https://sourceware.org/pipermail/gdb-patches/2022-March/186607.html
[v2] https://sourceware.org/pipermail/gdb-patches/2022-March/186741.html
[v3] https://sourceware.org/pipermail/gdb-patches/2022-April/187929.html

In addition, many thanks to Tom and Pedro for their patient and help.
Comment 4 Tom Tromey 2022-04-18 14:52:59 UTC
Fixed.