This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] stepping over an infinite source line


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.

Attachment: analysis.txt
Description: analysis.txt

Attachment: step_over.patch
Description: step_over.patch


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]