From 93fe4e330ebd39ea1b061383fe3521deb961e93a Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Sat, 22 Feb 1992 09:16:11 +0000 Subject: [PATCH] Saberlint. * symmisc.c, xcoffread.c: Move debug functions to symmisc.c. --- gdb/ChangeLog | 7 +- gdb/buildsym.c | 1 - gdb/dwarfread.c | 3 - gdb/gdbtypes.c | 11 +-- gdb/minsyms.c | 1 - gdb/printcmd.c | 189 ++++++++++++++++++++++++++++++++++--------------- gdb/saber.suppress | 2 + gdb/xcoffread.c | 201 +---------------------------------------------------- 8 files changed, 148 insertions(+), 267 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dedc0ed..16ab8de 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -10,6 +10,10 @@ Sat Feb 22 00:56:39 1992 Stu Grossman (grossman at cygnus.com) Sat Feb 22 00:08:50 1992 John Gilmore (gnu at cygnus.com) + * buildsym.c, dwarfread.c, gdbtypes.c, inflow.c, main.c, + minsyms.c, printcmd.c, remote.c, saber.suppress: Saberlint. + * symmisc.c, xcoffread.c: Move debug functions to symmisc.c. + * xm-sun3os4.h, xm-sun4os4.h: Enable HAVE_MMAP. * minsyms.c (install_minimal_symbols): Add bunches to any @@ -27,7 +31,8 @@ Sat Feb 22 00:08:50 1992 John Gilmore (gnu at cygnus.com) Fri Feb 21 17:29:54 1992 John Gilmore (gnu at cygnus.com) * Check in Fred Fish's changes in these modules. Fred - will make ChangeLog entries for all of them. + will make ChangeLog entries for all of them. Update VERSION + to 4.4.2. * Makefile.in * altos-xdep.c diff --git a/gdb/buildsym.c b/gdb/buildsym.c index c90c558..11d5091 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -969,7 +969,6 @@ scan_file_globals (objfile) struct objfile *objfile; { int hash; - int mf; struct minimal_symbol *msymbol; struct symbol *sym, *prev; diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 399ff47..0f0a8bd 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -1160,9 +1160,6 @@ read_tag_pointer_type (dip) { struct type *type; struct type *utype; - char *sub; - char *subend; - short temp; type = decode_die_type (dip); if ((utype = lookup_utype (dip -> dieref)) == NULL) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9190871..c67b41c 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "defs.h" +#include #include "bfd.h" #include "symtab.h" #include "symfile.h" @@ -50,7 +51,7 @@ alloc_type (objfile) type = (struct type *) obstack_alloc (&objfile -> type_obstack, sizeof (struct type)); } - (void) memset (type, 0, sizeof (struct type)); + (void) memset ((char *)type, 0, sizeof (struct type)); /* Initialize the fields that might not be zero. */ @@ -249,7 +250,7 @@ smash_to_member_type (type, domain, to_type) objfile = TYPE_OBJFILE (type); - (void) memset (type, 0, sizeof (struct type)); + (void) memset ((char *)type, 0, sizeof (struct type)); TYPE_OBJFILE (type) = objfile; TYPE_TARGET_TYPE (type) = to_type; TYPE_DOMAIN_TYPE (type) = domain; @@ -276,7 +277,7 @@ smash_to_method_type (type, domain, to_type, args) objfile = TYPE_OBJFILE (type); - (void) memset (type, 0, sizeof (struct type)); + (void) memset ((char *)type, 0, sizeof (struct type)); TYPE_OBJFILE (type) = objfile; TYPE_TARGET_TYPE (type) = to_type; TYPE_DOMAIN_TYPE (type) = domain; @@ -603,7 +604,7 @@ check_stub_type (type) (struct symtab **) NULL); if (sym) { - memcpy (type, SYMBOL_TYPE(sym), sizeof (struct type)); + memcpy ((char *)type, (char *)SYMBOL_TYPE(sym), sizeof (struct type)); } } } @@ -789,7 +790,7 @@ lookup_fundamental_type (objfile, typeid) nbytes = FT_NUM_MEMBERS * sizeof (struct type *); objfile -> fundamental_types = (struct type **) obstack_alloc (&objfile -> type_obstack, nbytes); - (void) memset (objfile -> fundamental_types, 0, nbytes); + (void) memset ((char *)objfile -> fundamental_types, 0, nbytes); } typep = objfile -> fundamental_types + typeid; if ((type = *typep) == NULL) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 974596e..865b5a6 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -404,7 +404,6 @@ install_minimal_symbols (objfile) register int mcount; register struct msym_bunch *bunch; register struct minimal_symbol *msymbols; - int nbytes; int alloc_count; if (msym_count > 0) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a9a2fdf..9e75ab2 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -22,20 +22,18 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include "frame.h" #include "symtab.h" +#include "gdbtypes.h" #include "value.h" #include "language.h" #include "expression.h" #include "gdbcore.h" #include "gdbcmd.h" #include "target.h" +#include "breakpoint.h" extern int asm_demangle; /* Whether to demangle syms in asm printouts */ extern int addressprint; /* Whether to print hex addresses in HLL " */ -extern struct block *get_current_block (); - -static void print_frame_nameless_args (); - struct format_data { int count; @@ -77,10 +75,116 @@ int current_display_number; int inspect_it = 0; -static void do_one_display (); +enum display_status {disabled, enabled}; + +struct display +{ + /* Chain link to next auto-display item. */ + struct display *next; + /* Expression to be evaluated and displayed. */ + struct expression *exp; + /* Item number of this auto-display item. */ + int number; + /* Display format specified. */ + struct format_data format; + /* Innermost block required by this expression when evaluated */ + struct block *block; + /* Status of this display (enabled or disabled) */ + enum display_status status; +}; + +/* Chain of expressions whose values should be displayed + automatically each time the program stops. */ + +static struct display *display_chain; + +static int display_number; + +/* Prototypes for local functions */ + +static void +delete_display PARAMS ((int)); + +static void +enable_display PARAMS ((char *)); + +static void +disable_display_command PARAMS ((char *, int)); + +static void +disassemble_command PARAMS ((char *, int)); + +static int +containing_function_bounds PARAMS ((CORE_ADDR, CORE_ADDR *, CORE_ADDR *)); -void do_displays (); -void print_scalar_formatted (); +static void +printf_command PARAMS ((char *, int)); + +static void +print_frame_nameless_args PARAMS ((CORE_ADDR, long, int, int, FILE *)); + +static void +display_info PARAMS ((void)); + +static void +do_one_display PARAMS ((struct display *)); + +static void +undisplay_command PARAMS ((char *)); + +static void +free_display PARAMS ((struct display *)); + +static void +display_command PARAMS ((char *, int)); + +static void +ptype_command PARAMS ((char *, int)); + +static struct type * +ptype_eval PARAMS ((struct expression *)); + +static void +whatis_command PARAMS ((char *, int)); + +static void +whatis_exp PARAMS ((char *, int)); + +static void +x_command PARAMS ((char *, int)); + +static void +address_info PARAMS ((char *, int)); + +static void +set_command PARAMS ((char *, int)); + +static void +output_command PARAMS ((char *, int)); + +static void +call_command PARAMS ((char *, int)); + +static void +inspect_command PARAMS ((char *, int)); + +static void +print_command PARAMS ((char *, int)); + +static void +print_command_1 PARAMS ((char *, int, int)); + +static void +validate_format PARAMS ((struct format_data, char *)); + +static void +do_examine PARAMS ((struct format_data, CORE_ADDR)); + +static void +print_formatted PARAMS ((value, int, int)); + +static struct format_data +decode_format PARAMS ((char **, int, int)); /* Decode a format specification. *STRING_PTR should point to it. @@ -93,11 +197,11 @@ void print_scalar_formatted (); found in the specification. In addition, *STRING_PTR is advanced past the specification and past all whitespace following it. */ -struct format_data +static struct format_data decode_format (string_ptr, oformat, osize) char **string_ptr; - char oformat; - char osize; + int oformat; + int osize; { struct format_data val; register char *p = *string_ptr; @@ -191,8 +295,8 @@ decode_format (string_ptr, oformat, osize) static void print_formatted (val, format, size) register value val; - register char format; - char size; + register int format; + int size; { int len = TYPE_LENGTH (VALUE_TYPE (val)); @@ -236,7 +340,7 @@ void print_scalar_formatted (valaddr, type, format, size, stream) char *valaddr; struct type *type; - char format; + int format; int size; FILE *stream; { @@ -467,20 +571,20 @@ print_address_symbolic (addr, stream, do_demangle, leadin) char *leadin; { int name_location; - register int i = find_pc_misc_function (addr); + register struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (addr); /* If nothing comes out, don't print anything symbolic. */ - if (i < 0) + if (msymbol == NULL) return; fputs_filtered (leadin, stream); fputs_filtered ("<", stream); if (do_demangle) - fputs_demangled (misc_function_vector[i].name, stream, 1); + fputs_demangled (msymbol -> name, stream, 1); else - fputs_filtered (misc_function_vector[i].name, stream); - name_location = misc_function_vector[i].address; + fputs_filtered (msymbol -> name, stream); + name_location = msymbol -> address; if (addr - name_location) fprintf_filtered (stream, "+%d>", addr - name_location); else @@ -649,9 +753,10 @@ print_command_1 (exp, inspect, voidprint) type = VALUE_TYPE (val); if (objectprint - && (TYPE_CODE (type) == TYPE_CODE_PTR + && ( TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_CODE (type) == TYPE_CODE_REF) - && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT) + && ( TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT + || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_UNION)) { value v; @@ -768,6 +873,7 @@ address_info (exp, from_tty) int from_tty; { register struct symbol *sym; + register struct minimal_symbol *msymbol; register long val; int is_a_field_of_this; /* C++: lookup_symbol sets this to nonzero if exp is a field of `this'. */ @@ -779,21 +885,17 @@ address_info (exp, from_tty) &is_a_field_of_this, (struct symtab **)NULL); if (sym == 0) { - register int i; - if (is_a_field_of_this) { printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp); return; } - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, exp)) - break; + msymbol = lookup_minimal_symbol (exp, (struct objfile *) NULL); - if (i < misc_function_count) + if (msymbol != NULL) printf ("Symbol \"%s\" is at %s in a file compiled without debugging.\n", - exp, local_hex_string(misc_function_vector[i].address)); + exp, local_hex_string(msymbol -> address)); else error ("No symbol \"%s\" in current context.", exp); return; @@ -1009,31 +1111,6 @@ ptype_command (typename, from_tty) whatis_exp (typename, 1); } -enum display_status {disabled, enabled}; - -struct display -{ - /* Chain link to next auto-display item. */ - struct display *next; - /* Expression to be evaluated and displayed. */ - struct expression *exp; - /* Item number of this auto-display item. */ - int number; - /* Display format specified. */ - struct format_data format; - /* Innermost block required by this expression when evaluated */ - struct block *block; - /* Status of this display (enabled or disabled) */ - enum display_status status; -}; - -/* Chain of expressions whose values should be displayed - automatically each time the program stops. */ - -static struct display *display_chain; - -static int display_number; - /* Add an expression to the auto-display chain. Specify the expression. */ @@ -1114,7 +1191,7 @@ clear_displays () /* Delete the auto-display number NUM. */ -void +static void delete_display (num) int num; { @@ -1310,7 +1387,7 @@ Num Enb Expression\n"); } } -void +static void enable_display (args) char *args; { @@ -1350,7 +1427,7 @@ enable_display (args) } /* ARGSUSED */ -void +static void disable_display_command (args, from_tty) char *args; int from_tty; @@ -1674,7 +1751,7 @@ printf_command (arg, from_tty) { char *s1; if (nargs == allocated_args) - val_args = (value *) xrealloc (val_args, + val_args = (value *) xrealloc ((char *) val_args, (allocated_args *= 2) * sizeof (value)); s1 = s; diff --git a/gdb/saber.suppress b/gdb/saber.suppress index b1e1772..7ea1a86 100644 --- a/gdb/saber.suppress +++ b/gdb/saber.suppress @@ -394,6 +394,8 @@ suppress 590 on ignore_symbol /* Formal param not used */ suppress 590 on ignore_symbols /* Formal param not used */ +suppress 590 on signo +/* Formal param not used */ suppress 652 in ../bfd/libaout.h /* The declaration has no effect */ suppress 442 in ../bfd/archive.c diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 207a54b..13c0e17 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -166,42 +166,6 @@ aixcoff_symfile_init PARAMS ((struct sym_fns *)); static void aixcoff_new_init PARAMS ((void)); -static void -dump_minimal_symbols PARAMS ((struct objfile *)); - -static void -dump_symtab_lines PARAMS ((struct symtab *)); - -static void -dump_symtabs PARAMS ((struct symtab *)); - -static void -dump_last_symtab PARAMS ((struct symtab *)); - -static void -dump_blockvector PARAMS ((struct blockvector *)); - -static void -dump_block PARAMS ((struct block *)); - -static char * -dump_addrclass PARAMS ((int)); - -static char * -dump_namespace PARAMS ((int)); - -static void -dump_symbol PARAMS ((struct symbol *)); - -static void -dump_type PARAMS ((struct type *)); - -static void -dump_linetable PARAMS ((struct linetable *)); - -static void -dump_strtbl PARAMS ((void)); - static int init_lineno PARAMS ((bfd *, long, int)); @@ -1098,170 +1062,7 @@ init_lineno (abfd, offset, size) make_cleanup (free, linetab); /* Be sure it gets de-allocated. */ return 0; } - - -static void -dump_strtbl () -{ - int ii; - printf ("===STRING TABLE DUMP...\n\n"); - for ( ii=0; ii < strtbl_len; ++ii ) - printf ("%c", isprint (*(strtbl+ii)) ? *(strtbl+ii) : ' '); - printf ("\n"); -} - -static void -dump_linetable (ltb) - struct linetable *ltb; -{ - int ii; - for (ii=0; ii < ltb->nitems; ++ii) - printf ("line: %d, addr: 0x%x\n", ltb->item[ii].line, ltb->item[ii].pc); -} - -static void -dump_type (typeP) - struct type *typeP; -{ - printf ("0x%x: name: %s\n", typeP, typeP->name ? typeP->name : "(nil)"); -} - -static void -dump_symbol (pp) - struct symbol *pp; -{ - printf (" sym: %s\t%s,\t%s\ttype: 0x%x, val: 0x%x end: 0x%x\n", - pp->name, dump_namespace (pp->namespace), - dump_addrclass (pp->class), pp->type, - SYMBOL_CLASS(pp) == LOC_BLOCK ? BLOCK_START(SYMBOL_BLOCK_VALUE(pp)) - : pp->value.value, - SYMBOL_CLASS(pp) == LOC_BLOCK ? BLOCK_END(SYMBOL_BLOCK_VALUE(pp)) : 0); -} - -static char * -dump_namespace (ns) -int ns; -{ - static char *ns_name [] = { - "UNDEF_NS", "VAR_NS", "STRUCT_NS", "LABEL_NS"}; - - switch (ns) { - case UNDEF_NAMESPACE: - case VAR_NAMESPACE: - case STRUCT_NAMESPACE: - case LABEL_NAMESPACE: - return ns_name[ns]; - } - - return "***ERROR***"; -} - -static char * -dump_addrclass (ac) -int ac; /* address class */ -{ - static char *ac_name [] = { - "LOC_UNDEF", - "LOC_CONST", - "LOC_STATIC", - "LOC_REGISTER", - "LOC_ARG", - "LOC_REF_ARG", - "LOC_REGPARM", - "LOC_LOCAL", - "LOC_TYPEDEF", - "LOC_LABEL", - "LOC_BLOCK", - "LOC_CONST_BYTES", - "LOC_LOCAL_ARG", - }; - switch (ac) { - case LOC_UNDEF: - case LOC_CONST: - case LOC_STATIC: - case LOC_REGISTER: - case LOC_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_LOCAL: - case LOC_TYPEDEF: - case LOC_LABEL: - case LOC_BLOCK: - case LOC_CONST_BYTES: - case LOC_LOCAL_ARG: - return ac_name [ac]; - } - return "***ERROR***"; -} - -static void -dump_block (pp) - struct block *pp; -{ - int ii; - printf ("BLOCK..: start: 0x%x, end: 0x%x\n", pp->startaddr, pp->endaddr); - for (ii=0; ii < pp->nsyms; ++ii) - dump_symbol (pp->sym[ii]); -} - -static void -dump_blockvector (pp) - struct blockvector *pp; -{ - int ii; - for (ii=0; ii < pp->nblocks; ++ii) - dump_block (pp->block [ii]); -} - -static void -dump_last_symtab (pp) - struct symtab *pp; -{ - for ( ; pp; pp = pp->next) { - if ( pp->next == 0 ) { - printf ("SYMTAB NAME: %s\n", pp->filename); - dump_blockvector (pp->blockvector); - } - } -} - -static void -dump_symtabs (pp) - struct symtab *pp; -{ - for ( ; pp; pp = pp->next) { - printf ("SYMTAB NAME: %s\n", pp->filename ? pp->filename : "(nil)"); -/* if (pp->linetable) - dump_linetable (pp->linetable); */ - dump_blockvector (pp->blockvector); - } -} - -static void -dump_symtab_lines (pp) - struct symtab *pp; -{ - for ( ; pp; pp = pp->next) { - printf ("SYMTAB NAME: %s\n", pp->filename ? pp->filename : "(nil)"); - if (pp->linetable) - dump_linetable (pp->linetable); - /* dump_blockvector (pp->blockvector); */ - } -} - -static void -dump_minimal_symbols (objfile) -struct objfile *objfile; -{ - struct minimal_symbol *msymbol; - - for (msymbol = objfile -> msymbols; msymbol -> name != NULL; msymbol++) - { - printf ("name: %s, addr: 0x%x\n", msymbol -> name, msymbol -> address); - } -} - - + /* dbx allows the text of a symbol name to be continued into the next symbol name! When such a continuation is encountered (a \ at the end of the text of a name) -- 2.7.4