diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1991-05-02 04:28:42 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1991-05-02 04:28:42 +0000 |
commit | e1ce8aa5ed46310d716472d19d2e87da2833d599 (patch) | |
tree | cacaf1a83d8e388b049c2b3bc454f311dd34b6e2 /gdb | |
parent | 04a0511c0af3d07f7b4587fbf4715d2b956f1fad (diff) | |
download | gdb-e1ce8aa5ed46310d716472d19d2e87da2833d599.zip gdb-e1ce8aa5ed46310d716472d19d2e87da2833d599.tar.gz gdb-e1ce8aa5ed46310d716472d19d2e87da2833d599.tar.bz2 |
The list of changes is too long to fit in the cvs log (since it truncates!).
Look at the ChangeLog for Apr 30 and May 1.
Diffstat (limited to 'gdb')
-rwxr-xr-x | gdb/Makefile.dist | 16 | ||||
-rw-r--r-- | gdb/Makefile.in | 16 | ||||
-rw-r--r-- | gdb/coffread.c | 10 | ||||
-rw-r--r-- | gdb/command.c | 6 | ||||
-rw-r--r-- | gdb/core.c | 3 | ||||
-rw-r--r-- | gdb/cplus-dem.c | 12 | ||||
-rw-r--r-- | gdb/dbxread.c | 39 | ||||
-rw-r--r-- | gdb/defs.h | 35 | ||||
-rwxr-xr-x | gdb/expread.y | 70 | ||||
-rw-r--r-- | gdb/findvar.c | 12 | ||||
-rw-r--r-- | gdb/gdbcore.h | 6 | ||||
-rw-r--r-- | gdb/ieee-float.c | 28 | ||||
-rw-r--r-- | gdb/infcmd.c | 12 | ||||
-rw-r--r-- | gdb/infrun.c | 1 | ||||
-rw-r--r-- | gdb/inftarg.c | 4 | ||||
-rw-r--r-- | gdb/main.c | 8 | ||||
-rwxr-xr-x | gdb/param.h | 3 | ||||
-rw-r--r-- | gdb/printcmd.c | 44 | ||||
-rw-r--r-- | gdb/remote.c | 19 | ||||
-rw-r--r-- | gdb/solib.c | 2 | ||||
-rw-r--r-- | gdb/stack.c | 3 | ||||
-rw-r--r-- | gdb/symfile.c | 6 | ||||
-rw-r--r-- | gdb/symtab.c | 2 | ||||
-rw-r--r-- | gdb/symtab.h | 15 | ||||
-rw-r--r-- | gdb/target.c | 11 | ||||
-rw-r--r-- | gdb/tm-68k.h | 2 | ||||
-rw-r--r-- | gdb/tm-sparc.h | 14 | ||||
-rw-r--r-- | gdb/utils.c | 5 | ||||
-rw-r--r-- | gdb/valprint.c | 56 | ||||
-rw-r--r-- | gdb/values.c | 78 |
30 files changed, 393 insertions, 145 deletions
diff --git a/gdb/Makefile.dist b/gdb/Makefile.dist index 6c5060b..fc7efb1 100755 --- a/gdb/Makefile.dist +++ b/gdb/Makefile.dist @@ -488,14 +488,10 @@ gdb.cxref: $(SFILES) force_update : -# When used with GDB, the demangler should never look for leading underscores -# because GDB strips them off during symbol read-in. Thus -Dnounderscore. -# Adding "param.h" gets us the USG define without having to edit cplus-dem.c -# (which is used by other programs which may or may not have a "param.h"). -# (no newline is added, so line numbers still work right). +# When used with GDB, the demangler should never look for leading +# underscores because GDB strips them off during symbol read-in. Thus +# -Dnounderscore. + cplus-dem.o : cplus-dem.c - sed <`echo ${srcdir}/cplus-dem.c | sed 's,^\./,,'` \ - >cplus.tmp.c \ - '1s,^,#include "param.h" ,' - ${CC} -c ${CFLAGS} -Dnounderscore cplus.tmp.c - mv cplus.tmp.o cplus-dem.o + ${CC} -c ${CFLAGS} -Dnounderscore \ + `echo ${srcdir}/cplus-dem.c | sed 's,^\./,,'` diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 6c5060b..fc7efb1 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -488,14 +488,10 @@ gdb.cxref: $(SFILES) force_update : -# When used with GDB, the demangler should never look for leading underscores -# because GDB strips them off during symbol read-in. Thus -Dnounderscore. -# Adding "param.h" gets us the USG define without having to edit cplus-dem.c -# (which is used by other programs which may or may not have a "param.h"). -# (no newline is added, so line numbers still work right). +# When used with GDB, the demangler should never look for leading +# underscores because GDB strips them off during symbol read-in. Thus +# -Dnounderscore. + cplus-dem.o : cplus-dem.c - sed <`echo ${srcdir}/cplus-dem.c | sed 's,^\./,,'` \ - >cplus.tmp.c \ - '1s,^,#include "param.h" ,' - ${CC} -c ${CFLAGS} -Dnounderscore cplus.tmp.c - mv cplus.tmp.o cplus-dem.o + ${CC} -c ${CFLAGS} -Dnounderscore \ + `echo ${srcdir}/cplus-dem.c | sed 's,^\./,,'` diff --git a/gdb/coffread.c b/gdb/coffread.c index 0472591..9ef0092 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -394,7 +394,7 @@ make_blockvector () /* Manage the vector of line numbers. */ -static +static void record_line (line, pc) int line; CORE_ADDR pc; @@ -616,6 +616,7 @@ coff_symfile_init (sf) of the line table (minimum and maximum file offset) so that the mainline code can read the whole thing for efficiency. */ +/* ARGSUSED */ static void find_linenos (abfd, asect, vpinfo) bfd *abfd; @@ -653,6 +654,11 @@ find_linenos (abfd, asect, vpinfo) } +/* The BFD for this file -- only good while we're actively reading + symbols into a psymtab or a symtab. */ + +static bfd *symfile_bfd; + /* Read a symbol file, after initialization by coff_symfile_init. */ /* FIXME! Addr and Mainline are not used yet -- this will not work for shared libraries or add_file! */ @@ -1897,6 +1903,7 @@ read_struct_type (index, length, lastsym) /* Read a definition of an enumeration type, and create and return a suitable type object. Also defines the symbols that represent the values of the type. */ +/* Currently assumes it's sizeof (int) and doesn't use length. */ static struct type * read_enum_type (index, length, lastsym) @@ -1960,6 +1967,7 @@ read_enum_type (index, length, lastsym) /* Now fill in the fields of the type-structure. */ + /* FIXME: Should be sizeof (int) on target, not host. */ TYPE_LENGTH (type) = sizeof (int); TYPE_CODE (type) = TYPE_CODE_ENUM; TYPE_NFIELDS (type) = nsyms; diff --git a/gdb/command.c b/gdb/command.c index dc9d5fc..36661be 100644 --- a/gdb/command.c +++ b/gdb/command.c @@ -15,11 +15,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <stdio.h> #include "defs.h" #include "command.h" #include "symtab.h" #include "value.h" -#include <stdio.h> #include <ctype.h> #include <string.h> @@ -160,6 +160,7 @@ add_abbrev_prefix_cmd (name, class, fun, doc, prefixlist, prefixname, return c; } +/* ARGSUSED */ void not_just_help_class_command (args, from_tty, c) char *args; @@ -254,8 +255,6 @@ delete_cmd (name, list) } } -void help_cmd (), help_list (), help_cmd_list (); - /* This command really has to deal with two things: * 1) I want documentation on *this string* (usually called by * "help commandname"). @@ -1083,6 +1082,7 @@ cmd_show_list (list, from_tty, prefix) } } +/* ARGSUSED */ static void shell_escape (arg, from_tty) char *arg; @@ -56,6 +56,7 @@ extern struct target_ops core_ops; /* Discard all vestiges of any previous core file and mark data and stack spaces as empty. */ +/* ARGSUSED */ void core_close (quitting) int quitting; @@ -390,6 +391,8 @@ core_xfer_memory (memaddr, myaddr, len, write) independent part. Fetch_core_registers is the machine-dependent part, typically implemented in the xm-file for each architecture. */ +/* We just get all the registers, so we don't use regno. */ +/* ARGSUSED */ static int get_core_registers (regno) int regno; diff --git a/gdb/cplus-dem.c b/gdb/cplus-dem.c index b01cb93..95c4529 100644 --- a/gdb/cplus-dem.c +++ b/gdb/cplus-dem.c @@ -64,6 +64,10 @@ #include <stdio.h> #include <ctype.h> +/* GDB-specific, FIXME. */ +#include "defs.h" +#include "param.h" + #ifdef USG #include <memory.h> #include <string.h> @@ -194,21 +198,19 @@ static void remember_type (); #endif /* Takes operator name as e.g. "++" and returns mangled - operator name (e.g. "postincrement_expr"). */ + operator name (e.g. "postincrement_expr"), or NULL if not found. */ char * cplus_mangle_opname (opname) char *opname; { int i, len = strlen (opname); - string name; for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) { if (strlen (optable[i].out) == len && memcmp (optable[i].out, opname, len) == 0) - return optable[i].in; + return (char *)optable[i].in; } - error ("no mangling for `%s'", opname); return 0; } @@ -440,7 +442,7 @@ do_type (type, result, arg_mode) success = 0; *type += 2; while (n-- > 0) - do_type (type, result); + do_type (type, result, arg_mode); break; case 'P': diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 5abe56e..6c79982 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -769,7 +769,9 @@ really_free_pendings (foo) int foo; { struct pending *next, *next1; +#if 0 struct pending_block *bnext, *bnext1; +#endif for (next = free_pendings; next; next = next1) { @@ -1252,6 +1254,11 @@ record_misc_function (name, address, type) address, misc_type); } +/* The BFD for this file -- only good while we're actively reading + symbols into a psymtab or a symtab. */ + +static bfd *symfile_bfd; + /* Scan and build partial symbols for a symbol file. We have been initialized by a call to dbx_symfile_init, which put all the relevant info into a "struct dbx_symfile_info" @@ -2888,7 +2895,7 @@ read_ofile_symtab (desc, stringtab, stringtab_size, sym_offset, if (type & N_STAB) { - short desc = bufp->n_desc; + short bufp_n_desc = bufp->n_desc; unsigned long valu = bufp->n_value; /* Check for a pair of N_SO symbols. */ @@ -2912,15 +2919,15 @@ read_ofile_symtab (desc, stringtab, stringtab_size, sym_offset, bufp->n_un.n_strx); namestring2 = bufp->n_un.n_strx + stringtab; - process_symbol_pair (N_SO, desc, valu, namestring, + process_symbol_pair (N_SO, bufp_n_desc, valu, namestring, N_SO, bufp->n_desc, bufp->n_value, namestring2); } else - process_one_symbol(type, desc, valu, namestring); + process_one_symbol(type, bufp_n_desc, valu, namestring); } else - process_one_symbol (type, desc, valu, namestring); + process_one_symbol (type, bufp_n_desc, valu, namestring); } /* We skip checking for a new .o or -l file; that should never happen in this routine. */ @@ -3377,13 +3384,14 @@ define_symbol (valu, string, desc, type) case 'r': { double d = atof (p); - char *valu; + char *dbl_valu; SYMBOL_TYPE (sym) = builtin_type_double; - valu = (char *) obstack_alloc (symbol_obstack, sizeof (double)); - bcopy (&d, valu, sizeof (double)); - SWAP_TARGET_AND_HOST (valu, sizeof (double)); - SYMBOL_VALUE_BYTES (sym) = valu; + dbl_valu = + (char *) obstack_alloc (symbol_obstack, sizeof (double)); + bcopy (&d, dbl_valu, sizeof (double)); + SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double)); + SYMBOL_VALUE_BYTES (sym) = dbl_valu; SYMBOL_CLASS (sym) = LOC_CONST_BYTES; } break; @@ -3433,7 +3441,7 @@ define_symbol (valu, string, desc, type) } else { - struct type *type; + struct type *type_read; synonym = *p == 't'; if (synonym) @@ -3443,13 +3451,13 @@ define_symbol (valu, string, desc, type) strlen (SYMBOL_NAME (sym))); } - type = read_type (&p); + type_read = read_type (&p); if ((deftype == 'F' || deftype == 'f') - && TYPE_CODE (type) != TYPE_CODE_FUNC) - SYMBOL_TYPE (sym) = lookup_function_type (type); + && TYPE_CODE (type_read) != TYPE_CODE_FUNC) + SYMBOL_TYPE (sym) = lookup_function_type (type_read); else - SYMBOL_TYPE (sym) = type; + SYMBOL_TYPE (sym) = type_read; } switch (deftype) @@ -4330,7 +4338,8 @@ read_struct_type (pp, type) /* Special GNU C++ name. */ if (*++p == 'v') { - char *prefix, *name = 0; + const char *prefix; + char *name = 0; struct type *context; switch (*++p) @@ -118,6 +118,11 @@ extern void free_current_contents (); extern int myread (); extern int query (); extern int lines_to_list (); +extern void wrap_here ( +#ifdef __STDC__ + char * +#endif + ); extern void reinitialize_more_filter (); extern void fputs_filtered (); extern void puts_filtered (); @@ -136,6 +141,13 @@ extern void print_sys_errmsg (); extern void print_address_symbolic (); extern void print_address (); +/* From source.c */ +void mod_path ( +#ifdef __STDC__ + char *, char ** +#endif + ); + /* From readline (but not in any readline .h files). */ extern char *tilde_expand (); @@ -170,6 +182,15 @@ char *baud_rate; #define LONG_MAX 0x7fffffff #endif +#if !defined (INT_MAX) +#define INT_MAX 0x7fffffff +#endif + +#if !defined (INT_MIN) +/* Two's complement, 32 bit. */ +#define INT_MIN -0x80000000 +#endif + /* Just like CHAR_BIT in <limits.h> but describes the target machine. */ #if !defined (TARGET_CHAR_BIT) #define TARGET_CHAR_BIT 8 @@ -181,4 +202,18 @@ char *baud_rate; #define TARGET_LONG_LONG_BIT 64 #endif +/* Convert a LONGEST to an int. This is used in contexts (e.g. number + of arguments to a function, number in a value history, register + number, etc.) where the value must not be larger than can fit + in an int. */ +#if !defined (longest_to_int) +#if defined (LONG_LONG) +#define longest_to_int(x) (((x) > INT_MAX || (x) < INT_MIN) \ + ? error ("Value out of range.") : (int) (x)) +#else /* No LONG_LONG. */ +/* Assume sizeof (int) == sizeof (long). */ +#define longest_to_int(x) ((int) (x)) +#endif /* No LONG_LONG. */ +#endif /* No longest_to_int. */ + #endif /* no DEFS_H */ diff --git a/gdb/expread.y b/gdb/expread.y index 44b1b5c..6772d79 100755 --- a/gdb/expread.y +++ b/gdb/expread.y @@ -108,11 +108,18 @@ struct symtoken An array should be preceded in the list by the size of the array. */ enum type_pieces {tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function}; -static enum type_pieces *type_stack; +/* The stack can contain either an enum type_pieces or an int. */ +union type_stack_elt { + enum type_pieces piece; + int int_val; +}; +static union type_stack_elt *type_stack; static int type_stack_depth, type_stack_size; static void push_type (); +static void push_type_int (); static enum type_pieces pop_type (); +static int pop_type_int (); /* Allow debugging of parsing. */ #define YYDEBUG 1 @@ -646,12 +653,33 @@ variable: name_not_typename { case LOC_REGISTER: case LOC_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: case LOC_LOCAL: case LOC_LOCAL_ARG: if (innermost_block == 0 || contained_in (block_found, innermost_block)) innermost_block = block_found; + case LOC_UNDEF: + case LOC_CONST: + case LOC_STATIC: + case LOC_TYPEDEF: + case LOC_LABEL: + case LOC_BLOCK: + case LOC_EXTERNAL: + case LOC_CONST_BYTES: + + /* In this case the expression can + be evaluated regardless of what + frame we are in, so there is no + need to check for the + innermost_block. These cases are + listed so that gcc -Wall will + report types that may not have + been considered. */ + + break; } write_exp_elt_opcode (OP_VAR_VALUE); write_exp_elt_sym (sym); @@ -732,7 +760,7 @@ ptype : typebase follow_type = lookup_reference_type (follow_type); break; case tp_array: - array_size = (int) pop_type (); + array_size = pop_type_int (); if (array_size != -1) follow_type = create_array_type (follow_type, array_size); @@ -762,12 +790,12 @@ direct_abs_decl: '(' abs_decl ')' { $$ = $2; } | direct_abs_decl array_mod { - push_type ((enum type_pieces) $2); + push_type_int ($2); push_type (tp_array); } | array_mod { - push_type ((enum type_pieces) $1); + push_type_int ($1); push_type (tp_array); $$ = 0; } @@ -1915,25 +1943,47 @@ push_type (tp) if (type_stack_depth == type_stack_size) { type_stack_size *= 2; - type_stack = (enum type_pieces *) - xrealloc (type_stack, type_stack_size * sizeof (enum type_pieces)); + type_stack = (union type_stack_elt *) + xrealloc (type_stack, type_stack_size * sizeof (*type_stack)); + } + type_stack[type_stack_depth++].piece = tp; +} + +static void +push_type_int (n) + int n; +{ + if (type_stack_depth == type_stack_size) + { + type_stack_size *= 2; + type_stack = (union type_stack_elt *) + xrealloc (type_stack, type_stack_size * sizeof (*type_stack)); } - type_stack[type_stack_depth++] = tp; + type_stack[type_stack_depth++].int_val = n; } static enum type_pieces pop_type () { if (type_stack_depth) - return type_stack[--type_stack_depth]; + return type_stack[--type_stack_depth].piece; return tp_end; } +static int +pop_type_int () +{ + if (type_stack_depth) + return type_stack[--type_stack_depth].int_val; + /* "Can't happen". */ + return 0; +} + void _initialize_expread () { type_stack_size = 80; type_stack_depth = 0; - type_stack = (enum type_pieces *) - xmalloc (type_stack_size * sizeof (enum type_pieces)); + type_stack = (union type_stack_elt *) + xmalloc (type_stack_size * sizeof (*type_stack)); } diff --git a/gdb/findvar.c b/gdb/findvar.c index 5ac03bc..106fadf 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -177,7 +177,7 @@ read_relative_register_raw_bytes (regnum, myaddr) return 0; } - get_saved_register (myaddr, &optim, (CORE_ADDR) NULL, selected_frame, + get_saved_register (myaddr, &optim, (CORE_ADDR *) NULL, selected_frame, regnum, (enum lval_type *)NULL); return optim; } @@ -366,7 +366,6 @@ read_var_value (var, frame) struct frame_info *fi; struct type *type = SYMBOL_TYPE (var); CORE_ADDR addr; - int val; register int len; v = allocate_value (type); @@ -378,8 +377,7 @@ read_var_value (var, frame) switch (SYMBOL_CLASS (var)) { case LOC_CONST: - val = SYMBOL_VALUE (var); - bcopy (&val, VALUE_CONTENTS_RAW (v), len); + bcopy (&SYMBOL_VALUE (var), VALUE_CONTENTS_RAW (v), len); SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (v), len); VALUE_LVAL (v) = not_lval; return v; @@ -430,7 +428,7 @@ read_var_value (var, frame) return 0; } addr += SYMBOL_VALUE (var); - addr = read_memory_integer (addr, sizeof (CORE_ADDR)); + read_memory (addr, &addr, sizeof (CORE_ADDR)); break; case LOC_LOCAL: @@ -460,7 +458,7 @@ read_var_value (var, frame) v = value_from_register (type, SYMBOL_VALUE (var), frame); - if (REG_STRUCT_HAS_ADDR(b->gcc_compile_flag) + if (REG_STRUCT_HAS_ADDR (BLOCK_GCC_COMPILED (b)) && TYPE_CODE (type) == TYPE_CODE_STRUCT) addr = *(CORE_ADDR *)VALUE_CONTENTS (v); else @@ -665,7 +663,7 @@ locate_var_value (var, frame) { char *buf = alloca (TYPE_LENGTH (type)); read_memory (addr, buf, TYPE_LENGTH (type)); - addr = unpack_long (type, buf); + addr = unpack_pointer (type, buf); type = TYPE_TARGET_TYPE (type); } diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h index 991ce64..0be67bb 100644 --- a/gdb/gdbcore.h +++ b/gdb/gdbcore.h @@ -45,6 +45,12 @@ void read_memory (); /* Read an integer from debugged memory, given address and number of bytes. */ long read_memory_integer (); +void write_memory ( +#ifdef __STDC__ + CORE_ADDR, char *, int +#endif + ); + /* Hook for `exec_file_command' command to call. */ extern void (*exec_file_display_hook) (); diff --git a/gdb/ieee-float.c b/gdb/ieee-float.c index 4a2c04c..224d0cf 100644 --- a/gdb/ieee-float.c +++ b/gdb/ieee-float.c @@ -34,30 +34,30 @@ ieee_extended_to_double (ext_format, from, to) { unsigned char *ufrom = (unsigned char *)from; double dto; - unsigned long mant0, mant1, exp; + unsigned long mant0, mant1, exponent; bcopy (&from[MANBYTE_H], &mant0, 4); bcopy (&from[MANBYTE_L], &mant1, 4); - exp = ((ufrom[EXPBYTE_H] & (unsigned char)~SIGNMASK) << 8) | ufrom[EXPBYTE_L]; + exponent = ((ufrom[EXPBYTE_H] & (unsigned char)~SIGNMASK) << 8) | ufrom[EXPBYTE_L]; #if 0 /* We can't do anything useful with a NaN anyway, so ignore its difference. It will end up as Infinity or something close. */ - if (exp == EXT_EXP_NAN) { + if (exponent == EXT_EXP_NAN) { /* We have a NaN source. */ dto = 0.123456789; /* Not much else useful to do -- we don't know if the host system even *has* NaNs, nor how to generate an innocuous one if it does. */ } else #endif - if (exp == 0 && mant0 == 0 && mant1 == 0) { + if (exponent == 0 && mant0 == 0 && mant1 == 0) { dto = 0; } else { /* Build the result algebraically. Might go infinite, underflow, etc; who cares. */ mant0 |= 0x80000000; - dto = ldexp ((double)mant0, exp - EXT_EXP_BIAS - 31); - dto += ldexp ((double)mant1, exp - EXT_EXP_BIAS - 31 - 32); + dto = ldexp ((double)mant0, exponent - EXT_EXP_BIAS - 31); + dto += ldexp ((double)mant1, exponent - EXT_EXP_BIAS - 31 - 32); if (ufrom[EXPBYTE_H] & SIGNMASK) /* If negative... */ dto = -dto; /* ...negate. */ } @@ -75,7 +75,7 @@ double_to_ieee_extended (ext_format, from, to) { double dfrom = *from; unsigned long twolongs[2]; - unsigned long mant0, mant1, exp; + unsigned long mant0, mant1, exponent; unsigned char twobytes[2]; bzero (to, TOTALSIZE); @@ -97,27 +97,27 @@ double_to_ieee_extended (ext_format, from, to) bcopy (from, twolongs, 8); bcopy (from, twobytes, 2); #if HOST_BYTE_ORDER == BIG_ENDIAN - exp = ((twobytes[1] & 0xF0) >> 4) | (twobytes[0] & 0x7F) << 4; + exponent = ((twobytes[1] & 0xF0) >> 4) | (twobytes[0] & 0x7F) << 4; mant0 = (twolongs[0] << 11) | twolongs[1] >> 21; mant1 = (twolongs[1] << 11); #else - exp = ((twobytes[0] & 0xF0) >> 4) | (twobytes[1] & 0x7F) << 4; + exponent = ((twobytes[0] & 0xF0) >> 4) | (twobytes[1] & 0x7F) << 4; mant0 = (twolongs[1] << 11) | twolongs[0] >> 21; mant1 = (twolongs[0] << 11); #endif /* Fiddle with leading 1-bit, implied in double, explicit in extended. */ - if (exp == 0) + if (exponent == 0) mant0 &= 0x7FFFFFFF; else mant0 |= 0x80000000; - exp -= DBL_EXP_BIAS; /* Get integer exp */ - exp += EXT_EXP_BIAS; /* Offset for extended *&/ + exponent -= DBL_EXP_BIAS; /* Get integer exp */ + exponent += EXT_EXP_BIAS; /* Offset for extended */ /* OK, now store it in extended format. */ - to[EXPBYTE_H] |= (unsigned char)(exp >> 8); /* Retain sign */ - to[EXPBYTE_L] = (unsigned char) exp; + to[EXPBYTE_H] |= (unsigned char)(exponent >> 8); /* Retain sign */ + to[EXPBYTE_L] = (unsigned char) exponent; bcopy (&mant0, &to[MANBYTE_H], 4); bcopy (&mant1, &to[MANBYTE_L], 4); diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 2ebfb0b..f387ba0 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -122,6 +122,7 @@ CORE_ADDR read_pc (); void breakpoint_clear_ignore_counts (); +/* ARGSUSED */ void tty_command (file, from_tty) char *file; @@ -218,6 +219,7 @@ continue_command (proc_count_exp, from_tty) /* Step until outside of current statement. */ static void step_1 (); +/* ARGSUSED */ static void step_command (count_string, from_tty) char * count_string; @@ -228,6 +230,7 @@ step_command (count_string, from_tty) /* Likewise, but skip over subroutine calls as if single instructions. */ +/* ARGSUSED */ static void next_command (count_string, from_tty) char * count_string; @@ -238,6 +241,7 @@ next_command (count_string, from_tty) /* Likewise, but step only one instruction. */ +/* ARGSUSED */ static void stepi_command (count_string, from_tty) char * count_string; @@ -246,6 +250,7 @@ stepi_command (count_string, from_tty) step_1 (0, 1, count_string); } +/* ARGSUSED */ static void nexti_command (count_string, from_tty) char * count_string; @@ -453,6 +458,7 @@ The expression which contained the function call has been discarded."); we set. I'm going to postpone this until after a hopeful rewrite of wait_for_inferior and the proceed status code. -- randy */ +/* ARGSUSED */ void until_next_command (from_tty) int from_tty; @@ -584,6 +590,7 @@ finish_command (arg, from_tty) } } +/* ARGSUSED */ static void program_info (args, from_tty) char *args; @@ -732,6 +739,7 @@ unset_environment_command (var, from_tty) const static char path_var_name[] = "PATH"; +/* ARGSUSED */ void path_info (args, from_tty) char *args; @@ -752,11 +760,11 @@ path_command (dirname, from_tty) dont_repeat (); exec_path = strsave (get_in_environ (inferior_environ, path_var_name)); - mod_path (dirname, from_tty, &exec_path); + mod_path (dirname, &exec_path); set_in_environ (inferior_environ, path_var_name, exec_path); free (exec_path); if (from_tty) - path_info (); + path_info ((char *)NULL, from_tty); } CORE_ADDR diff --git a/gdb/infrun.c b/gdb/infrun.c index c6117f7..acdcb70 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -260,6 +260,7 @@ void normal_stop (); /* Things to clean up if we QUIT out of resume (). */ +/* ARGSUSED */ static void resume_cleanups (arg) int arg; diff --git a/gdb/inftarg.c b/gdb/inftarg.c index 5b52fda..9e3f729 100644 --- a/gdb/inftarg.c +++ b/gdb/inftarg.c @@ -123,6 +123,8 @@ child_prepare_to_store () /* Convert data from raw format for register REGNUM to virtual format for register REGNUM. */ +/* Some machines won't need to use regnum. */ +/* ARGSUSED */ void host_convert_to_virtual (regnum, from, to) int regnum; @@ -135,6 +137,7 @@ host_convert_to_virtual (regnum, from, to) /* Convert data from virtual format for register REGNUM to raw format for register REGNUM. */ +/* ARGSUSED */ void host_convert_from_virtual (regnum, from, to) int regnum; @@ -153,6 +156,7 @@ child_files_info () attach_flag? "attached": "child", inferior_pid); } +/* ARGSUSED */ static void child_open (arg, from_tty) char *arg; @@ -1455,6 +1455,7 @@ error_no_arg (why) error ("Argument required (%s).", why); } +/* ARGSUSED */ static void help_command (command, from_tty) char *command; @@ -1584,6 +1585,7 @@ GDB is free software and you are welcome to distribute copies of it\n\ under certain conditions; type \"info copying\" to see the conditions.\n"); } +/* ARGSUSED */ static void show_version (args, from_tty) char *args; @@ -1629,6 +1631,7 @@ input_from_terminal_p () return (instream == stdin) & caution; } +/* ARGSUSED */ static void pwd_command (args, from_tty) char *args; @@ -1710,6 +1713,7 @@ cd_command (dir, from_tty) pwd_command ((char *) 0, 1); } +/* ARGSUSED */ static void source_command (args, from_tty) char *args; @@ -1885,6 +1889,7 @@ show_commands (args, from_tty) } /* Called by do_setshow_command. */ +/* ARGSUSED */ static void set_history_size_command (args, from_tty, c) char *args; @@ -1897,6 +1902,7 @@ set_history_size_command (args, from_tty, c) stifle_history (history_size); } +/* ARGSUSED */ static void set_history (args, from_tty) char *args; @@ -1906,6 +1912,7 @@ set_history (args, from_tty) help_list (sethistlist, "set history ", -1, stdout); } +/* ARGSUSED */ static void show_history (args, from_tty) char *args; @@ -1917,6 +1924,7 @@ show_history (args, from_tty) int info_verbose = 0; /* Default verbose msgs off */ /* Called by do_setshow_command. An elaborate joke. */ +/* ARGSUSED */ static void set_verbose (args, from_tty, c) char *args; diff --git a/gdb/param.h b/gdb/param.h index a0b59e5..62eee1c 100755 --- a/gdb/param.h +++ b/gdb/param.h @@ -21,8 +21,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ param-no-tm.h. Any future inclusions of param.h will be protected against by the #if !defined stuff below. */ -/* Some tm files need CORE_ADDR, for example. */ -#include "defs.h" +/* This file requires defs.h. */ #if !defined (PARAM_H) #include "tm.h" diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 3442e58..149239e 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -363,7 +363,7 @@ print_scalar_formatted (valaddr, type, format, size, stream) break; case 'a': - print_address ((CORE_ADDR) val_long, stream); + print_address (unpack_pointer (type, valaddr), stream); break; case 'c': @@ -670,6 +670,7 @@ print_command_1 (exp, inspect, voidprint) inspect_it = 0; /* Reset print routines to normal */ } +/* ARGSUSED */ static void print_command (exp, from_tty) char *exp; @@ -679,6 +680,7 @@ print_command (exp, from_tty) } /* Same as print, except in epoch, it gets its own window */ +/* ARGSUSED */ static void inspect_command (exp, from_tty) char *exp; @@ -690,6 +692,7 @@ inspect_command (exp, from_tty) } /* Same as print, except it doesn't print void results. */ +/* ARGSUSED */ static void call_command (exp, from_tty) char *exp; @@ -698,6 +701,7 @@ call_command (exp, from_tty) print_command_1 (exp, 0, 0); } +/* ARGSUSED */ static void output_command (exp, from_tty) char *exp; @@ -727,6 +731,7 @@ output_command (exp, from_tty) do_cleanups (old_chain); } +/* ARGSUSED */ static void set_command (exp, from_tty) char *exp; @@ -739,13 +744,14 @@ set_command (exp, from_tty) do_cleanups (old_chain); } +/* ARGSUSED */ static void address_info (exp, from_tty) char *exp; int from_tty; { register struct symbol *sym; - register CORE_ADDR val; + register long val; int is_a_field_of_this; /* C++: lookup_symbol sets this to nonzero if exp is a field of `this'. */ @@ -803,19 +809,19 @@ address_info (exp, from_tty) break; case LOC_ARG: - printf ("an argument at offset %d", (int)val); + printf ("an argument at offset %ld", val); break; case LOC_LOCAL_ARG: - printf ("an argument at frame offset %d", (int)val); + printf ("an argument at frame offset %ld", val); break; case LOC_LOCAL: - printf ("a local variable at frame offset %d", (int)val); + printf ("a local variable at frame offset %ld", val); break; case LOC_REF_ARG: - printf ("a reference argument at offset %d", (int)val); + printf ("a reference argument at offset %ld", val); break; case LOC_TYPEDEF: @@ -882,7 +888,7 @@ x_command (exp, from_tty) && VALUE_LVAL (val) == lval_memory) next_address = VALUE_ADDRESS (val); else - next_address = (CORE_ADDR) value_as_long (val); + next_address = value_as_pointer (val); do_cleanups (old_chain); } @@ -931,6 +937,7 @@ whatis_exp (exp, show) do_cleanups (old_chain); } +/* ARGSUSED */ static void whatis_command (exp, from_tty) char *exp; @@ -943,6 +950,7 @@ whatis_command (exp, from_tty) } /* TYPENAME is either the name of a type, or an expression. */ +/* ARGSUSED */ static void ptype_command (typename, from_tty) char *typename; @@ -1256,7 +1264,7 @@ do_one_display (d) else printf_filtered (" "); - addr = (CORE_ADDR) value_as_long (evaluate_expression (d->exp)); + addr = value_as_pointer (evaluate_expression (d->exp)); if (d->format.format == 'i') addr = ADDR_BITS_REMOVE (addr); @@ -1385,6 +1393,7 @@ enable_display (args) } } +/* ARGSUSED */ void disable_display_command (args, from_tty) char *args; @@ -1454,7 +1463,7 @@ print_frame_args (func, fi, num, stream) /* Offset of next stack argument beyond the one we have seen that is at the highest offset. -1 if we haven't come to a stack argument yet. */ - int highest_offset = -1; + long highest_offset = -1; int arg_size; /* Number of ints of arguments that we have printed so far. */ int args_printed = 0; @@ -1489,7 +1498,7 @@ print_frame_args (func, fi, num, stream) case LOC_ARG: case LOC_REF_ARG: { - int current_offset = SYMBOL_VALUE (sym); + long current_offset = SYMBOL_VALUE (sym); arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym)); @@ -1536,7 +1545,7 @@ print_frame_args (func, fi, num, stream) enough about the stack to find them. */ if (num != -1) { - int start; + long start; CORE_ADDR addr; if (highest_offset == -1) @@ -1559,7 +1568,7 @@ print_frame_args (func, fi, num, stream) static void print_frame_nameless_args (argsaddr, start, num, first, stream) CORE_ADDR argsaddr; - int start; + long start; int num; int first; FILE *stream; @@ -1584,6 +1593,7 @@ print_frame_nameless_args (argsaddr, start, num, first, stream) } } +/* ARGSUSED */ static void printf_command (arg, from_tty) char *arg; @@ -1740,8 +1750,9 @@ printf_command (arg, from_tty) if (argclass[i] == string_arg) { char *str; - int tem, j; - tem = value_as_long (val_args[i]); + CORE_ADDR tem; + int j; + tem = value_as_pointer (val_args[i]); /* This is a %s argument. Find the length of the string. */ for (j = 0; ; j++) @@ -1777,8 +1788,8 @@ printf_command (arg, from_tty) else #endif { - *((int *) &arg_bytes[argindex]) = value_as_long (val_args[i]); - argindex += sizeof (int); + *((long *) &arg_bytes[argindex]) = value_as_long (val_args[i]); + argindex += sizeof (long); } } } @@ -1831,6 +1842,7 @@ containing_function_bounds (pc, low, high) Two arguments are interpeted as bounds within which to dump assembly. */ +/* ARGSUSED */ static void disassemble_command (arg, from_tty) char *arg; diff --git a/gdb/remote.c b/gdb/remote.c index d3df38d..3f3d91a 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -138,6 +138,7 @@ remote_start() /* Clean up connection to a remote debugger. */ +/* ARGSUSED */ void remote_close (quitting) int quitting; @@ -196,7 +197,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); #endif /* Set up read timeout timer. */ - if ((void (*)) signal (SIGALRM, remote_timer) == (void (*)) -1) + if ((void (*)()) signal (SIGALRM, remote_timer) == (void (*)()) -1) perror ("remote_open: error in signal"); #endif @@ -276,7 +277,9 @@ remote_resume (step, siggnal) } /* Wait until the remote machine stops, then return, - storing status in STATUS just as `wait' would. */ + storing status in STATUS just as `wait' would. + Returns "pid" (though it's not clear what, if anything, that + means in the case of this target). */ int remote_wait (status) @@ -291,10 +294,13 @@ remote_wait (status) if (buf[0] != 'S') error ("Invalid remote reply: %s", buf); WSETSTOP ((*status), (((fromhex (buf[1])) << 4) + (fromhex (buf[2])))); + return 0; } /* Read the remote registers into the block REGS. */ +/* Currently we just read all the registers, so we don't use regno. */ +/* ARGSUSED */ int remote_fetch_registers (regno) int regno; @@ -336,6 +342,7 @@ remote_prepare_to_store () /* Store the remote registers from the contents of the block REGISTERS. FIXME, eventually just store one register if that's all that is needed. */ +/* ARGSUSED */ int remote_store_registers (regno) int regno; @@ -466,15 +473,15 @@ remote_read_bytes (memaddr, myaddr, len) } /* Read or write LEN bytes from inferior memory at MEMADDR, transferring - to or from debugger address MYADDR. Write to inferior if WRITE is + to or from debugger address MYADDR. Write to inferior if SHOULD_WRITE is nonzero. Returns length of data written or read; 0 for error. */ int -remote_xfer_inferior_memory(memaddr, myaddr, len, write) +remote_xfer_inferior_memory(memaddr, myaddr, len, should_write) CORE_ADDR memaddr; char *myaddr; int len; - int write; + int should_write; { int origlen = len; int xfersize; @@ -485,7 +492,7 @@ remote_xfer_inferior_memory(memaddr, myaddr, len, write) else xfersize = len; - if (write) + if (should_write) remote_write_bytes(memaddr, myaddr, xfersize); else remote_read_bytes (memaddr, myaddr, xfersize); diff --git a/gdb/solib.c b/gdb/solib.c index 0faf260..66f5bea 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -158,7 +158,7 @@ int i; status = target_read_memory ( (CORE_ADDR)so_list_ptr->inferior_lm_add, - &so_list_ptr->inferior_lm, + (char *)&so_list_ptr->inferior_lm, sizeof(struct link_map)); if (status == 0) inferior_lm = so_list_ptr->inferior_lm.lm_next; diff --git a/gdb/stack.c b/gdb/stack.c index e8041fb..09a7f49 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -756,6 +756,7 @@ print_frame_label_vars (frame, this_level_only, stream) return values_printed; } +/* ARGSUSED */ static void locals_info (args, from_tty) char *args; @@ -972,6 +973,7 @@ frame_command (level_exp, from_tty) /* Select the frame up one or COUNT stack levels from the previously selected frame, and print it briefly. */ +/* ARGSUSED */ static void up_silently_command (count_exp, from_tty) char *count_exp; @@ -1004,6 +1006,7 @@ up_command (count_exp, from_tty) /* Select the frame down one or COUNT stack levels from the previously selected frame, and print it briefly. */ +/* ARGSUSED */ static void down_silently_command (count_exp, from_tty) char *count_exp; diff --git a/gdb/symfile.c b/gdb/symfile.c index e1345db..734d36a 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -82,7 +82,7 @@ char *symfile = 0; /* The modification date of the file when they were loaded. */ -int symfile_mtime = 0; +long /* really time_t */ symfile_mtime = 0; /* Structures with which to manage partial symbol allocation. */ @@ -595,6 +595,7 @@ symfile_init (sym_bfd) } } error ("I'm sorry, Dave, I can't do that. Symbol format unknown."); + return 0; /* Appease lint. */ } /* This function runs the load command of our current target. */ @@ -623,6 +624,7 @@ add_symbol_file_command (args, from_tty) /* This function allows the addition of incrementally linked object files. */ +/* ARGSUSED */ void add_syms_addr_command (arg_string, from_tty) char* arg_string; @@ -801,6 +803,7 @@ clear_symtab_users_once () /* Delete the specified psymtab, and any others that reference it. */ +static void cashier_psymtab (pst) struct partial_symtab *pst; { @@ -859,7 +862,6 @@ free_named_symtabs (name) register struct symtab *s; register struct symtab *prev; register struct partial_symtab *ps; - register struct partial_symtab *pprev; struct blockvector *bv; int blewit = 0; diff --git a/gdb/symtab.c b/gdb/symtab.c index 17cc626..7427300 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -226,7 +226,7 @@ check_stub_type(type) struct symbol *sym; if (name == 0) { - complain (&stub_noname_complaint, 0, 0); + complain (&stub_noname_complaint, 0); return; } if (sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0, diff --git a/gdb/symtab.h b/gdb/symtab.h index d9746e8..99e370c 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -818,6 +818,11 @@ extern struct type *lookup_member_type (); extern struct type *lookup_method_type (); extern struct type *lookup_class (); extern void smash_to_method_type (); +void smash_to_member_type ( +#ifdef __STDC__ + struct type *, struct type *, struct type * +#endif + ); extern struct type *allocate_stub_method (); /* end of C++ stuff. */ @@ -902,6 +907,16 @@ void symbol_file_add (); /* source.c */ int identify_source_line (); void print_source_lines (); +void forget_cached_source_info ( +#ifdef __STDC__ + void +#endif + ); +void select_source_symtab ( +#ifdef __STDC__ + struct symtab * +#endif + ); char **make_symbol_completion_list (); diff --git a/gdb/target.c b/gdb/target.c index 53e9de1..a23c910 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -76,18 +76,15 @@ struct target_ops **current_target_stack; static struct cmd_list_element *targetlist = NULL; -/* Docstring for target (as in "help target"). */ - -static char *target_doc = NULL; - /* The user just typed 'target' without the name of a target. */ +/* ARGSUSED */ static void target_command (arg, from_tty) char *arg; int from_tty; { - fputs_filtered ("Argument required (target name).", stdout); + fputs_filtered ("Argument required (target name).\n", stdout); } /* Add a possible target architecture to the list. */ @@ -160,6 +157,7 @@ noprocess () error ("You can't do that without a process to debug"); } +/* ARGSUSED */ static int nosymbol (name, addrp) char *name; @@ -168,6 +166,7 @@ nosymbol (name, addrp) return 1; /* Symbol does not exist in target env */ } +/* ARGSUSED */ static void default_terminal_info (args, from_tty) char *args; @@ -214,6 +213,7 @@ static void kill_or_be_killed (from_tty) int from_tty; { + /* FIXME: What is savecur for? Why isn't it used? */ struct target_ops *savecur; if (target_has_execution) @@ -467,6 +467,7 @@ bump: } +/* ARGSUSED */ static void target_info (args, from_tty) char *args; diff --git a/gdb/tm-68k.h b/gdb/tm-68k.h index b3c6c37..af629c3 100644 --- a/gdb/tm-68k.h +++ b/gdb/tm-68k.h @@ -286,7 +286,7 @@ extern struct ext_format ext_format_68881 []; the address in which a function should return its structure value, as a CORE_ADDR (or an expression that can be used as one). */ -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) +#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(CORE_ADDR *)(REGBUF)) /* Describe the pointer in each stack frame to the previous stack frame (its caller). */ diff --git a/gdb/tm-sparc.h b/gdb/tm-sparc.h index aa72a57..f7acf3c 100644 --- a/gdb/tm-sparc.h +++ b/gdb/tm-sparc.h @@ -286,7 +286,12 @@ extern CORE_ADDR skip_prologue (); as a CORE_ADDR (or an expression that can be used as one). */ #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ - (read_memory_integer (((int *)(REGBUF))[SP_REGNUM]+(16*4), 4)) + (sparc_extract_struct_value_address (REGBUF)) +CORE_ADDR sparc_extract_struct_value_address ( +#ifdef __STDC__ + char [REGISTER_BYTES] +#endif + ); /* Describe the pointer in each stack frame to the previous stack frame @@ -296,9 +301,6 @@ extern CORE_ADDR skip_prologue (); of <sun4/reg.h> (also known as <machine/reg.h>). */ #include <sun4/reg.h> -#define GET_RWINDOW_REG(FRAME, REG) \ - (read_memory_integer ((CORE_ADDR)&((struct rwindow *)FRAME)->REG, 4)) - /* FRAME_CHAIN takes a frame's nominal address and produces the frame's chain-pointer. @@ -337,8 +339,8 @@ extern CORE_ADDR skip_prologue (); (fci)->next->bottom : (fci)->next->frame) : \ read_register (SP_REGNUM)); -#define FRAME_CHAIN(thisframe) \ - GET_RWINDOW_REG ((thisframe)->frame, rw_in[6]) +#define FRAME_CHAIN(thisframe) (sparc_frame_chain (thisframe)) +CORE_ADDR sparc_frame_chain (); #define FRAME_CHAIN_VALID(chain, thisframe) \ (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) diff --git a/gdb/utils.c b/gdb/utils.c index cb1eb9c..b014d3c 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -693,6 +693,7 @@ lines_to_list () return 10; } +/* ARGSUSED */ static void set_width_command (args, from_tty, c) char *args; @@ -1205,11 +1206,11 @@ char * strstr (in, find) const char *in, *find; { - register char *p = in - 1; + register const char *p = in - 1; while (0 != (p = strchr (p+1, *find))) { if (strcmp (p, find)) - return p; + return (char *)p; } return 0; } diff --git a/gdb/valprint.c b/gdb/valprint.c index 4dc9778..fc64139 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -669,6 +669,10 @@ val_print (type, valaddr, address, stream, format, switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: + /* FIXME: TYPE_LENGTH (type) is unsigned and therefore always + 0. Is "> 0" meant? I'm not sure what an "array of + unspecified length" (mentioned in the comment for the else-part + of this if) is. */ if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) { @@ -762,9 +766,11 @@ val_print (type, valaddr, address, stream, format, struct fn_field *f; int j, len2; char *kind = ""; + CORE_ADDR addr; - val = unpack_long (builtin_type_int, valaddr); - if (val < 128) + addr = unpack_pointer (lookup_pointer_type (builtin_type_void), + valaddr); + if (addr < 128) { len = TYPE_NFN_FIELDS (domain); for (i = 0; i < len; i++) @@ -775,7 +781,7 @@ val_print (type, valaddr, address, stream, format, for (j = 0; j < len2; j++) { QUIT; - if (TYPE_FN_FIELD_VOFFSET (f, j) == val) + if (TYPE_FN_FIELD_VOFFSET (f, j) == addr) { kind = "virtual"; goto common; @@ -785,7 +791,7 @@ val_print (type, valaddr, address, stream, format, } else { - struct symbol *sym = find_pc_function ((CORE_ADDR) val); + struct symbol *sym = find_pc_function (addr); if (sym == 0) error ("invalid pointer to member function"); len = TYPE_NFN_FIELDS (domain); @@ -821,7 +827,7 @@ val_print (type, valaddr, address, stream, format, } fprintf_filtered (stream, "("); type_print (type, "", stream, -1); - fprintf_filtered (stream, ") %d", (int) val >> 3); + fprintf_filtered (stream, ") %d", (int) addr >> 3); } else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_MEMBER) { @@ -869,7 +875,7 @@ val_print (type, valaddr, address, stream, format, } else { - CORE_ADDR addr = (CORE_ADDR) unpack_long (type, valaddr); + CORE_ADDR addr = unpack_pointer (type, valaddr); elttype = TYPE_TARGET_TYPE (type); if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) @@ -968,7 +974,7 @@ val_print (type, valaddr, address, stream, format, else /* print vtbl's nicely */ if (is_vtbl_member(type)) { - CORE_ADDR vt_address = (CORE_ADDR) unpack_long (type, valaddr); + CORE_ADDR vt_address = unpack_pointer (type, valaddr); int vt_index = find_pc_misc_function (vt_address); if (vt_index >= 0 @@ -981,11 +987,11 @@ val_print (type, valaddr, address, stream, format, } if (vtblprint) { - value val; + value vt_val; - val = value_at (TYPE_TARGET_TYPE (type), vt_address); - val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), - VALUE_ADDRESS (val), stream, format, + vt_val = value_at (TYPE_TARGET_TYPE (type), vt_address); + val_print (VALUE_TYPE (vt_val), VALUE_CONTENTS (vt_val), + VALUE_ADDRESS (vt_val), stream, format, deref_ref, recurse + 1, pretty); if (pretty) { @@ -1018,11 +1024,13 @@ val_print (type, valaddr, address, stream, format, { if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF) { - value val = value_at (TYPE_TARGET_TYPE (type), - (CORE_ADDR) unpack_long (builtin_type_int, - valaddr)); - val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), - VALUE_ADDRESS (val), stream, format, + value deref_val = + value_at + (TYPE_TARGET_TYPE (type), + unpack_pointer (lookup_pointer_type (builtin_type_void), + valaddr)); + val_print (VALUE_TYPE (deref_val), VALUE_CONTENTS (deref_val), + VALUE_ADDRESS (deref_val), stream, format, deref_ref, recurse + 1, pretty); } else @@ -1066,7 +1074,11 @@ val_print (type, valaddr, address, stream, format, if (i < len) fputs_filtered (TYPE_FIELD_NAME (type, i), stream); else - fprintf_filtered (stream, "%d", (int) val); +#ifdef LONG_LONG + fprintf_filtered (stream, "%lld", val); +#else + fprintf_filtered (stream, "%ld", val); +#endif break; case TYPE_CODE_FUNC: @@ -1100,7 +1112,7 @@ val_print (type, valaddr, address, stream, format, char *p; /* Pointer to first (i.e. lowest address) nonzero character. */ char *first_addr; - unsigned len = TYPE_LENGTH (type); + len = TYPE_LENGTH (type); #if TARGET_BYTE_ORDER == BIG_ENDIAN for (p = valaddr; @@ -1442,8 +1454,8 @@ type_print_varspec_suffix (type, stream, show, passed_a_ptr) fprintf_filtered (stream, ")"); fprintf_filtered (stream, "["); - if (TYPE_LENGTH (type) >= 0 - && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) + if (/* always true */ /* TYPE_LENGTH (type) >= 0 + && */ TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) fprintf_filtered (stream, "%d", (TYPE_LENGTH (type) / TYPE_LENGTH (TYPE_TARGET_TYPE (type)))); @@ -1763,10 +1775,12 @@ type_print_base (type, stream, show, level) } } +#if 0 /* Validate an input or output radix setting, and make sure the user knows what they really did here. Radix setting is confusing, e.g. setting the input radix to "10" never changes it! */ +/* ARGSUSED */ static void set_input_radix (args, from_tty, c) char *args; @@ -1779,7 +1793,9 @@ set_input_radix (args, from_tty, c) printf_filtered ("Input radix set to decimal %d, hex %x, octal %o\n", radix, radix, radix); } +#endif +/* ARGSUSED */ static void set_output_radix (args, from_tty, c) char *args; diff --git a/gdb/values.c b/gdb/values.c index 670ed24..5f41e64 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -532,6 +532,19 @@ value_as_double (val) error ("Invalid floating value found in program."); return foo; } +/* Extract a value as a C pointer. + Does not deallocate the value. */ +CORE_ADDR +value_as_pointer (val) + value val; +{ + /* This coerces arrays and functions, which is necessary (e.g. + in disassemble_command). It also dereferences references, which + I suspect is the most logical thing to do. */ + if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_ENUM) + COERCE_ARRAY (val); + return unpack_pointer (VALUE_TYPE (val), VALUE_CONTENTS (val)); +} /* Unpack raw data (copied from debugee, target byte order) at VALADDR as a long, or as a double, assuming the raw data is described @@ -674,10 +687,13 @@ unpack_long (type, valaddr) error ("That operation is not possible on an integer of that size."); } } +#if 0 + /* There is no guarantee that a pointer can fit within a LONGEST. + Callers should use unpack_pointer instead. */ else if (code == TYPE_CODE_PTR || code == TYPE_CODE_REF) { - if (len == sizeof (char *)) + if (len == sizeof (CORE_ADDR)) { CORE_ADDR retval; bcopy (valaddr, &retval, sizeof (retval)); @@ -685,10 +701,15 @@ unpack_long (type, valaddr) return retval; } } +#endif else if (code == TYPE_CODE_MEMBER) error ("not implemented: member types in unpack_long"); +#if 0 error ("Value not integer or pointer."); +#else + error ("Value not integer."); +#endif return 0; /* For lint -- never reached */ } @@ -735,6 +756,7 @@ unpack_double (type, valaddr, invp) else { error ("Unexpected type of floating point number."); + return 0; /* Placate lint. */ } } else if (nosign) { @@ -749,6 +771,46 @@ unpack_double (type, valaddr, invp) return unpack_long (type, valaddr); } } + +/* Unpack raw data (copied from debugee, target byte order) at VALADDR + as a CORE_ADDR, assuming the raw data is described by type TYPE. + We don't assume any alignment for the raw data. Return value is in + host byte order. + + If you want functions and arrays to be coerced to pointers, and + references to be dereferenced, call value_as_pointer() instead. + + C++: It is assumed that the front-end has taken care of + all matters concerning pointers to members. A pointer + to member which reaches here is considered to be equivalent + to an INT (or some size). After all, it is only an offset. */ + +CORE_ADDR +unpack_pointer (type, valaddr) + struct type *type; + char *valaddr; +{ + register enum type_code code = TYPE_CODE (type); + register int len = TYPE_LENGTH (type); + + if (code == TYPE_CODE_PTR + || code == TYPE_CODE_REF) + { + if (len == sizeof (CORE_ADDR)) + { + CORE_ADDR retval; + bcopy (valaddr, &retval, sizeof (retval)); + SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); + return retval; + } + error ("Unrecognized pointer size."); + } + else if (code == TYPE_CODE_MEMBER) + error ("not implemented: member types in unpack_pointer"); + + error ("Value is not a pointer."); + return 0; /* For lint -- never reached */ +} /* Given a value ARG1 (offset by OFFSET bytes) of a struct or union type ARG_TYPE, @@ -922,6 +984,7 @@ 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; @@ -954,11 +1017,11 @@ value_headof (arg, btype, dtype) /* Now search through the virtual function table. */ entry = value_ind (vtbl); entry_type = VALUE_TYPE (entry); - nelems = value_as_long (value_field (entry, 2)); + nelems = longest_to_int (value_as_long (value_field (entry, 2))); for (i = 1; i <= nelems; i++) { entry = value_subscript (vtbl, value_from_long (builtin_type_int, i)); - offset = value_as_long (value_field (entry, 0)); + offset = longest_to_int (value_as_long (value_field (entry, 0))); if (offset < best_offset) { best_offset = offset; @@ -970,7 +1033,7 @@ value_headof (arg, btype, dtype) /* Move the pointer according to BEST_ENTRY's offset, and figure out what type we should return as the new pointer. */ - pc_for_sym = value_as_long (value_field (best_entry, 2)); + pc_for_sym = value_as_pointer (value_field (best_entry, 2)); sym = find_pc_function (pc_for_sym); demangled_name = cplus_demangle (SYMBOL_NAME (sym), -1); *(strchr (demangled_name, ':')) = '\0'; @@ -1111,7 +1174,8 @@ baseclass_addr (type, index, valaddr, valuep, errp) CORE_ADDR addr; int status; - addr = unpack_long (TYPE_FIELD_TYPE (type, i), + addr + = unpack_pointer (TYPE_FIELD_TYPE (type, i), valaddr + (TYPE_FIELD_BITPOS (type, i) / 8)); status = target_read_memory (addr, @@ -1143,7 +1207,7 @@ baseclass_addr (type, index, valaddr, valuep, errp) { char *baddr; - baddr = baseclass_addr (type, i, valaddr, valuep); + baddr = baseclass_addr (type, i, valaddr, valuep, errp); if (baddr) return baddr; } @@ -1190,6 +1254,8 @@ check_stub_method (type, i, j) if (OPNAME_PREFIX_P (field_name)) { char *opname = cplus_mangle_opname (field_name + 3); + if (opname == NULL) + error ("No mangling for \"%s\"", field_name); mangled_name_len += strlen (opname); mangled_name = (char *)xmalloc (mangled_name_len); |