From 8050a57b2c1a8e7a54a81b540e6446d310a08b6b Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Thu, 9 Jul 1992 04:40:39 +0000 Subject: [PATCH] * dwarfread.c (alloc_utype, decode_subscr_data): Call alloc_type to create new blank types, instead of handcrafting them. * defs.h (printfi_filtered): Add prototype. * utils.c (printfi_filtered): New function. * gdbtypes.c (recursive_dump_type): Use printfi_filtered to to simplify the code. Other cleanups. * gdbtypes.c (check_stub_method): Demangle using DMGL_ANSI. * gdbtypes.h (struct cplus_struct_type): Add comments describing use of various fields. * gdbtypes.c (print_bit_vector, print_cplus_stuff): New functions. * c-exp.y (%token): Add CLASS as a token for C++, add grammar production that currently treats it exactly the same as STRUCT. * c-exp.y (yylex): Recognize "class" as token CLASS. * symtab.c (gdb_mangle_name): Rewrite to match current g++ stabs. * symtab.c (decode_line_1): Fix to pass quoted args on down to general symbol handling code. Call cplus_mangle_opname with DMGL_ANSI. * symtab.c (decode_line_2): Print demangled function names in breakpoint menus, instead of just file and line number. * symtab.c (name_match): Call cplus_demangle with DMGL_ANSI. * valprint.c (type_print_base): Print "class" for C++ classes, rather than "struct". Print section labels for public, protected and private members of C++ classes. * values.c: Include demangle.h. * values.c (value_headof): Call cplus_demangle with DMGL_ANSI. --- gdb/ChangeLog | 28 +++++ gdb/buildsym.c | 2 +- gdb/c-exp.y | 7 +- gdb/dwarfread.c | 12 +-- gdb/gdbtypes.c | 276 +++++++++++++++++++++++++++++++++--------------- gdb/gdbtypes.h | 20 +++- gdb/symtab.c | 85 ++++++++------- gdb/valprint.c | 41 ++++++- gdb/values.c | 3 +- 9 files changed, 331 insertions(+), 143 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c2142d48fdb..fbac9ba9e78 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,31 @@ +Wed Jul 8 21:34:30 1992 Fred Fish (fnf@cygnus.com) + + * dwarfread.c (alloc_utype, decode_subscr_data): Call alloc_type + to create new blank types, instead of handcrafting them. + * defs.h (printfi_filtered): Add prototype. + * utils.c (printfi_filtered): New function. + * gdbtypes.c (recursive_dump_type): Use printfi_filtered to + to simplify the code. Other cleanups. + * gdbtypes.c (check_stub_method): Demangle using DMGL_ANSI. + * gdbtypes.h (struct cplus_struct_type): Add comments describing + use of various fields. + * gdbtypes.c (print_bit_vector, print_cplus_stuff): New functions. + * c-exp.y (%token): Add CLASS as a token for C++, add grammar + production that currently treats it exactly the same as STRUCT. + * c-exp.y (yylex): Recognize "class" as token CLASS. + * symtab.c (gdb_mangle_name): Rewrite to match current g++ stabs. + * symtab.c (decode_line_1): Fix to pass quoted args on down to + general symbol handling code. Call cplus_mangle_opname with + DMGL_ANSI. + * symtab.c (decode_line_2): Print demangled function names in + breakpoint menus, instead of just file and line number. + * symtab.c (name_match): Call cplus_demangle with DMGL_ANSI. + * valprint.c (type_print_base): Print "class" for C++ classes, + rather than "struct". Print section labels for public, protected + and private members of C++ classes. + * values.c: Include demangle.h. + * values.c (value_headof): Call cplus_demangle with DMGL_ANSI. + Wed Jul 8 17:23:07 1992 Stu Grossman (grossman at cygnus.com) * Makefile.in (VERSION): Update to 4.5.8. diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 2a7ea380272..104df4702e8 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -2770,7 +2770,7 @@ read_struct_type (pp, type, objfile) } else for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); --i) if (! strncmp (TYPE_FIELD_NAME (t, i), vptr_name, - sizeof (vptr_name) -1)) + sizeof (vptr_name) - 1)) { TYPE_VPTR_FIELDNO (type) = i; break; diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 4cc8eb67f55..cc092475ceb 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -155,7 +155,7 @@ parse_number PARAMS ((char *, int, int, YYSTYPE *)); %token NAME_OR_INT NAME_OR_UINT -%token STRUCT UNION ENUM SIZEOF UNSIGNED COLONCOLON +%token STRUCT CLASS UNION ENUM SIZEOF UNSIGNED COLONCOLON %token TEMPLATE %token ERROR @@ -864,6 +864,9 @@ typebase | STRUCT name { $$ = lookup_struct (copy_name ($2), expression_context_block); } + | CLASS name + { $$ = lookup_struct (copy_name ($2), + expression_context_block); } | UNION name { $$ = lookup_union (copy_name ($2), expression_context_block); } @@ -1366,6 +1369,8 @@ yylex () return SIZEOF; break; case 5: + if (!strncmp (tokstart, "class", 5)) + return CLASS; if (!strncmp (tokstart, "union", 5)) return UNION; if (!strncmp (tokstart, "short", 5)) diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 0b022883143..484472db867 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -699,11 +699,7 @@ alloc_utype (die_ref, utypep) { if (utypep == NULL) { - utypep = (struct type *) - obstack_alloc (¤t_objfile -> type_obstack, - sizeof (struct type)); - memset (utypep, 0, sizeof (struct type)); - TYPE_OBJFILE (utypep) = current_objfile; + utypep = alloc_type (current_objfile); } *typep = utypep; } @@ -1117,11 +1113,7 @@ decode_subscr_data (scan, end) nexttype = decode_subscr_data (scan, end); if (nexttype != NULL) { - typep = (struct type *) - obstack_alloc (¤t_objfile -> type_obstack, - sizeof (struct type)); - memset (typep, 0, sizeof (struct type)); - TYPE_OBJFILE (typep) = current_objfile; + typep = alloc_type (current_objfile); TYPE_CODE (typep) = TYPE_CODE_ARRAY; TYPE_LENGTH (typep) = TYPE_LENGTH (nexttype); TYPE_LENGTH (typep) *= (highbound - lowbound) + 1; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 5f03549eb0f..1965cd83b70 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -335,7 +335,7 @@ create_array_type (element_type, number) TYPE_FIELD_TYPE (range_type, 0) = builtin_type_int; /* FIXME */ TYPE_FIELD_TYPE (range_type, 1) = builtin_type_int; /* FIXME */ } - TYPE_FIELD_TYPE(result_type,0)=range_type; + TYPE_FIELD_TYPE (result_type, 0) = range_type; TYPE_VPTR_FIELDNO (result_type) = -1; return (result_type); @@ -740,7 +740,8 @@ check_stub_method (type, i, j) { struct fn_field *f; char *mangled_name = gdb_mangle_name (type, i, j); - char *demangled_name = cplus_demangle (mangled_name, DMGL_PARAMS); + char *demangled_name = cplus_demangle (mangled_name, + DMGL_PARAMS | DMGL_ANSI); char *argtypetext, *p; int depth = 0, argcount = 1; struct type **argtypes; @@ -1107,109 +1108,210 @@ lookup_fundamental_type (objfile, typeid) #if MAINTENANCE_CMDS -void recursive_dump_type (type, spaces) - struct type *type; - int spaces; +static void +print_bit_vector (bits, nbits) + B_TYPE *bits; + int nbits; { - int idx; - struct field *fldp; - - print_spaces_filtered (spaces, stdout); - printf_filtered ("type node @ 0x%x\n", type); - print_spaces_filtered (spaces, stdout); - printf_filtered ("name: 0x%x '%s'\n", type -> name, - type -> name ? type -> name : ""); - print_spaces_filtered (spaces, stdout); - printf_filtered ("code: 0x%x ", type -> code); - switch (type -> code) + int bitno; + + for (bitno = 0; bitno < nbits; bitno++) { - case TYPE_CODE_UNDEF: printf_filtered ("TYPE_CODE_UNDEF"); break; - case TYPE_CODE_PTR: printf_filtered ("TYPE_CODE_PTR"); break; - case TYPE_CODE_ARRAY: printf_filtered ("TYPE_CODE_ARRAY"); break; - case TYPE_CODE_STRUCT: printf_filtered ("TYPE_CODE_STRUCT"); break; - case TYPE_CODE_UNION: printf_filtered ("TYPE_CODE_UNION"); break; - case TYPE_CODE_ENUM: printf_filtered ("TYPE_CODE_ENUM"); break; - case TYPE_CODE_FUNC: printf_filtered ("TYPE_CODE_FUNC"); break; - case TYPE_CODE_INT: printf_filtered ("TYPE_CODE_INT"); break; - case TYPE_CODE_FLT: printf_filtered ("TYPE_CODE_FLT"); break; - case TYPE_CODE_VOID: printf_filtered ("TYPE_CODE_VOID"); break; - case TYPE_CODE_SET: printf_filtered ("TYPE_CODE_SET"); break; - case TYPE_CODE_RANGE: printf_filtered ("TYPE_CODE_RANGE"); break; - case TYPE_CODE_PASCAL_ARRAY: printf_filtered ("TYPE_CODE_PASCAL_ARRAY"); break; - case TYPE_CODE_ERROR: printf_filtered ("TYPE_CODE_ERROR"); break; - case TYPE_CODE_MEMBER: printf_filtered ("TYPE_CODE_MEMBER"); break; - case TYPE_CODE_METHOD: printf_filtered ("TYPE_CODE_METHOD"); break; - case TYPE_CODE_REF: printf_filtered ("TYPE_CODE_REF"); break; - case TYPE_CODE_CHAR: printf_filtered ("TYPE_CODE_CHAR"); break; - case TYPE_CODE_BOOL: printf_filtered ("TYPE_CODE_BOOL"); break; - default: printf_filtered (""); break; + if ((bitno % 8) == 0) + { + puts_filtered (" "); + } + if (B_TST (bits, bitno)) + { + printf_filtered ("1"); + } + else + { + printf_filtered ("0"); + } } - printf_filtered ("\n"); - print_spaces_filtered (spaces, stdout); - printf_filtered ("length: %d\n", type -> length); - print_spaces_filtered (spaces, stdout); - printf_filtered ("objfile: 0x%x\n", type -> objfile); - print_spaces_filtered (spaces, stdout); - printf_filtered ("target_type: 0x%x\n", type -> target_type); - if (type -> target_type != NULL) +} + +static void +print_cplus_stuff (type, spaces) + struct type *type; + int spaces; +{ + int bitno; + + printfi_filtered (spaces, "cplus_stuff: @ 0x%x\n", + TYPE_CPLUS_SPECIFIC (type)); + printfi_filtered (spaces, "n_baseclasses: %d\n", + TYPE_N_BASECLASSES (type)); + if (TYPE_N_BASECLASSES (type) > 0) { - recursive_dump_type (type -> target_type, spaces + 2); + printfi_filtered (spaces, "virtual_field_bits: %d @ 0x%x:", + TYPE_N_BASECLASSES (type), + TYPE_FIELD_VIRTUAL_BITS (type)); + print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type), + TYPE_N_BASECLASSES (type)); + puts_filtered ("\n"); } - print_spaces_filtered (spaces, stdout); - printf_filtered ("pointer_type: 0x%x\n", type -> pointer_type); - print_spaces_filtered (spaces, stdout); - printf_filtered ("reference_type: 0x%x\n", type -> reference_type); - print_spaces_filtered (spaces, stdout); - printf_filtered ("function_type: 0x%x\n", type -> function_type); - - print_spaces_filtered (spaces, stdout); - printf_filtered ("flags: 0x%x", type -> flags); - if (type -> flags & TYPE_FLAG_UNSIGNED) - printf_filtered (" TYPE_FLAG_UNSIGNED"); - if (type -> flags & TYPE_FLAG_SIGNED) - printf_filtered (" TYPE_FLAG_SIGNED"); - if (type -> flags & TYPE_FLAG_STUB) - printf_filtered (" TYPE_FLAG_STUB"); - printf_filtered ("\n"); - - print_spaces_filtered (spaces, stdout); - printf_filtered ("nfields: %d at 0x%x\n", type -> nfields, type -> fields); - for (idx = 0; idx < type -> nfields; idx++) + if (TYPE_NFIELDS (type) > 0) { - fldp = &(type -> fields[idx]); - print_spaces_filtered (spaces + 2, stdout); - printf_filtered ("[%d] bitpos %d bitsize %d type 0x%x name 0x%x '%s'\n", - idx, fldp -> bitpos, fldp -> bitsize, fldp -> type, - fldp -> name, fldp -> name ? fldp -> name : ""); - if (fldp -> type != NULL) + if (TYPE_FIELD_PRIVATE_BITS (type) != NULL) + { + printfi_filtered (spaces, "private_field_bits: %d @ 0x%x:", + TYPE_NFIELDS (type), + TYPE_FIELD_PRIVATE_BITS (type)); + print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type), + TYPE_NFIELDS (type)); + puts_filtered ("\n"); + } + if (TYPE_FIELD_PROTECTED_BITS (type) != NULL) { - recursive_dump_type (fldp -> type, spaces + 4); + printfi_filtered (spaces, "protected_field_bits: %d @ 0x%x:", + TYPE_NFIELDS (type), + TYPE_FIELD_PROTECTED_BITS (type)); + print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type), + TYPE_NFIELDS (type)); + puts_filtered ("\n"); } } +} + +void +recursive_dump_type (type, spaces) + struct type *type; + int spaces; +{ + int idx; - print_spaces_filtered (spaces, stdout); - printf_filtered ("vptr_basetype: 0x%x\n", type -> vptr_basetype); - if (type -> vptr_basetype != NULL) + printfi_filtered (spaces, "type node @ 0x%x\n", type); + printfi_filtered (spaces, "name: @ 0x%x '%s'\n", TYPE_NAME (type), + TYPE_NAME (type) ? TYPE_NAME (type) : ""); + printfi_filtered (spaces, "code: 0x%x ", TYPE_CODE (type)); + switch (TYPE_CODE (type)) { - recursive_dump_type (type -> vptr_basetype, spaces + 2); + case TYPE_CODE_UNDEF: + printf_filtered ("TYPE_CODE_UNDEF"); + break; + case TYPE_CODE_PTR: + printf_filtered ("TYPE_CODE_PTR"); + break; + case TYPE_CODE_ARRAY: + printf_filtered ("TYPE_CODE_ARRAY"); + break; + case TYPE_CODE_STRUCT: + printf_filtered ("TYPE_CODE_STRUCT"); + break; + case TYPE_CODE_UNION: + printf_filtered ("TYPE_CODE_UNION"); + break; + case TYPE_CODE_ENUM: + printf_filtered ("TYPE_CODE_ENUM"); + break; + case TYPE_CODE_FUNC: + printf_filtered ("TYPE_CODE_FUNC"); + break; + case TYPE_CODE_INT: + printf_filtered ("TYPE_CODE_INT"); + break; + case TYPE_CODE_FLT: + printf_filtered ("TYPE_CODE_FLT"); + break; + case TYPE_CODE_VOID: + printf_filtered ("TYPE_CODE_VOID"); + break; + case TYPE_CODE_SET: + printf_filtered ("TYPE_CODE_SET"); + break; + case TYPE_CODE_RANGE: + printf_filtered ("TYPE_CODE_RANGE"); + break; + case TYPE_CODE_PASCAL_ARRAY: + printf_filtered ("TYPE_CODE_PASCAL_ARRAY"); + break; + case TYPE_CODE_ERROR: + printf_filtered ("TYPE_CODE_ERROR"); + break; + case TYPE_CODE_MEMBER: + printf_filtered ("TYPE_CODE_MEMBER"); + break; + case TYPE_CODE_METHOD: + printf_filtered ("TYPE_CODE_METHOD"); + break; + case TYPE_CODE_REF: + printf_filtered ("TYPE_CODE_REF"); + break; + case TYPE_CODE_CHAR: + printf_filtered ("TYPE_CODE_CHAR"); + break; + case TYPE_CODE_BOOL: + printf_filtered ("TYPE_CODE_BOOL"); + break; + default: + printf_filtered (""); + break; } - - print_spaces_filtered (spaces, stdout); - printf_filtered ("vptr_fieldno: %d\n", type -> vptr_fieldno); - - switch (type -> code) + puts_filtered ("\n"); + printfi_filtered (spaces, "length: %d\n", TYPE_LENGTH (type)); + printfi_filtered (spaces, "objfile: @ 0x%x\n", TYPE_OBJFILE (type)); + printfi_filtered (spaces, "target_type: @ 0x%x\n", TYPE_TARGET_TYPE (type)); + if (TYPE_TARGET_TYPE (type) != NULL) + { + recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2); + } + printfi_filtered (spaces, "pointer_type: @ 0x%x\n", + TYPE_POINTER_TYPE (type)); + printfi_filtered (spaces, "reference_type: @ 0x%x\n", + TYPE_REFERENCE_TYPE (type)); + printfi_filtered (spaces, "function_type: @ 0x%x\n", + TYPE_FUNCTION_TYPE (type)); + printfi_filtered (spaces, "flags: 0x%x", TYPE_FLAGS (type)); + if (TYPE_FLAGS (type) & TYPE_FLAG_UNSIGNED) + { + puts_filtered (" TYPE_FLAG_UNSIGNED"); + } + if (TYPE_FLAGS (type) & TYPE_FLAG_SIGNED) + { + puts_filtered (" TYPE_FLAG_SIGNED"); + } + if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) + { + puts_filtered (" TYPE_FLAG_STUB"); + } + puts_filtered ("\n"); + printfi_filtered (spaces, "nfields: %d @ 0x%x\n", TYPE_NFIELDS (type), + TYPE_FIELDS (type)); + for (idx = 0; idx < TYPE_NFIELDS (type); idx++) + { + printfi_filtered (spaces + 2, + "[%d] bitpos %d bitsize %d type 0x%x name 0x%x '%s'\n", + idx, TYPE_FIELD_BITPOS (type, idx), + TYPE_FIELD_BITSIZE (type, idx), + TYPE_FIELD_TYPE (type, idx), + TYPE_FIELD_NAME (type, idx), + TYPE_FIELD_NAME (type, idx) != NULL + ? TYPE_FIELD_NAME (type, idx) + : ""); + if (TYPE_FIELD_TYPE (type, idx) != NULL) + { + recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4); + } + } + printfi_filtered (spaces, "vptr_basetype: @ 0x%x\n", + TYPE_VPTR_BASETYPE (type)); + if (TYPE_VPTR_BASETYPE (type) != NULL) + { + recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2); + } + printfi_filtered (spaces, "vptr_fieldno: %d\n", TYPE_VPTR_FIELDNO (type)); + switch (TYPE_CODE (type)) { case TYPE_CODE_METHOD: case TYPE_CODE_FUNC: - print_spaces_filtered (spaces, stdout); - printf_filtered ("arg_types: 0x%x\n", - type -> type_specific.arg_types); + printfi_filtered (spaces, "arg_types: @ 0x%x\n", + TYPE_ARG_TYPES (type)); break; case TYPE_CODE_STRUCT: - print_spaces_filtered (spaces, stdout); - printf_filtered ("cplus_stuff: 0x%x\n", - type -> type_specific.cplus_stuff); + print_cplus_stuff (type, spaces); break; } } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 699eff0ae15..7a16b37161f 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -230,7 +230,9 @@ struct type struct type **arg_types; - /* CPLUS_STUFF is for TYPE_CODE_STRUCT. */ + /* CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to point to + cplus_struct_default, a default static instance of a struct + cplus_struct_type. */ struct cplus_struct_type *cplus_stuff; @@ -244,11 +246,25 @@ struct type struct cplus_struct_type { + /* For derived classes, the number of base classes is given by + n_baseclasses and virtual_field_bits is a bit vector containing one bit + per base class. + If the base class is virtual, the corresponding bit will be set. */ - B_TYPE *virtual_field_bits; /* if base class is virtual */ + B_TYPE *virtual_field_bits; + + /* For classes with private fields, the number of fields is given by + nfields and private_field_bits is a bit vector containing one bit + per field. + If the field is private, the corresponding bit will be set. */ B_TYPE *private_field_bits; + /* For classes with protected fields, the number of fields is given by + nfields and protected_field_bits is a bit vector containing one bit + per field. + If the field is private, the corresponding bit will be set. */ + B_TYPE *protected_field_bits; /* Number of methods described for this type */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 1913c5bb1cf..a0033d90f6c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -261,48 +261,58 @@ gdb_mangle_name (type, i, j) struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); struct fn_field *method = &f[j]; char *field_name = TYPE_FN_FIELDLIST_NAME (type, i); - int is_constructor = strcmp(field_name, TYPE_NAME (type)) == 0; + char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); + char *opname; + int is_constructor = strcmp (field_name, type_name_no_tag (type)) == 0; /* Need a new type prefix. */ char *const_prefix = method->is_const ? "C" : ""; char *volatile_prefix = method->is_volatile ? "V" : ""; - char *newname = type_name_no_tag (type); char buf[20]; - int len = strlen (newname); - sprintf (buf, "__%s%s%d", const_prefix, volatile_prefix, len); + if (is_constructor) + { + buf[0] = '\0'; + } + else + { + sprintf (buf, "__%s%s", const_prefix, volatile_prefix); + } + mangled_name_len = ((is_constructor ? 0 : strlen (field_name)) - + strlen (buf) + len - + strlen (TYPE_FN_FIELD_PHYSNAME (f, j)) - + 1); + + strlen (buf) + strlen (physname) + 1); /* Only needed for GNU-mangled names. ANSI-mangled names work with the normal mechanisms. */ if (OPNAME_PREFIX_P (field_name)) { - char *opname = cplus_mangle_opname (field_name + 3, 0); + opname = cplus_mangle_opname (field_name + 3, 0); if (opname == NULL) - error ("No mangling for \"%s\"", field_name); + { + error ("No mangling for \"%s\"", field_name); + } mangled_name_len += strlen (opname); - mangled_name = (char *)xmalloc (mangled_name_len); + mangled_name = (char *) xmalloc (mangled_name_len); strncpy (mangled_name, field_name, 3); - mangled_name[3] = '\0'; - strcat (mangled_name, opname); + strcpy (mangled_name + 3, opname); } else { - mangled_name = (char *)xmalloc (mangled_name_len); + mangled_name = (char *) xmalloc (mangled_name_len); if (is_constructor) - mangled_name[0] = '\0'; + { + mangled_name[0] = '\0'; + } else - strcpy (mangled_name, field_name); + { + strcpy (mangled_name, field_name); + } } strcat (mangled_name, buf); - strcat (mangled_name, newname); - strcat (mangled_name, TYPE_FN_FIELD_PHYSNAME (f, j)); + strcat (mangled_name, physname); - return mangled_name; + return (mangled_name); } @@ -1440,6 +1450,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) char *copy; struct symbol *sym_class; int i1; + int is_quoted; struct symbol **sym_arr; struct type *t; char **physnames; @@ -1454,22 +1465,9 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) default_line = current_source_line; } + /* See if arg is *PC */ - /* Check to see if *ARGPTR points to a string that has been quoted with - gdb_completer_quote_characters. If so, P will be left pointing at - someplace other than *ARGPTR */ - - if (((p = skip_quoted (*argptr)) != *argptr) && - ((*(p - 1) != **argptr) || - (strchr (gdb_completer_quote_characters, **argptr) == NULL))) - { - /* Not quoted symbol string specification, reset P */ - p = *argptr; - } - - /* See if arg is *PC or '' */ - - if ((**argptr == '*') || (p != *argptr)) + if (**argptr == '*') { if (**argptr == '*') { @@ -1486,7 +1484,8 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */ - s = 0; + s = NULL; + is_quoted = (strchr (gdb_completer_quote_characters, **argptr) != NULL); for (p = *argptr; *p; p++) { @@ -1495,7 +1494,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) } while (p[0] == ' ' || p[0] == '\t') p++; - if (p[0] == ':') + if ((p[0] == ':') && !is_quoted) { /* C++ */ @@ -1532,7 +1531,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) char *tmp = alloca (q1 - q + 1); memcpy (tmp, q, q1 - q); tmp[q1 - q] = '\0'; - opname = cplus_mangle_opname (tmp, 1); + opname = cplus_mangle_opname (tmp, DMGL_ANSI); if (opname == NULL) { warning ("no mangling for \"%s\"", tmp); @@ -1857,6 +1856,7 @@ decode_line_2 (sym_arr, nelts, funfirstline) char *args, *arg1; int i; char *prompt; + char *demangled; values.sals = (struct symtab_and_line *) alloca (nelts * sizeof(struct symtab_and_line)); return_values.sals = (struct symtab_and_line *) xmalloc (nelts * sizeof(struct symtab_and_line)); @@ -1875,8 +1875,15 @@ decode_line_2 (sym_arr, nelts, funfirstline) values.sals[i] = find_pc_line (pc, 0); values.sals[i].pc = (values.sals[i].end && values.sals[i].pc != pc) ? values.sals[i].end : pc; - printf("[%d] file:%s; line number:%d\n", - (i+2), values.sals[i].symtab->filename, values.sals[i].line); + demangled = cplus_demangle (SYMBOL_NAME (sym_arr[i]), + DMGL_PARAMS | DMGL_ANSI); + printf("[%d] %s at %s:%d\n", (i+2), + demangled ? demangled : SYMBOL_NAME (sym_arr[i]), + values.sals[i].symtab->filename, values.sals[i].line); + if (demangled != NULL) + { + free (demangled); + } } else printf ("?HERE\n"); i++; @@ -2042,7 +2049,7 @@ static int name_match (name) char *name; { - char *demangled = cplus_demangle (name, 0); + char *demangled = cplus_demangle (name, DMGL_ANSI); if (demangled != NULL) { int cond = re_exec (demangled); diff --git a/gdb/valprint.c b/gdb/valprint.c index e8c99ec260c..0f4d27602c4 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1700,7 +1700,7 @@ type_print_base (type, stream, show, level) register int lastval; char *mangled_name; char *demangled_name; - + enum {s_none, s_public, s_private, s_protected} section_type; QUIT; wrap_here (" "); @@ -1731,7 +1731,8 @@ type_print_base (type, stream, show, level) break; case TYPE_CODE_STRUCT: - fprintf_filtered (stream, "struct "); + fprintf_filtered (stream, + HAVE_CPLUS_STRUCT (type) ? "class " : "struct "); goto struct_union; case TYPE_CODE_UNION: @@ -1765,6 +1766,8 @@ type_print_base (type, stream, show, level) /* If there is a base class for this type, do not print the field that it occupies. */ + + section_type = s_none; for (i = TYPE_N_BASECLASSES (type); i < len; i++) { QUIT; @@ -1773,6 +1776,40 @@ type_print_base (type, stream, show, level) !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5)) continue; + /* If this is a C++ class we can print the various C++ section + labels. */ + + if (HAVE_CPLUS_STRUCT (type)) + { + if (TYPE_FIELD_PROTECTED (type, i)) + { + if (section_type != s_protected) + { + section_type = s_protected; + print_spaces_filtered (level + 4, stream); + fprintf_filtered (stream, "protected:\n"); + } + } + else if (TYPE_FIELD_PRIVATE (type, i)) + { + if (section_type != s_private) + { + section_type = s_private; + print_spaces_filtered (level + 4, stream); + fprintf_filtered (stream, "private:\n"); + } + } + else + { + if (section_type != s_public) + { + section_type = s_public; + print_spaces_filtered (level + 4, stream); + fprintf_filtered (stream, "public:\n"); + } + } + } + print_spaces_filtered (level + 4, stream); if (TYPE_FIELD_STATIC (type, i)) { diff --git a/gdb/values.c b/gdb/values.c index 7ab825416bf..8c299ccb25c 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -27,6 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "command.h" #include "gdbcmd.h" #include "target.h" +#include "demangle.h" /* Local function prototypes. */ @@ -1067,7 +1068,7 @@ value_headof (arg, btype, dtype) { pc_for_sym = value_as_pointer (value_field (best_entry, 2)); sym = find_pc_function (pc_for_sym); - demangled_name = cplus_demangle (SYMBOL_NAME (sym), 0); + demangled_name = cplus_demangle (SYMBOL_NAME (sym), DMGL_ANSI); *(strchr (demangled_name, ':')) = '\0'; } sym = lookup_symbol (demangled_name, 0, VAR_NAMESPACE, 0, 0); -- 2.30.2