[lldb-dev] issue with lldb-mi -var-update with pointers

Ted Woodward via lldb-dev lldb-dev at lists.llvm.org
Tue May 30 13:50:37 PDT 2017


I have a simple testcase that modifies the value pointed to by an int *.
I've created a variable with -var-create, and then after the value has been
updated, check it with -var-update. -var-update returns no changes, but the
value has changed.

test.c:
#include <stdlib.h>

int main(void)
{
  int vec[] = {1, 2, 3, 4};
  int foo = 0;
  int *bar = &foo;
  int i = 0;

  for (i = 0; i < 4; i++)
    *bar += vec[i];

  return foo;
}

Commands:
-break-insert -t -f test.c:10
-break-insert -t -f test.c:13
-exec-run
-var-create --thread 1 --frame 0 - * bar
-var-list-children var0
-var-evaluate-expression var0.*bar
-exec-continue
-var-update 1 var0
-var-evaluate-expression var0.*bar


Output:
(gdb)
-var-create --thread 1 --frame 0 - * bar
^done,name="var0",numchild="1",value="0x00007fffffffed30",type="int
*",thread-id="1",has_more="0"
(gdb)
-var-list-children var0
^done,numchild="1",children=[child={name="var0.*bar",exp="*bar",numchild="0"
,type="int",thread-id="1",has_more="0"}],has_more="0"
(gdb)
-var-evaluate-expression var0.*bar
^done,value="0"

***Value is 0

(gdb)
-exec-continue
^running
(gdb)
=thread-exited,id="1",group-id="i1"
(gdb)
*running,thread-id="all"
(gdb)
=thread-created,id="1",group-id="i1"
(gdb)
*stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={level="0",addr
="0x0000000000400530",func="main",args=[],file="test.c",fullname="/local/scr
atch/ted/tip/newfull/test.c",line="13"},thread-id="1",stopped-threads="all"
(gdb)
-var-update 1 var0
^done,changelist=[]

***No changes

(gdb)
-var-evaluate-expression var0.*bar
^done,value="10"

***Value is 10, even though we reported no changes.

The child shows an update:
(gdb)
-var-update 1 var0.*bar
^done,changelist=[{name="var0.*bar",value="10",in_scope="true",type_changed=
"false",has_more="0"}]


--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project




More information about the lldb-dev mailing list