1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
com.commandF(&resultData, "-var-create %s @ %s", stringToCStr(watchId), stringToCStr(varName));
com.commandF(&resultData, "-data-evaluate-expression %s", stringToCStr(expr));
com.commandF(&resultData, "-var-update --all-values *");
com.commandF(&resultData, "-var-list-children --simple-values %s", stringToCStr(watchId));
com.commandF(&resultData, "-var-delete %s", stringToCStr(watchId));
com.commandF(&resultData, "-var-info-path-expression %s", stringToCStr(w.getWatchId()));
com.commandF(&resultData, "-data-evaluate-expression &(%s)", stringToCStr(expr));
The following is the complete set of GDB/MI operations defined to access this functionality:
Operation Description
-enable-pretty-printing enable Python-based pretty-printing (VERY Important to print std::string and other structures!!!).
-var-create create a variable object
-var-delete delete the variable object and/or its children
-var-set-format set the display format of this variable
-var-show-format show the display format of this variable
-var-info-num-children tells how many children this object has
-var-list-children return a list of the object’s children
-var-info-type show the type of this variable object
-var-info-expression print parent-relative expression that this variable object represents
-var-info-path-expression print full expression that this variable object represents
-var-show-attributes is this variable editable? does it exist here?
-var-evaluate-expression get the value of this variable
-var-assign set the value of this variable
-var-update update the variable and its children
-var-set-frozen set frozeness attribute
-var-set-update-range set range of children to display on update
"-data-evaluate-expression %s"
"-data-add-expression %s"
"-data-delete-expression id1 id2 ..."
"-data-list-expressions"
#
# var examples.
# using 'hellostruct' as the example with a 'Person' struct that contains a 'Location' struct.
#
# 'me'
#
"-var-create x2112 "*" me"
^done,name="x2112",numchild="1",value="{...}",type="Person",thread-id="1",has_more="0"
"-var-info-type x2112"
"-var-info-type x2112.public.location"
^done,type="Person"
^done,type="Location"
"-var-info-num-children x2112"
^done,numchild="1"
"-var-list-children --no-values x2112"
^done,numchild="1",
children=[
child={name="x2112.public",exp="public",numchild="4",thread-id="1"}
],
has_more="0"
"-var-list-children --no-values x2112.public"
^done,numchild="4",
children=[
child={name="x2112.public.name", exp="name", numchild="2", type="std::string", thread-id="1"},
child={name="x2112.public.age", exp="age", numchild="0", type="int", thread-id="1"},
child={name="x2112.public.salary", exp="salary", numchild="0", type="float", thread-id="1"},
child={name="x2112.public.location", exp="location", numchild="1", type="Location", thread-id="1"}
],
has_more="0"
"-var-list-children --all-values x2112"
^done,numchild="1",
children=[
child={name="x2112.public", exp="public", numchild="4", value="", thread-id="1"}
],
has_more="0"
"-var-list-children --all-values x2112.public"
^done,numchild="4",
children=[
child={name="x2112.public.name", exp="name", numchild="2", value="{...}", type="std::string", thread-id="1"},
child={name="x2112.public.age", exp="age", numchild="0", value="60", type="int", thread-id="1"},
child={name="x2112.public.salary", exp="salary", numchild="0", value="0.25", type="float", thread-id="1"},
child={name="x2112.public.location", exp="location", numchild="1", value="{...}", type="Location", thread-id="1"}
],
has_more="0"
"-var-list-children --simple-values x2112.public"
^done,numchild="4",
children=[
child={name="x2112.public.name", exp="name", numchild="2", type="std::string", thread-id="1"},
child={name="x2112.public.age", exp="age", numchild="0", value="60", type="int", thread-id="1"},
child={name="x2112.public.salary", exp="salary", numchild="0", value="0.25", type="float", thread-id="1"},
child={name="x2112.public.location", exp="location", numchild="1", type="Location", thread-id="1"}
],
has_more="0"
"-var-evaluate-expression x2112"
^done,value="{...}"
"-var-evaluate-expression x2112.name"
"-var-evaluate-expression x2112.age"
"-var-evaluate-expression x2112.salary"
"-var-evaluate-expression x2112.location"
^done,value="{...}"
^done,value="60"
^done,value="0.25"
^done,value="{...}"
"-var-info-expression x2112"
"-var-info-expression x2112.public"
"-var-info-expression x2112.public.age"
^done,lang="C++",exp="me"
^done,lang="C++",exp="public"
^done,lang="C++",exp="age"
"-var-info-path-expression x2112"
"-var-info-path-expression x2112.public"
"-var-info-path-expression x2112.public.age"
^done,path_expr="me"
^done,path_expr=""
^done,path_expr="((me).age)"
"-var-delete x2112"
^done,ndeleted="1"
#
# 'me.name'
#
"-var-create x2112 "*" me.name"
^done,name="x2112",numchild="2",value="{...}",type="std::string",thread-id="1",has_more="0"
"-var-info-type x2112"
^done,type="std::string"
"-var-info-num-children x2112"
^done,numchild="2"
"-var-evaluate-expression x2112"
^done,value="{...}"
"-var-list-children --no-values x2112"
^done,numchild="2",
children=[
child={name="x2112.public", exp="public", numchild="1", thread-id="1"},
child={name="x2112.private", exp="private", numchild="3", thread-id="1"}
],
has_more="0"
"-var-list-children --no-values x2112.public"
^done,numchild="1",
children=[
child={name="x2112.public.npos",exp="npos",numchild="0",type="const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::size_type",thread-id="1"}
],
has_more="0"
"-var-list-children --no-values x2112.private"
^done,numchild="3",
children=[
child={name="x2112.private._M_dataplus",exp="_M_dataplus",numchild="2",type="std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider",thread-id="1"},
child={name="x2112.private._M_string_length",exp="_M_string_length",numchild="0",type="std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::size_type",thread-id="1"},
child={name="x2112.private.2_anonymous",exp="<anonymous union>",numchild="1",type="union {...}",thread-id="1"}
],
has_more="0"
"-var-list-children --no-values x2112.public.npos"
^done,numchild="0",has_more="0"
"-var-show-attributes seer4.public.name"
"-var-show-attributes seer4.public.age"
^done,attr="noneditable"
^done,attr="editable"
|