From 1304f099bc900e60f31817b19cc22634880c6611 Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Thu, 11 Jun 1992 08:43:29 +0000 Subject: [PATCH] Small changes from Solaris port. The big stuff is not all working yet. * inferior.h (register_valid): Declare. * remote-udi.c, rs6000-xdep.c, sparc-xdep.c, tm-rs6000.h: Remove decl. * objfiles.h (ALL_OBJFILE_{SYMTABS,PSYMTABS,MSYMBOLS}): Add macros for traversing the data structures in a single objfile. * tm-m88k.h, tm-sparc.h (REGISTER_NAMES): Remove extra semicolon. * tm-i960.h (REGISTER_NAMES): Cosmetic change. * infcmd.c: Lint. --- gdb/ChangeLog | 10 +++ gdb/infcmd.c | 206 +++++++++++++++++++++++++++++++++------------- gdb/objfiles.h | 23 +++++- gdb/remote-udi.c | 1 - gdb/rs6000-xdep.c | 1 - gdb/sparc-xdep.c | 2 - gdb/tm-i960.h | 2 +- gdb/tm-m88k.h | 2 +- gdb/tm-rs6000.h | 3 +- gdb/tm-sparc.h | 2 +- 10 files changed, 181 insertions(+), 71 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7fb91edc24b..52fe89586ed 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Thu Jun 11 01:33:40 1992 John Gilmore (gnu at cygnus.com) + + * inferior.h (register_valid): Declare. + * remote-udi.c, rs6000-xdep.c, sparc-xdep.c, tm-rs6000.h: Remove decl. + * objfiles.h (ALL_OBJFILE_{SYMTABS,PSYMTABS,MSYMBOLS}): Add + macros for traversing the data structures in a single objfile. + * tm-m88k.h, tm-sparc.h (REGISTER_NAMES): Remove extra semicolon. + * tm-i960.h (REGISTER_NAMES): Cosmetic change. + * infcmd.c: Lint. + Tue Jun 9 17:19:45 1992 Fred Fish (fnf@cygnus.com) * c-exp.y, m2-exp.y: Move remapping defines for malloc and diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 7f35a2baf11..b31a52cf663 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -17,12 +17,12 @@ 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 #include #include -#include "defs.h" #include "symtab.h" +#include "gdbtypes.h" #include "frame.h" #include "inferior.h" #include "environ.h" @@ -31,9 +31,80 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include "target.h" -extern char *sys_siglist[]; +static void +continue_command PARAMS ((char *, int)); + +static void +until_next_command PARAMS ((int)); + +static void +until_command PARAMS ((char *, int)); + +static void +path_info PARAMS ((char *, int)); + +static void +path_command PARAMS ((char *, int)); + +static void +unset_command PARAMS ((char *, int)); + +static void +float_info PARAMS ((char *, int)); + +static void +detach_command PARAMS ((char *, int)); + +static void +nofp_registers_info PARAMS ((char *, int)); + +static void +all_registers_info PARAMS ((char *, int)); + +static void +registers_info PARAMS ((char *, int)); + +static void +do_registers_info PARAMS ((int, int)); + +static void +unset_environment_command PARAMS ((char *, int)); + +static void +set_environment_command PARAMS ((char *, int)); + +static void +environment_info PARAMS ((char *, int)); + +static void +program_info PARAMS ((char *, int)); + +static void +finish_command PARAMS ((char *, int)); + +static void +signal_command PARAMS ((char *, int)); + +static void +jump_command PARAMS ((char *, int)); + +static void +step_1 PARAMS ((int, int, char *)); + +static void +nexti_command PARAMS ((char *, int)); -extern void until_break_command (); /* breakpoint.c */ +static void +stepi_command PARAMS ((char *, int)); + +static void +next_command PARAMS ((char *, int)); + +static void +step_command PARAMS ((char *, int)); + +static void +run_command PARAMS ((char *, int)); #define ERROR_NO_INFERIOR \ if (!target_has_execution) error ("The program is not being run."); @@ -117,9 +188,6 @@ int step_multi; struct environ *inferior_environ; -CORE_ADDR read_pc (); -void breakpoint_clear_ignore_counts (); - /* ARGSUSED */ void @@ -153,7 +221,7 @@ Start it from the beginning? ")) exec_file = (char *) get_exec_file (0); - /* The exec file is re-read every time we do an inferior_died, so + /* The exec file is re-read every time we do a generic_mourn_inferior, so we just have to worry about the symbol file. */ reread_symbols (); @@ -167,7 +235,7 @@ Start it from the beginning? ")) if (from_tty) { - printf ("Starting program: %s %s\n", + printf_filtered ("Starting program: %s %s\n", exec_file? exec_file: "", inferior_args); fflush (stdout); } @@ -176,7 +244,7 @@ Start it from the beginning? ")) environ_vector (inferior_environ)); } -void +static void continue_command (proc_count_exp, from_tty) char *proc_count_exp; int from_tty; @@ -202,13 +270,13 @@ continue_command (proc_count_exp, from_tty) /* set_ignore_count prints a message ending with a period. So print two spaces before "Continuing.". */ if (from_tty) - printf (" "); + printf_filtered (" "); num = bpstat_num (&bs); } } if (from_tty) - printf ("Continuing.\n"); + printf_filtered ("Continuing.\n"); clear_proceed_status (); @@ -216,12 +284,11 @@ 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; + char *count_string; int from_tty; { step_1 (0, 0, count_string); @@ -232,7 +299,7 @@ step_command (count_string, from_tty) /* ARGSUSED */ static void next_command (count_string, from_tty) - char * count_string; + char *count_string; int from_tty; { step_1 (1, 0, count_string); @@ -243,7 +310,7 @@ next_command (count_string, from_tty) /* ARGSUSED */ static void stepi_command (count_string, from_tty) - char * count_string; + char *count_string; int from_tty; { step_1 (0, 1, count_string); @@ -252,7 +319,7 @@ stepi_command (count_string, from_tty) /* ARGSUSED */ static void nexti_command (count_string, from_tty) - char * count_string; + char *count_string; int from_tty; { step_1 (1, 1, count_string); @@ -266,15 +333,21 @@ step_1 (skip_subroutines, single_inst, count_string) { register int count = 1; FRAME fr; + struct cleanup *cleanups = 0; ERROR_NO_INFERIOR; count = count_string ? parse_and_eval_address (count_string) : 1; + if (!single_inst || skip_subroutines) /* leave si command alone */ + { + enable_longjmp_breakpoint(); + cleanups = make_cleanup(disable_longjmp_breakpoint, 0); + } + for (; count > 0; count--) { clear_proceed_status (); - fr = get_current_frame (); if (!fr) /* Avoid coredump here. Why tho? */ error ("No current frame"); @@ -285,22 +358,22 @@ step_1 (skip_subroutines, single_inst, count_string) find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end); if (step_range_end == 0) { - int misc; + struct minimal_symbol *msymbol; - misc = find_pc_misc_function (stop_pc); + msymbol = lookup_minimal_symbol_by_pc (stop_pc); target_terminal_ours (); - printf ("Current function has no line number information.\n"); + printf_filtered ("Current function has no line number information.\n"); fflush (stdout); /* No info or after _etext ("Can't happen") */ - if (misc == -1 || misc == misc_function_count - 1) + if (msymbol == NULL || (msymbol + 1) -> name == NULL) error ("No data available on pc function."); - printf ("Single stepping until function exit.\n"); + printf_filtered ("Single stepping until function exit.\n"); fflush (stdout); - step_range_start = misc_function_vector[misc].address; - step_range_end = misc_function_vector[misc + 1].address; + step_range_start = msymbol -> address; + step_range_end = (msymbol + 1) -> address; } } else @@ -325,6 +398,9 @@ step_1 (skip_subroutines, single_inst, count_string) write_register (NPC_REGNUM, read_register (PC_REGNUM)); #endif } + + if (!single_inst || skip_subroutines) + do_cleanups(cleanups); } /* Continue program at specified address. */ @@ -350,7 +426,7 @@ jump_command (arg, from_tty) } sal = sals.sals[0]; - free (sals.sals); + free ((PTR)sals.sals); if (sal.symtab == 0 && sal.pc == 0) error ("No source file has been specified."); @@ -369,7 +445,7 @@ jump_command (arg, from_tty) addr = ADDR_BITS_SET (sal.pc); if (from_tty) - printf ("Continuing at %s.\n", local_hex_string(addr)); + printf_filtered ("Continuing at %s.\n", local_hex_string(addr)); clear_proceed_status (); proceed (addr, 0, 0); @@ -393,7 +469,7 @@ signal_command (signum_exp, from_tty) signum = parse_and_eval_address (signum_exp); if (from_tty) - printf ("Continuing with signal %d.\n", signum); + printf_filtered ("Continuing with signal %d.\n", signum); clear_proceed_status (); proceed (stop_pc, signum, 0); @@ -454,7 +530,7 @@ The expression which contained the function call has been discarded."); of wait_for_inferior and the proceed status code. -- randy */ /* ARGSUSED */ -void +static void until_next_command (from_tty) int from_tty; { @@ -476,12 +552,12 @@ until_next_command (from_tty) if (!func) { - int misc_func = find_pc_misc_function (pc); + struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); - if (misc_func != -1) + if (msymbol == NULL) error ("Execution is not within a known function."); - step_range_start = misc_function_vector[misc_func].address; + step_range_start = msymbol -> address; step_range_end = pc; } else @@ -500,7 +576,7 @@ until_next_command (from_tty) proceed ((CORE_ADDR) -1, -1, 1); } -void +static void until_command (arg, from_tty) char *arg; int from_tty; @@ -525,6 +601,8 @@ finish_command (arg, from_tty) register FRAME frame; struct frame_info *fi; register struct symbol *function; + struct breakpoint *breakpoint; + struct cleanup *old_chain; if (arg) error ("The \"finish\" command does not take any arguments."); @@ -542,7 +620,10 @@ finish_command (arg, from_tty) fi = get_frame_info (frame); sal = find_pc_line (fi->pc, 0); sal.pc = fi->pc; - set_momentary_breakpoint (sal, frame); + + breakpoint = set_momentary_breakpoint (sal, frame, bp_finish); + + old_chain = make_cleanup(delete_breakpoint, breakpoint); /* Find the function we will return from. */ @@ -560,7 +641,9 @@ finish_command (arg, from_tty) proceed_to_finish = 1; /* We want stop_registers, please... */ proceed ((CORE_ADDR) -1, -1, 0); - if (bpstat_momentary_breakpoint (stop_bpstat) && function != 0) + /* Did we stop at our breakpoint? */ + if (bpstat_find_breakpoint(stop_bpstat, breakpoint) != NULL + && function != 0) { struct type *value_type; register value val; @@ -585,6 +668,7 @@ finish_command (arg, from_tty) value_print (val, stdout, 0, Val_no_prettyprint); printf_filtered ("\n"); } + do_cleanups(old_chain); } /* ARGSUSED */ @@ -598,14 +682,14 @@ program_info (args, from_tty) if (!target_has_execution) { - printf ("The program being debugged is not being run.\n"); + printf_filtered ("The program being debugged is not being run.\n"); return; } target_files_info (); - printf ("Program stopped at %s.\n", local_hex_string(stop_pc)); + printf_filtered ("Program stopped at %s.\n", local_hex_string(stop_pc)); if (stop_step) - printf ("It stopped after being stepped.\n"); + printf_filtered ("It stopped after being stepped.\n"); else if (num != 0) { /* There may be several breakpoints in the same place, so this @@ -613,9 +697,9 @@ program_info (args, from_tty) while (num != 0) { if (num < 0) - printf ("It stopped at a breakpoint that has since been deleted.\n"); + printf_filtered ("It stopped at a breakpoint that has since been deleted.\n"); else - printf ("It stopped at breakpoint %d.\n", num); + printf_filtered ("It stopped at breakpoint %d.\n", num); num = bpstat_num (&bs); } } @@ -623,39 +707,40 @@ program_info (args, from_tty) #ifdef PRINT_RANDOM_SIGNAL PRINT_RANDOM_SIGNAL (stop_signal); #else - printf ("It stopped with signal %d (%s).\n", - stop_signal, - (stop_signal > NSIG)? "unknown": sys_siglist[stop_signal]); + printf_filtered ("It stopped with signal %d (%s).\n", + stop_signal, safe_strsignal (stop_signal)); #endif } if (!from_tty) - printf ("Type \"info stack\" or \"info registers\" for more information.\n"); + printf_filtered ("Type \"info stack\" or \"info registers\" for more information.\n"); } static void -environment_info (var) +environment_info (var, from_tty) char *var; + int from_tty; { if (var) { register char *val = get_in_environ (inferior_environ, var); if (val) - printf ("%s = %s\n", var, val); + printf_filtered ("%s = %s\n", var, val); else - printf ("Environment variable \"%s\" not defined.\n", var); + printf_filtered ("Environment variable \"%s\" not defined.\n", var); } else { register char **vector = environ_vector (inferior_environ); while (*vector) - printf ("%s\n", *vector++); + printf_filtered ("%s\n", *vector++); } } static void -set_environment_command (arg) +set_environment_command (arg, from_tty) char *arg; + int from_tty; { register char *p, *val, *var; int nullset = 0; @@ -705,7 +790,7 @@ set_environment_command (arg) var = savestring (arg, p - arg); if (nullset) { - printf ("Setting environment variable \"%s\" to null value.\n", var); + printf_filtered ("Setting environment variable \"%s\" to null value.\n", var); set_in_environ (inferior_environ, var, ""); } else @@ -737,18 +822,18 @@ unset_environment_command (var, from_tty) const static char path_var_name[] = "PATH"; /* ARGSUSED */ -void +static void path_info (args, from_tty) char *args; int from_tty; { - printf ("Executable and object file path: %s\n", + printf_filtered ("Executable and object file path: %s\n", get_in_environ (inferior_environ, path_var_name)); } /* Add zero or more directories to the front of the execution path. */ -void +static void path_command (dirname, from_tty) char *dirname; int from_tty; @@ -781,7 +866,7 @@ write_pc (val) pc_changed = 0; } -char *reg_names[] = REGISTER_NAMES; +const char * const reg_names[] = REGISTER_NAMES; /* Print out the machine register regnum. If regnum is -1, print all registers (fpregs == 1) or all non-float registers @@ -909,15 +994,17 @@ registers_info (addr_exp, fpregs) } static void -all_registers_info (addr_exp) +all_registers_info (addr_exp, from_tty) char *addr_exp; + int from_tty; { registers_info (addr_exp, 1); } static void -nofp_registers_info (addr_exp) +nofp_registers_info (addr_exp, from_tty) char *addr_exp; + int from_tty; { registers_info (addr_exp, 0); } @@ -970,13 +1057,14 @@ detach_command (args, from_tty) /* ARGSUSED */ static void -float_info (addr_exp) +float_info (addr_exp, from_tty) char *addr_exp; + int from_tty; { #ifdef FLOAT_INFO FLOAT_INFO; #else - printf ("No floating point info available for this processor.\n"); + printf_filtered ("No floating point info available for this processor.\n"); #endif } @@ -988,7 +1076,7 @@ unset_command (args, from_tty) char *args; int from_tty; { - printf ("\"unset\" must be followed by the name of an unset subcommand.\n"); + printf_filtered ("\"unset\" must be followed by the name of an unset subcommand.\n"); help_list (unsetlist, "unset ", -1, stdout); } diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 51a2a822de2..68bfd9ab3e7 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -325,22 +325,39 @@ have_minimal_symbols PARAMS ((void)); (obj) != NULL? ((nxt)=(obj)->next,1) :0; \ (obj) = (nxt)) + +/* Traverse all symtabs in one objfile. */ + +#define ALL_OBJFILE_SYMTABS(objfile, s) \ + for ((s) = (objfile) -> symtabs; (s) != NULL; (s) = (s) -> next) + +/* Traverse all psymtabs in one objfile. */ + +#define ALL_OBJFILE_PSYMTABS(objfile, p) \ + for ((p) = (objfile) -> psymtabs; (p) != NULL; (p) = (p) -> next) + +/* Traverse all minimal symbols in one objfile. */ + +#define ALL_OBJFILE_MSYMBOLS(objfile, m) \ + for ((m) = (objfile) -> msymbols; (m)->name != NULL; (m)++) + + /* Traverse all symtabs in all objfiles. */ #define ALL_SYMTABS(objfile, s) \ ALL_OBJFILES (objfile) \ - for ((s) = (objfile) -> symtabs; (s) != NULL; (s) = (s) -> next) + ALL_OBJFILE_SYMTABS (objfile, s) /* Traverse all psymtabs in all objfiles. */ #define ALL_PSYMTABS(objfile, p) \ ALL_OBJFILES (objfile) \ - for ((p) = (objfile) -> psymtabs; (p) != NULL; (p) = (p) -> next) + ALL_OBJFILE_PSYMTABS (objfile, p) /* Traverse all minimal symbols in all objfiles. */ #define ALL_MSYMBOLS(objfile, m) \ ALL_OBJFILES (objfile) \ - for ((m) = (objfile) -> msymbols; (m)->name != NULL; (m)++) + ALL_OBJFILE_MSYMBOLS (objfile, m) #endif /* !defined (OBJFILES_H) */ diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index 68e8d37bb8f..09572589c55 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -61,7 +61,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #endif -extern char register_valid[]; extern int stop_soon_quietly; /* for wait_for_inferior */ extern struct value *call_function_by_hand(); static void udi_resume(); diff --git a/gdb/rs6000-xdep.c b/gdb/rs6000-xdep.c index 2c491d44c9b..516331da20e 100644 --- a/gdb/rs6000-xdep.c +++ b/gdb/rs6000-xdep.c @@ -59,7 +59,6 @@ static int special_regs[] = { /* Nonzero if we just simulated a single step break. */ extern int one_stepped; -extern char register_valid[]; extern struct obstack frame_cache_obstack; diff --git a/gdb/sparc-xdep.c b/gdb/sparc-xdep.c index 327388ebfb5..01ae20410f7 100644 --- a/gdb/sparc-xdep.c +++ b/gdb/sparc-xdep.c @@ -33,8 +33,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include -extern char register_valid[]; - /* We don't store all registers immediately when requested, since they get sent over in large chunks anyway. Instead, we accumulate most of the changes and send them over once. "deferred_stores" keeps diff --git a/gdb/tm-i960.h b/gdb/tm-i960.h index 7dba1dec15d..561b06ae1d7 100644 --- a/gdb/tm-i960.h +++ b/gdb/tm-i960.h @@ -94,7 +94,7 @@ extern CORE_ADDR saved_pc_after_call (); /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",\ /* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \ /* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp", \ - /* 32 */ "pc", "ac", "ip", "tc", "fp0", "fp1", "fp2", "fp3", \ + /* 32 */ "pc", "ac", "ip", "tc", "fp0", "fp1", "fp2", "fp3",\ } /* Register numbers of various important registers (used to index diff --git a/gdb/tm-m88k.h b/gdb/tm-m88k.h index 31b62cbc787..7ab1ead998a 100644 --- a/gdb/tm-m88k.h +++ b/gdb/tm-m88k.h @@ -180,7 +180,7 @@ extern CORE_ADDR skip_prologue (); "fpit",\ "fpsr",\ "fpcr",\ - }; + } /* Register numbers of various important registers. diff --git a/gdb/tm-rs6000.h b/gdb/tm-rs6000.h index d4456075090..fbc824d89ee 100644 --- a/gdb/tm-rs6000.h +++ b/gdb/tm-rs6000.h @@ -185,8 +185,7 @@ extern int aix_loadInfoTextIndex; the new frame is not set up until the new function executes some instructions. */ -extern char registers[]; -extern char register_valid []; +#include "inferior.h" /* For registers[] and register_valid[]. */ #define SAVED_PC_AFTER_CALL(frame) \ (register_valid [LR_REGNUM] ? \ diff --git a/gdb/tm-sparc.h b/gdb/tm-sparc.h index a86694c5b15..69cad054b28 100644 --- a/gdb/tm-sparc.h +++ b/gdb/tm-sparc.h @@ -137,7 +137,7 @@ extern CORE_ADDR sparc_pc_adjust(); "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ \ - "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr" }; + "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr" } /* Register numbers of various important registers. Note that some of these values are "real" register numbers, -- 2.30.2