diff options
author | Daniel Jacobowitz <drow@false.org> | 2005-07-15 04:12:19 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2005-07-15 04:12:19 +0000 |
commit | 1ecb4ee0309ec7962314a8f98d45ac91be48aebf (patch) | |
tree | a653dbd8674e8acc1979271d013ec8a8023af084 | |
parent | fb6ae37f9e6776de6a048387949575b08a52ab1f (diff) | |
download | fsf-binutils-gdb-1ecb4ee0309ec7962314a8f98d45ac91be48aebf.zip fsf-binutils-gdb-1ecb4ee0309ec7962314a8f98d45ac91be48aebf.tar.gz fsf-binutils-gdb-1ecb4ee0309ec7962314a8f98d45ac91be48aebf.tar.bz2 |
2005-07-15 Nick Roberts <nickrob@snap.net.nz>
Daniel Jacobowitz <dan@codesourcery.com>
* mi/mi-cmds.h (mi_no_values, mi_simple_values, mi_all_values): New
declarations.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Use string
constants instead of literals for MI command options.
* mi/mi-cmd-var.c (mi_no_values, mi_simple_values, mi_all_values):
New variables.
(mi_parse_values_option, mi_print_value_p): New functions.
(mi_cmd_var_list_children): Use mi_parse_values_option and
mi_print_value_p.
(mi_cmd_var_update): Support a PRINT_VALUES option. Update calls
to varobj_update_one.
(varobj_update_one): Take a print_values argument. Call
mi_print_value_p.
* varobj.c (varobj_get_gdb_type): New function.
* varobj.h (varobj_get_gdb_type): New prototype.
-rw-r--r-- | gdb/ChangeLog | 19 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-stack.c | 12 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-var.c | 97 | ||||
-rw-r--r-- | gdb/mi/mi-cmds.h | 6 | ||||
-rw-r--r-- | gdb/varobj.c | 11 | ||||
-rw-r--r-- | gdb/varobj.h | 4 |
6 files changed, 120 insertions, 29 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ef7f690..005380b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,22 @@ +2005-07-15 Nick Roberts <nickrob@snap.net.nz> + Daniel Jacobowitz <dan@codesourcery.com> + + * mi/mi-cmds.h (mi_no_values, mi_simple_values, mi_all_values): New + declarations. + * mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Use string + constants instead of literals for MI command options. + * mi/mi-cmd-var.c (mi_no_values, mi_simple_values, mi_all_values): + New variables. + (mi_parse_values_option, mi_print_value_p): New functions. + (mi_cmd_var_list_children): Use mi_parse_values_option and + mi_print_value_p. + (mi_cmd_var_update): Support a PRINT_VALUES option. Update calls + to varobj_update_one. + (varobj_update_one): Take a print_values argument. Call + mi_print_value_p. + * varobj.c (varobj_get_gdb_type): New function. + * varobj.h (varobj_get_gdb_type): New prototype. + 2005-07-13 Daniel Jacobowitz <dan@codesourcery.com> * ppc-linux-tdep.c (ppc_linux_init_abi): Set 64-bit link map offsets. diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 7b311a3..a7a5a17 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -1,5 +1,5 @@ /* MI Command Set - stack commands. - Copyright 2000, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Contributed by Cygnus Solutions (a Red Hat company). This file is part of GDB. @@ -136,16 +136,18 @@ mi_cmd_stack_list_locals (char *command, char **argv, int argc) frame = get_selected_frame (NULL); if (strcmp (argv[0], "0") == 0 - || strcmp (argv[0], "--no-values") == 0) + || strcmp (argv[0], mi_no_values) == 0) print_values = PRINT_NO_VALUES; else if (strcmp (argv[0], "1") == 0 - || strcmp (argv[0], "--all-values") == 0) + || strcmp (argv[0], mi_all_values) == 0) print_values = PRINT_ALL_VALUES; else if (strcmp (argv[0], "2") == 0 - || strcmp (argv[0], "--simple-values") == 0) + || strcmp (argv[0], mi_simple_values) == 0) print_values = PRINT_SIMPLE_VALUES; else - error (_("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\", 2 or \"--simple-values\"")); + error (_("Unknown value for PRINT_VALUES: must be: \ +0 or \"%s\", 1 or \"%s\", 2 or \"%s\""), + mi_no_values, mi_all_values, mi_simple_values); list_args_or_locals (1, print_values, frame); return MI_CMD_DONE; } diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 96e7beb..df244cc 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -1,6 +1,6 @@ /* MI Command Set - varobj commands. - Copyright 2000, 2002, 2004 Free Software Foundation, Inc. + Copyright 2000, 2002, 2004, 2005 Free Software Foundation, Inc. Contributed by Cygnus Solutions (a Red Hat company). @@ -30,9 +30,14 @@ #include <ctype.h> #include "gdb_string.h" +const char mi_no_values[] = "--no-values"; +const char mi_simple_values[] = "--simple-values"; +const char mi_all_values[] = "--all-values"; + extern int varobjdebug; /* defined in varobj.c */ -static int varobj_update_one (struct varobj *var); +static int varobj_update_one (struct varobj *var, + enum print_values print_values); /* VAROBJ operations */ @@ -247,6 +252,49 @@ mi_cmd_var_info_num_children (char *command, char **argv, int argc) return MI_CMD_DONE; } +/* Parse a string argument into a print_values value. */ + +static enum print_values +mi_parse_values_option (const char *arg) +{ + if (strcmp (arg, "0") == 0 + || strcmp (arg, mi_no_values) == 0) + return PRINT_NO_VALUES; + else if (strcmp (arg, "1") == 0 + || strcmp (arg, mi_all_values) == 0) + return PRINT_ALL_VALUES; + else if (strcmp (arg, "2") == 0 + || strcmp (arg, mi_simple_values) == 0) + return PRINT_SIMPLE_VALUES; + else + error (_("Unknown value for PRINT_VALUES\n\ +Must be: 0 or \"%s\", 1 or \"%s\", 2 or \"%s\""), + mi_no_values, mi_simple_values, mi_all_values); +} + +/* Return 1 if given the argument PRINT_VALUES we should display + a value of type TYPE. */ + +static int +mi_print_value_p (struct type *type, enum print_values print_values) +{ + if (type != NULL) + type = check_typedef (type); + + if (print_values == PRINT_NO_VALUES) + return 0; + + if (print_values == PRINT_ALL_VALUES) + return 1; + + /* For PRINT_SIMPLE_VALUES, only print the value if it has a type + and that type is not a compound type. */ + + return (TYPE_CODE (type) != TYPE_CODE_ARRAY + && TYPE_CODE (type) != TYPE_CODE_STRUCT + && TYPE_CODE (type) != TYPE_CODE_UNION); +} + enum mi_cmd_result mi_cmd_var_list_children (char *command, char **argv, int argc) { @@ -262,23 +310,19 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME")); /* Get varobj handle, if a valid var obj name was specified */ - if (argc == 1) var = varobj_get_handle (argv[0]); - else var = varobj_get_handle (argv[1]); + if (argc == 1) + var = varobj_get_handle (argv[0]); + else + var = varobj_get_handle (argv[1]); if (var == NULL) error (_("Variable object not found")); numchild = varobj_list_children (var, &childlist); ui_out_field_int (uiout, "numchild", numchild); if (argc == 2) - if (strcmp (argv[0], "0") == 0 - || strcmp (argv[0], "--no-values") == 0) - print_values = PRINT_NO_VALUES; - else if (strcmp (argv[0], "1") == 0 - || strcmp (argv[0], "--all-values") == 0) - print_values = PRINT_ALL_VALUES; - else - error (_("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\"")); - else print_values = PRINT_NO_VALUES; + print_values = mi_parse_values_option (argv[0]); + else + print_values = PRINT_NO_VALUES; if (numchild <= 0) return MI_CMD_DONE; @@ -295,12 +339,12 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) ui_out_field_string (uiout, "name", varobj_get_objname (*cc)); ui_out_field_string (uiout, "exp", varobj_get_expression (*cc)); ui_out_field_int (uiout, "numchild", varobj_get_num_children (*cc)); - if (print_values) + if (mi_print_value_p (varobj_get_gdb_type (*cc), print_values)) ui_out_field_string (uiout, "value", varobj_get_value (*cc)); type = varobj_get_type (*cc); /* C++ pseudo-variables (public, private, protected) do not have a type */ if (type) - ui_out_field_string (uiout, "type", varobj_get_type (*cc)); + ui_out_field_string (uiout, "type", type); do_cleanups (cleanup_child); cc++; } @@ -426,11 +470,20 @@ mi_cmd_var_update (char *command, char **argv, int argc) struct cleanup *cleanup; char *name; int nv; + enum print_values print_values; - if (argc != 1) - error (_("mi_cmd_var_update: Usage: NAME.")); + if (argc != 1 && argc != 2) + error (_("mi_cmd_var_update: Usage: [PRINT_VALUES] NAME.")); + + if (argc == 1) + name = argv[0]; + else + name = (argv[1]); - name = argv[0]; + if (argc == 2) + print_values = mi_parse_values_option (argv[0]); + else + print_values = PRINT_NO_VALUES; /* Check if the parameter is a "*" which means that we want to update all variables */ @@ -450,7 +503,7 @@ mi_cmd_var_update (char *command, char **argv, int argc) cr = rootlist; while (*cr != NULL) { - varobj_update_one (*cr); + varobj_update_one (*cr, print_values); cr++; } xfree (rootlist); @@ -467,7 +520,7 @@ mi_cmd_var_update (char *command, char **argv, int argc) cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist"); else cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist"); - varobj_update_one (var); + varobj_update_one (var, print_values); do_cleanups (cleanup); } return MI_CMD_DONE; @@ -478,7 +531,7 @@ mi_cmd_var_update (char *command, char **argv, int argc) scope), and 1 if it succeeds. */ static int -varobj_update_one (struct varobj *var) +varobj_update_one (struct varobj *var, enum print_values print_values) { struct varobj **changelist; struct varobj **cc; @@ -524,6 +577,8 @@ varobj_update_one (struct varobj *var) if (mi_version (uiout) > 1) cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_string (uiout, "name", varobj_get_objname (*cc)); + if (mi_print_value_p (varobj_get_gdb_type (*cc), print_values)) + ui_out_field_string (uiout, "value", varobj_get_value (*cc)); ui_out_field_string (uiout, "in_scope", "true"); ui_out_field_string (uiout, "type_changed", "false"); if (mi_version (uiout) > 1) diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index 0712608..fe4268f 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -1,6 +1,6 @@ /* MI Command Set for GDB, the GNU debugger. - Copyright 2000, 2003, 2004 Free Software Foundation, Inc. + Copyright 2000, 2003, 2004, 2005 Free Software Foundation, Inc. Contributed by Cygnus Solutions (a Red Hat company). @@ -50,6 +50,10 @@ enum print_values { PRINT_SIMPLE_VALUES }; +extern const char mi_no_values[]; +extern const char mi_simple_values[]; +extern const char mi_all_values[]; + typedef enum mi_cmd_result (mi_cmd_argv_ftype) (char *command, char **argv, int argc); /* Older MI commands have this interface. Retained until all old diff --git a/gdb/varobj.c b/gdb/varobj.c index 31d8fd2..388d0ce 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1,6 +1,7 @@ /* Implementation of the GDB variable objects API. - Copyright 1999, 2000, 2001, 2005 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -760,6 +761,14 @@ varobj_get_type (struct varobj *var) return thetype; } +/* Obtain the type of an object variable. */ + +struct type * +varobj_get_gdb_type (struct varobj *var) +{ + return var->type; +} + enum varobj_languages varobj_get_language (struct varobj *var) { diff --git a/gdb/varobj.h b/gdb/varobj.h index cd30233..68ae629 100644 --- a/gdb/varobj.h +++ b/gdb/varobj.h @@ -1,5 +1,5 @@ /* GDB variable objects API. - Copyright 1999, 2000 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -85,6 +85,8 @@ extern int varobj_list_children (struct varobj *var, extern char *varobj_get_type (struct varobj *var); +extern struct type *varobj_get_gdb_type (struct varobj *var); + extern enum varobj_languages varobj_get_language (struct varobj *var); extern int varobj_get_attributes (struct varobj *var); |