Hi, I sent this patch with the autoload-breakpoints patches because I found this issue when I test the autoload-breakpoints. But I think sent it together with a feature patch list is not a good idea. So I move it out for review. This is bug was found when I when I test autoload-breakpint code. And I found that it affect target-async too. It can be reproduce: (gdb) set target-async on (gdb) start Temporary breakpoint 1 at 0x4004c8: file 1.c, line 4. Starting program: /home/teawater/tmp/a.out Temporary breakpoint 1, main () at 1.c:4 4 sleep (20); (gdb) disassemble Dump of assembler code for function main: 0x00000000004004c4 <+0>: push %rbp 0x00000000004004c5 <+1>: mov %rsp,%rbp => 0x00000000004004c8 <+4>: mov $0x14,%edi 0x00000000004004cd <+9>: mov $0x0,%eax 0x00000000004004d2 <+14>: callq 0x4003d0 0x00000000004004d7 <+19>: mov $0x0,%eax 0x00000000004004dc <+24>: pop %rbp 0x00000000004004dd <+25>: retq End of assembler dump. (gdb) list 1 int 2 main() 3 { 4 sleep (20); 5 6 return 0; 7 } 8 (gdb) b 6 Breakpoint 2 at 0x4004d7: file 1.c, line 6. (gdb) c& Continuing. (gdb) d Delete all breakpoints? (y or n) y warning: Error removing breakpoint 2 (gdb) Program received signal SIGTRAP, Trace/breakpoint trap. 0x00000000004004d8 in main () at 1.c:6 6 return 0; c Continuing. Program received signal SIGSEGV, Segmentation fault. 0x00000000004004d8 in main () at 1.c:6 6 return 0; (gdb) info reg pc pc: 0x4004d8 (gdb) disassemble main Dump of assembler code for function main: 0x00000000004004c4 <+0>: push %rbp 0x00000000004004c5 <+1>: mov %rsp,%rbp 0x00000000004004c8 <+4>: mov $0x14,%edi 0x00000000004004cd <+9>: mov $0x0,%eax 0x00000000004004d2 <+14>: callq 0x4003d0 0x00000000004004d7 <+19>: int3 => 0x00000000004004d8 <+20>: add %al,(%rax) 0x00000000004004da <+22>: add %al,(%rax) 0x00000000004004dc <+24>: pop %rbp 0x00000000004004dd <+25>: retq End of assembler dump. This because is when GDB got fail when it remove the breakpoint, it give up the control of this breakpoint. There are 2 issues about it: 1. When the GDB stop, this breakpoint is not be removed. 2. If inferior is stoped by this breakpoint, adjust_pc_after_break didn't know this stop is beauce the breakpoint, so the pc address will not be adjust to the right value. I add a list called bp_location_remove_fail_chain, when GDB got fail with remove a breakpoint, add it to this list. When adjust_pc_after_break check if this address is the breakpint, check this list too. And when gdb remve all breakpoints, try remove breakpint in this list. Thanks, Hui 2012-04-11 Hui Zhu * breakpoint.c (ALL_BP_LOCATION_REMOV_FAIL): New macro. (ALL_BP_LOCATION_REMOV_FAIL_SAFE): New macro. (bp_location_remove_fail_chain_inserted_here_p): New function. (bp_location_remove_fail_chain_insert): New function. (bp_location_remove_fail_chain_remove): New function. (remove_breakpoints): Call remove_breakpoint with the bp_locations inside the ALL_BP_LOCATION_REMOV_FAIL_SAFE. (software_breakpoint_inserted_here_p): Call bp_location_remove_fail_chain_inserted_here_p. (update_global_location_list): Call bp_location_remove_fail_chain_insert. * breakpoint.h (bp_location_remove_fail_chain_remove): New extern. * target.c (target_kill): Call bp_location_remove_fail_chain_remove. (target_detach): Ditto. (target_disconnect): Ditto.