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]

Re: -var-update and address changes


On Thursday 04 May 2006 18:50, Daniel Jacobowitz wrote:
> On Wed, May 03, 2006 at 10:02:21AM +0400, Vladimir Prus wrote:
> > On Tuesday 02 May 2006 21:22, Jim Ingham wrote:
> > > Shouldn't the call to var->root->lang->value_of_root down at the
> > > bottom of value_of_root take care of fetching the new value?
> >
> > Well, it fetches the new value, I believe.
>
> For the wrong frame.
>
> I've only lightly tested this; could you give it a try?  If it works, I
> think we should really get the "@" syntax added to the manual and
> testsuite.

This appears to work for a simple case of variable 'i' defined both in 'main' 
and in 'foo' called from main.

For the case where I'm stepping into 'bar' that has no 'i', -var-update 
correctly says that 'i' has gone out of scope. However, after -exec-finish, 
-var-update does not say that 'i' is not back in scope -- which would be nice 
if "@-varobjs" are to be used for watches.

Here's example I've used for testing:

include <stdio.h>

int foo()
{
    int i = 15;
    printf("foo\n");
}

int bar()
{
}

int main()
{
    int i = 5;
    printf("hi 1\n");
    foo();
    bar();
}

and example session:

b 19
&"b 19\n"
~"Breakpoint 1 at 0x804849e: file s.cpp, line 19.\n"
^done
(gdb)
r
&"r\n"
~"Starting program: /space/p2/ghost/build/mi-tests/a.out \n"
hi 1
foo
~"\n"
~"Breakpoint 1, main () at s.cpp:19\n"
~"19\t    bar();\n"
^done
(gdb)
-var-create I @ i
^done,name="I",numchild="0",type="int"
(gdb)
-exec-step
^running
(gdb)
*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x08048473",func="bar",args=[],file="s.cpp",fullname="/space/p2/ghost/build/mi-tests/s.cpp",line="12"}
(gdb)
-var-update *
^done,changelist=[{name="I",in_scope="false"}]
(gdb)
-exec-finish
^running
(gdb)
*stopped,reason="function-finished",thread-id="0",frame={addr="0x080484a3",func="main",args=[],file="s.cpp",fullname="/space/p2/ghost/build/mi-tests/s.cpp",line="20"},gdb-result-var="$1",return-value="4"
(gdb)
-var-update *
^done,changelist=[]
(gdb)
p i
&"p i\n"
~"$2 = 5"
~"\n"
^done
(gdb)

- Volodya


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