[RFC/RFA] continue stepping if landed in new range of same line

Daniel Jacobowitz drow@false.org
Fri Dec 21 14:01:00 GMT 2007


On Fri, Dec 21, 2007 at 10:07:30AM +0400, Joel Brobecker wrote:
> I am wondering what emacs would do with the following example:
> 
>     void increment (int *a, int *b) { *a = *a + 1; *b = *b + 1; }
> 
> I wanted to try, but I must be missing something in my setup as
> emacs doesn't indent either cases.

You should just need to be in c-mode.  Might need
(c-toggle-auto-state 1) too (C-c C-a).

void increment (int *a, int *b)
{
  *a = *a + 1;
  *b = *b + 1;
}

(I was wrong about it being perfect; still, pretty good)
 
> I think that the debugger would need the help of the compiler in order
> to be able to do that. With the example above, I get the following code
> on x86:

Ideally we'd combine this with the is_stmt flag and column number
support, and put a caret where we wanted.

> Indeed, when I deactived the code that checks for the last line
> in our function, here is the new behavior:
> 
>     (gdb) b *increment
>     Breakpoint 1 at 0x80483c0: file f.c, line 1.
>     (gdb) run
>     Starting program: /home/no-backup/brobecke/next/C/g 
>     
>     Breakpoint 1, increment (a=0xbfd16d60, b=0xbfd16d5c) at f.c:1
>     1       void increment (int *a, int *b) { *a = *a + 1; *b = *b + 1; }
>     (gdb) n
>     main () at g.c:12
>     12        printf ("a = %d, b = %d\n", a, b);
> 
> Before I disabled this code, GDB would stop at line f.c:1 one more
> time before landing back in the caller.
> 
> Perhaps if this is a requirement, we might want to add a testcase
> for it in our testsuite.  Optimization is not necessary in order
> to reproduce this...  Just for kicks, I ran the testsuite with
> the disabled code, to see if anything would fail because of it,
> and not unexpectedly, nothing did...

To be honest, I find this behavior a bit surprising.

-- 
Daniel Jacobowitz
CodeSourcery



More information about the Gdb-patches mailing list