diff options
-rw-r--r-- | gdb/blockframe.c | 3 | ||||
-rw-r--r-- | gdb/cplus-dem.c | 2 | ||||
-rw-r--r-- | gdb/dbxread.c | 6 | ||||
-rw-r--r-- | gdb/defs.h | 28 | ||||
-rw-r--r-- | gdb/infptrace.c | 14 | ||||
-rw-r--r-- | gdb/infrun.c | 42 | ||||
-rw-r--r-- | gdb/printcmd.c | 21 | ||||
-rw-r--r-- | gdb/sparc-tdep.c | 58 | ||||
-rw-r--r-- | gdb/symfile.c | 5 | ||||
-rw-r--r-- | gdb/symtab.c | 5 | ||||
-rw-r--r-- | gdb/utils.c | 6 | ||||
-rw-r--r-- | gdb/valops.c | 20 |
12 files changed, 147 insertions, 63 deletions
diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 93d26cd..ba4cc24 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with GDB; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <stdio.h> #include "defs.h" #include "param.h" #include "symtab.h" @@ -575,7 +576,7 @@ find_pc_partial_function (pc, name, address) cache_pc_function_low = pc - FUNCTION_START_OFFSET; } cache_pc_function_name = misc_function_vector[miscfunc].name; - if (miscfunc < misc_function_count && 1 /* FIXME mf_text again? */ ) + if (miscfunc < misc_function_count /* && FIXME mf_text again? */ ) cache_pc_function_high = misc_function_vector[miscfunc+1].address; else cache_pc_function_high = cache_pc_function_low + 1; diff --git a/gdb/cplus-dem.c b/gdb/cplus-dem.c index 750bdae..4eae9a4 100644 --- a/gdb/cplus-dem.c +++ b/gdb/cplus-dem.c @@ -94,7 +94,7 @@ extern char *cplus_demangle (); as long as we're including defs.h. */ extern void *xmalloc (int); extern void *xrealloc (char *, int); -extern void free (char *); +extern void free (void *); #else extern char *xmalloc (); extern char *xrealloc (); diff --git a/gdb/dbxread.c b/gdb/dbxread.c index cd87db4..4644fef 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -121,7 +121,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "command.h" #include "target.h" #include "gdbcore.h" /* for bfd stuff */ -#include "liba.out.h" /* FIXME Secret internal BFD stuff for a.out */ +#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */ #include "symfile.h" struct dbx_symfile_info { @@ -4986,6 +4986,7 @@ read_huge_number (pp, end, valu, bits) char overflow = 0; int nbits = 0; int c; + long upper_limit; if (*p == '-') { @@ -5001,9 +5002,10 @@ read_huge_number (pp, end, valu, bits) p++; } + upper_limit = LONG_MAX / radix; while ((c = *p++) >= '0' && c <= ('0' + radix)) { - if (n <= LONG_MAX / radix) + if (n <= upper_limit) { n *= radix; n += c - '0'; /* FIXME this overflows anyway */ @@ -36,15 +36,25 @@ typedef unsigned int CORE_ADDR; * If non-ansi, non-gcc, then eliminate "const" entirely, making those * objects be read-write rather than read-only. */ +#ifndef const #ifndef __STDC__ # ifdef __GNUC__ # define const __const__ -# define volatile __volatile__ # else # define const /*nothing*/ +# endif /* GNUC */ +#endif /* STDC */ +#endif /* const */ + +#ifndef volatile +#ifndef __STDC__ +# ifdef __GNUC__ +# define volatile __volatile__ +# else # define volatile /*nothing*/ # endif /* GNUC */ #endif /* STDC */ +#endif /* volatile */ extern char *savestring (); extern char *strsave (); @@ -61,14 +71,16 @@ extern char *reg_names[]; extern volatile void error(), fatal(); /* Various possibilities for alloca. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef sparc -# include <alloca.h> -# endif - extern char *alloca (); +#ifndef alloca +# ifdef __GNUC__ +# define alloca __builtin_alloca +# else +# ifdef sparc +# include <alloca.h> +# endif + extern char *alloca (); # endif +#endif extern int errno; /* System call error return status */ diff --git a/gdb/infptrace.c b/gdb/infptrace.c index 2298c98..23da854 100644 --- a/gdb/infptrace.c +++ b/gdb/infptrace.c @@ -106,19 +106,16 @@ child_resume (step, signal) int signal; { errno = 0; - /* An address of (int *)1 tells it to continue from where it was. + + /* An address of (int *)1 tells ptrace to continue from where it was. (If GDB wanted it to start some other way, we have already written a new PC value to the child.) */ + if (step) - { -#if defined (NO_SINGLE_STEP) - single_step (signal); -#else /* Have single step. */ - ptrace (PT_STEP, inferior_pid, (int *)1, signal); -#endif /* Have single step. */ - } + ptrace (PT_STEP, inferior_pid, (int *)1, signal); else ptrace (PT_CONTINUE, inferior_pid, (int *)1, signal); + if (errno) perror_with_name ("ptrace"); } @@ -245,7 +242,6 @@ fetch_inferior_registers (regno) fetch_register (regno); else fetch_register (regno); - return 0; } /* Registers we shouldn't try to store. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index acdcb70..9e5b750 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -172,6 +172,12 @@ extern char *inferior_thisrun_terminal; name && !strcmp ("_sigtramp", name) #endif +#ifdef TDESC +#include "tdesc.h" +int safe_to_init_tdesc_context = 0; +extern dc_dcontext_t current_context; +#endif + /* Tables of how to react to signals; the user sets them. */ static char signal_stop[NSIG]; @@ -283,6 +289,14 @@ resume (step, sig) { struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0); QUIT; + +#ifdef NO_SINGLE_STEP + if (step) { + single_step(); /* Do it the hard way, w/temp breakpoints */ + step = 0; /* ...and don't ask hardware to do it. */ + } +#endif + target_resume (step, sig); discard_cleanups (old_cleanups); } @@ -717,6 +731,9 @@ wait_for_inferior () int stop_step_resume_break; struct symtab_and_line sal; int remove_breakpoints_on_following_step = 0; +#ifdef TDESC + extern dc_handle_t tdesc_handle; +#endif #if 0 /* This no longer works now that read_register is lazy; @@ -741,6 +758,9 @@ wait_for_inferior () if (WIFEXITED (w)) { target_terminal_ours (); /* Must do this before mourn anyway */ +#ifdef TDESC + safe_to_init_tdesc_context = 0; +#endif if (WEXITSTATUS (w)) printf ("\nProgram exited with code 0%o.\n", (unsigned int)WEXITSTATUS (w)); @@ -761,6 +781,9 @@ wait_for_inferior () stop_signal = WTERMSIG (w); target_terminal_ours (); /* Must do this before mourn anyway */ target_kill ((char *)0, 0); /* kill mourns as well */ +#ifdef TDESC + safe_to_init_tdesc_context = 0; +#endif #ifdef PRINT_RANDOM_SIGNAL printf ("\nProgram terminated: "); PRINT_RANDOM_SIGNAL (stop_signal); @@ -785,6 +808,14 @@ wait_for_inferior () #endif /* NO_SINGLE_STEP */ stop_pc = read_pc (); +#ifdef TDESC + if (safe_to_init_tdesc_context) + { + current_context = init_dcontext(); + set_current_frame ( create_new_frame (get_frame_base (read_pc()),read_pc())); + } + else +#endif /* TDESC */ set_current_frame ( create_new_frame (read_register (FP_REGNUM), read_pc ())); @@ -1225,6 +1256,14 @@ wait_for_inferior () to one-proceed past a breakpoint. */ /* If we've just finished a special step resume and we don't want to hit a breakpoint, pull em out. */ +#ifdef TDESC + if (!tdesc_handle) + { + init_tdesc(); + safe_to_init_tdesc_context = 1; + } +#endif + if (!step_resume_break_address && remove_breakpoints_on_following_step) { @@ -1252,7 +1291,8 @@ wait_for_inferior () that we shouldn't rewrite the regs when we were stopped by a random signal from the inferior process. */ - if (!stop_breakpoint && (stop_signal != SIGCLD) + if (!bpstat_explains_signal (stop_bpstat) + && (stop_signal != SIGCLD) && !stopped_by_random_signal) { CORE_ADDR pc_contents = read_register (PC_REGNUM); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 149239e..a5251eb 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -993,27 +993,30 @@ ptype_command (typename, from_tty) whatis_exp (typename, 1); return; } - printf_filtered ("No type named %s, but there is a ", - typename); + printf_filtered ("No type named %s, ", typename); + wrap_here (""); + printf_filtered ("but there is "); switch (TYPE_CODE (SYMBOL_TYPE (sym))) { case TYPE_CODE_STRUCT: - printf_filtered ("struct"); + printf_filtered ("a struct"); break; case TYPE_CODE_UNION: - printf_filtered ("union"); + printf_filtered ("a union"); break; case TYPE_CODE_ENUM: - printf_filtered ("enum"); + printf_filtered ("an enum"); break; default: printf_filtered ("(Internal error in gdb)"); break; } - printf_filtered (" %s. Type \"help ptype\".\n", typename); + printf_filtered (" %s. ", typename); + wrap_here (""); + printf_filtered ("(Type \"help ptype\".)\n"); type = SYMBOL_TYPE (sym); } } @@ -1531,11 +1534,13 @@ print_frame_args (func, fi, num, stream) /* Avoid value_print because it will deref ref parameters. We just want to print their addresses. Print ??? for args whose address - we do not know. */ + we do not know. We pass 2 as "recurse" to val_print because our + standard indentation here is 4 spaces, and val_print indents + 2 for each recurse. */ val = read_var_value (sym, FRAME_INFO_ID (fi)); if (val) val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), VALUE_ADDRESS (val), - stream, 0, 0, 0, Val_no_prettyprint); + stream, 0, 0, 2, Val_no_prettyprint); else fputs_filtered ("???", stream); first = 0; diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 5118fc3..a59986d 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -29,19 +29,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "target.h" #include "ieee-float.h" -#include <sys/param.h> -#include <sys/dir.h> -#include <sys/user.h> -#include <signal.h> -#include <sys/ioctl.h> -#include <fcntl.h> - #include <sys/ptrace.h> -#include <sys/file.h> -#include <sys/stat.h> -#include <sys/core.h> - #include "gdbcore.h" /* From infrun.c */ @@ -69,9 +58,16 @@ static binsn_quantum break_mem[3]; int one_stepped; +/* single_step() is called just before we want to resume the inferior, + if we want to single-step it but there is no hardware or kernel single-step + support (as on all SPARCs). We find all the possible targets of the + coming instruction and breakpoint them. + + single_step is also called just after the inferior stops. If we had + set up a simulated single-step, we undo our damage. */ + void -single_step (signal) - int signal; +single_step () { branch_type br, isannulled(); CORE_ADDR pc; @@ -107,8 +103,7 @@ single_step (signal) target_insert_breakpoint (target, break_mem[2]); } - /* Let it go */ - ptrace (7, inferior_pid, 1, signal); + /* We are ready to let it go */ one_stepped = 1; return; } @@ -127,6 +122,28 @@ single_step (signal) } } +CORE_ADDR +sparc_frame_chain (thisframe) + FRAME thisframe; +{ + CORE_ADDR retval; + read_memory ((CORE_ADDR)&(((struct rwindow *)(thisframe->frame))->rw_in[6]), + &retval, + sizeof (CORE_ADDR)); + return retval; +} + +CORE_ADDR +sparc_extract_struct_value_address (regbuf) + char regbuf[REGISTER_BYTES]; +{ + CORE_ADDR retval; + read_memory (((int *)(regbuf))[SP_REGNUM]+(16*4), + &retval, + sizeof (CORE_ADDR)); + return retval; +} + /* * Find the pc saved in frame FRAME. */ @@ -138,11 +155,14 @@ frame_saved_pc (frame) /* If it's at the bottom, the return value's stored in i7/rp */ if (get_current_frame () == frame) - prev_pc = GET_RWINDOW_REG (read_register (SP_REGNUM), rw_in[7]); + read_memory ((CORE_ADDR)&((struct rwindow *) + (read_register (SP_REGNUM)))->rw_in[7], + &prev_pc, sizeof (CORE_ADDR)); else - /* Wouldn't this always work? This would allow this routine to - be completely a macro. */ - prev_pc = GET_RWINDOW_REG (frame->bottom, rw_in[7]); + /* Wouldn't this always work? */ + read_memory ((CORE_ADDR)&((struct rwindow *)(frame->bottom))->rw_in[7], + &prev_pc, + sizeof (CORE_ADDR)); return PC_ADJUST (prev_pc); } diff --git a/gdb/symfile.c b/gdb/symfile.c index 734d36a..1964417 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -40,7 +40,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ extern int info_verbose; -extern int close (); extern void qsort (); extern char *getenv (); @@ -865,6 +864,10 @@ free_named_symtabs (name) struct blockvector *bv; int blewit = 0; + /* Some symbol formats have trouble providing file names... */ + if (name == 0 || *name == '\0') + return 0; + /* Look for a psymtab with the specified name. */ again2: diff --git a/gdb/symtab.c b/gdb/symtab.c index 6ebea5e..4b2541b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -37,8 +37,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <string.h> #include <sys/stat.h> -extern int close (); -extern void qsort (); extern char *getenv (); extern char *cplus_demangle (); @@ -2234,7 +2232,6 @@ decode_line_2 (sym_arr, nelts, funfirstline) int nelts; int funfirstline; { - char *getenv(); struct symtabs_and_lines values, return_values; register CORE_ADDR pc; char *args, *arg1, *command_line_input (); @@ -2466,7 +2463,7 @@ list_symbols (regexp, class, bpt) int found_in_file = 0; if (regexp) - if (0 != (val = (char *) re_comp (regexp))) + if (0 != (val = re_comp (regexp))) error ("Invalid regexp (%s): %s", val, regexp); /* Search through the partial_symtab_list *first* for all symbols diff --git a/gdb/utils.c b/gdb/utils.c index cce338d..28c3c87 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -58,7 +58,8 @@ extern char *realloc(); /* Can't #define it since printcmd.c needs it */ void vprintf (format, ap) - char *format; void *ap; + char *format; + va_alist ap; { vfprintf (stdout, format, ap); } @@ -380,6 +381,7 @@ void quit () { target_terminal_ours (); + wrap_here ((char *)0); /* Force out any pending output */ #ifdef HAVE_TERMIO ioctl (fileno (stdout), TCFLSH, 1); #else /* not HAVE_TERMIO */ @@ -873,7 +875,7 @@ fputs_filtered (linebuffer, stream) if (*lineptr == '\n') { chars_printed = 0; - wrap_here (""); /* Spit out chars, cancel further wraps */ + wrap_here ((char *)0); /* Spit out chars, cancel further wraps */ lines_printed++; putc ('\n', stream); lineptr++; diff --git a/gdb/valops.c b/gdb/valops.c index 75620d0..92ec751 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -92,6 +92,10 @@ value_cast (type, arg2) { return value_at_lazy (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2)); } + else if (code1 == TYPE_CODE_VOID) + { + return value_zero (builtin_type_void, not_lval); + } else { error ("Invalid cast."); @@ -495,7 +499,7 @@ value_ind (arg1) (CORE_ADDR) value_as_long (arg1)); else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) return value_at_lazy (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - (CORE_ADDR) value_as_long (arg1)); + value_as_pointer (arg1)); error ("Attempt to take contents of a non-pointer value."); return 0; /* For lint -- never reached */ } @@ -620,7 +624,7 @@ find_function_addr (function, retval_type) } else if (code == TYPE_CODE_PTR) { - funaddr = value_as_long (function); + funaddr = value_as_pointer (function); if (TYPE_CODE (TYPE_TARGET_TYPE (ftype)) == TYPE_CODE_FUNC || TYPE_CODE (TYPE_TARGET_TYPE (ftype)) == TYPE_CODE_METHOD) value_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype)); @@ -632,10 +636,10 @@ find_function_addr (function, retval_type) /* Handle the case of functions lacking debugging info. Their values are characters since their addresses are char */ if (TYPE_LENGTH (ftype) == 1) - funaddr = value_as_long (value_addr (function)); + funaddr = value_as_pointer (value_addr (function)); else /* Handle integer used as address of a function. */ - funaddr = value_as_long (function); + funaddr = (CORE_ADDR) value_as_long (function); value_type = builtin_type_int; } @@ -950,7 +954,7 @@ value_string (ptr, len) val = target_call_function (val, 1, &blocklen); if (value_zerop (val)) error ("No memory available for string constant."); - write_memory ((CORE_ADDR) value_as_long (val), copy, len + 1); + write_memory (value_as_pointer (val), copy, len + 1); VALUE_TYPE (val) = lookup_pointer_type (builtin_type_char); return val; } @@ -1002,7 +1006,8 @@ search_struct_field (name, arg1, offset, type, looking_for_baseclass) if (BASETYPE_VIA_VIRTUAL (type, i)) { value v2; - baseclass_addr (type, i, VALUE_CONTENTS (arg1) + offset, &v2); + baseclass_addr (type, i, VALUE_CONTENTS (arg1) + offset, + &v2, (int *)NULL); if (v2 == 0) error ("virtual baseclass botch"); if (found_baseclass) @@ -1074,7 +1079,8 @@ search_struct_method (name, arg1, args, offset, static_memfuncp, type) if (BASETYPE_VIA_VIRTUAL (type, i)) { value v2; - baseclass_addr (type, i, VALUE_CONTENTS (arg1) + offset, &v2); + baseclass_addr (type, i, VALUE_CONTENTS (arg1) + offset, + &v2, (int *)NULL); if (v2 == 0) error ("virtual baseclass botch"); v = search_struct_method (name, v2, args, 0, |