From 51b57ded888cbdacb5ad126363f8ae6adc9541b6 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Mon, 29 Jun 1992 23:34:38 +0000 Subject: [PATCH] * dbxread.c, i386-pinsn.c, i386-tdep.c, regex.c, solib.c, symmisc.c, symtab.h, tm-i386v4.h, valprint.c, values.c: Lint. * breakpoint.c, c-exp.y, coffread.c, command.c, environ.c, eval.c, findvar.c, infcmd.c, infptrace.c, infrun.c, m2-exp.y, parse.c, putenv.c, solib.c, sparc-xdep.c, symtab.c, tm-i386v.h, tm-sparc.h, utils.c, valarith.c, valops.c, valprint.c, values.c: Replace bcopy() use with memcpy(), which is more standard and can take advantage of gcc's builtin functions for increased performance. * breakpoint.c, buildsym.c, coffread.c, dbxread.c, i386-tdep.c, ieee-float.c, infcmd.c, sparc-tdep.c, stack.c, symtab.c, symtab.h, target.c, values.c: Replace bzero() use with memset(), which is more standard and can take advantage of gcc's builtin functions for increased performance. * i386-tdep.c, main.c, valprint.c: Replace bcmp() use with memcmp(), which is more standard and can take advantage of gcc's builtin functions for increased performance. --- gdb/ChangeLog | 19 +++++ gdb/breakpoint.c | 16 ++-- gdb/buildsym.c | 22 +++--- gdb/c-exp.y | 2 +- gdb/coffread.c | 23 +++--- gdb/command.c | 2 +- gdb/cplus-dem.c | 39 ++++++---- gdb/dbxread.c | 6 +- gdb/defs.h | 12 +++ gdb/elfread.c | 11 +++ gdb/environ.c | 49 ++++++------ gdb/eval.c | 2 +- gdb/findvar.c | 153 ++++++++++++++++++++---------------- gdb/i386-pinsn.c | 85 +++++++++++++++++--- gdb/i386-tdep.c | 42 +++++++++- gdb/ieee-float.c | 2 +- gdb/infcmd.c | 2 +- gdb/infptrace.c | 6 +- gdb/infrun.c | 4 +- gdb/language.c | 9 ++- gdb/m2-exp.y | 2 +- gdb/main.c | 230 ++++++++++++++++++++++++++++++++++++++----------------- gdb/mipsread.c | 17 ++-- gdb/objfiles.c | 1 - gdb/parse.c | 10 +-- gdb/procfs.c | 6 +- gdb/putenv.c | 2 +- gdb/regex.c | 3 +- gdb/solib.c | 52 ++++++++++--- gdb/sparc-tdep.c | 2 +- gdb/sparc-xdep.c | 42 +++++----- gdb/stack.c | 2 +- gdb/symmisc.c | 43 ++++++++--- gdb/symtab.c | 15 ++-- gdb/symtab.h | 24 +++++- gdb/target.c | 4 +- gdb/tm-i386v.h | 8 +- gdb/tm-i386v4.h | 3 + gdb/tm-sparc.h | 16 ++-- gdb/utils.c | 100 +++++++++++++++++++++++- gdb/valarith.c | 11 ++- gdb/valops.c | 30 +++++--- gdb/valprint.c | 22 ++++-- gdb/values.c | 59 +++++++------- 44 files changed, 837 insertions(+), 373 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4494748..75839fb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,22 @@ +Mon Jun 29 16:30:25 1992 Fred Fish (fnf@cygnus.com) + + * dbxread.c, i386-pinsn.c, i386-tdep.c, regex.c, solib.c, symmisc.c, + symtab.h, tm-i386v4.h, valprint.c, values.c: Lint. + * breakpoint.c, c-exp.y, coffread.c, command.c, environ.c, eval.c, + findvar.c, infcmd.c, infptrace.c, infrun.c, m2-exp.y, parse.c, + putenv.c, solib.c, sparc-xdep.c, symtab.c, tm-i386v.h, tm-sparc.h, + utils.c, valarith.c, valops.c, valprint.c, values.c: + Replace bcopy() use with memcpy(), which is more standard and can + take advantage of gcc's builtin functions for increased performance. + * breakpoint.c, buildsym.c, coffread.c, dbxread.c, i386-tdep.c, + ieee-float.c, infcmd.c, sparc-tdep.c, stack.c, symtab.c, symtab.h, + target.c, values.c: + Replace bzero() use with memset(), which is more standard and can + take advantage of gcc's builtin functions for increased performance. + * i386-tdep.c, main.c, valprint.c: + Replace bcmp() use with memcmp(), which is more standard and can + take advantage of gcc's builtin functions for increased performance. + Sun Jun 28 13:30:22 1992 Fred Fish (fnf@cygnus.com) * remote.c (remote_wait): Fix cast on signal() call. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index bf7148f..4f09111 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -391,8 +391,8 @@ read_memory_nobpt (memaddr, myaddr, len) bptlen -= (membpt + bptlen) - (memaddr + len); } - bcopy (b->shadow_contents + bptoffset, - myaddr + membpt - memaddr, bptlen); + (void) memcpy (myaddr + membpt - memaddr, + b->shadow_contents + bptoffset, bptlen); if (membpt > memaddr) { @@ -577,7 +577,7 @@ bpstat_copy (bs) for (; bs != NULL; bs = bs->next) { tmp = (bpstat) xmalloc (sizeof (*tmp)); - bcopy (bs, tmp, sizeof (*tmp)); + (void) memcpy (tmp, bs, sizeof (*tmp)); if (p == NULL) /* This is the first thing in the chain. */ retval = tmp; @@ -1209,7 +1209,7 @@ set_raw_breakpoint (sal) register struct breakpoint *b, *b1; b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint)); - bzero (b, sizeof *b); + (void) memset (b, 0, sizeof (*b)); b->address = sal.pc; b->symtab = sal.symtab; b->line_number = sal.line; @@ -1377,6 +1377,12 @@ mention (b) if (b->symtab) printf_filtered (": file %s, line %d.", b->symtab->filename, b->line_number); + break; + case bp_until: + case bp_finish: + case bp_longjmp: + case bp_longjmp_resume: + break; } printf_filtered ("\n"); } @@ -1796,7 +1802,7 @@ get_catch_sals (this_level_only) bl = blockvector_for_pc (BLOCK_END (block) - 4, &index); blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); - bzero (blocks_searched, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); + (void) memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); while (block != 0) { diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 4417177..bf8cdda 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -220,8 +220,8 @@ dbx_lookup_type (typenums) type_vector = (struct type **) xrealloc ((char *) type_vector, (type_vector_length * sizeof (struct type *))); - bzero (&type_vector[old_len], - (type_vector_length - old_len) * sizeof (struct type *)); + (void) memset (&type_vector[old_len], 0, + (type_vector_length - old_len) * sizeof (struct type *)); } return &type_vector[index]; } @@ -243,8 +243,8 @@ dbx_lookup_type (typenums) f->length *= 2; f->vector = (struct type **) xrealloc ((char *) f->vector, f->length * sizeof (struct type *)); - bzero (&f->vector[f_orig_length], - (f->length - f_orig_length) * sizeof (struct type *)); + (void) memset (&f->vector[f_orig_length], 0, + (f->length - f_orig_length) * sizeof (struct type *)); } return &f->vector[index]; } @@ -968,7 +968,7 @@ void buildsym_new_init () { /* Empty the hash table of global syms looking for values. */ - bzero (global_sym_chain, sizeof global_sym_chain); + (void) memset (global_sym_chain, 0, sizeof global_sym_chain); buildsym_init (); } @@ -2825,7 +2825,7 @@ read_array_type (pp, type, objfile) /* Create range type. */ range_type = (struct type *) obstack_alloc (&objfile -> type_obstack, sizeof (struct type)); - bzero (range_type, sizeof (struct type)); + (void) memset (range_type, 0, sizeof (struct type)); TYPE_OBJFILE (range_type) = objfile; TYPE_CODE (range_type) = TYPE_CODE_RANGE; TYPE_TARGET_TYPE (range_type) = index_type; @@ -2905,7 +2905,7 @@ read_enum_type (pp, type, objfile) n = read_number (pp, ','); sym = (struct symbol *) obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol)); - bzero (sym, sizeof (struct symbol)); + (void) memset (sym, 0, sizeof (struct symbol)); SYMBOL_NAME (sym) = name; SYMBOL_CLASS (sym) = LOC_CONST; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; @@ -3254,7 +3254,7 @@ read_range_type (pp, typenums, objfile) result_type = (struct type *) obstack_alloc (&objfile -> type_obstack, sizeof (struct type)); - bzero (result_type, sizeof (struct type)); + (void) memset (result_type, 0, sizeof (struct type)); TYPE_OBJFILE (result_type) = objfile; TYPE_LENGTH (result_type) = nbits / TARGET_CHAR_BIT; TYPE_CODE (result_type) = TYPE_CODE_INT; @@ -3366,7 +3366,7 @@ read_range_type (pp, typenums, objfile) result_type = (struct type *) obstack_alloc (&objfile -> type_obstack, sizeof (struct type)); - bzero (result_type, sizeof (struct type)); + (void) memset (result_type, 0, sizeof (struct type)); TYPE_OBJFILE (result_type) = objfile; TYPE_CODE (result_type) = TYPE_CODE_RANGE; @@ -3381,7 +3381,7 @@ read_range_type (pp, typenums, objfile) TYPE_FIELDS (result_type) = (struct field *) obstack_alloc (&objfile -> type_obstack, 2 * sizeof (struct field)); - bzero (TYPE_FIELDS (result_type), 2 * sizeof (struct field)); + (void) memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field)); TYPE_FIELD_BITPOS (result_type, 0) = n2; TYPE_FIELD_BITPOS (result_type, 1) = n3; @@ -3469,7 +3469,7 @@ read_args (pp, end, objfile) else if (TYPE_CODE (types[n-1]) != TYPE_CODE_VOID) { rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *)); - bzero (rval + n, sizeof (struct type *)); + (void) memset (rval + n, 0, sizeof (struct type *)); } else { diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 5e6932c..20effd2 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1221,7 +1221,7 @@ yylex () { char *err_copy = (char *) alloca (p - tokstart + 1); - bcopy (tokstart, err_copy, p - tokstart); + (void) memcpy (err_copy, tokstart, p - tokstart); err_copy[p - tokstart] = 0; error ("Invalid number \"%s\".", err_copy); } diff --git a/gdb/coffread.c b/gdb/coffread.c index 75468f7..959c3bf 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -324,7 +324,7 @@ coff_lookup_type (index) type_vector = (struct type **) xrealloc ((char *) type_vector, type_vector_length * sizeof (struct type *)); - bzero (&type_vector[old_vector_length], + (void) memset (&type_vector[old_vector_length], 0, (type_vector_length - old_vector_length) * sizeof(struct type *)); } return &type_vector[index]; @@ -776,7 +776,6 @@ coff_symfile_read (objfile, addr, mainline) int num_symbols; int symtab_offset; int stringtab_offset; - struct symtab *s; info = (struct coff_symfile_info *) objfile -> sym_private; symfile_bfd = abfd; /* Kludge for swap routines */ @@ -919,14 +918,14 @@ read_coff_symtab (symtab_offset, nsyms, objfile) nlist_stream_global = stream; nlist_nsyms_global = nsyms; last_source_file = 0; - bzero (opaque_type_chain, sizeof opaque_type_chain); + (void) memset (opaque_type_chain, 0, sizeof opaque_type_chain); if (type_vector) /* Get rid of previous one */ free ((PTR)type_vector); type_vector_length = 160; type_vector = (struct type **) xmalloc (type_vector_length * sizeof (struct type *)); - bzero (type_vector, type_vector_length * sizeof (struct type *)); + (void) memset (type_vector, 0, type_vector_length * sizeof (struct type *)); coff_start_symtab (); @@ -1319,7 +1318,7 @@ init_stringtab (chan, offset) if (stringtab == NULL) return -1; - bcopy (&length, stringtab, sizeof length); + (void) memcpy (stringtab, &length, sizeof length); if (length == sizeof length) /* Empty table -- just the count */ return 0; @@ -1426,7 +1425,7 @@ init_lineno (chan, offset, size) return -1; /* Terminate it with an all-zero sentinel record */ - bzero (linetab + size, local_linesz); + (void) memset (linetab + size, 0, local_linesz); make_cleanup (free, linetab); /* Be sure it gets de-allocated. */ return 0; @@ -1485,7 +1484,7 @@ patch_type (type, real_type) TYPE_FIELDS (target) = (struct field *) obstack_alloc (¤t_objfile -> type_obstack, field_size); - bcopy (TYPE_FIELDS (real_target), TYPE_FIELDS (target), field_size); + (void) memcpy (TYPE_FIELDS (target), TYPE_FIELDS (real_target), field_size); if (TYPE_NAME (real_target)) { @@ -1576,7 +1575,7 @@ process_coff_symbol (cs, aux, objfile) #endif struct type *temptype; - bzero (sym, sizeof (struct symbol)); + (void) memset (sym, 0, sizeof (struct symbol)); name = cs->c_name; name = (name[0] == '_' ? name + offset : name); SYMBOL_NAME (sym) = obstack_copy0 (&objfile->symbol_obstack, name, strlen (name)); @@ -1595,8 +1594,8 @@ process_coff_symbol (cs, aux, objfile) struct type *new = (struct type *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct type)); - bcopy(lookup_function_type (decode_function_type (cs, cs->c_type, aux)), - new, sizeof(struct type)); + (void) memcpy (new, lookup_function_type (decode_function_type (cs, cs->c_type, aux)), + sizeof(struct type)); SYMBOL_TYPE (sym) = new; in_function_type = SYMBOL_TYPE(sym); #else @@ -1793,7 +1792,7 @@ decode_type (cs, c_type, aux) type = (struct type *) obstack_alloc (¤t_objfile -> type_obstack, sizeof (struct type)); - bzero (type, sizeof (struct type)); + (void) memset (type, 0, sizeof (struct type)); TYPE_OBJFILE (type) = current_objfile; base_type = decode_type (cs, new_c_type, aux); @@ -2104,7 +2103,7 @@ coff_read_enum_type (index, length, lastsym) { case C_MOE: sym = (struct symbol *) xmalloc (sizeof (struct symbol)); - bzero (sym, sizeof (struct symbol)); + (void) memset (sym, 0, sizeof (struct symbol)); SYMBOL_NAME (sym) = savestring (name, strlen (name)); SYMBOL_CLASS (sym) = LOC_CONST; diff --git a/gdb/command.c b/gdb/command.c index 0d2cfe7..51fa8f3 100644 --- a/gdb/command.c +++ b/gdb/command.c @@ -235,7 +235,7 @@ add_show_from_set (setcmd, list) struct cmd_list_element *showcmd = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element)); - bcopy (setcmd, showcmd, sizeof (struct cmd_list_element)); + (void) memcpy (showcmd, setcmd, sizeof (struct cmd_list_element)); delete_cmd (showcmd->name, list); showcmd->type = show_cmd; diff --git a/gdb/cplus-dem.c b/gdb/cplus-dem.c index 18418f0..69f0b29 100644 --- a/gdb/cplus-dem.c +++ b/gdb/cplus-dem.c @@ -175,8 +175,10 @@ typedef struct string /* Beware: these aren't required to be */ static char * mop_up PARAMS ((string *, struct work_stuff *, int)); +#if 0 static int demangle_method_args PARAMS ((string *, const char **, struct work_stuff *)); +#endif static int demangle_template PARAMS ((string *declp, const char **, struct work_stuff *)); @@ -211,8 +213,10 @@ string_init PARAMS ((string *)); static void string_clear PARAMS ((string *)); +#if 0 static int string_empty PARAMS ((string *)); +#endif static void string_append PARAMS ((string *, const char *)); @@ -335,7 +339,6 @@ cplus_demangle (mangled, options) string decl; int success = 0; struct work_stuff work[1]; - const char *p; char *demangled = NULL; if ((mangled != NULL) && (*mangled != '\0')) @@ -582,7 +585,6 @@ demangle_template (declp, mangled, work) struct work_stuff *work; { int i; - int n; string tname; string trawname; int is_pointer; @@ -662,8 +664,8 @@ demangle_template (declp, mangled, work) { case 'P': case 'R': - done = is_pointer = 1; - break; + done = is_pointer = 1; + break; case 'C': /* const */ case 'S': /* explicitly signed [char] */ case 'U': /* unsigned */ @@ -671,29 +673,29 @@ demangle_template (declp, mangled, work) case 'F': /* function */ case 'M': /* member function */ case 'O': /* ??? */ - old_p++; - continue; + old_p++; + continue; case 'Q': /* repetition of following */ case 'T': /* remembered type */ - abort (); - break; + abort (); + break; case 'v': /* void */ - abort (); - break; + abort (); + break; case 'x': /* long long */ case 'l': /* long */ case 'i': /* int */ case 's': /* short */ case 'c': /* char */ - done = is_integral = 1; - break; + done = is_integral = 1; + break; case 'r': /* long double */ case 'd': /* double */ case 'f': /* float */ - done = is_real = 1; - break; + done = is_real = 1; + break; default: - abort (); + abort (); } } if (is_integral) @@ -786,6 +788,7 @@ demangle_template (declp, mangled, work) success = demangle_args (declp, mangled, work); } } + return (success); } /* @@ -1839,6 +1842,8 @@ string_clear (s) s->p = s->b; } +#if 0 + static int string_empty (s) string *s; @@ -1846,6 +1851,8 @@ string_empty (s) return (s->b == s->p); } +#endif + static void string_append (p, s) string *p; @@ -1901,6 +1908,7 @@ string_prepend (p, s) } #if 0 + static void string_prepends (p, s) string *p, *s; @@ -1910,6 +1918,7 @@ string_prepends (p, s) string_prependn (p, s->b, s->p - s->b); } } + #endif static void diff --git a/gdb/dbxread.c b/gdb/dbxread.c index a1bb47a..1b60cd1 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -424,7 +424,7 @@ add_new_header_file (name, instance) header_files[i].length = 10; header_files[i].vector = (struct type **) xmalloc (10 * sizeof (struct type *)); - bzero (header_files[i].vector, 10 * sizeof (struct type *)); + (void) memset (header_files[i].vector, 0, 10 * sizeof (struct type *)); add_this_object_header_file (i); } @@ -1872,7 +1872,7 @@ process_one_symbol (type, desc, valu, name, offset, objfile) int i; struct symbol *sym = (struct symbol *) xmmalloc (objfile -> md, sizeof (struct symbol)); - bzero (sym, sizeof *sym); + (void) memset (sym, 0, sizeof *sym); SYMBOL_NAME (sym) = savestring (name, strlen (name)); SYMBOL_CLASS (sym) = LOC_BLOCK; SYMBOL_NAMESPACE (sym) = (enum namespace)((long) @@ -2014,7 +2014,7 @@ DEFUN(elfstab_build_psymtabs, (objfile, addr, mainline, DBX_STRINGTAB_SIZE (objfile) = stabstrsize; DBX_SYMTAB_OFFSET (objfile) = staboffset; - if (stabstrsize < 0) + if (stabstrsize < 0) /* FIXME: stabstrsize is unsigned; never true! */ error ("ridiculous string table size: %d bytes", stabstrsize); DBX_STRINGTAB (objfile) = (char *) obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1); diff --git a/gdb/defs.h b/gdb/defs.h index a7f2458..a4b0a23 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -643,6 +643,9 @@ perror PARAMS ((const char *)); /* 4.9.10.4 */ extern double atof PARAMS ((const char *nptr)); /* 4.10.1.1 */ +extern int +atoi PARAMS ((const char *)); /* 4.10.1.2 */ + #ifndef MALLOC_INCOMPATIBLE extern PTR @@ -661,6 +664,12 @@ qsort PARAMS ((void *base, size_t nmemb, /* 4.10.5.2 */ size_t size, int (*comp)(const void *, const void *))); +extern PTR +memcpy PARAMS ((void *, const void *, size_t)); /* 4.11.2.1 */ + +extern int +memcmp PARAMS ((const void *, const void *, size_t)); /* 4.11.4.1 */ + extern char * strchr PARAMS ((const char *, int)); /* 4.11.5.2 */ @@ -673,6 +682,9 @@ strstr PARAMS ((const char *, const char *)); /* 4.11.5.7 */ extern char * strtok PARAMS ((char *, const char *)); /* 4.11.5.8 */ +extern PTR +memset PARAMS ((void *, int, size_t)); /* 4.11.6.1 */ + extern char * strerror PARAMS ((int)); /* 4.11.6.2 */ diff --git a/gdb/elfread.c b/gdb/elfread.c index d9c76d8..56e3a89 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -69,9 +69,16 @@ elf_symfile_finish PARAMS ((struct objfile *)); static void elf_symtab_read PARAMS ((bfd *, CORE_ADDR, struct objfile *)); +#if 0 static void record_minimal_symbol PARAMS ((char *, CORE_ADDR, enum minimal_symbol_type, struct objfile *)); +#endif + +static void +record_minimal_symbol_and_info PARAMS ((char *, CORE_ADDR, + enum minimal_symbol_type, char *, + struct objfile *)); static void elf_locate_sections PARAMS ((bfd *, asection *, PTR)); @@ -169,6 +176,8 @@ DESCRIPTION */ +#if 0 /* FIXME: Unused */ + static void record_minimal_symbol (name, address, ms_type, objfile) char *name; @@ -180,6 +189,8 @@ record_minimal_symbol (name, address, ms_type, objfile) prim_record_minimal_symbol (name, address, ms_type); } +#endif + static void record_minimal_symbol_and_info (name, address, ms_type, info, objfile) char *name; diff --git a/gdb/environ.c b/gdb/environ.c index 45767e5..bdc784a 100644 --- a/gdb/environ.c +++ b/gdb/environ.c @@ -1,29 +1,28 @@ /* environ.c -- library for manipulating environments for GNU. Copyright (C) 1986, 1989 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 - the Free Software Foundation; either version 1, or (at your option) - any later version. +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 +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - 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. */ +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. */ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) +#include "defs.h" #include "environ.h" #include +#include "defs.h" /* For strsave(). */ -extern char *xmalloc (); -extern char *xrealloc (); -extern void free (); /* Return a new environment object. */ @@ -74,13 +73,13 @@ init_environ (e) (e->allocated + 1) * sizeof (char *)); } - bcopy (environ, e->vector, (i + 1) * sizeof (char *)); + (void) memcpy (e->vector, environ, (i + 1) * sizeof (char *)); while (--i >= 0) { register int len = strlen (e->vector[i]); register char *new = (char *) xmalloc (len + 1); - bcopy (e->vector[i], new, len + 1); + (void) memcpy (new, e->vector[i], len + 1); e->vector[i] = new; } } @@ -99,14 +98,14 @@ environ_vector (e) char * get_in_environ (e, var) - struct environ *e; - char *var; + const struct environ *e; + const char *var; { register int len = strlen (var); register char **vector = e->vector; register char *s; - for (; s = *vector; vector++) + for (; (s = *vector) != NULL; vector++) if (!strncmp (s, var, len) && s[len] == '=') return &s[len + 1]; @@ -119,15 +118,15 @@ get_in_environ (e, var) void set_in_environ (e, var, value) struct environ *e; - char *var; - char *value; + const char *var; + const char *value; { register int i; register int len = strlen (var); register char **vector = e->vector; register char *s; - for (i = 0; s = vector[i]; i++) + for (i = 0; (s = vector[i]) != NULL; i++) if (!strncmp (s, var, len) && s[len] == '=') break; @@ -175,13 +174,13 @@ unset_in_environ (e, var) register char **vector = e->vector; register char *s; - for (; s = *vector; vector++) + for (; (s = *vector) != NULL; vector++) if (!strncmp (s, var, len) && s[len] == '=') { free (s); - bcopy (vector + 1, vector, - (e->allocated - (vector - e->vector)) * sizeof (char *)); + (void) memcpy (vector, vector + 1, + (e->allocated - (vector - e->vector)) * sizeof (char *)); e->vector[e->allocated - 1] = 0; return; } diff --git a/gdb/eval.c b/gdb/eval.c index 9aa3f61..2b70c4b 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1068,7 +1068,7 @@ parse_and_eval_type (p, length) char *tmp = (char *)alloca (length + 4); struct expression *expr; tmp[0] = '('; - bcopy (p, tmp+1, length); + (void) memcpy (tmp+1, p, length); tmp[length+1] = ')'; tmp[length+2] = '0'; tmp[length+3] = '\0'; diff --git a/gdb/findvar.c b/gdb/findvar.c index b65853e..3563c58 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -17,9 +17,9 @@ 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 "defs.h" #include "symtab.h" +#include "gdbtypes.h" #include "frame.h" #include "value.h" #include "gdbcore.h" @@ -129,7 +129,7 @@ get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) if (optimized != NULL) *optimized = 0; addr = find_saved_register (frame, regnum); - if (addr != NULL) + if (addr != 0) { if (lval != NULL) *lval = lval_memory; @@ -171,8 +171,9 @@ read_relative_register_raw_bytes (regnum, myaddr) int optim; if (regnum == FP_REGNUM && selected_frame) { - bcopy (&FRAME_FP(selected_frame), myaddr, sizeof (CORE_ADDR)); - SWAP_TARGET_AND_HOST (myaddr, sizeof (CORE_ADDR)); /* in target order */ + (void) memcpy (myaddr, &FRAME_FP(selected_frame), + REGISTER_RAW_SIZE(FP_REGNUM)); + SWAP_TARGET_AND_HOST (myaddr, REGISTER_RAW_SIZE(FP_REGNUM)); /* in target order */ return 0; } @@ -201,8 +202,8 @@ value_of_register (regnum) target_convert_to_virtual (regnum, raw_buffer, virtual_buffer); val = allocate_value (REGISTER_VIRTUAL_TYPE (regnum)); - bcopy (virtual_buffer, VALUE_CONTENTS_RAW (val), - REGISTER_VIRTUAL_SIZE (regnum)); + (void) memcpy (VALUE_CONTENTS_RAW (val), virtual_buffer, + REGISTER_VIRTUAL_SIZE (regnum)); VALUE_LVAL (val) = lval; VALUE_ADDRESS (val) = addr; VALUE_REGNO (val) = regnum; @@ -262,7 +263,7 @@ read_register_bytes (regbyte, myaddr, len) break; } if (myaddr != NULL) - bcopy (®isters[regbyte], myaddr, len); + (void) memcpy (myaddr, ®isters[regbyte], len); } /* Read register REGNO into memory at MYADDR, which must be large enough @@ -276,7 +277,8 @@ read_register_gen (regno, myaddr) { if (!register_valid[regno]) target_fetch_registers (regno); - bcopy (®isters[REGISTER_BYTE (regno)], myaddr, REGISTER_RAW_SIZE (regno)); + (void) memcpy (myaddr, ®isters[REGISTER_BYTE (regno)], + REGISTER_RAW_SIZE (regno)); } /* Copy LEN bytes of consecutive data from memory at MYADDR @@ -290,22 +292,24 @@ write_register_bytes (regbyte, myaddr, len) { /* Make sure the entire registers array is valid. */ read_register_bytes (0, (char *)NULL, REGISTER_BYTES); - bcopy (myaddr, ®isters[regbyte], len); + (void) memcpy (®isters[regbyte], myaddr, len); target_store_registers (-1); } /* Return the contents of register REGNO, regarding it as an integer. */ +/* FIXME, this loses when the REGISTER_VIRTUAL (REGNO) is true. Also, + why is the return type CORE_ADDR rather than some integer type? */ CORE_ADDR read_register (regno) int regno; { - int reg; + REGISTER_TYPE reg; + if (!register_valid[regno]) target_fetch_registers (regno); - /* FIXME, this loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - reg = *(int *) ®isters[REGISTER_BYTE (regno)]; - SWAP_TARGET_AND_HOST (®, sizeof (int)); + memcpy (®, ®isters[REGISTER_BYTE (regno)], sizeof (REGISTER_TYPE)); + SWAP_TARGET_AND_HOST (®, sizeof (REGISTER_TYPE)); return reg; } @@ -315,24 +319,27 @@ read_register (regno) #endif /* Store VALUE in the register number REGNO, regarded as an integer. */ +/* FIXME, this loses when REGISTER_VIRTUAL (REGNO) is true. Also, + shouldn't the val arg be a LONGEST or something? */ void write_register (regno, val) int regno, val; { + REGISTER_TYPE reg; + /* On the sparc, writing %g0 is a no-op, so we don't even want to change the registers array if something writes to this register. */ if (CANNOT_STORE_REGISTER (regno)) return; - SWAP_TARGET_AND_HOST (&val, sizeof (int)); + reg = val; + SWAP_TARGET_AND_HOST (®, sizeof (REGISTER_TYPE)); target_prepare_to_store (); register_valid [regno] = 1; - /* FIXME, this loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - /* FIXME, this depends on REGISTER_BYTE (regno) being aligned for host */ - *(int *) ®isters[REGISTER_BYTE (regno)] = val; + memcpy (®isters[REGISTER_BYTE (regno)], ®, sizeof (REGISTER_TYPE)); target_store_registers (regno); } @@ -347,7 +354,8 @@ supply_register (regno, val) char *val; { register_valid[regno] = 1; - bcopy (val, ®isters[REGISTER_BYTE (regno)], REGISTER_RAW_SIZE (regno)); + (void) memcpy (®isters[REGISTER_BYTE (regno)], val, + REGISTER_RAW_SIZE (regno)); } /* Given a struct symbol for a variable, @@ -376,14 +384,14 @@ read_var_value (var, frame) switch (SYMBOL_CLASS (var)) { case LOC_CONST: - bcopy (&SYMBOL_VALUE (var), VALUE_CONTENTS_RAW (v), len); + (void) memcpy (VALUE_CONTENTS_RAW (v), &SYMBOL_VALUE (var), len); SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (v), len); VALUE_LVAL (v) = not_lval; return v; case LOC_LABEL: addr = SYMBOL_VALUE_ADDRESS (var); - bcopy (&addr, VALUE_CONTENTS_RAW (v), len); + (void) memcpy (VALUE_CONTENTS_RAW (v), &addr, len); SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (v), len); VALUE_LVAL (v) = not_lval; return v; @@ -392,7 +400,7 @@ read_var_value (var, frame) { char *bytes_addr; bytes_addr = SYMBOL_VALUE_BYTES (var); - bcopy (bytes_addr, VALUE_CONTENTS_RAW (v), len); + (void) memcpy (VALUE_CONTENTS_RAW (v), bytes_addr, len); VALUE_LVAL (v) = not_lval; return v; } @@ -401,43 +409,59 @@ read_var_value (var, frame) addr = SYMBOL_VALUE_ADDRESS (var); break; -/* Nonzero if a struct which is located in a register or a LOC_ARG - really contains - the address of the struct, not the struct itself. GCC_P is nonzero - if the function was compiled with GCC. */ -#if !defined (REG_STRUCT_HAS_ADDR) -#define REG_STRUCT_HAS_ADDR(gcc_p) 0 -#endif - case LOC_ARG: - fi = get_frame_info (frame); - if (fi == NULL) - return 0; - addr = FRAME_ARGS_ADDRESS (fi); - if (!addr) { - return 0; - } + if (SYMBOL_BASEREG_VALID (var)) + { + addr = FRAME_GET_BASEREG_VALUE (frame, SYMBOL_BASEREG (var)); + } + else + { + fi = get_frame_info (frame); + if (fi == NULL) + return 0; + addr = FRAME_ARGS_ADDRESS (fi); + } + if (!addr) + { + return 0; + } addr += SYMBOL_VALUE (var); break; case LOC_REF_ARG: - fi = get_frame_info (frame); - if (fi == NULL) - return 0; - addr = FRAME_ARGS_ADDRESS (fi); - if (!addr) { - return 0; - } + if (SYMBOL_BASEREG_VALID (var)) + { + addr = FRAME_GET_BASEREG_VALUE (frame, SYMBOL_BASEREG (var)); + } + else + { + fi = get_frame_info (frame); + if (fi == NULL) + return 0; + addr = FRAME_ARGS_ADDRESS (fi); + } + if (!addr) + { + return 0; + } addr += SYMBOL_VALUE (var); - read_memory (addr, &addr, sizeof (CORE_ADDR)); + read_memory (addr, (char *) &addr, sizeof (CORE_ADDR)); break; case LOC_LOCAL: case LOC_LOCAL_ARG: - fi = get_frame_info (frame); - if (fi == NULL) - return 0; - addr = SYMBOL_VALUE (var) + FRAME_LOCALS_ADDRESS (fi); + if (SYMBOL_BASEREG_VALID (var)) + { + addr = FRAME_GET_BASEREG_VALUE (frame, SYMBOL_BASEREG (var)); + } + else + { + fi = get_frame_info (frame); + if (fi == NULL) + return 0; + addr = FRAME_LOCALS_ADDRESS (fi); + } + addr += SYMBOL_VALUE (var); break; case LOC_TYPEDEF: @@ -459,8 +483,17 @@ read_var_value (var, frame) v = value_from_register (type, SYMBOL_VALUE (var), frame); + /* Nonzero if a struct which is located in a register or a LOC_ARG + really contains + the address of the struct, not the struct itself. GCC_P is nonzero + if the function was compiled with GCC. */ +#if !defined (REG_STRUCT_HAS_ADDR) +#define REG_STRUCT_HAS_ADDR(gcc_p) 0 +#endif + if (REG_STRUCT_HAS_ADDR (BLOCK_GCC_COMPILED (b)) - && TYPE_CODE (type) == TYPE_CODE_STRUCT) + && ( (TYPE_CODE (type) == TYPE_CODE_STRUCT) + || (TYPE_CODE (type) == TYPE_CODE_UNION))) addr = *(CORE_ADDR *)VALUE_CONTENTS (v); else return v; @@ -575,7 +608,7 @@ value_from_register (type, regnum, frame) endian machines. */ /* Copy into the contents section of the value. */ - bcopy (value_bytes, VALUE_CONTENTS_RAW (v), len); + (void) memcpy (VALUE_CONTENTS_RAW (v), value_bytes, len); return v; } @@ -607,11 +640,11 @@ value_from_register (type, regnum, frame) with raw type `extended' and virtual type `double'. Fetch it as a `double' and then convert to `float'. */ v = allocate_value (REGISTER_VIRTUAL_TYPE (regnum)); - bcopy (virtual_buffer, VALUE_CONTENTS_RAW (v), len); + (void) memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer, len); v = value_cast (type, v); } else - bcopy (virtual_buffer, VALUE_CONTENTS_RAW (v), len); + (void) memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer, len); } else { @@ -625,8 +658,8 @@ value_from_register (type, regnum, frame) } #endif - bcopy (virtual_buffer + VALUE_OFFSET (v), - VALUE_CONTENTS_RAW (v), len); + (void) memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer + VALUE_OFFSET (v), + len); } return v; @@ -657,18 +690,6 @@ locate_var_value (var, frame) || TYPE_CODE (type) == TYPE_CODE_FUNC) { addr = VALUE_ADDRESS (lazy_value); - - /* C++: The "address" of a reference should yield the address - * of the object pointed to. So force an extra de-reference. */ - - if (TYPE_CODE (type) == TYPE_CODE_REF) - { - char *buf = alloca (TYPE_LENGTH (type)); - read_memory (addr, buf, TYPE_LENGTH (type)); - addr = unpack_pointer (type, buf); - type = TYPE_TARGET_TYPE (type); - } - return value_from_longest (lookup_pointer_type (type), (LONGEST) addr); } diff --git a/gdb/i386-pinsn.c b/gdb/i386-pinsn.c index 89261aa..c6ecaa6 100644 --- a/gdb/i386-pinsn.c +++ b/gdb/i386-pinsn.c @@ -104,6 +104,8 @@ int OP_J(), OP_SEG(); int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C(); int OP_D(), OP_T(), OP_rm(); +static void dofloat (), putop (), append_prefix (), set_op (); +static int get16 (), get32 (); #define b_mode 1 #define v_mode 2 @@ -845,6 +847,7 @@ struct dis386 grps[][8] = { static int prefixes; +static void ckprefix () { prefixes = 0; @@ -916,13 +919,14 @@ extern void fputs_filtered (); * 100 bytes is certainly enough, unless symbol printing is added later * The function returns the length of this instruction in bytes. */ + +int i386dis (pc, inbuf, stream) int pc; unsigned char *inbuf; FILE *stream; { struct dis386 *dp; - char *p; int i; int enter_instruction; char *first, *second, *third; @@ -1297,7 +1301,7 @@ char *fgrps[][8] = { }, }; - +static void dofloat () { struct dis386 *dp; @@ -1335,20 +1339,27 @@ dofloat () } /* ARGSUSED */ +int OP_ST (ignore) + int ignore; { oappend ("%st"); + return (0); } /* ARGSUSED */ +int OP_STi (ignore) + int ignore; { sprintf (scratchbuf, "%%st(%d)", rm); oappend (scratchbuf); + return (0); } /* capital letters in template are macros */ +static void putop (template) char *template; { @@ -1383,13 +1394,14 @@ putop (template) static void oappend (s) -char *s; + char *s; { strcpy (obufp, s); obufp += strlen (s); *obufp = 0; } +static void append_prefix () { if (prefixes & PREFIX_CS) @@ -1406,17 +1418,21 @@ append_prefix () oappend ("%gs:"); } +int OP_indirE (bytemode) + int bytemode; { oappend ("*"); OP_E (bytemode); + return (0); } +int OP_E (bytemode) + int bytemode; { int disp; int havesib; - int didoutput = 0; int base; int index; int scale; @@ -1449,7 +1465,7 @@ OP_E (bytemode) oappend (""); break; } - return; + return (0); } append_prefix (); @@ -1525,9 +1541,12 @@ OP_E (bytemode) } oappend (")"); } + return (0); } +int OP_G (bytemode) + int bytemode; { switch (bytemode) { @@ -1550,8 +1569,10 @@ OP_G (bytemode) oappend (""); break; } + return (0); } +static int get32 () { int x = 0; @@ -1563,6 +1584,7 @@ get32 () return (x); } +static int get16 () { int x = 0; @@ -1572,14 +1594,17 @@ get16 () return (x); } +static void set_op (op) -int op; + int op; { op_index[op_ad] = op_ad; op_address[op_ad] = op; } +int OP_REG (code) + int code; { char *s; @@ -1610,9 +1635,12 @@ OP_REG (code) break; } oappend (s); + return (0); } +int OP_I (bytemode) + int bytemode; { int op; @@ -1632,13 +1660,16 @@ OP_I (bytemode) break; default: oappend (""); - return; + return (0); } sprintf (scratchbuf, "$0x%x", op); oappend (scratchbuf); + return (0); } +int OP_sI (bytemode) + int bytemode; { int op; @@ -1658,13 +1689,16 @@ OP_sI (bytemode) break; default: oappend (""); - return; + return (0); } sprintf (scratchbuf, "$0x%x", op); oappend (scratchbuf); + return (0); } +int OP_J (bytemode) + int bytemode; { int disp; int mask = -1; @@ -1688,25 +1722,31 @@ OP_J (bytemode) break; default: oappend (""); - return; + return (0); } disp = (start_pc + codep - start_codep + disp) & mask; set_op (disp); sprintf (scratchbuf, "0x%x", disp); oappend (scratchbuf); + return (0); } /* ARGSUSED */ +int OP_SEG (dummy) + int dummy; { static char *sreg[] = { "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", }; oappend (sreg[reg]); + return (0); } +int OP_DIR (size) + int size; { int seg, offset; @@ -1741,10 +1781,13 @@ OP_DIR (size) oappend (""); break; } + return (0); } /* ARGSUSED */ +int OP_OFF (bytemode) + int bytemode; { int off; @@ -1755,55 +1798,76 @@ OP_OFF (bytemode) sprintf (scratchbuf, "0x%x", off); oappend (scratchbuf); + return (0); } /* ARGSUSED */ +int OP_ESDI (dummy) + int dummy; { oappend ("%es:("); oappend (aflag ? "%edi" : "%di"); oappend (")"); + return (0); } /* ARGSUSED */ +int OP_DSSI (dummy) + int dummy; { oappend ("%ds:("); oappend (aflag ? "%esi" : "%si"); oappend (")"); + return (0); } /* ARGSUSED */ +int OP_ONE (dummy) + int dummy; { oappend ("1"); + return (0); } /* ARGSUSED */ +int OP_C (dummy) + int dummy; { codep++; /* skip mod/rm */ sprintf (scratchbuf, "%%cr%d", reg); oappend (scratchbuf); + return (0); } /* ARGSUSED */ +int OP_D (dummy) + int dummy; { codep++; /* skip mod/rm */ sprintf (scratchbuf, "%%db%d", reg); oappend (scratchbuf); + return (0); } /* ARGSUSED */ +int OP_T (dummy) + int dummy; { codep++; /* skip mod/rm */ sprintf (scratchbuf, "%%tr%d", reg); oappend (scratchbuf); + return (0); } +int OP_rm (bytemode) + int bytemode; { switch (bytemode) { @@ -1814,9 +1878,12 @@ OP_rm (bytemode) oappend (names16[rm]); break; } + return (0); } #define MAXLEN 20 + +int print_insn (memaddr, stream) CORE_ADDR memaddr; FILE *stream; diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index ab56e62..da3f3cb 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -21,6 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "frame.h" #include "inferior.h" #include "gdbcore.h" +#include "target.h" #ifdef USE_PROC_FS /* Target dependent support for /proc */ #include @@ -203,9 +204,9 @@ i386_get_frame_setup (pc) static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 }; pos = codestream_tell (); codestream_read (buf, 4); - if (bcmp (buf, proto1, 3) == 0) + if (memcmp (buf, proto1, 3) == 0) pos += 3; - else if (bcmp (buf, proto2, 4) == 0) + else if (memcmp (buf, proto2, 4) == 0) pos += 4; codestream_seek (pos); @@ -388,13 +389,12 @@ i386_frame_find_saved_regs (fip, fsrp) struct frame_saved_regs *fsrp; { long locals; - unsigned char *p; unsigned char op; CORE_ADDR dummy_bottom; CORE_ADDR adr; int i; - bzero (fsrp, sizeof *fsrp); + (void) memset (fsrp, 0, sizeof *fsrp); /* if frame is the end of a dummy, compute where the * beginning would be @@ -644,3 +644,37 @@ fill_fpregset (fpregsetp, regno) #endif /* defined (FP0_REGNUM) */ #endif /* USE_PROC_FS */ + +#ifdef GET_LONGJMP_TARGET + +/* Figure out where the longjmp will land. Slurp the args out of the stack. + We expect the first arg to be a pointer to the jmp_buf structure from which + we extract the pc (JB_PC) that we will land at. The pc is copied into PC. + This routine returns true on success. */ + +int +get_longjmp_target(pc) + CORE_ADDR *pc; +{ + CORE_ADDR sp, jb_addr; + + sp = read_register(SP_REGNUM); + + if (target_read_memory(sp + SP_ARG0, /* Offset of first arg on stack */ + (char *) &jb_addr, + sizeof(CORE_ADDR))) + return 0; + + + SWAP_TARGET_AND_HOST(&jb_addr, sizeof(CORE_ADDR)); + + if (target_read_memory(jb_addr + JB_PC * JB_ELEMENT_SIZE, (char *) pc, + sizeof(CORE_ADDR))) + return 0; + + SWAP_TARGET_AND_HOST(pc, sizeof(CORE_ADDR)); + + return 1; +} + +#endif /* GET_LONGJMP_TARGET */ diff --git a/gdb/ieee-float.c b/gdb/ieee-float.c index f170bd5..ee4ecd5 100644 --- a/gdb/ieee-float.c +++ b/gdb/ieee-float.c @@ -77,7 +77,7 @@ double_to_ieee_extended (ext_format, from, to) unsigned long mant0, mant1, exponent; unsigned char tobytes[8]; - bzero (to, TOTALSIZE); + (void) memset (to, 0, TOTALSIZE); if (dfrom == 0) return; /* Result is zero */ if (dfrom != dfrom) { diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 56deaac..04bf1ab 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -528,7 +528,7 @@ The expression which contained the function call has been discarded."); /* On return, the stack dummy has been popped already. */ - bcopy (stop_registers, buffer, sizeof stop_registers); + (void) memcpy (buffer, stop_registers, sizeof stop_registers); } /* Proceed until we reach a different source line with pc greater than diff --git a/gdb/infptrace.c b/gdb/infptrace.c index 5246157..e9fa66d 100644 --- a/gdb/infptrace.c +++ b/gdb/infptrace.c @@ -395,7 +395,8 @@ child_xfer_memory (memaddr, myaddr, len, write, target) /* Copy data to be written over corresponding part of buffer */ - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); + (void) memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, + len); /* Write the entire buffer. */ @@ -430,7 +431,8 @@ child_xfer_memory (memaddr, myaddr, len, write, target) } /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); + (void) memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), + len); } return len; } diff --git a/gdb/infrun.c b/gdb/infrun.c index 924bfcd..e8e4a7c 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1800,7 +1800,7 @@ save_inferior_status (inf_status, restore_stack_info) inf_status->restore_stack_info = restore_stack_info; inf_status->proceed_to_finish = proceed_to_finish; - bcopy (stop_registers, inf_status->stop_registers, REGISTER_BYTES); + (void) memcpy (inf_status->stop_registers, stop_registers, REGISTER_BYTES); record_selected_frame (&(inf_status->selected_frame_address), &(inf_status->selected_level)); @@ -1834,7 +1834,7 @@ restore_inferior_status (inf_status) breakpoint_proceeded = inf_status->breakpoint_proceeded; proceed_to_finish = inf_status->proceed_to_finish; - bcopy (inf_status->stop_registers, stop_registers, REGISTER_BYTES); + (void) memcpy (stop_registers, inf_status->stop_registers, REGISTER_BYTES); /* The inferior can be gone if the user types "print exit(0)" (and perhaps other times). */ diff --git a/gdb/language.c b/gdb/language.c index 3ad4136..c9fc34b 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -625,8 +625,9 @@ character_type (type) return (TYPE_CODE(type) == TYPE_CODE_INT) && TYPE_LENGTH(type) == sizeof(char) ? 1 : 0; + default: + return (0); } - return (0); } /* Returns non-zero if the value is a boolean type */ @@ -642,8 +643,9 @@ boolean_type (type) case language_c: case language_cplus: return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1; + default: + return (0); } - return (0); } /* Returns non-zero if the value is a floating-point type */ @@ -679,8 +681,9 @@ structured_type(type) return (TYPE_CODE(type) == TYPE_CODE_STRUCT) || (TYPE_CODE(type) == TYPE_CODE_SET) || (TYPE_CODE(type) == TYPE_CODE_ARRAY); + default: + return (0); } - return (0); } /* This page contains functions that return info about diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 7b70e4e..a6f96a3 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -987,7 +987,7 @@ yylex () { char *err_copy = (char *) alloca (p - tokstart + 1); - bcopy (tokstart, err_copy, p - tokstart); + (void) memcpy (err_copy, tokstart, p - tokstart); err_copy[p - tokstart] = 0; error ("Invalid number \"%s\".", err_copy); } diff --git a/gdb/main.c b/gdb/main.c index 3546525..544199f 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -1,5 +1,6 @@ /* Top level `main' program for GDB, the GNU debugger. - Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992 + Free Software Foundation, Inc. This file is part of GDB. @@ -19,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include "gdbcmd.h" +#include "call-cmds.h" #include "symtab.h" #include "inferior.h" #include "signals.h" @@ -648,7 +650,8 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); } error_pre_print = "\n\n"; - warning_pre_print = "\n\nwarning: "; + /* We may get more than one warning, don't double space all of them... */ + warning_pre_print = "\nwarning: "; /* Now perform all the actions indicated by the arguments. */ if (cdarg != NULL) @@ -664,7 +667,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); for (i = 0; i < ndir; i++) if (!setjmp (to_top_level)) directory_command (dirarg[i], 0); - free (dirarg); + free ((PTR)dirarg); do_cleanups (ALL_CLEANUPS); if (execarg != NULL @@ -772,9 +775,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); the same file (it should exist, also). */ if (!homedir - || bcmp ((char *) &homebuf, - (char *) &cwdbuf, - sizeof (struct stat))) + || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat))) if (!inhibit_gdbinit && access (gdbinit, R_OK) == 0) if (!setjmp (to_top_level)) source_command (gdbinit, 0); @@ -790,7 +791,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); source_command (cmdarg[i], !batch); do_cleanups (ALL_CLEANUPS); } - free (cmdarg); + free ((PTR)cmdarg); /* Read in the old history after all the command files have been read. */ initialize_history(); @@ -1020,6 +1021,11 @@ static char *history_filename; /* Variables which are necessary for fancy command line editing. */ char *gdb_completer_word_break_characters = " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,"; +/* Characters that can be used to quote completion strings. Note that we + can't include '"' because the gdb C parser treats such quoted sequences + as strings. */ +char *gdb_completer_quote_characters = + "'"; /* Functions that are used as part of the fancy command line editing. */ @@ -1033,39 +1039,52 @@ noop_completer (text) return NULL; } -/* Generate symbol names one by one for the completer. If STATE is - zero, then we need to initialize, otherwise the initialization has - already taken place. TEXT is what we expect the symbol to start - with. RL_LINE_BUFFER is available to be looked at; it contains the - entire text of the line. RL_POINT is the offset in that line of - the cursor. You should pretend that the line ends at RL_POINT. - The result is NULL if there are no more completions, else a char - string which is a possible completion. */ +/* Generate symbol names one by one for the completer. Each time we are + called return another potential completion to the caller. + + TEXT is what we expect the symbol to start with. + + MATCHES is the number of matches that have currently been collected from + calling this completion function. When zero, then we need to initialize, + otherwise the initialization has already taken place and we can just + return the next potential completion string. + Returns NULL if there are no more completions, else a pointer to a string + which is a possible completion. + + RL_LINE_BUFFER is available to be looked at; it contains the entire text + of the line. RL_POINT is the offset in that line of the cursor. You + should pretend that the line ends at RL_POINT. */ + static char * -symbol_completion_function (text, state) +symbol_completion_function (text, matches) char *text; - int state; + int matches; { - static char **list = (char **)NULL; - static int index; - char *output; - extern char *rl_line_buffer; - extern int rl_point; + static char **list = (char **)NULL; /* Cache of completions */ + static int index; /* Next cached completion */ + char *output = NULL; char *tmp_command, *p; struct cmd_list_element *c, *result_list; + extern char *rl_line_buffer; + extern int rl_point; - if (!state) + if (matches == 0) { - /* Free the storage used by LIST, but not by the strings inside. This is - because rl_complete_internal () frees the strings. */ + /* The caller is beginning to accumulate a new set of completions, so + we need to find all of them now, and cache them for returning one at + a time on future calls. */ + if (list) - free (list); + { + /* Free the storage used by LIST, but not by the strings inside. + This is because rl_complete_internal () frees the strings. */ + free ((PTR)list); + } list = 0; index = 0; - /* Decide whether to complete on a list of gdb commands or on - symbols. */ + /* Decide whether to complete on a list of gdb commands or on symbols. */ tmp_command = (char *) alloca (rl_point + 1); p = tmp_command; @@ -1074,21 +1093,27 @@ symbol_completion_function (text, state) if (rl_point == 0) { - /* An empty line we want to consider ambiguous; that is, - it could be any command. */ + /* An empty line we want to consider ambiguous; that is, it + could be any command. */ c = (struct cmd_list_element *) -1; result_list = 0; } else - c = lookup_cmd_1 (&p, cmdlist, &result_list, 1); + { + c = lookup_cmd_1 (&p, cmdlist, &result_list, 1); + } /* Move p up to the next interesting thing. */ while (*p == ' ' || *p == '\t') - p++; + { + p++; + } if (!c) - /* He's typed something unrecognizable. Sigh. */ - list = (char **) 0; + { + /* He's typed something unrecognizable. Sigh. */ + list = NULL; + } else if (c == (struct cmd_list_element *) -1) { /* If we didn't recognize everything up to the thing that @@ -1096,25 +1121,34 @@ symbol_completion_function (text, state) yet, we are in trouble. Part of the trouble might be that the list of delimiters used by readline includes '-', which we use in commands. Check for this. */ - if (p + strlen(text) != tmp_command + rl_point) { - if (tmp_command[rl_point - strlen(text) - 1] == '-') - text = p; - else { - /* This really should not produce an error. Better would - be to pretend to hit RETURN here; this would produce a - response like "Ambiguous command: foo, foobar, etc", - and leave the line available for re-entry with ^P. Instead, - this error blows away the user's typed input without - any way to get it back. */ - error (" Unrecognized command."); + + if (p + strlen(text) != tmp_command + rl_point) + { + if (tmp_command[rl_point - strlen(text) - 1] == '-') + { + text = p; + } + else + { + /* This really should not produce an error. Better would + be to pretend to hit RETURN here; this would produce a + response like "Ambiguous command: foo, foobar, etc", + and leave the line available for re-entry with ^P. + Instead, this error blows away the user's typed input + without any way to get it back. */ + error (" Unrecognized command."); + } } - } /* He's typed something ambiguous. This is easier. */ if (result_list) - list = complete_on_cmdlist (*result_list->prefixlist, text); + { + list = complete_on_cmdlist (*result_list->prefixlist, text); + } else - list = complete_on_cmdlist (cmdlist, text); + { + list = complete_on_cmdlist (cmdlist, text); + } } else { @@ -1128,48 +1162,91 @@ symbol_completion_function (text, state) command. */ if (!*p && *text) - /* Always (might be longer versions of thie command). */ - list = complete_on_cmdlist (result_list, text); + { + /* Always (might be longer versions of thie command). */ + list = complete_on_cmdlist (result_list, text); + } else if (!*p && !*text) { if (c->prefixlist) - list = complete_on_cmdlist (*c->prefixlist, ""); + { + list = complete_on_cmdlist (*c->prefixlist, ""); + } else - list = (*c->completer) (""); + { + list = (*c->completer) (""); + } } else { if (c->prefixlist && !c->allow_unknown) { -#if 0 - /* Something like "info adsfkdj". But error() is not - the proper response; just return no completions - instead. */ - *p = '\0'; - error ("\"%s\" command requires a subcommand.", - tmp_command); -#else + /* Something like "info adsfkdj". But error() is not the + proper response; just return no completions instead. */ list = NULL; -#endif } else - list = (*c->completer) (text); + { + list = (*c->completer) (text); + } } } } - /* If the debugged program wasn't compiled with symbols, or if we're - clearly completing on a command and no command matches, return - NULL. */ - if (!list) - return ((char *)NULL); + /* If we found a list of potential completions during initialization then + dole them out one at a time. The vector of completions is NULL + terminated, so after returning the last one, return NULL (and continue + to do so) each time we are called after that, until a new list is + available. */ - output = list[index]; - if (output) - index++; + if (list) + { + output = list[index]; + if (output) + { + index++; + } + } return (output); } + +/* Skip over a possibly quoted word (as defined by the quote characters + and word break characters the completer uses). Returns pointer to the + location after the "word". */ + +char * +skip_quoted (str) + char *str; +{ + char quote_char = '\0'; + char *scan; + + for (scan = str; *scan != '\0'; scan++) + { + if (quote_char != '\0') + { + /* Ignore everything until the matching close quote char */ + if (*scan == quote_char) + { + /* Found matching close quote. */ + scan++; + break; + } + } + else if (strchr (gdb_completer_quote_characters, *scan)) + { + /* Found start of a quoted string. */ + quote_char = *scan; + } + else if (strchr (gdb_completer_word_break_characters, *scan)) + { + break; + } + } + return (scan); +} + #ifdef STOP_SIGNAL static void @@ -1492,7 +1569,7 @@ free_command_lines (lptr) { next = l->next; free (l->line); - free (l); + free ((PTR)l); l = next; } } @@ -1601,6 +1678,14 @@ validate_comname (comname) } } +/* This is just a placeholder in the command data structures. */ +static void +user_defined_command (ignore, from_tty) + char *ignore; + int from_tty; +{ +} + static void define_command (comname, from_tty) char *comname; @@ -1646,7 +1731,7 @@ End with a line saying just \"end\".\n", comname); if (c && c->class == class_user) free_command_lines (&c->user_commands); - newc = add_cmd (comname, class_user, not_just_help_class_command, + newc = add_cmd (comname, class_user, user_defined_command, (c && c->class == class_user) ? c->doc : savestring ("User-defined.", 13), &cmdlist); newc->user_commands = cmds; @@ -2151,6 +2236,7 @@ initialize_main () /* Setup important stuff for command line editing. */ rl_completion_entry_function = (int (*)()) symbol_completion_function; rl_completer_word_break_characters = gdb_completer_word_break_characters; + rl_completer_quote_characters = gdb_completer_quote_characters; rl_readline_name = "gdb"; /* Define the classes of commands. diff --git a/gdb/mipsread.c b/gdb/mipsread.c index dd3171e..b4a81f1 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -71,6 +71,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "coff/mips.h" /* COFF-like aspects of ecoff files */ #include "coff/ecoff-ext.h" /* External forms of ecoff sym structures */ +#include "libbfd.h" /* FIXME Secret internal BFD stuff (bfd_read) */ #include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */ #include "aout/aout64.h" #include "aout/stab_gnu.h" /* STABS information */ @@ -340,8 +341,6 @@ mipscoff_symfile_read (objfile, addr, mainline) CORE_ADDR addr; int mainline; { - bfd *abfd = objfile -> obfd; - init_minimal_symbol_collection (); make_cleanup (discard_minimal_symbols, 0); @@ -385,10 +384,10 @@ static PTR xzalloc(size) unsigned int size; { - PTR p = xmalloc(size); + PTR p = xmalloc (size); - memset(p, 0, size); - return p; + (void) memset (p, 0, size); + return p; } /* Exported procedure: Builds a symtab from the PST partial one. @@ -524,6 +523,7 @@ fixup_symtab (hdr, data, f_ptr, abfd) /* This function depends on the external and internal forms of the MIPS symbol table taking identical space. Check this assumption at compile-time. */ +#if 0 /* FIXME: Unused */ static check_hdr1[1 + sizeof (struct hdr_ext) - sizeof (HDRR)] = {0}; static check_hdr2[1 + sizeof (HDRR) - sizeof (struct hdr_ext)] = {0}; static check_fdr1[1 + sizeof (struct fdr_ext) - sizeof (FDR)] = {0}; @@ -536,6 +536,7 @@ fixup_symtab (hdr, data, f_ptr, abfd) static check_ext2[1 + sizeof (EXTR) - sizeof (struct ext_ext)] = {0}; static check_rfd1[1 + sizeof (struct rfd_ext) - sizeof (RFDT)] = {0}; static check_rfd2[1 + sizeof (RFDT) - sizeof (struct rfd_ext)] = {0}; +#endif /* Swap in the header record. */ ecoff_swap_hdr_in (abfd, hdr, hdr); @@ -845,6 +846,8 @@ add_pending(fh, sh, t) /* Throw away undef entries when done with file index F_IDX */ /* FIXME -- storage leak. This is never called!!! --gnu */ +#if 0 + static void free_pending(f_idx) int f_idx; @@ -858,6 +861,8 @@ free_pending(f_idx) pending_list[f_idx] = 0; } +#endif + static char * prepend_tag_kind(tag_name, type_code) char *tag_name; @@ -1630,7 +1635,6 @@ parse_procedure (pr, bound, have_stabs) SYMR *sh = (SYMR*)pr->isym; struct block *b; struct mips_extra_func_info *e; - char name[100]; char *sh_name; /* Static procedure at address pr->adr. Sigh. */ @@ -2347,7 +2351,6 @@ psymtab_to_symtab_1(pst, filename) * This symbol table contains stabs-in-ecoff entries. */ - SYMR *sh; PDR *pr; /* Parse local symbols first */ diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 9b30c0f..7d670d1 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -248,7 +248,6 @@ void free_objfile (objfile) struct objfile *objfile; { - struct objfile *ofp; int mmfd; /* First do any symbol file specific actions required when we are diff --git a/gdb/parse.c b/gdb/parse.c index c8fc9b7..48c4169 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -219,7 +219,7 @@ write_exp_string (str) xrealloc ((char *) expout, (sizeof (struct expression) + (expout_size * sizeof (union exp_element)))); } - bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len); + (void) memcpy ((char *) &expout->elts[expout_ptr - lenelt], str.ptr, len); ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0; write_exp_elt_longcst ((LONGEST) len); } @@ -231,7 +231,7 @@ char * copy_name (token) struct stoken token; { - bcopy (token.ptr, namecopy, token.length); + (void) memcpy (namecopy, token.ptr, token.length); namecopy[token.length] = 0; return namecopy; } @@ -251,7 +251,7 @@ prefixify_expression (expr) temp = (struct expression *) alloca (len); /* Copy the original expression into temp. */ - bcopy (expr, temp, len); + (void) memcpy (temp, expr, len); prefixify_subexp (temp, expr, inpos, outpos); } @@ -481,8 +481,8 @@ prefixify_subexp (inexpr, outexpr, inend, outbeg) /* Copy the final operator itself, from the end of the input to the beginning of the output. */ inend -= oplen; - bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg], - oplen * sizeof (union exp_element)); + (void) memcpy (&outexpr->elts[outbeg], &inexpr->elts[inend], + oplen * sizeof (union exp_element)); outbeg += oplen; /* Find the lengths of the arg subexpressions. */ diff --git a/gdb/procfs.c b/gdb/procfs.c index f06915e..4af048b 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -40,9 +40,11 @@ regardless of whether or not the actual target has floating point hardware. #include #include #include +#include #include "inferior.h" #include "target.h" +#include "command.h" #define MAX_SYSCALLS 256 /* Maximum number of syscalls for table */ @@ -626,8 +628,6 @@ NOTES static void init_syscall_table () { - int syscallnum; - #if defined (SYS_exit) syscall_table[SYS_exit] = "exit"; #endif @@ -1466,7 +1466,6 @@ proc_iterate_over_mappings (func) int funcstat = 0; struct prmap *prmaps; struct prmap *prmap; - CORE_ADDR baseaddr = 0; if (pi.valid && (ioctl (pi.fd, PIOCNMAP, &nmap) == 0)) { @@ -2766,7 +2765,6 @@ info_proc (args, from_tty) struct procinfo pii; struct procinfo *pip; struct cleanup *old_chain; - char *nexttok; char **argv; int argsize; int summary = 1; diff --git a/gdb/putenv.c b/gdb/putenv.c index 15689e3..907a91e 100644 --- a/gdb/putenv.c +++ b/gdb/putenv.c @@ -100,7 +100,7 @@ putenv( entry ) if ( new_environ == (char **) NULL ) return( -1 ); - bcopy( (char *) environ, (char *) new_environ, size*PSIZE ); + (void) memcpy ((char *) new_environ, (char *) environ, size*PSIZE ); new_environ[size] = entry; new_environ[size+1] = NULL; diff --git a/gdb/regex.c b/gdb/regex.c index 59695cf..e4261b3 100644 --- a/gdb/regex.c +++ b/gdb/regex.c @@ -122,6 +122,7 @@ static int obscure_syntax = 0; int re_set_syntax (syntax) + int syntax; { int ret; @@ -706,7 +707,7 @@ re_compile_fastmap (bufp) register char *fastmap = bufp->fastmap; register unsigned char *p = pattern; register unsigned char *pend = pattern + size; - register int j, k; + register int j; unsigned char *translate = (unsigned char *) bufp->translate; unsigned char *stackb[NFAILURES]; diff --git a/gdb/solib.c b/gdb/solib.c index 6dc6572..d9ec318 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -94,12 +94,16 @@ struct so_list { struct objfile *objfile; /* objfile for loaded lib */ struct section_table *sections; struct section_table *sections_end; + struct section_table *textsection; }; static struct so_list *so_list_head; /* List of known shared objects */ static CORE_ADDR debug_base; /* Base of dynamic linker structures */ static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */ +extern int +fdmatch PARAMS ((int, int)); /* In libiberty */ + /* Local function prototypes */ static void @@ -115,7 +119,7 @@ static int disable_break PARAMS ((void)); static void -info_sharedlibrary_command PARAMS ((void)); +info_sharedlibrary_command PARAMS ((char *, int)); static int symbol_add_stub PARAMS ((char *)); @@ -223,6 +227,10 @@ solib_map_sections (so) p -> addr += (CORE_ADDR) LM_ADDR (so); p -> endaddr += (CORE_ADDR) LM_ADDR (so); so -> lmend = (CORE_ADDR) max (p -> endaddr, so -> lmend); + if (strcmp (p -> sec_ptr -> name, ".text") == 0) + { + so -> textsection = p; + } } } @@ -664,7 +672,8 @@ symbol_add_stub (arg) register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */ so -> objfile = symbol_file_add (so -> so_name, so -> from_tty, - (unsigned int) LM_ADDR (so), 0, 0, 0); + (unsigned int) so -> textsection -> addr, + 0, 0, 0); return (1); } @@ -765,8 +774,9 @@ solib_add (arg_string, from_tty, target) if (so -> so_name[0]) { count = so -> sections_end - so -> sections; - bcopy (so -> sections, (char *)(target -> to_sections + old), - (sizeof (struct section_table)) * count); + (void) memcpy ((char *) (target -> to_sections + old), + so -> sections, + (sizeof (struct section_table)) * count); old += count; } } @@ -791,7 +801,9 @@ DESCRIPTION */ static void -info_sharedlibrary_command () +info_sharedlibrary_command (ignore, from_tty) + char *ignore; + int from_tty; { register struct so_list *so = NULL; /* link map state variable */ int header_done = 0; @@ -1003,12 +1015,11 @@ static int enable_break () { - int j; - #ifndef SVR4_SHARED_LIBS + int j; int in_debugger; - + /* Get link_dynamic structure */ j = target_read_memory (debug_base, (char *) &dynamic_copy, @@ -1193,11 +1204,34 @@ special_symbol_handling (so) struct so_list *so; { #ifndef SVR4_SHARED_LIBS + int j; + + if (debug_addr == 0) + { + /* Get link_dynamic structure */ + + j = target_read_memory (debug_base, (char *) &dynamic_copy, + sizeof (dynamic_copy)); + if (j) + { + /* unreadable */ + return; + } + + /* Calc address of debugger interface structure */ + /* FIXME, this needs work for cross-debugging of core files + (byteorder, size, alignment, etc). */ + + debug_addr = (CORE_ADDR) dynamic_copy.ldd; + } /* Read the debugger structure from the inferior, just to make sure we have a current copy. */ - read_memory (debug_addr, (char *) &debug_copy, sizeof (debug_copy)); + j = target_read_memory (debug_addr, (char *) &debug_copy, + sizeof (debug_copy)); + if (j) + return; /* unreadable */ /* Get common symbol definitions for the loaded object. */ diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index eb25d4e..3bafd6a 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -464,7 +464,7 @@ sparc_frame_find_saved_regs (fi, saved_regs_addr) if (!fid) fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS"); - bzero (saved_regs_addr, sizeof (*saved_regs_addr)); + (void) memset (saved_regs_addr, 0, sizeof (*saved_regs_addr)); /* Old test. if (fi->pc >= frame - CALL_DUMMY_LENGTH - 0x140 diff --git a/gdb/sparc-xdep.c b/gdb/sparc-xdep.c index 2cc150e..42e0fd9 100644 --- a/gdb/sparc-xdep.c +++ b/gdb/sparc-xdep.c @@ -76,7 +76,7 @@ fetch_inferior_registers (regno) perror("ptrace_getregs"); registers[REGISTER_BYTE (0)] = 0; - bcopy (&inferior_registers.r_g1, ®isters[REGISTER_BYTE (1)], 15 * REGISTER_RAW_SIZE (G0_REGNUM)); + (void) memcpy (®isters[REGISTER_BYTE (1)], &inferior_registers.r_g1, 15 * REGISTER_RAW_SIZE (G0_REGNUM)); *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc; @@ -103,8 +103,9 @@ fetch_inferior_registers (regno) (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0)) perror("ptrace_getfpregs"); - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fpu_fr); + (void) memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)], + &inferior_fp_registers, + sizeof inferior_fp_registers.fpu_fr); /* bcopy (&inferior_fp_registers.Fpu_fsr, ®isters[REGISTER_BYTE (FPS_REGNUM)], sizeof (FPU_FSR_TYPE)); FIXME??? -- gnu@cyg */ @@ -209,8 +210,9 @@ store_inferior_registers (regno) { if (!register_valid[G1_REGNUM]) abort(); - bcopy (®isters[REGISTER_BYTE (G1_REGNUM)], - &inferior_registers.r_g1, 15 * REGISTER_RAW_SIZE (G1_REGNUM)); + (void) memcpy (&inferior_registers.r_g1, + ®isters[REGISTER_BYTE (G1_REGNUM)], + 15 * REGISTER_RAW_SIZE (G1_REGNUM)); inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; @@ -229,13 +231,13 @@ store_inferior_registers (regno) if (wanna_store & FP_REGS) { if (!register_valid[FP0_REGNUM+9]) abort(); - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], - &inferior_fp_registers, - sizeof inferior_fp_registers.fpu_fr); + (void) memcpy (&inferior_fp_registers, + ®isters[REGISTER_BYTE (FP0_REGNUM)], + sizeof inferior_fp_registers.fpu_fr); -/* bcopy (®isters[REGISTER_BYTE (FPS_REGNUM)], - &inferior_fp_registers.Fpu_fsr, - sizeof (FPU_FSR_TYPE)); +/* (void) memcpy (&inferior_fp_registers.Fpu_fsr, + ®isters[REGISTER_BYTE (FPS_REGNUM)], + sizeof (FPU_FSR_TYPE)); ****/ if (0 != ptrace (PTRACE_SETFPREGS, inferior_pid, @@ -261,9 +263,9 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, ignore) *(int *)®isters[REGISTER_BYTE (0)] = 0; /* The globals and output registers. */ - bcopy (&gregs->r_g1, - ®isters[REGISTER_BYTE (G1_REGNUM)], - 15 * REGISTER_RAW_SIZE (G1_REGNUM)); + (void) memcpy (®isters[REGISTER_BYTE (G1_REGNUM)], + &gregs->r_g1, + 15 * REGISTER_RAW_SIZE (G1_REGNUM)); *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps; *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc; *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc; @@ -293,12 +295,12 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, ignore) #define fpuregs ((struct fpu *) core_reg_sect) if (core_reg_size >= sizeof (struct fpu)) { - bcopy (fpuregs->fpu_regs, - ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof (fpuregs->fpu_regs)); - bcopy (&fpuregs->fpu_fsr, - ®isters[REGISTER_BYTE (FPS_REGNUM)], - sizeof (FPU_FSR_TYPE)); + (void) memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)], + fpuregs->fpu_regs, + sizeof (fpuregs->fpu_regs)); + (void) memcpy (®isters[REGISTER_BYTE (FPS_REGNUM)], + &fpuregs->fpu_fsr, + sizeof (FPU_FSR_TYPE)); } else fprintf (stderr, "Couldn't read float regs from core file\n"); diff --git a/gdb/stack.c b/gdb/stack.c index f0625e2..7857347 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -779,7 +779,7 @@ print_frame_label_vars (frame, this_level_only, stream) bl = blockvector_for_pc (BLOCK_END (block) - 4, &index); blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); - bzero (blocks_printed, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); + (void) memset (blocks_printed, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); while (block != 0) { diff --git a/gdb/symmisc.c b/gdb/symmisc.c index a78b399..b460734 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -26,6 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "breakpoint.h" #include "command.h" #include "obstack.h" +#include "language.h" #include @@ -255,7 +256,7 @@ dump_psymtab (objfile, psymtab, outfile) psymtab -> filename); fprintf_filtered (outfile, "(object 0x%x)\n\n", psymtab); fprintf (outfile, " Read from object file %s (0x%x)\n", - objfile -> name, objfile); + objfile -> name, (unsigned int) objfile); if (psymtab -> readin) { @@ -299,7 +300,7 @@ dump_symtab (objfile, symtab, outfile) fprintf (outfile, "\nSymtab for file %s\n", symtab->filename); fprintf (outfile, "Read from object file %s (%x)\n", objfile->name, - objfile); + (unsigned int) objfile); fprintf (outfile, "Language: %s\n", language_str (symtab -> language)); /* First print the line table. */ @@ -320,10 +321,10 @@ dump_symtab (objfile, symtab, outfile) b = BLOCKVECTOR_BLOCK (bv, i); depth = block_depth (b) * 2; print_spaces (depth, outfile); - fprintf (outfile, "block #%03d (object 0x%x) ", i, b); + fprintf (outfile, "block #%03d (object 0x%x) ", i, (unsigned int) b); fprintf (outfile, "[0x%x..0x%x]", BLOCK_START (b), BLOCK_END (b)); if (BLOCK_SUPERBLOCK (b)) - fprintf (outfile, " (under 0x%x)", BLOCK_SUPERBLOCK (b)); + fprintf (outfile, " (under 0x%x)", (unsigned int) BLOCK_SUPERBLOCK (b)); if (BLOCK_FUNCTION (b)) fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b))); fputc ('\n', outfile); @@ -461,12 +462,28 @@ print_symbol (symbol, depth, outfile) break; case LOC_ARG: - fprintf (outfile, "arg at 0x%lx,", SYMBOL_VALUE (symbol)); + if (SYMBOL_BASEREG_VALID (symbol)) + { + fprintf (outfile, "arg at 0x%lx from register %d,", + SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); + } + else + { + fprintf (outfile, "arg at 0x%lx,", SYMBOL_VALUE (symbol)); + } break; case LOC_LOCAL_ARG: - fprintf (outfile, "arg at offset 0x%x from fp,", - SYMBOL_VALUE (symbol)); + if (SYMBOL_BASEREG_VALID (symbol)) + { + fprintf (outfile, "arg at offset 0x%lx from register %d,", + SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); + } + else + { + fprintf (outfile, "arg at offset 0x%lx from fp,", + SYMBOL_VALUE (symbol)); + } case LOC_REF_ARG: fprintf (outfile, "reference arg at 0x%lx,", SYMBOL_VALUE (symbol)); @@ -477,7 +494,15 @@ print_symbol (symbol, depth, outfile) break; case LOC_LOCAL: - fprintf (outfile, "local at 0x%lx,", SYMBOL_VALUE (symbol)); + if (SYMBOL_BASEREG_VALID (symbol)) + { + fprintf (outfile, "local at 0x%lx from register %d", + SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); + } + else + { + fprintf (outfile, "local at 0x%lx,", SYMBOL_VALUE (symbol)); + } break; case LOC_TYPEDEF: @@ -489,7 +514,7 @@ print_symbol (symbol, depth, outfile) case LOC_BLOCK: fprintf (outfile, "block (object 0x%x) starting at 0x%x,", - SYMBOL_BLOCK_VALUE (symbol), + (unsigned int) SYMBOL_BLOCK_VALUE (symbol), BLOCK_START (SYMBOL_BLOCK_VALUE (symbol))); break; diff --git a/gdb/symtab.c b/gdb/symtab.c index 7c7f3b0..d92605e 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1494,7 +1494,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) p1 = p; while (p != *argptr && p[-1] == ' ') --p; copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); + (void) memcpy (copy, *argptr, p - *argptr); copy[p - *argptr] = 0; /* Discard the class name from the arg. */ @@ -1535,7 +1535,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) else { copy = (char *) alloca (p - *argptr + 1 + (q1 - q)); - bcopy (*argptr, copy, p - *argptr); + (void) memcpy (copy, *argptr, p - *argptr); copy[p - *argptr] = '\0'; } @@ -1630,7 +1630,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) p1 = p; while (p != *argptr && p[-1] == ' ') --p; copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); + (void) memcpy (copy, *argptr, p - *argptr); copy[p - *argptr] = 0; /* Find that file's data. */ @@ -1717,7 +1717,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) p = skip_quoted (*argptr); copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); + (void) memcpy (copy, *argptr, p - *argptr); copy[p - *argptr] = '\0'; if ((copy[0] == copy [p - *argptr - 1]) && strchr (gdb_completer_quote_characters, copy[0]) != NULL) @@ -1784,7 +1784,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) values.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line)); values.nelts = 1; - bzero (&values.sals[0], sizeof (values.sals[0])); + (void) memset (&values.sals[0], 0, sizeof (values.sals[0])); values.sals[0].symtab = sym_symtab; values.sals[0].line = SYMBOL_LINE (sym); return values; @@ -1899,7 +1899,8 @@ decode_line_2 (sym_arr, nelts, funfirstline) error ("cancelled"); else if (num == 1) { - bcopy (values.sals, return_values.sals, (nelts * sizeof(struct symtab_and_line))); + (void) memcpy (return_values.sals, values.sals, + (nelts * sizeof(struct symtab_and_line))); return_values.nelts = nelts; return return_values; } @@ -2729,7 +2730,7 @@ expensive_mangler (lookfor) to in_function_type if it was called correctly). Note that since we are modifying a type, the result of - lookup_function_type() should be bcopy()ed before calling + lookup_function_type() should be memcpy()ed before calling this. When not in strict typing mode, the expression evaluator can choose to ignore this. diff --git a/gdb/symtab.h b/gdb/symtab.h index eeb8a53..d8f51da 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -30,12 +30,12 @@ extern struct objfile *current_objfile; #define obstack_chunk_free free /* Some macros for char-based bitfields. */ -#define B_SET(a,x) (a[x>>3] |= (1 << (x&7))) -#define B_CLR(a,x) (a[x>>3] &= ~(1 << (x&7))) -#define B_TST(a,x) (a[x>>3] & (1 << (x&7))) +#define B_SET(a,x) ((a)[(x)>>3] |= (1 << ((x)&7))) +#define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7))) +#define B_TST(a,x) ((a)[(x)>>3] & (1 << ((x)&7))) #define B_TYPE unsigned char #define B_BYTES(x) ( 1 + ((x)>>3) ) -#define B_CLRALL(a,x) bzero (a, B_BYTES(x)) +#define B_CLRALL(a,x) (void) memset ((a), 0, B_BYTES(x)) /* Define a simple structure used to hold some very basic information about @@ -490,7 +490,15 @@ extern int current_source_line; #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain #define SYMBOL_TYPE(symbol) (symbol)->type #define SYMBOL_LINE(symbol) (symbol)->line +#if 0 +/* This currently fails because some symbols are not being initialized + to zero on allocation, and no code is currently setting this value. + Basereg handling will probably change significantly in the next release. + FIXME -fnf */ #define SYMBOL_BASEREG_VALID(symbol) (symbol)->aux_value.basereg.regno_valid +#else +#define SYMBOL_BASEREG_VALID(symbol) 0 +#endif #define SYMBOL_BASEREG(symbol) (symbol)->aux_value.basereg.regno /* The virtual function table is now an array of structures @@ -578,6 +586,11 @@ extern void prim_record_minimal_symbol PARAMS ((const char *, CORE_ADDR, enum minimal_symbol_type)); +extern void +prim_record_minimal_symbol_and_info PARAMS ((const char *, CORE_ADDR, + enum minimal_symbol_type, + char *info)); + extern struct minimal_symbol * lookup_minimal_symbol PARAMS ((const char *, struct objfile *)); @@ -672,6 +685,9 @@ make_symbol_completion_list PARAMS ((char *)); /* symtab.c */ +extern void +clear_symtab_users_once PARAMS ((void)); + extern struct partial_symtab * find_main_psymtab PARAMS ((void)); diff --git a/gdb/target.c b/gdb/target.c index 83fe708..d253623 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -27,6 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inferior.h" #include "bfd.h" #include "symfile.h" +#include "objfiles.h" extern int errno; @@ -169,6 +170,7 @@ nomemory (memaddr, myaddr, len, write) int len; int write; { + errno = EIO; /* Can't read/write this location */ return 0; /* No bytes handled */ } @@ -520,7 +522,7 @@ target_xfer_memory (memaddr, myaddr, len, write) /* If this address is for nonexistent memory, read zeros if reading, or do nothing if writing. Return error. */ if (!write) - bzero (myaddr, len); + (void) memset (myaddr, 0, len); if (errno == 0) return EIO; else diff --git a/gdb/tm-i386v.h b/gdb/tm-i386v.h index 21fca33..68875ba 100644 --- a/gdb/tm-i386v.h +++ b/gdb/tm-i386v.h @@ -179,12 +179,14 @@ i386_skip_prologue PARAMS ((int)); /* Convert data from raw format for register REGNUM to virtual format for register REGNUM. */ -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);} +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ + {(void) memcpy ((TO), (FROM), 4);} /* Convert data from virtual format for register REGNUM to raw format for register REGNUM. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);} +#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ + {(void) memcpy ((TO), (FROM), 4);} /* Return the GDB type object for the "standard" data type of data in register N. */ @@ -206,7 +208,7 @@ i386_skip_prologue PARAMS ((int)); into VALBUF. */ #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) + (void) memcpy ((VALBUF), (REGBUF), TYPE_LENGTH (TYPE)) /* Write into appropriate registers a function return value of type TYPE, given in virtual format. */ diff --git a/gdb/tm-i386v4.h b/gdb/tm-i386v4.h index 727e350..59a3733 100644 --- a/gdb/tm-i386v4.h +++ b/gdb/tm-i386v4.h @@ -63,4 +63,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ we extract the pc (JB_PC) that we will land at. The pc is copied into ADDR. This routine returns true on success */ +extern int +get_longjmp_target PARAMS ((CORE_ADDR *)); + #define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR) diff --git a/gdb/tm-sparc.h b/gdb/tm-sparc.h index 69cad05..09b6964 100644 --- a/gdb/tm-sparc.h +++ b/gdb/tm-sparc.h @@ -222,13 +222,13 @@ extern CORE_ADDR sparc_pc_adjust(); to virtual format for register REGNUM. */ #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ bcopy ((FROM), (TO), 4); } +{ (void) memcpy ((TO), (FROM), 4); } /* Convert data from virtual format for register REGNUM to raw format for register REGNUM. */ #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ bcopy ((FROM), (TO), 4); } +{ (void) memcpy ((TO), (FROM), 4); } /* Return the GDB type object for the "standard" data type of data in register N. */ @@ -256,13 +256,15 @@ extern CORE_ADDR sparc_pc_adjust(); { \ if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ { \ - bcopy (((int *)(REGBUF))+FP0_REGNUM, \ - (VALBUF), TYPE_LENGTH(TYPE)); \ + (void) memcpy ((VALBUF), \ + ((int *)(REGBUF))+FP0_REGNUM, \ + TYPE_LENGTH(TYPE)); \ } \ else \ - bcopy ((char *)(REGBUF) + 4 * 8 + \ - (TYPE_LENGTH(TYPE) >= 4 ? 0 : 4 - TYPE_LENGTH(TYPE)), \ - (VALBUF), TYPE_LENGTH(TYPE)); \ + (void) memcpy ((VALBUF), \ + (char *)(REGBUF) + 4 * 8 + \ + (TYPE_LENGTH(TYPE) >= 4 ? 0 : 4 - TYPE_LENGTH(TYPE)), \ + TYPE_LENGTH(TYPE)); \ } /* Write into appropriate registers a function return value diff --git a/gdb/utils.c b/gdb/utils.c index bdadedb..15efc73 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -18,10 +18,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" - +#if !defined(__GO32__) #include #include #include +#endif #include #include #include @@ -402,6 +403,7 @@ quit () { target_terminal_ours (); wrap_here ((char *)0); /* Force out any pending output */ +#if !defined(__GO32__) #ifdef HAVE_TERMIO ioctl (fileno (stdout), TCFLSH, 1); #else /* not HAVE_TERMIO */ @@ -412,6 +414,7 @@ quit () #else error ("Quit (expect signal %d when inferior is resumed)", SIGINT); #endif /* TIOCGPGRP */ +#endif } /* Control C comes here */ @@ -631,7 +634,7 @@ savestring (ptr, size) int size; { register char *p = (char *) xmalloc (size + 1); - bcopy (ptr, p, size); + (void) memcpy (p, ptr, size); p[size] = 0; return p; } @@ -643,7 +646,7 @@ msavestring (md, ptr, size) int size; { register char *p = (char *) xmmalloc (md, size + 1); - bcopy (ptr, p, size); + (void) memcpy (p, ptr, size); p[size] = 0; return p; } @@ -1285,6 +1288,24 @@ print_spaces_filtered (n, stream) /* C++ demangler stuff. */ +/* Make a copy of a symbol, applying C++ demangling if demangling is enabled + and a demangled version exists. Note that the value returned from + cplus_demangle is already allocated in malloc'd memory. */ + +char * +strdup_demangled (name) + const char *name; +{ + char *demangled = NULL; + + if (demangle) + { + demangled = cplus_demangle (name, DMGL_PARAMS | DMGL_ANSI); + } + return ((demangled != NULL) ? demangled : strdup (name)); +} + + /* Print NAME on STREAM, demangling if necessary. */ void fprint_symbol (stream, name) @@ -1301,6 +1322,73 @@ fprint_symbol (stream, name) free (demangled); } } + +/* Do a strcmp() type operation on STRING1 and STRING2, ignoring any + differences in whitespace. Returns 0 if they match, non-zero if they + don't (slightly different than strcmp()'s range of return values). */ + +int +strcmp_iw (string1, string2) + const char *string1; + const char *string2; +{ + while ((*string1 != '\0') && (*string2 != '\0')) + { + while (isspace (*string1)) + { + string1++; + } + while (isspace (*string2)) + { + string2++; + } + if (*string1 != *string2) + { + break; + } + if (*string1 != '\0') + { + string1++; + string2++; + } + } + return (!((*string1 == '\0') && (*string2 == '\0'))); +} + +/* Demangle NAME and compare the result with LOOKFOR, ignoring any differences + in whitespace. + + If a match is found, returns a pointer to the demangled version of NAME + in malloc'd memory, which needs to be freed by the caller after use. + If a match is not found, returns NULL. + + OPTIONS is a flags word that controls the demangling process and is just + passed on to the demangler. + + When the caller sees a non-NULL result, it knows that NAME is the mangled + equivalent of LOOKFOR, and it can use either NAME, the "official demangled" + version of NAME (the return value) or the "unofficial demangled" version + of NAME (LOOKFOR, which it already knows). */ + +char * +demangle_and_match (name, lookfor, options) + const char *name; + const char *lookfor; + int options; +{ + char *demangled; + + if ((demangled = cplus_demangle (name, options)) != NULL) + { + if (strcmp_iw (demangled, lookfor) != 0) + { + free (demangled); + demangled = NULL; + } + } + return (demangled); +} + void _initialize_utils () @@ -1322,6 +1410,10 @@ _initialize_utils () /* These defaults will be used if we are unable to get the correct values from termcap. */ +#if defined(__GO32__) + lines_per_page = ScreenRows(); + chars_per_line = ScreenCols(); +#else lines_per_page = 24; chars_per_line = 80; /* Initialize the screen height and width from termcap. */ @@ -1364,7 +1456,7 @@ _initialize_utils () /* If there is a better way to determine the window size, use it. */ SIGWINCH_HANDLER (); #endif - +#endif /* If the output is not a terminal, don't paginate it. */ if (!ISATTY (stdout)) lines_per_page = UINT_MAX; diff --git a/gdb/valarith.c b/gdb/valarith.c index c52a06e..4c0706b 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -17,11 +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 "defs.h" #include "value.h" #include "symtab.h" +#include "gdbtypes.h" #include "expression.h" #include "target.h" #include @@ -135,7 +134,8 @@ value_subscripted_rvalue (array, idx) error ("no such vector element"); v = allocate_value (elt_type); - bcopy (VALUE_CONTENTS (array) + elt_offs, VALUE_CONTENTS (v), elt_size); + (void) memcpy (VALUE_CONTENTS (v), VALUE_CONTENTS (array) + elt_offs, + elt_size); if (VALUE_LVAL (array) == lval_internalvar) VALUE_LVAL (v) = lval_internalvar_component; @@ -550,7 +550,7 @@ value_binop (arg1, arg2, op) return val; } -/* Simulate the C operator ! -- return 1 if ARG1 contains zeros. */ +/* Simulate the C operator ! -- return 1 if ARG1 contains zero. */ int value_zerop (arg1) @@ -561,6 +561,9 @@ value_zerop (arg1) COERCE_ARRAY (arg1); + if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_FLT) + return 0 == value_as_double (arg1); + len = TYPE_LENGTH (VALUE_TYPE (arg1)); p = VALUE_CONTENTS (arg1); diff --git a/gdb/valops.c b/gdb/valops.c index 1213e9e..8135cde 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -130,7 +130,7 @@ value_zero (type, lv) { register value val = allocate_value (type); - memset (VALUE_CONTENTS (val), 0, TYPE_LENGTH (type)); + (void) memset (VALUE_CONTENTS (val), 0, TYPE_LENGTH (type)); VALUE_LVAL (val) = lv; return val; @@ -323,7 +323,7 @@ value_assign (toval, fromval) amount_copied += reg_size, regno++) { get_saved_register (buffer + amount_copied, - (int *)NULL, (CORE_ADDR)NULL, + (int *)NULL, (CORE_ADDR *)NULL, frame, regno, (enum lval_type *)NULL); } @@ -333,10 +333,10 @@ value_assign (toval, fromval) (int) value_as_long (fromval), VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); else if (use_buffer) - bcopy (raw_buffer, buffer + byte_offset, use_buffer); + (void) memcpy (buffer + byte_offset, raw_buffer, use_buffer); else - bcopy (VALUE_CONTENTS (fromval), buffer + byte_offset, - TYPE_LENGTH (type)); + (void) memcpy (buffer + byte_offset, VALUE_CONTENTS (fromval), + TYPE_LENGTH (type)); /* Copy it back. */ for ((regno = VALUE_FRAME_REGNUM (toval) + reg_offset, @@ -379,8 +379,9 @@ value_assign (toval, fromval) } val = allocate_value (type); - bcopy (toval, val, VALUE_CONTENTS_RAW (val) - (char *) val); - bcopy (VALUE_CONTENTS (fromval), VALUE_CONTENTS_RAW (val), TYPE_LENGTH (type)); + (void) memcpy (val, toval, VALUE_CONTENTS_RAW (val) - (char *) val); + (void) memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval), + TYPE_LENGTH (type)); VALUE_TYPE (val) = type; return val; @@ -741,7 +742,7 @@ call_function_by_hand (function, nargs, args) /* Create a call sequence customized for this function and the number of arguments for it. */ - bcopy (dummy, dummy1, sizeof dummy); + (void) memcpy (dummy1, dummy, sizeof dummy); for (i = 0; i < sizeof dummy / sizeof (REGISTER_TYPE); i++) SWAP_TARGET_AND_HOST (&dummy1[i], sizeof (REGISTER_TYPE)); FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, @@ -1331,8 +1332,9 @@ check_field (arg1, name) to resolve user expressions of the form "DOMAIN::NAME". */ value -value_struct_elt_for_reference (domain, curtype, name, intype) +value_struct_elt_for_reference (domain, offset, curtype, name, intype) struct type *domain, *curtype, *intype; + int offset; char *name; { register struct type *t = curtype; @@ -1367,7 +1369,7 @@ value_struct_elt_for_reference (domain, curtype, name, intype) return value_from_longest (lookup_reference_type (lookup_member_type (TYPE_FIELD_TYPE (t, i), domain)), - (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3)); + offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3)); } } @@ -1431,7 +1433,15 @@ value_struct_elt_for_reference (domain, curtype, name, intype) for (i = TYPE_N_BASECLASSES (t) - 1; i >= 0; i--) { + value v; + int base_offset; + + if (BASETYPE_VIA_VIRTUAL (t, i)) + base_offset = 0; + else + base_offset = TYPE_BASECLASS_BITPOS (t, i) / 8; v = value_struct_elt_for_reference (domain, + offset + base_offset, TYPE_BASECLASS (t, i), name, intype); diff --git a/gdb/valprint.c b/gdb/valprint.c index 7a6da40..8c91cc7 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -236,7 +236,7 @@ print_floating (valaddr, type, stream) if (len == sizeof (float)) { /* It's single precision. */ - bcopy (valaddr, &low, sizeof (low)); + (void) memcpy ((char *) &low, valaddr, sizeof (low)); /* target -> host. */ SWAP_TARGET_AND_HOST (&low, sizeof (float)); nonnegative = low >= 0; @@ -250,11 +250,11 @@ print_floating (valaddr, type, stream) /* It's double precision. Get the high and low words. */ #if TARGET_BYTE_ORDER == BIG_ENDIAN - bcopy (valaddr+4, &low, sizeof (low)); - bcopy (valaddr+0, &high, sizeof (high)); + (void) memcpy (&low, valaddr+4, sizeof (low)); + (void) memcpy (&high, valaddr+0, sizeof (high)); #else - bcopy (valaddr+0, &low, sizeof (low)); - bcopy (valaddr+4, &high, sizeof (high)); + (void) memcpy (&low, valaddr+0, sizeof (low)); + (void) memcpy (&high, valaddr+4, sizeof (high)); #endif SWAP_TARGET_AND_HOST (&low, sizeof (low)); SWAP_TARGET_AND_HOST (&high, sizeof (high)); @@ -368,7 +368,7 @@ value_print (val, stream, format, pretty) rep1 = i + 1; reps = 1; while (rep1 < n - && !bcmp (VALUE_CONTENTS (val) + typelen * i, + && !memcmp (VALUE_CONTENTS (val) + typelen * i, VALUE_CONTENTS (val) + typelen * rep1, typelen)) { ++reps; @@ -815,8 +815,8 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) rep1 = i + 1; reps = 1; while (rep1 < len - && !bcmp (valaddr + i * eltlen, - valaddr + rep1 * eltlen, eltlen)) + && !memcmp (valaddr + i * eltlen, + valaddr + rep1 * eltlen, eltlen)) { ++reps; ++rep1; @@ -1562,6 +1562,9 @@ type_print_varspec_prefix (type, stream, show, passed_a_ptr) case TYPE_CODE_ERROR: case TYPE_CODE_CHAR: case TYPE_CODE_BOOL: + case TYPE_CODE_SET: + case TYPE_CODE_RANGE: + case TYPE_CODE_PASCAL_ARRAY: /* These types need no prefix. They are listed here so that gcc -Wall will reveal any types that haven't been handled. */ break; @@ -1662,6 +1665,9 @@ type_print_varspec_suffix (type, stream, show, passed_a_ptr, demangled_args) case TYPE_CODE_ERROR: case TYPE_CODE_CHAR: case TYPE_CODE_BOOL: + case TYPE_CODE_SET: + case TYPE_CODE_RANGE: + case TYPE_CODE_PASCAL_ARRAY: /* These types do not need a suffix. They are listed so that gcc -Wall will report types that may not have been considered. */ break; diff --git a/gdb/values.c b/gdb/values.c index bf9fa7c..c21599e 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -211,9 +211,9 @@ value_copy (arg) VALUE_LAZY (val) = VALUE_LAZY (arg); if (!VALUE_LAZY (val)) { - bcopy (VALUE_CONTENTS_RAW (arg), VALUE_CONTENTS_RAW (val), - TYPE_LENGTH (VALUE_TYPE (arg)) - * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1)); + memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS_RAW (arg), + TYPE_LENGTH (VALUE_TYPE (arg)) + * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1)); } return val; } @@ -247,7 +247,7 @@ record_latest_value (val) register struct value_history_chunk *new = (struct value_history_chunk *) xmalloc (sizeof (struct value_history_chunk)); - bzero (new->values, sizeof new->values); + (void) memset (new->values, 0, sizeof new->values); new->next = value_history_chain; value_history_chain = new; } @@ -437,8 +437,8 @@ set_internalvar_component (var, offset, bitpos, bitsize, newval) modify_field (addr, (int) value_as_long (newval), bitpos, bitsize); else - bcopy (VALUE_CONTENTS (newval), addr, - TYPE_LENGTH (VALUE_TYPE (newval))); + (void) memcpy (addr, VALUE_CONTENTS (newval), + TYPE_LENGTH (VALUE_TYPE (newval))); } void @@ -587,7 +587,7 @@ unpack_long (type, valaddr) if (len == sizeof (float)) { float retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -595,7 +595,7 @@ unpack_long (type, valaddr) if (len == sizeof (double)) { double retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -616,7 +616,7 @@ unpack_long (type, valaddr) if (len == sizeof (short)) { unsigned short retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -624,7 +624,7 @@ unpack_long (type, valaddr) if (len == sizeof (int)) { unsigned int retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -632,7 +632,7 @@ unpack_long (type, valaddr) if (len == sizeof (long)) { unsigned long retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -640,7 +640,7 @@ unpack_long (type, valaddr) if (len == sizeof (long long)) { unsigned long long retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -655,7 +655,7 @@ unpack_long (type, valaddr) if (len == sizeof (char)) { SIGNED char retval; /* plain chars might be unsigned on host */ - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -663,7 +663,7 @@ unpack_long (type, valaddr) if (len == sizeof (short)) { short retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -671,7 +671,7 @@ unpack_long (type, valaddr) if (len == sizeof (int)) { int retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -679,7 +679,7 @@ unpack_long (type, valaddr) if (len == sizeof (long)) { long retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -688,7 +688,7 @@ unpack_long (type, valaddr) if (len == sizeof (long long)) { long long retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -706,14 +706,14 @@ unpack_long (type, valaddr) if (len == sizeof(long)) { unsigned long retval; - bcopy (valaddr, &retval, sizeof(retval)); + (void) memcpy (&retval, valaddr, sizeof(retval)); SWAP_TARGET_AND_HOST (&retval, sizeof(retval)); return retval; } else if (len == sizeof(short)) { unsigned short retval; - bcopy (valaddr, &retval, len); + (void) memcpy (&retval, valaddr, len); SWAP_TARGET_AND_HOST (&retval, len); return retval; } @@ -755,7 +755,7 @@ unpack_double (type, valaddr, invp) if (len == sizeof (float)) { float retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -763,7 +763,7 @@ unpack_double (type, valaddr, invp) if (len == sizeof (double)) { double retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -816,7 +816,7 @@ unpack_pointer (type, valaddr) if (len == sizeof (CORE_ADDR)) { CORE_ADDR retval; - bcopy (valaddr, &retval, sizeof (retval)); + (void) memcpy (&retval, valaddr, sizeof (retval)); SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); return retval; } @@ -872,9 +872,8 @@ value_primitive_field (arg1, offset, fieldno, arg_type) if (VALUE_LAZY (arg1)) VALUE_LAZY (v) = 1; else - bcopy (VALUE_CONTENTS_RAW (arg1) + offset, - VALUE_CONTENTS_RAW (v), - TYPE_LENGTH (type)); + (void) memcpy (VALUE_CONTENTS_RAW (v), + VALUE_CONTENTS_RAW (arg1) + offset, TYPE_LENGTH (type)); } VALUE_LVAL (v) = VALUE_LVAL (arg1); if (VALUE_LVAL (arg1) == lval_internalvar) @@ -1008,8 +1007,6 @@ value_headof (arg, btype, dtype) /* First collect the vtables we must look at for this object. */ /* FIXME-tiemann: right now, just look at top-most vtable. */ value vtbl, entry, best_entry = 0; - /* FIXME: entry_type is never used. */ - struct type *entry_type; int i, nelems; int offset, best_offset = 0; struct symbol *sym; @@ -1034,7 +1031,7 @@ value_headof (arg, btype, dtype) know that we aren't happy, but don't throw an error. FIXME: there has to be a better way to do this. */ struct type *error_type = (struct type *)xmalloc (sizeof (struct type)); - bcopy (VALUE_TYPE (arg), error_type, sizeof (struct type)); + (void) memcpy (error_type, VALUE_TYPE (arg), sizeof (struct type)); TYPE_NAME (error_type) = savestring ("suspicious *", sizeof ("suspicious *")); VALUE_TYPE (arg) = error_type; return arg; @@ -1221,7 +1218,7 @@ unpack_field_as_long (type, valaddr, fieldno) int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); int lsbcount; - bcopy (valaddr + bitpos / 8, &val, sizeof (val)); + (void) memcpy (&val, valaddr + bitpos / 8, sizeof (val)); SWAP_TARGET_AND_HOST (&val, sizeof (val)); /* Extract bits. See comment above. */ @@ -1270,7 +1267,7 @@ modify_field (addr, fieldval, bitpos, bitsize) && 0 != (fieldval & ~((1<