This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: GDB/MI - var-update/create BUG
On Tue, 26 Oct 2010 18:01:30 -0400, Eran Ifrah wrote:
> If I have a local variable with the same name in different scopes,
> when switching between the scopes the content of the variable object
> does not reflect the new variable.
This is correct from the GDB's point of view, normally you want to track that
_variable_, not that _name_. Anywhere you are.
You should use '@' instead of '*' for frame if you want to track it by name,
see "floating" in: info '(gdb)GDB/MI Variable Objects'
Thanks,
Jan
g++ -o 2 2.C -Wall -g
gdb -nx -i=mi <2.cmd ./2
==> 2.C <==
#include <string>
void foo() {
std::string mystr = " second value ";
mystr += " appended content";
}
int main(int argc, char **argv) {
std::string mystr = " first value ";
foo();
mystr += " appended content";
return 0;
}
==> 2.cmd <==
-break-insert -t 8
-exec-run
-var-create - * mystr._M_dataplus._M_p
-break-insert -t 4
-exec-continue
-var-update *
-var-evaluate-expression "var1"
->
^done,value="0x601028 \" first value \""
==> 2-floating.cmd <==
-break-insert -t 8
-exec-run
-var-create - @ mystr._M_dataplus._M_p
-break-insert -t 4
-exec-continue
-var-update *
-var-evaluate-expression "var1"
->
^done,value="0x601058 \" second value \""