[patch] stepping over an infinite source line

Abid, Hafiz Hafiz_Abid@mentor.com
Fri May 24 16:42:00 GMT 2013


Hi All,
This patch solves a problem of source stepping over a potentially infinite single-line loop. In such cases, there is a chance of user unable to gain control after stepping as ctrl-c is ignored by the stub. Following session gives an example. 

The patch was written by Pedro. I thought maintainers may find it useful for mainline too. I have also attached a file that contains the summary of analysis done on this problem. No regression on x86_64 (native,  gdbserver).

(gdb) target remote :10000
Remote debugging using :10000
(gdb) tbreak main
Temporary breakpoint 1 at 0x4004b8: file test.c, line 4.
(gdb) c
Continuing.

Temporary breakpoint 1, main () at test.c:4
4	   while (d == 0);
(gdb) list
1	int main (void)  {
2	   volatile static unsigned long d = 0;
3	
4	   while (d == 0);
5	
6	   return 0;
7	}
(gdb) n
^C^C0x00000000004004c0 in main () at test.c:4 // first ^C gets ignored here.
4	   while (d == 0);

Regards,
Abid

gdb:
2013-05-24  Pedro Alves  <pedro@codesourcery.com>

	Cannot regain control of debugger when source
	stepping over a potentially infinite single-line loop.

	* remote.c (remote_wait_as): If a ctrl-c was pending and the
	target stopped with an event not SIGINT, make sure the current
	command quits after handing the event.

gdb/gdbserver:
2013-05-24  Pedro Alves  <pedro@codesourcery.com>

	Cannot regain control of debugger when source
	stepping over a potentially infinite single-line loop.

	* linux-low.c (linux_wait_for_event): Handle expected SIGINTs.
	(cancel_sigint_callback): New.
	(linux_wait_1): Cancel or ignore pending SIGINTs.
	(linux_request_interrupt): Set flag that we've queued a SIGINT.
	* linux-low.h (struct lwp_info) <sigint_expected>: New field.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: analysis.txt
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20130524/c998a0fa/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: step_over.patch
Type: application/octet-stream
Size: 6352 bytes
Desc: step_over.patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20130524/c998a0fa/attachment.obj>


More information about the Gdb-patches mailing list