mi-cmd-var.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. /* MI Command Set - varobj commands.
  2. Copyright (C) 2000-2022 Free Software Foundation, Inc.
  3. Contributed by Cygnus Solutions (a Red Hat company).
  4. This file is part of GDB.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #include "defs.h"
  16. #include "mi-cmds.h"
  17. #include "mi-main.h"
  18. #include "ui-out.h"
  19. #include "mi-out.h"
  20. #include "varobj.h"
  21. #include "language.h"
  22. #include "value.h"
  23. #include <ctype.h>
  24. #include "mi-getopt.h"
  25. #include "gdbthread.h"
  26. #include "mi-parse.h"
  27. #include "gdbsupport/gdb_optional.h"
  28. #include "inferior.h"
  29. static void varobj_update_one (struct varobj *var,
  30. enum print_values print_values,
  31. bool is_explicit);
  32. static int mi_print_value_p (struct varobj *var,
  33. enum print_values print_values);
  34. /* Print variable object VAR. The PRINT_VALUES parameter controls
  35. if the value should be printed. The PRINT_EXPRESSION parameter
  36. controls if the expression should be printed. */
  37. static void
  38. print_varobj (struct varobj *var, enum print_values print_values,
  39. int print_expression)
  40. {
  41. struct ui_out *uiout = current_uiout;
  42. int thread_id;
  43. uiout->field_string ("name", varobj_get_objname (var));
  44. if (print_expression)
  45. {
  46. std::string exp = varobj_get_expression (var);
  47. uiout->field_string ("exp", exp);
  48. }
  49. uiout->field_signed ("numchild", varobj_get_num_children (var));
  50. if (mi_print_value_p (var, print_values))
  51. {
  52. std::string val = varobj_get_value (var);
  53. uiout->field_string ("value", val);
  54. }
  55. std::string type = varobj_get_type (var);
  56. if (!type.empty ())
  57. uiout->field_string ("type", type);
  58. thread_id = varobj_get_thread_id (var);
  59. if (thread_id > 0)
  60. uiout->field_signed ("thread-id", thread_id);
  61. if (varobj_get_frozen (var))
  62. uiout->field_signed ("frozen", 1);
  63. gdb::unique_xmalloc_ptr<char> display_hint = varobj_get_display_hint (var);
  64. if (display_hint)
  65. uiout->field_string ("displayhint", display_hint.get ());
  66. if (varobj_is_dynamic_p (var))
  67. uiout->field_signed ("dynamic", 1);
  68. }
  69. /* VAROBJ operations */
  70. void
  71. mi_cmd_var_create (const char *command, char **argv, int argc)
  72. {
  73. struct ui_out *uiout = current_uiout;
  74. CORE_ADDR frameaddr = 0;
  75. struct varobj *var;
  76. char *frame;
  77. char *expr;
  78. enum varobj_type var_type;
  79. if (argc != 3)
  80. error (_("-var-create: Usage: NAME FRAME EXPRESSION."));
  81. frame = argv[1];
  82. expr = argv[2];
  83. const char *name = argv[0];
  84. std::string gen_name;
  85. if (strcmp (name, "-") == 0)
  86. {
  87. gen_name = varobj_gen_name ();
  88. name = gen_name.c_str ();
  89. }
  90. else if (!isalpha (name[0]))
  91. error (_("-var-create: name of object must begin with a letter"));
  92. if (strcmp (frame, "*") == 0)
  93. var_type = USE_CURRENT_FRAME;
  94. else if (strcmp (frame, "@") == 0)
  95. var_type = USE_SELECTED_FRAME;
  96. else
  97. {
  98. var_type = USE_SPECIFIED_FRAME;
  99. frameaddr = string_to_core_addr (frame);
  100. }
  101. if (varobjdebug)
  102. gdb_printf (gdb_stdlog,
  103. "Name=\"%s\", Frame=\"%s\" (%s), Expression=\"%s\"\n",
  104. name, frame, hex_string (frameaddr), expr);
  105. var = varobj_create (name, expr, frameaddr, var_type);
  106. if (var == NULL)
  107. error (_("-var-create: unable to create variable object"));
  108. print_varobj (var, PRINT_ALL_VALUES, 0 /* don't print expression */);
  109. uiout->field_signed ("has_more", varobj_has_more (var, 0));
  110. }
  111. void
  112. mi_cmd_var_delete (const char *command, char **argv, int argc)
  113. {
  114. char *name;
  115. struct varobj *var;
  116. int numdel;
  117. int children_only_p = 0;
  118. struct ui_out *uiout = current_uiout;
  119. if (argc < 1 || argc > 2)
  120. error (_("-var-delete: Usage: [-c] EXPRESSION."));
  121. name = argv[0];
  122. /* If we have one single argument it cannot be '-c' or any string
  123. starting with '-'. */
  124. if (argc == 1)
  125. {
  126. if (strcmp (name, "-c") == 0)
  127. error (_("-var-delete: Missing required "
  128. "argument after '-c': variable object name"));
  129. if (*name == '-')
  130. error (_("-var-delete: Illegal variable object name"));
  131. }
  132. /* If we have 2 arguments they must be '-c' followed by a string
  133. which would be the variable name. */
  134. if (argc == 2)
  135. {
  136. if (strcmp (name, "-c") != 0)
  137. error (_("-var-delete: Invalid option."));
  138. children_only_p = 1;
  139. name = argv[1];
  140. }
  141. /* If we didn't error out, now NAME contains the name of the
  142. variable. */
  143. var = varobj_get_handle (name);
  144. numdel = varobj_delete (var, children_only_p);
  145. uiout->field_signed ("ndeleted", numdel);
  146. }
  147. /* Parse a string argument into a format value. */
  148. static enum varobj_display_formats
  149. mi_parse_format (const char *arg)
  150. {
  151. if (arg != NULL)
  152. {
  153. int len;
  154. len = strlen (arg);
  155. if (strncmp (arg, "natural", len) == 0)
  156. return FORMAT_NATURAL;
  157. else if (strncmp (arg, "binary", len) == 0)
  158. return FORMAT_BINARY;
  159. else if (strncmp (arg, "decimal", len) == 0)
  160. return FORMAT_DECIMAL;
  161. else if (strncmp (arg, "hexadecimal", len) == 0)
  162. return FORMAT_HEXADECIMAL;
  163. else if (strncmp (arg, "octal", len) == 0)
  164. return FORMAT_OCTAL;
  165. else if (strncmp (arg, "zero-hexadecimal", len) == 0)
  166. return FORMAT_ZHEXADECIMAL;
  167. }
  168. error (_("Must specify the format as: \"natural\", "
  169. "\"binary\", \"decimal\", \"hexadecimal\", \"octal\" or \"zero-hexadecimal\""));
  170. }
  171. void
  172. mi_cmd_var_set_format (const char *command, char **argv, int argc)
  173. {
  174. enum varobj_display_formats format;
  175. struct varobj *var;
  176. struct ui_out *uiout = current_uiout;
  177. if (argc != 2)
  178. error (_("-var-set-format: Usage: NAME FORMAT."));
  179. /* Get varobj handle, if a valid var obj name was specified. */
  180. var = varobj_get_handle (argv[0]);
  181. format = mi_parse_format (argv[1]);
  182. /* Set the format of VAR to the given format. */
  183. varobj_set_display_format (var, format);
  184. /* Report the new current format. */
  185. uiout->field_string ("format", varobj_format_string[(int) format]);
  186. /* Report the value in the new format. */
  187. std::string val = varobj_get_value (var);
  188. uiout->field_string ("value", val);
  189. }
  190. void
  191. mi_cmd_var_set_visualizer (const char *command, char **argv, int argc)
  192. {
  193. struct varobj *var;
  194. if (argc != 2)
  195. error (_("Usage: NAME VISUALIZER_FUNCTION."));
  196. var = varobj_get_handle (argv[0]);
  197. if (var == NULL)
  198. error (_("Variable object not found"));
  199. varobj_set_visualizer (var, argv[1]);
  200. }
  201. void
  202. mi_cmd_var_set_frozen (const char *command, char **argv, int argc)
  203. {
  204. struct varobj *var;
  205. bool frozen;
  206. if (argc != 2)
  207. error (_("-var-set-format: Usage: NAME FROZEN_FLAG."));
  208. var = varobj_get_handle (argv[0]);
  209. if (strcmp (argv[1], "0") == 0)
  210. frozen = false;
  211. else if (strcmp (argv[1], "1") == 0)
  212. frozen = true;
  213. else
  214. error (_("Invalid flag value"));
  215. varobj_set_frozen (var, frozen);
  216. /* We don't automatically return the new value, or what varobjs got
  217. new values during unfreezing. If this information is required,
  218. client should call -var-update explicitly. */
  219. }
  220. void
  221. mi_cmd_var_show_format (const char *command, char **argv, int argc)
  222. {
  223. struct ui_out *uiout = current_uiout;
  224. enum varobj_display_formats format;
  225. struct varobj *var;
  226. if (argc != 1)
  227. error (_("-var-show-format: Usage: NAME."));
  228. /* Get varobj handle, if a valid var obj name was specified. */
  229. var = varobj_get_handle (argv[0]);
  230. format = varobj_get_display_format (var);
  231. /* Report the current format. */
  232. uiout->field_string ("format", varobj_format_string[(int) format]);
  233. }
  234. void
  235. mi_cmd_var_info_num_children (const char *command, char **argv, int argc)
  236. {
  237. struct ui_out *uiout = current_uiout;
  238. struct varobj *var;
  239. if (argc != 1)
  240. error (_("-var-info-num-children: Usage: NAME."));
  241. /* Get varobj handle, if a valid var obj name was specified. */
  242. var = varobj_get_handle (argv[0]);
  243. uiout->field_signed ("numchild", varobj_get_num_children (var));
  244. }
  245. /* Return 1 if given the argument PRINT_VALUES we should display
  246. the varobj VAR. */
  247. static int
  248. mi_print_value_p (struct varobj *var, enum print_values print_values)
  249. {
  250. struct type *type;
  251. if (print_values == PRINT_NO_VALUES)
  252. return 0;
  253. if (print_values == PRINT_ALL_VALUES)
  254. return 1;
  255. if (varobj_is_dynamic_p (var))
  256. return 1;
  257. type = varobj_get_gdb_type (var);
  258. if (type == NULL)
  259. return 1;
  260. else
  261. {
  262. type = check_typedef (type);
  263. /* For PRINT_SIMPLE_VALUES, only print the value if it has a type
  264. and that type is not a compound type. */
  265. return (type->code () != TYPE_CODE_ARRAY
  266. && type->code () != TYPE_CODE_STRUCT
  267. && type->code () != TYPE_CODE_UNION);
  268. }
  269. }
  270. void
  271. mi_cmd_var_list_children (const char *command, char **argv, int argc)
  272. {
  273. struct ui_out *uiout = current_uiout;
  274. struct varobj *var;
  275. enum print_values print_values;
  276. int from, to;
  277. if (argc < 1 || argc > 4)
  278. error (_("-var-list-children: Usage: "
  279. "[PRINT_VALUES] NAME [FROM TO]"));
  280. /* Get varobj handle, if a valid var obj name was specified. */
  281. if (argc == 1 || argc == 3)
  282. var = varobj_get_handle (argv[0]);
  283. else
  284. var = varobj_get_handle (argv[1]);
  285. if (argc > 2)
  286. {
  287. from = atoi (argv[argc - 2]);
  288. to = atoi (argv[argc - 1]);
  289. }
  290. else
  291. {
  292. from = -1;
  293. to = -1;
  294. }
  295. const std::vector<varobj *> &children
  296. = varobj_list_children (var, &from, &to);
  297. uiout->field_signed ("numchild", to - from);
  298. if (argc == 2 || argc == 4)
  299. print_values = mi_parse_print_values (argv[0]);
  300. else
  301. print_values = PRINT_NO_VALUES;
  302. gdb::unique_xmalloc_ptr<char> display_hint = varobj_get_display_hint (var);
  303. if (display_hint)
  304. uiout->field_string ("displayhint", display_hint.get ());
  305. if (from < to)
  306. {
  307. /* For historical reasons this might emit a list or a tuple, so
  308. we construct one or the other. */
  309. gdb::optional<ui_out_emit_tuple> tuple_emitter;
  310. gdb::optional<ui_out_emit_list> list_emitter;
  311. if (mi_version (uiout) == 1)
  312. tuple_emitter.emplace (uiout, "children");
  313. else
  314. list_emitter.emplace (uiout, "children");
  315. for (int ix = from; ix < to && ix < children.size (); ix++)
  316. {
  317. ui_out_emit_tuple child_emitter (uiout, "child");
  318. print_varobj (children[ix], print_values, 1 /* print expression */);
  319. }
  320. }
  321. uiout->field_signed ("has_more", varobj_has_more (var, to));
  322. }
  323. void
  324. mi_cmd_var_info_type (const char *command, char **argv, int argc)
  325. {
  326. struct ui_out *uiout = current_uiout;
  327. struct varobj *var;
  328. if (argc != 1)
  329. error (_("-var-info-type: Usage: NAME."));
  330. /* Get varobj handle, if a valid var obj name was specified. */
  331. var = varobj_get_handle (argv[0]);
  332. std::string type_name = varobj_get_type (var);
  333. uiout->field_string ("type", type_name);
  334. }
  335. void
  336. mi_cmd_var_info_path_expression (const char *command, char **argv, int argc)
  337. {
  338. struct ui_out *uiout = current_uiout;
  339. struct varobj *var;
  340. if (argc != 1)
  341. error (_("Usage: NAME."));
  342. /* Get varobj handle, if a valid var obj name was specified. */
  343. var = varobj_get_handle (argv[0]);
  344. const char *path_expr = varobj_get_path_expr (var);
  345. uiout->field_string ("path_expr", path_expr);
  346. }
  347. void
  348. mi_cmd_var_info_expression (const char *command, char **argv, int argc)
  349. {
  350. struct ui_out *uiout = current_uiout;
  351. const struct language_defn *lang;
  352. struct varobj *var;
  353. if (argc != 1)
  354. error (_("-var-info-expression: Usage: NAME."));
  355. /* Get varobj handle, if a valid var obj name was specified. */
  356. var = varobj_get_handle (argv[0]);
  357. lang = varobj_get_language (var);
  358. uiout->field_string ("lang", lang->natural_name ());
  359. std::string exp = varobj_get_expression (var);
  360. uiout->field_string ("exp", exp);
  361. }
  362. void
  363. mi_cmd_var_show_attributes (const char *command, char **argv, int argc)
  364. {
  365. struct ui_out *uiout = current_uiout;
  366. int attr;
  367. const char *attstr;
  368. struct varobj *var;
  369. if (argc != 1)
  370. error (_("-var-show-attributes: Usage: NAME."));
  371. /* Get varobj handle, if a valid var obj name was specified */
  372. var = varobj_get_handle (argv[0]);
  373. attr = varobj_get_attributes (var);
  374. /* FIXME: define masks for attributes */
  375. if (attr & 0x00000001)
  376. attstr = "editable";
  377. else
  378. attstr = "noneditable";
  379. uiout->field_string ("attr", attstr);
  380. }
  381. void
  382. mi_cmd_var_evaluate_expression (const char *command, char **argv, int argc)
  383. {
  384. struct ui_out *uiout = current_uiout;
  385. struct varobj *var;
  386. enum varobj_display_formats format;
  387. int formatFound;
  388. int oind;
  389. char *oarg;
  390. enum opt
  391. {
  392. OP_FORMAT
  393. };
  394. static const struct mi_opt opts[] =
  395. {
  396. {"f", OP_FORMAT, 1},
  397. { 0, 0, 0 }
  398. };
  399. /* Parse arguments. */
  400. format = FORMAT_NATURAL;
  401. formatFound = 0;
  402. oind = 0;
  403. while (1)
  404. {
  405. int opt = mi_getopt ("-var-evaluate-expression", argc, argv,
  406. opts, &oind, &oarg);
  407. if (opt < 0)
  408. break;
  409. switch ((enum opt) opt)
  410. {
  411. case OP_FORMAT:
  412. if (formatFound)
  413. error (_("Cannot specify format more than once"));
  414. format = mi_parse_format (oarg);
  415. formatFound = 1;
  416. break;
  417. }
  418. }
  419. if (oind >= argc)
  420. error (_("Usage: [-f FORMAT] NAME"));
  421. if (oind < argc - 1)
  422. error (_("Garbage at end of command"));
  423. /* Get varobj handle, if a valid var obj name was specified. */
  424. var = varobj_get_handle (argv[oind]);
  425. if (formatFound)
  426. {
  427. std::string val = varobj_get_formatted_value (var, format);
  428. uiout->field_string ("value", val);
  429. }
  430. else
  431. {
  432. std::string val = varobj_get_value (var);
  433. uiout->field_string ("value", val);
  434. }
  435. }
  436. void
  437. mi_cmd_var_assign (const char *command, char **argv, int argc)
  438. {
  439. struct ui_out *uiout = current_uiout;
  440. struct varobj *var;
  441. if (argc != 2)
  442. error (_("-var-assign: Usage: NAME EXPRESSION."));
  443. /* Get varobj handle, if a valid var obj name was specified. */
  444. var = varobj_get_handle (argv[0]);
  445. if (!varobj_editable_p (var))
  446. error (_("-var-assign: Variable object is not editable"));
  447. const char *expression = argv[1];
  448. /* MI command '-var-assign' may write memory, so suppress memory
  449. changed notification if it does. */
  450. scoped_restore save_suppress
  451. = make_scoped_restore (&mi_suppress_notification.memory, 1);
  452. if (!varobj_set_value (var, expression))
  453. error (_("-var-assign: Could not assign "
  454. "expression to variable object"));
  455. std::string val = varobj_get_value (var);
  456. uiout->field_string ("value", val);
  457. }
  458. /* Helper for mi_cmd_var_update - update each VAR. */
  459. static void
  460. mi_cmd_var_update_iter (struct varobj *var, bool only_floating,
  461. enum print_values print_values)
  462. {
  463. bool thread_stopped;
  464. int thread_id = varobj_get_thread_id (var);
  465. if (thread_id == -1)
  466. {
  467. thread_stopped = (inferior_ptid == null_ptid
  468. || inferior_thread ()->state == THREAD_STOPPED);
  469. }
  470. else
  471. {
  472. thread_info *tp = find_thread_global_id (thread_id);
  473. thread_stopped = (tp == NULL
  474. || tp->state == THREAD_STOPPED);
  475. }
  476. if (thread_stopped
  477. && (!only_floating || varobj_floating_p (var)))
  478. varobj_update_one (var, print_values, false /* implicit */);
  479. }
  480. void
  481. mi_cmd_var_update (const char *command, char **argv, int argc)
  482. {
  483. struct ui_out *uiout = current_uiout;
  484. char *name;
  485. enum print_values print_values;
  486. if (argc != 1 && argc != 2)
  487. error (_("-var-update: Usage: [PRINT_VALUES] NAME."));
  488. if (argc == 1)
  489. name = argv[0];
  490. else
  491. name = argv[1];
  492. if (argc == 2)
  493. print_values = mi_parse_print_values (argv[0]);
  494. else
  495. print_values = PRINT_NO_VALUES;
  496. /* For historical reasons this might emit a list or a tuple, so we
  497. construct one or the other. */
  498. gdb::optional<ui_out_emit_tuple> tuple_emitter;
  499. gdb::optional<ui_out_emit_list> list_emitter;
  500. if (mi_version (uiout) <= 1)
  501. tuple_emitter.emplace (uiout, "changelist");
  502. else
  503. list_emitter.emplace (uiout, "changelist");
  504. /* Check if the parameter is a "*", which means that we want to
  505. update all variables. */
  506. if ((*name == '*' || *name == '@') && (*(name + 1) == '\0'))
  507. {
  508. /* varobj_update_one automatically updates all the children of
  509. VAROBJ. Therefore update each VAROBJ only once by iterating
  510. only the root VAROBJs. */
  511. all_root_varobjs ([=] (varobj *var)
  512. {
  513. mi_cmd_var_update_iter (var, *name == '0', print_values);
  514. });
  515. }
  516. else
  517. {
  518. /* Get varobj handle, if a valid var obj name was specified. */
  519. struct varobj *var = varobj_get_handle (name);
  520. varobj_update_one (var, print_values, true /* explicit */);
  521. }
  522. }
  523. /* Helper for mi_cmd_var_update(). */
  524. static void
  525. varobj_update_one (struct varobj *var, enum print_values print_values,
  526. bool is_explicit)
  527. {
  528. struct ui_out *uiout = current_uiout;
  529. std::vector<varobj_update_result> changes = varobj_update (&var, is_explicit);
  530. for (const varobj_update_result &r : changes)
  531. {
  532. int from, to;
  533. gdb::optional<ui_out_emit_tuple> tuple_emitter;
  534. if (mi_version (uiout) > 1)
  535. tuple_emitter.emplace (uiout, nullptr);
  536. uiout->field_string ("name", varobj_get_objname (r.varobj));
  537. switch (r.status)
  538. {
  539. case VAROBJ_IN_SCOPE:
  540. if (mi_print_value_p (r.varobj, print_values))
  541. {
  542. std::string val = varobj_get_value (r.varobj);
  543. uiout->field_string ("value", val);
  544. }
  545. uiout->field_string ("in_scope", "true");
  546. break;
  547. case VAROBJ_NOT_IN_SCOPE:
  548. uiout->field_string ("in_scope", "false");
  549. break;
  550. case VAROBJ_INVALID:
  551. uiout->field_string ("in_scope", "invalid");
  552. break;
  553. }
  554. if (r.status != VAROBJ_INVALID)
  555. {
  556. if (r.type_changed)
  557. uiout->field_string ("type_changed", "true");
  558. else
  559. uiout->field_string ("type_changed", "false");
  560. }
  561. if (r.type_changed)
  562. {
  563. std::string type_name = varobj_get_type (r.varobj);
  564. uiout->field_string ("new_type", type_name);
  565. }
  566. if (r.type_changed || r.children_changed)
  567. uiout->field_signed ("new_num_children",
  568. varobj_get_num_children (r.varobj));
  569. gdb::unique_xmalloc_ptr<char> display_hint
  570. = varobj_get_display_hint (r.varobj);
  571. if (display_hint)
  572. uiout->field_string ("displayhint", display_hint.get ());
  573. if (varobj_is_dynamic_p (r.varobj))
  574. uiout->field_signed ("dynamic", 1);
  575. varobj_get_child_range (r.varobj, &from, &to);
  576. uiout->field_signed ("has_more", varobj_has_more (r.varobj, to));
  577. if (!r.newobj.empty ())
  578. {
  579. ui_out_emit_list list_emitter (uiout, "new_children");
  580. for (varobj *child : r.newobj)
  581. {
  582. ui_out_emit_tuple inner_tuple_emitter (uiout, NULL);
  583. print_varobj (child, print_values, 1 /* print_expression */);
  584. }
  585. }
  586. }
  587. }
  588. void
  589. mi_cmd_enable_pretty_printing (const char *command, char **argv, int argc)
  590. {
  591. if (argc != 0)
  592. error (_("-enable-pretty-printing: no arguments allowed"));
  593. varobj_enable_pretty_printing ();
  594. }
  595. void
  596. mi_cmd_var_set_update_range (const char *command, char **argv, int argc)
  597. {
  598. struct varobj *var;
  599. int from, to;
  600. if (argc != 3)
  601. error (_("-var-set-update-range: Usage: VAROBJ FROM TO"));
  602. var = varobj_get_handle (argv[0]);
  603. from = atoi (argv[1]);
  604. to = atoi (argv[2]);
  605. varobj_set_child_range (var, from, to);
  606. }