This is the mail archive of the gdb@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]

Unable to interrupt a stepping GDB


Hi,

I have simple C code line like this (it might work with other long running
"steps", too):

for (; a; --a);

with "a" being set to a high value.

When I execute 'next' GDB will step until it reaches the next line (which
takes time, of course). GDB will fire alot of 's' packets to the remote stub
until "a" is down to zero. There are times when I want to interrupt the
target by hitting 'CTRL-C'.

This works about 66% of the time. Result:

Program received signal SIGINT, Interrupt.
0x00200068 in delay (a=10) at ../src/loop.c:16
16        for (;a ;--a);

Unfortunately there are quite some situations when hitting 'CTRL-C' does NOT
work. GDB just does not stop. This is quite an issue when used by the
Eclipse CDT/MI, but it also happens on the command line.

On the command line GDB it is possible to hit 'CTRL-C' severeal times or
just hold down the keys and GDB will stop after a while with a result like
this:

Program received signal SIGINT, Interrupt.
0x00200068 in delay (a=10) at ../src/loop.c:16
16        for (;a ;--a);
(gdb) Quit (expect signal SIGINT when the program is resumed)

***
I think it might be a bug. In remote.c: remote_wait (...) it says:

      ofunc = signal (SIGINT, remote_interrupt);
      getpkt (&rs->buf, &rs->buf_size, 1);
      signal (SIGINT, ofunc);

So I guess GDB does only listen for SIGINT correctly while waiting for the
stub to stop. But what happens if the user hits 'CTRL-C' after getpkt and
before sending the next 's' step packet to the stub ? A long running step
operation might send thousands of 's' step packets, so the chances are quite
high the user might hit CTRL-C at the "wrong time": after getpkt.

Should I raise a bug ? Does anyone know how to fix this?

Thanks

Sascha


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