OLD | NEW |
1 /* Implementation of the GDB variable objects API. | 1 /* Implementation of the GDB variable objects API. |
2 | 2 |
3 Copyright (C) 1999-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1999-2012 Free Software Foundation, Inc. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 the Free Software Foundation; either version 3 of the License, or |
8 (at your option) any later version. | 8 (at your option) any later version. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, | 10 This program is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 GNU General Public License for more details. | 13 GNU General Public License for more details. |
14 | 14 |
15 You should have received a copy of the GNU General Public License | 15 You should have received a copy of the GNU General Public License |
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
17 | 17 |
18 #include "defs.h" | 18 #include "defs.h" |
19 #include "exceptions.h" | 19 #include "exceptions.h" |
20 #include "value.h" | 20 #include "value.h" |
21 #include "expression.h" | 21 #include "expression.h" |
22 #include "frame.h" | 22 #include "frame.h" |
23 #include "language.h" | 23 #include "language.h" |
24 #include "wrapper.h" | |
25 #include "gdbcmd.h" | 24 #include "gdbcmd.h" |
26 #include "block.h" | 25 #include "block.h" |
27 #include "valprint.h" | 26 #include "valprint.h" |
28 | 27 |
29 #include "gdb_assert.h" | 28 #include "gdb_assert.h" |
30 #include "gdb_string.h" | 29 #include "gdb_string.h" |
31 #include "gdb_regex.h" | 30 #include "gdb_regex.h" |
32 | 31 |
33 #include "varobj.h" | 32 #include "varobj.h" |
34 #include "vec.h" | 33 #include "vec.h" |
35 #include "gdbthread.h" | 34 #include "gdbthread.h" |
36 #include "inferior.h" | 35 #include "inferior.h" |
| 36 #include "ada-varobj.h" |
| 37 #include "ada-lang.h" |
37 | 38 |
38 #if HAVE_PYTHON | 39 #if HAVE_PYTHON |
39 #include "python/python.h" | 40 #include "python/python.h" |
40 #include "python/python-internal.h" | 41 #include "python/python-internal.h" |
41 #else | 42 #else |
42 typedef int PyObject; | 43 typedef int PyObject; |
43 #endif | 44 #endif |
44 | 45 |
| 46 /* The names of varobjs representing anonymous structs or unions. */ |
| 47 #define ANONYMOUS_STRUCT_NAME _("<anonymous struct>") |
| 48 #define ANONYMOUS_UNION_NAME _("<anonymous union>") |
| 49 |
45 /* Non-zero if we want to see trace of varobj level stuff. */ | 50 /* Non-zero if we want to see trace of varobj level stuff. */ |
46 | 51 |
47 int varobjdebug = 0; | 52 int varobjdebug = 0; |
48 static void | 53 static void |
49 show_varobjdebug (struct ui_file *file, int from_tty, | 54 show_varobjdebug (struct ui_file *file, int from_tty, |
50 struct cmd_list_element *c, const char *value) | 55 struct cmd_list_element *c, const char *value) |
51 { | 56 { |
52 fprintf_filtered (file, _("Varobj debugging is %s.\n"), value); | 57 fprintf_filtered (file, _("Varobj debugging is %s.\n"), value); |
53 } | 58 } |
54 | 59 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 static struct type *get_value_type (struct varobj *var); | 263 static struct type *get_value_type (struct varobj *var); |
259 | 264 |
260 static struct type *get_target_type (struct type *); | 265 static struct type *get_target_type (struct type *); |
261 | 266 |
262 static enum varobj_display_formats variable_default_display (struct varobj *); | 267 static enum varobj_display_formats variable_default_display (struct varobj *); |
263 | 268 |
264 static void cppush (struct cpstack **pstack, char *name); | 269 static void cppush (struct cpstack **pstack, char *name); |
265 | 270 |
266 static char *cppop (struct cpstack **pstack); | 271 static char *cppop (struct cpstack **pstack); |
267 | 272 |
| 273 static int update_type_if_necessary (struct varobj *var, |
| 274 struct value *new_value); |
| 275 |
268 static int install_new_value (struct varobj *var, struct value *value, | 276 static int install_new_value (struct varobj *var, struct value *value, |
269 int initial); | 277 int initial); |
270 | 278 |
271 /* Language-specific routines. */ | 279 /* Language-specific routines. */ |
272 | 280 |
273 static enum varobj_languages variable_language (struct varobj *var); | 281 static enum varobj_languages variable_language (struct varobj *var); |
274 | 282 |
275 static int number_of_children (struct varobj *); | 283 static int number_of_children (struct varobj *); |
276 | 284 |
277 static char *name_of_variable (struct varobj *); | 285 static char *name_of_variable (struct varobj *); |
(...skipping 16 matching lines...) Expand all Loading... |
294 static int is_root_p (struct varobj *var); | 302 static int is_root_p (struct varobj *var); |
295 | 303 |
296 #if HAVE_PYTHON | 304 #if HAVE_PYTHON |
297 | 305 |
298 static struct varobj *varobj_add_child (struct varobj *var, | 306 static struct varobj *varobj_add_child (struct varobj *var, |
299 const char *name, | 307 const char *name, |
300 struct value *value); | 308 struct value *value); |
301 | 309 |
302 #endif /* HAVE_PYTHON */ | 310 #endif /* HAVE_PYTHON */ |
303 | 311 |
| 312 static int default_value_is_changeable_p (struct varobj *var); |
| 313 |
304 /* C implementation */ | 314 /* C implementation */ |
305 | 315 |
306 static int c_number_of_children (struct varobj *var); | 316 static int c_number_of_children (struct varobj *var); |
307 | 317 |
308 static char *c_name_of_variable (struct varobj *parent); | 318 static char *c_name_of_variable (struct varobj *parent); |
309 | 319 |
310 static char *c_name_of_child (struct varobj *parent, int index); | 320 static char *c_name_of_child (struct varobj *parent, int index); |
311 | 321 |
312 static char *c_path_expr_of_child (struct varobj *child); | 322 static char *c_path_expr_of_child (struct varobj *child); |
313 | 323 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 382 |
373 static struct value *ada_value_of_root (struct varobj **var_handle); | 383 static struct value *ada_value_of_root (struct varobj **var_handle); |
374 | 384 |
375 static struct value *ada_value_of_child (struct varobj *parent, int index); | 385 static struct value *ada_value_of_child (struct varobj *parent, int index); |
376 | 386 |
377 static struct type *ada_type_of_child (struct varobj *parent, int index); | 387 static struct type *ada_type_of_child (struct varobj *parent, int index); |
378 | 388 |
379 static char *ada_value_of_variable (struct varobj *var, | 389 static char *ada_value_of_variable (struct varobj *var, |
380 enum varobj_display_formats format); | 390 enum varobj_display_formats format); |
381 | 391 |
| 392 static int ada_value_is_changeable_p (struct varobj *var); |
| 393 |
| 394 static int ada_value_has_mutated (struct varobj *var, struct value *new_val, |
| 395 struct type *new_type); |
| 396 |
382 /* The language specific vector */ | 397 /* The language specific vector */ |
383 | 398 |
384 struct language_specific | 399 struct language_specific |
385 { | 400 { |
386 | 401 |
387 /* The language of this variable. */ | 402 /* The language of this variable. */ |
388 enum varobj_languages language; | 403 enum varobj_languages language; |
389 | 404 |
390 /* The number of children of PARENT. */ | 405 /* The number of children of PARENT. */ |
391 int (*number_of_children) (struct varobj * parent); | 406 int (*number_of_children) (struct varobj * parent); |
(...skipping 13 matching lines...) Expand all Loading... |
405 | 420 |
406 /* The ``struct value *'' of the INDEX'th child of PARENT. */ | 421 /* The ``struct value *'' of the INDEX'th child of PARENT. */ |
407 struct value *(*value_of_child) (struct varobj * parent, int index); | 422 struct value *(*value_of_child) (struct varobj * parent, int index); |
408 | 423 |
409 /* The type of the INDEX'th child of PARENT. */ | 424 /* The type of the INDEX'th child of PARENT. */ |
410 struct type *(*type_of_child) (struct varobj * parent, int index); | 425 struct type *(*type_of_child) (struct varobj * parent, int index); |
411 | 426 |
412 /* The current value of VAR. */ | 427 /* The current value of VAR. */ |
413 char *(*value_of_variable) (struct varobj * var, | 428 char *(*value_of_variable) (struct varobj * var, |
414 enum varobj_display_formats format); | 429 enum varobj_display_formats format); |
| 430 |
| 431 /* Return non-zero if changes in value of VAR must be detected and |
| 432 reported by -var-update. Return zero if -var-update should never |
| 433 report changes of such values. This makes sense for structures |
| 434 (since the changes in children values will be reported separately), |
| 435 or for artifical objects (like 'public' pseudo-field in C++). |
| 436 |
| 437 Return value of 0 means that gdb need not call value_fetch_lazy |
| 438 for the value of this variable object. */ |
| 439 int (*value_is_changeable_p) (struct varobj *var); |
| 440 |
| 441 /* Return nonzero if the type of VAR has mutated. |
| 442 |
| 443 VAR's value is still the varobj's previous value, while NEW_VALUE |
| 444 is VAR's new value and NEW_TYPE is the var's new type. NEW_VALUE |
| 445 may be NULL indicating that there is no value available (the varobj |
| 446 may be out of scope, of may be the child of a null pointer, for |
| 447 instance). NEW_TYPE, on the other hand, must never be NULL. |
| 448 |
| 449 This function should also be able to assume that var's number of |
| 450 children is set (not < 0). |
| 451 |
| 452 Languages where types do not mutate can set this to NULL. */ |
| 453 int (*value_has_mutated) (struct varobj *var, struct value *new_value, |
| 454 struct type *new_type); |
415 }; | 455 }; |
416 | 456 |
417 /* Array of known source language routines. */ | 457 /* Array of known source language routines. */ |
418 static struct language_specific languages[vlang_end] = { | 458 static struct language_specific languages[vlang_end] = { |
419 /* Unknown (try treating as C). */ | 459 /* Unknown (try treating as C). */ |
420 { | 460 { |
421 vlang_unknown, | 461 vlang_unknown, |
422 c_number_of_children, | 462 c_number_of_children, |
423 c_name_of_variable, | 463 c_name_of_variable, |
424 c_name_of_child, | 464 c_name_of_child, |
425 c_path_expr_of_child, | 465 c_path_expr_of_child, |
426 c_value_of_root, | 466 c_value_of_root, |
427 c_value_of_child, | 467 c_value_of_child, |
428 c_type_of_child, | 468 c_type_of_child, |
429 c_value_of_variable} | 469 c_value_of_variable, |
| 470 default_value_is_changeable_p, |
| 471 NULL /* value_has_mutated */} |
430 , | 472 , |
431 /* C */ | 473 /* C */ |
432 { | 474 { |
433 vlang_c, | 475 vlang_c, |
434 c_number_of_children, | 476 c_number_of_children, |
435 c_name_of_variable, | 477 c_name_of_variable, |
436 c_name_of_child, | 478 c_name_of_child, |
437 c_path_expr_of_child, | 479 c_path_expr_of_child, |
438 c_value_of_root, | 480 c_value_of_root, |
439 c_value_of_child, | 481 c_value_of_child, |
440 c_type_of_child, | 482 c_type_of_child, |
441 c_value_of_variable} | 483 c_value_of_variable, |
| 484 default_value_is_changeable_p, |
| 485 NULL /* value_has_mutated */} |
442 , | 486 , |
443 /* C++ */ | 487 /* C++ */ |
444 { | 488 { |
445 vlang_cplus, | 489 vlang_cplus, |
446 cplus_number_of_children, | 490 cplus_number_of_children, |
447 cplus_name_of_variable, | 491 cplus_name_of_variable, |
448 cplus_name_of_child, | 492 cplus_name_of_child, |
449 cplus_path_expr_of_child, | 493 cplus_path_expr_of_child, |
450 cplus_value_of_root, | 494 cplus_value_of_root, |
451 cplus_value_of_child, | 495 cplus_value_of_child, |
452 cplus_type_of_child, | 496 cplus_type_of_child, |
453 cplus_value_of_variable} | 497 cplus_value_of_variable, |
| 498 default_value_is_changeable_p, |
| 499 NULL /* value_has_mutated */} |
454 , | 500 , |
455 /* Java */ | 501 /* Java */ |
456 { | 502 { |
457 vlang_java, | 503 vlang_java, |
458 java_number_of_children, | 504 java_number_of_children, |
459 java_name_of_variable, | 505 java_name_of_variable, |
460 java_name_of_child, | 506 java_name_of_child, |
461 java_path_expr_of_child, | 507 java_path_expr_of_child, |
462 java_value_of_root, | 508 java_value_of_root, |
463 java_value_of_child, | 509 java_value_of_child, |
464 java_type_of_child, | 510 java_type_of_child, |
465 java_value_of_variable}, | 511 java_value_of_variable, |
| 512 default_value_is_changeable_p, |
| 513 NULL /* value_has_mutated */}, |
466 /* Ada */ | 514 /* Ada */ |
467 { | 515 { |
468 vlang_ada, | 516 vlang_ada, |
469 ada_number_of_children, | 517 ada_number_of_children, |
470 ada_name_of_variable, | 518 ada_name_of_variable, |
471 ada_name_of_child, | 519 ada_name_of_child, |
472 ada_path_expr_of_child, | 520 ada_path_expr_of_child, |
473 ada_value_of_root, | 521 ada_value_of_root, |
474 ada_value_of_child, | 522 ada_value_of_child, |
475 ada_type_of_child, | 523 ada_type_of_child, |
476 ada_value_of_variable} | 524 ada_value_of_variable, |
| 525 ada_value_is_changeable_p, |
| 526 ada_value_has_mutated} |
477 }; | 527 }; |
478 | 528 |
479 /* A little convenience enum for dealing with C++/Java. */ | 529 /* A little convenience enum for dealing with C++/Java. */ |
480 enum vsections | 530 enum vsections |
481 { | 531 { |
482 v_public = 0, v_private, v_protected | 532 v_public = 0, v_private, v_protected |
483 }; | 533 }; |
484 | 534 |
485 /* Private data */ | 535 /* Private data */ |
486 | 536 |
(...skipping 15 matching lines...) Expand all Loading... |
502 ((x) != NULL && (x)->type == NULL && (x)->value == NULL) | 552 ((x) != NULL && (x)->type == NULL && (x)->value == NULL) |
503 | 553 |
504 | 554 |
505 | 555 |
506 /* API Implementation */ | 556 /* API Implementation */ |
507 static int | 557 static int |
508 is_root_p (struct varobj *var) | 558 is_root_p (struct varobj *var) |
509 { | 559 { |
510 return (var->root->rootvar == var); | 560 return (var->root->rootvar == var); |
511 } | 561 } |
error: old chunk mismatch |
None
OLD | NEW |