From 2cd999854048fb4e3cd5c8762f40427221eb4112 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Thu, 19 Mar 1992 00:05:35 +0000 Subject: Some improvements to g++ debugging. * symtab.c (list_symbols): demangle before pattern matching. * symtab.c: Other fixes to improve handing of operators. * valprint.c (type_print_base): Fix test for constructor. * values.c (value_static_field): Allow evaluation of CLASS::METHOD, returning a function pointer. --- gdb/valprint.c | 101 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 74 insertions(+), 27 deletions(-) (limited to 'gdb/valprint.c') diff --git a/gdb/valprint.c b/gdb/valprint.c index b031e16..8b8c405 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include -#include #include "defs.h" +#include #include "symtab.h" +#include "gdbtypes.h" #include "value.h" #include "gdbcore.h" #include "gdbcmd.h" @@ -29,11 +29,59 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "language.h" #include + +/* Prototypes for local functions */ + +static void +print_string PARAMS ((FILE *, char *, unsigned int, int)); + +static void +show_print PARAMS ((char *, int)); + +static void +set_print PARAMS ((char *, int)); + +static void +set_radix PARAMS ((char *, int, struct cmd_list_element *)); + +static void +set_output_radix PARAMS ((char *, int, struct cmd_list_element *)); + +static void +type_print_base PARAMS ((struct type *, FILE *, int, int)); + +static void +type_print_varspec_suffix PARAMS ((struct type *, FILE *, int, int)); + +static void +type_print_varspec_prefix PARAMS ((struct type *, FILE *, int, int)); + +static void +type_print_derivation_info PARAMS ((FILE *, struct type *)); + +static void +type_print_method_args PARAMS ((struct type **, char *, char *, int, FILE *)); + +static void +cplus_val_print PARAMS ((struct type *, char *, FILE *, int, int, + enum val_prettyprint, struct type **)); + +static void +val_print_fields PARAMS ((struct type *, char *, FILE *, int, int, + enum val_prettyprint, struct type **)); + +static int +is_vtbl_member PARAMS ((struct type *)); + +static int +is_vtbl_ptr_type PARAMS ((struct type *)); + +static void +print_hex_chars PARAMS ((FILE *, unsigned char *, unsigned)); + extern int sys_nerr; extern char *sys_errlist[]; -extern void print_scalar_formatted(); /* printcmd.c */ -extern void print_address_demangle(); /* printcmd.c */ extern int demangle; /* whether to print C++ syms raw or source-form */ /* Maximum number of chars to print for a string pointer value @@ -41,11 +89,6 @@ extern int demangle; /* whether to print C++ syms raw or source-form */ static unsigned int print_max; -static void type_print_varspec_suffix (); -static void type_print_varspec_prefix (); -static void type_print_base (); -static void type_print_method_args (); - /* Default input and output radixes, and output format letter. */ unsigned input_radix = 10; @@ -74,14 +117,13 @@ int objectprint; /* Controls looking up an object's derived type struct obstack dont_print_obstack; -static void cplus_val_print (); /* Print the character string STRING, printing at most LENGTH characters. Printing stops early if the number hits print_max; repeat counts are printed as appropriate. Print ellipses at the end if we had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */ -void +static void print_string (stream, string, length, force_ellipses) FILE *stream; char *string; @@ -286,7 +328,7 @@ int value_print (val, stream, format, pretty) value val; FILE *stream; - char format; + int format; enum val_prettyprint pretty; { register unsigned int i, n, typelen; @@ -439,12 +481,13 @@ is_vtbl_member(type) DONT_PRINT is an array of baseclass types that we should not print, or zero if called from top level. */ + static void val_print_fields (type, valaddr, stream, format, recurse, pretty, dont_print) struct type *type; char *valaddr; FILE *stream; - char format; + int format; int recurse; enum val_prettyprint pretty; struct type **dont_print; @@ -547,7 +590,7 @@ cplus_val_print (type, valaddr, stream, format, recurse, pretty, dont_print) struct type *type; char *valaddr; FILE *stream; - char format; + int format; int recurse; enum val_prettyprint pretty; struct type **dont_print; @@ -634,13 +677,12 @@ cplus_val_print (type, valaddr, stream, format, recurse, pretty, dont_print) The PRETTY parameter controls prettyprinting. */ int -val_print (type, valaddr, address, stream, format, - deref_ref, recurse, pretty) +val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) struct type *type; char *valaddr; CORE_ADDR address; FILE *stream; - char format; + int format; int deref_ref; int recurse; enum val_prettyprint pretty; @@ -927,11 +969,18 @@ val_print (type, valaddr, address, stream, format, slower if print_max is set high, e.g. if you set print_max to 1000, not only will it take a long time to fetch short strings, but if you are near - the end of the address space, it might not work. - FIXME. */ + the end of the address space, it might not work. */ QUIT; errcode = target_read_memory (addr, string, print_max); if (errcode != 0) + { + /* Try reading just one character. If that succeeds, + assume we hit the end of the address space, but + the initial part of the string is probably safe. */ + char x[1]; + errcode = target_read_memory (addr, x, 1); + } + if (errcode != 0) force_ellipses = 0; else for (i = 0; i < print_max; i++) @@ -974,13 +1023,12 @@ val_print (type, valaddr, address, stream, format, { CORE_ADDR vt_address = unpack_pointer (type, valaddr); - int vt_index = find_pc_misc_function (vt_address); - if (vt_index >= 0 - && vt_address == misc_function_vector[vt_index].address) + struct minimal_symbol *msymbol = + lookup_minimal_symbol_by_pc (vt_address); + if ((msymbol != NULL) && (vt_address == msymbol -> address)) { fputs_filtered (" <", stream); - fputs_demangled (misc_function_vector[vt_index].name, - stream, 1); + fputs_demangled (msymbol -> name, stream, 1); fputs_filtered (">", stream); } if (vtblprint) @@ -1698,7 +1746,7 @@ type_print_base (type, stream, show, level) struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); - int is_constructor = strcmp(method_name, TYPE_NAME (type)) == 0; + int is_constructor = name && strcmp(method_name, name) == 0; for (j = 0; j < len2; j++) { QUIT; @@ -1723,7 +1771,6 @@ type_print_base (type, stream, show, level) if (TYPE_FN_FIELD_STUB (f, j)) { /* Build something we can demangle. */ - char *strchr (), *gdb_mangle_name (), *cplus_demangle (); char *mangled_name = gdb_mangle_name (type, i, j); char *demangled_name = cplus_demangle (mangled_name, 1); if (demangled_name == 0) @@ -2011,7 +2058,7 @@ _initialize_valprint () "Set default input and output number radix.", &setlist); add_show_from_set (c, &showlist); - c->function = set_radix; + c->function.sfunc = set_radix; /* Give people the defaults which they are used to. */ prettyprint = 0; -- cgit v1.1