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]

RE: [Patch] [MI] Out-of-scope varObjects no longer trigger a var-update change


 

> -----Original Message-----
> From: Nick Roberts [mailto:nickrob@snap.net.nz] 
> Sent: Friday, May 01, 2009 8:00 AM
> To: Marc Khouzam
> Cc: gdb-patches@sourceware.org
> Subject: [Patch] [MI] Out-of-scope varObjects no longer 
> trigger a var-update change
> 
>  > I believe a small bug slipped in the refactoring of varobj_update
>  > interface from:
>  > http://sourceware.org/ml/gdb-patches/2008-05/msg00106.html
>  > 
>  > From what I see, varobj that are not in scope don't get flagged
>  > as changed, because nothing was being pushed on the result vector.
>  > The attached patch fixes this.
> 
> I'm not sure that I see this.  If the variable goes out of 
> scope then, as the
> comment says, then value_of_root returns NULL.  But 
> (*varp)->value is not NULL,
> so install_new_value returns 1 and r.changed is set to 1 and 
> r gets pushed onto
> the result vector.

You had me questioning myself...
But in the case I'm looking at
install_new_value must be returning 0.
(Maybe that is the bug?  I didn't look at that.)
You can see below the particularities of my testcase.
 
>  > The MI part of the testsuite passed ok.
>  > I have an test to trigger the bug, if you care to see it.
> 
> Yes, please post that.  The current testsuite covers varobjs 
> that go out of
> scope.  If it is a regression then there needs to be a test 
> that covers this
> mode of failure in any case.

Below is the session.  The testcase is part of my Eclipse
regression testsuite and basically looks for the content
of a variable name the same thing as a previous variable,
which is part of a method named the same thing as where the
previous variable was.  You'll understand better from the code
below :-)

Note that the below passes after I applied my proposed patch.


~"GNU gdb (GDB) 6.8.50.20090420-cvs\n"
~"Copyright (C) 2009 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>\n"
~"This is free software: you are free to change and redistribute it.\n"
~"There is NO WARRANTY, to the extent permitted by law.  Type \"show
copying\"\n"
~"and \"show warranty\" for details.\n"
~"This GDB was configured as \"i686-pc-linux-gnu\".\n"~"For bug
reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>...\n"
(gdb) 
l 1 
&"l 1\n"
~"1\tstruct Z {\n"
~"2\tpublic:\n"
~"3\t    int x;\n"
~"4\t    int y;\n"
~"5\t};\n"
~"6\t\n"
~"7\tvoid sameName(int newVal) {\n"
~"8\t    Z z;\n"
~"9\t    z.x = newVal;\n"
~"10\t    return;\n"
^done
(gdb) 
l
&"l\n"
~"11\t}\n"
~"12\t\n"
~"13\tvoid sameName(int newVal, int ignore) {\n"
~"14\t    Z z;\n"
~"15\t    z.x = newVal;\n"
~"16\t    return;\n"
~"17\t}\n"
~"18\t\n"
~"19\t\n"
~"20\tint main() {\n"
^done
(gdb) 
l
&"l\n"
~"21\t    sameName(1);\n"
~"22\t    sameName(2, 0);\n"
~"23\t\n"
~"24\t    return 0;\n"
~"25\t}\n"
^done
(gdb)
b 10
&"b 10\n"
~"Breakpoint 1 at 0x8048410: file expression.cc, line 10.\n"
^done
(gdb) 
b 16
&"b 16\n"~"Breakpoint 2 at 0x804841e: file expression.cc, line 16.\n"
^done
(gdb) 
r
&"r\n"
~"Starting program: /local/home/lmckhou/testing/a.out \n"
=thread-group-created,id="31707"
=thread-created,id="1",group-id="31707"
^running
*running,thread-id="all"
(gdb) 
=library-loaded,id="/lib/ld-linux.so.2",target-name="/lib/ld-linux.so.2"
,host-name="/lib/ld-linux.so.2",symbols-loaded="0"
=library-loaded,id="/usr/lib/libstdc++.so.6",target-name="/usr/lib/libst
dc++.so.6",host-name="/usr/lib/libstdc++.so.6",symbols-loaded="0"
=library-loaded,id="/lib/libm.so.6",target-name="/lib/libm.so.6",host-na
me="/lib/libm.so.6",symbols-loaded="0"
=library-loaded,id="/lib/libgcc_s.so.1",target-name="/lib/libgcc_s.so.1"
,host-name="/lib/libgcc_s.so.1",symbols-loaded="0"
=library-loaded,id="/lib/libc.so.6",target-name="/lib/libc.so.6",host-na
me="/lib/libc.so.6",symbols-loaded="0"
~"\n"
~"Breakpoint 1, sameName (newVal=1) at expression.cc:11\n"
~"11\t}\n"
*stopped,frame={addr="0x08048410",func="sameName",args=[{name="newVal",v
alue="1"}],file="expression.cc",fullname="/local/home/lmckhou/testing/ex
pression.cc",line="11
"},thread-id="1",stopped-threads="all"(gdb) 
-var-create - * z
^done,name="var1",numchild="1",value="{...}",type="Z",thread-id="1"
(gdb) 
-var-list-children var1
^done,numchild="1",children=[child={name="var1.public",exp="public",numc
hild="2",thread-id="1"}]
(gdb) 
-var-list-children var1.public
^done,numchild="2",children=[child={name="var1.public.x",exp="x",numchil
d="0",type="int",thread-id="1"},child={name="var1.public.y",exp="y",numc
hild="0",type="int",t
hread-id="1"}]
(gdb) 
-var-info-path-expression var1.public.x
^done,path_expr="((z).x)"
(gdb) 
-var-info-path-expression var1.public.y
^done,path_expr="((z).y)"
(gdb) 
-var-evaluate-expression var1.public.x
^done,value="1"
(gdb) 
c
&"c\n"
~"Continuing.\n"
^running
*running,thread-id="1"
(gdb) 
~"\n"
~"Breakpoint 2, sameName (newVal=2, ignore=0) at expression.cc:17\n"
~"17\t}\n"
*stopped,frame={addr="0x0804841e",func="sameName",args=[{name="newVal",v
alue="2"},{name="ignore",value="0"}],file="expression.cc",fullname="/loc
al/home/lmckhou/testi
ng/expression.cc",line="17"},thread-id="1",stopped-threads="all"
(gdb) 
 -var-update 1 var1
^done,changelist=[]
(gdb)

========================================
== var1 should have gone out of scope ==
========================================


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