]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* configure.in: Check for unistd.h.
authorJ.T. Conklin <jtc@acorntoolworks.com>
Mon, 31 Jul 1995 22:46:03 +0000 (22:46 +0000)
committerJ.T. Conklin <jtc@acorntoolworks.com>
Mon, 31 Jul 1995 22:46:03 +0000 (22:46 +0000)
* configure: Regenerated.

* command.c, cp-valprint.c, fork-child.c, i386-tdep.c,
i386b-nat.c, inflow.c, main.c, maint.c, objfiles.c, solib.c,
source.c, stack.c, symfile.c, top.c, utils.c: Include strings.h
and/or unistd.h to bring prototypes into scope.

18 files changed:
gdb/ChangeLog
gdb/command.c
gdb/configure
gdb/configure.in
gdb/cp-valprint.c
gdb/fork-child.c
gdb/i386-tdep.c
gdb/i386b-nat.c
gdb/inflow.c
gdb/main.c
gdb/maint.c
gdb/objfiles.c
gdb/solib.c
gdb/source.c
gdb/stack.c
gdb/symfile.c
gdb/top.c
gdb/utils.c

index 9a7fd64a87887649e4cc1b4b92dde6e3d063020c..f079807415e2cbdcca9e78a3ba8a496e8265ba9b 100644 (file)
@@ -1,3 +1,24 @@
+Mon Jul 31 14:32:30 1995  J.T. Conklin  <jtc@rtl.cygnus.com>
+
+       * configure.in: Check for unistd.h.
+       * configure: Regenerated.
+
+       * command.c, cp-valprint.c, fork-child.c, i386-tdep.c,
+       i386b-nat.c, inflow.c, main.c, maint.c, objfiles.c, solib.c,
+       source.c, stack.c, symfile.c, top.c, utils.c: Include strings.h
+       and/or unistd.h to bring prototypes into scope.
+
+Sun Jul 30 01:40:11 1995  Peter Schauer  (pes@regent.e-technik.tu-muenchen.de)
+
+       * rs6000-tdep.c (frame_saved_pc):  Check for signal handler caller
+       before trying to determine the start of the function.
+       (skip_prologue):  Skip subroutine call which might save the
+       floating point registers only if it is within the first three
+       instructions.
+       Reinstate setting of alloca_reg if setup of a gcc frame pointer
+       is found.
+       (frame_get_cache_fsr):  Use new fields in rs6000_framedata.
+
 Sat Jul 29 14:43:35 1995  Stan Shebs  <shebs@andros.cygnus.com>
 
        * sparclite: Removed subdirectory.  aload and eload are now in
 Sat Jul 29 14:43:35 1995  Stan Shebs  <shebs@andros.cygnus.com>
 
        * sparclite: Removed subdirectory.  aload and eload are now in
index b112d730b5e5a93cfbf4e36c4d2acc3f444ce3ed..0735baed27022696b800098ba73fcd8f8b82e3ba 100644 (file)
@@ -21,6 +21,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "value.h"
 #include <ctype.h>
 #include <string.h>
 #include "value.h"
 #include <ctype.h>
 #include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 /* Prototypes for local functions */
 
 
 /* Prototypes for local functions */
 
index cf06eff792a829b5fb5b7ea3b64679e49d75d71e..e324daf0d138b5ccf6aec4cfa9353fa63447fc04 100755 (executable)
@@ -847,6 +847,42 @@ test "$program_suffix" != NONE &&
 test "$program_transform_name" = "" && program_transform_name="s,x,x,"
 
 
 test "$program_transform_name" = "" && program_transform_name="s,x,x,"
 
 
+for ac_hdr in unistd.h
+do
+ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 859 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
 
 ENABLE_CFLAGS=
 ENABLE_CLIBS=
 
 ENABLE_CFLAGS=
 ENABLE_CLIBS=
@@ -943,7 +979,7 @@ test -z "$x_direct_test_library" && x_direct_test_library=Xt
 test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
 test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
 cat > conftest.$ac_ext <<EOF
 test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
 test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
 cat > conftest.$ac_ext <<EOF
-#line 945 "configure"
+#line 983 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
@@ -1006,7 +1042,7 @@ rm -f conftest*
 ac_save_LIBS="$LIBS"
 LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
 ac_save_LIBS="$LIBS"
 LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1008 "configure"
+#line 1046 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1124,7 +1160,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lICE  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-lICE  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1126 "configure"
+#line 1164 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1167,7 +1203,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1169 "configure"
+#line 1207 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1201,7 +1237,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1203 "configure"
+#line 1241 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1240,7 +1276,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1242 "configure"
+#line 1280 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1278,7 +1314,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1280 "configure"
+#line 1318 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1335,7 +1371,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1337 "configure"
+#line 1375 "configure"
 #include "confdefs.h"
 #include <tk.h>
 EOF
 #include "confdefs.h"
 #include <tk.h>
 EOF
@@ -1437,7 +1473,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1439 "configure"
+#line 1477 "configure"
 #include "confdefs.h"
 #include <tclInt.h>
 EOF
 #include "confdefs.h"
 #include <tclInt.h>
 EOF
index 012e584e17466d1b85f505f0b4b63ff7040d9cd0..0c1158e3a8b930ee04c089bfec3a60a1cfdb56da 100644 (file)
@@ -15,6 +15,7 @@ AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
 AC_CANONICAL_SYSTEM
 AC_ARG_PROGRAM
 
 AC_CANONICAL_SYSTEM
 AC_ARG_PROGRAM
 
+AC_CHECK_HEADERS(unistd.h)
 
 dnl Handle optional features that can be enabled.
 ENABLE_CFLAGS=
 
 dnl Handle optional features that can be enabled.
 ENABLE_CFLAGS=
index a59943e05d688e962026fe1ff4149288ad31f07c..c32dbc728dc17f3d6b559fb3811b7559cfd817ab 100644 (file)
@@ -28,6 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "gdbcmd.h"
 #include "demangle.h"
 #include "annotate.h"
 #include "gdbcmd.h"
 #include "demangle.h"
 #include "annotate.h"
+#include <string.h>
 
 int vtblprint;                 /* Controls printing of vtbl's */
 int objectprint;               /* Controls looking up an object's derived type
 
 int vtblprint;                 /* Controls printing of vtbl's */
 int objectprint;               /* Controls looking up an object's derived type
index 26b74cf416541e5045f92a18d1051d7b62ba40ef..2b2daeb14eee9c80753deab591bc5507b9d8236d 100644 (file)
@@ -29,6 +29,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "thread.h"
 
 #include <signal.h>
 #include "thread.h"
 
 #include <signal.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 extern char **environ;
 
 
 extern char **environ;
 
index a02eace9a5f5860a99916007dd29d04746e104f3..d01b693a9a6ea7a75bb04254a7f3636f41ce76c0 100644 (file)
@@ -17,6 +17,7 @@ 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.  */
 
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
+#include <string.h>
 #include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "defs.h"
 #include "frame.h"
 #include "inferior.h"
@@ -25,22 +26,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "floatformat.h"
 #include "symtab.h"
 
 #include "floatformat.h"
 #include "symtab.h"
 
-static long
-i386_get_frame_setup PARAMS ((int));
-
-static void
-i386_follow_jump PARAMS ((void));
+static long i386_get_frame_setup PARAMS ((int));
 
 
-static void
-codestream_read PARAMS ((unsigned char *, int));
+static void i386_follow_jump PARAMS ((void));
 
 
-static void
-codestream_seek PARAMS ((int));
+static void codestream_read PARAMS ((unsigned char *, int));
 
 
-static unsigned char 
-codestream_fill PARAMS ((int));
+static void codestream_seek PARAMS ((int));
 
 
-/* helper functions for tm-i386.h */
+static unsigned char  codestream_fill PARAMS ((int));
 
 /* Stdio style buffering was used to minimize calls to ptrace, but this
    buffering did not take into account that the code section being accessed
 
 /* Stdio style buffering was used to minimize calls to ptrace, but this
    buffering did not take into account that the code section being accessed
@@ -432,7 +426,12 @@ i386_frame_find_saved_regs (fip, fsrp)
          op = codestream_get ();
          if (op < 0x50 || op > 0x57)
            break;
          op = codestream_get ();
          if (op < 0x50 || op > 0x57)
            break;
+#ifdef I386_REGNO_TO_SYMMETRY
+         /* Dynix uses different internal numbering.  Ick.  */
+         fsrp->regs[I386_REGNO_TO_SYMMETRY(op - 0x50)] = adr;
+#else
          fsrp->regs[op - 0x50] = adr;
          fsrp->regs[op - 0x50] = adr;
+#endif
          adr -= 4;
        }
     }
          adr -= 4;
        }
     }
@@ -545,16 +544,14 @@ i386_push_dummy_frame ()
 void
 i386_pop_frame ()
 {
 void
 i386_pop_frame ()
 {
-  FRAME frame = get_current_frame ();
+  struct frame_info *frame = get_current_frame ();
   CORE_ADDR fp;
   int regnum;
   struct frame_saved_regs fsr;
   CORE_ADDR fp;
   int regnum;
   struct frame_saved_regs fsr;
-  struct frame_info *fi;
   char regbuf[MAX_REGISTER_RAW_SIZE];
   
   char regbuf[MAX_REGISTER_RAW_SIZE];
   
-  fi = get_frame_info (frame);
-  fp = fi->frame;
-  get_frame_saved_regs (fi, &fsr);
+  fp = FRAME_FP (frame);
+  get_frame_saved_regs (frame, &fsr);
   for (regnum = 0; regnum < NUM_REGS; regnum++) 
     {
       CORE_ADDR adr;
   for (regnum = 0; regnum < NUM_REGS; regnum++) 
     {
       CORE_ADDR adr;
@@ -570,8 +567,6 @@ i386_pop_frame ()
   write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));
   write_register (SP_REGNUM, fp + 8);
   flush_cached_frames ();
   write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));
   write_register (SP_REGNUM, fp + 8);
   flush_cached_frames ();
-  set_current_frame ( create_new_frame (read_register (FP_REGNUM),
-                                       read_pc ()));
 }
 
 #ifdef GET_LONGJMP_TARGET
 }
 
 #ifdef GET_LONGJMP_TARGET
@@ -639,13 +634,12 @@ i386_extract_return_value(type, regbuf, valbuf)
 
 CORE_ADDR
 i386v4_sigtramp_saved_pc (frame)
 
 CORE_ADDR
 i386v4_sigtramp_saved_pc (frame)
-     FRAME frame;
+     struct frame_info *frame;
 {
   CORE_ADDR saved_pc_offset = 4;
   char *name = NULL;
 
 {
   CORE_ADDR saved_pc_offset = 4;
   char *name = NULL;
 
-  find_pc_partial_function (frame->pc, &name,
-                           (CORE_ADDR *)NULL,(CORE_ADDR *)NULL);
+  find_pc_partial_function (frame->pc, &name, NULL, NULL);
   if (name)
     {
       if (STREQ (name, "_sigreturn"))
   if (name)
     {
       if (STREQ (name, "_sigreturn"))
@@ -661,3 +655,9 @@ i386v4_sigtramp_saved_pc (frame)
   return read_memory_integer (read_register (SP_REGNUM) + saved_pc_offset, 4);
 }
 #endif /* I386V4_SIGTRAMP_SAVED_PC */
   return read_memory_integer (read_register (SP_REGNUM) + saved_pc_offset, 4);
 }
 #endif /* I386V4_SIGTRAMP_SAVED_PC */
+
+void
+_initialize_i386_tdep ()
+{
+  tm_print_insn = print_insn_i386;
+}
index beff646311d9ab2c3ae81cf72b9bc95b62252d43..ae17ce16762a129bba864033b356f76697244447 100644 (file)
@@ -72,6 +72,7 @@ i386_register_u_addr (blockend, regnum)
 
 
 #ifdef FLOAT_INFO
 
 
 #ifdef FLOAT_INFO
+#include "language.h"                  /* for local_hex_string */
 #include "floatformat.h"
 
 #include <sys/param.h>
 #include "floatformat.h"
 
 #include <sys/param.h>
@@ -115,7 +116,7 @@ struct env387
   unsigned char regs[8][10];
 };
 
   unsigned char regs[8][10];
 };
 
-static
+static void
 print_387_status (status, ep)
      unsigned short status;
      struct env387 *ep;
 print_387_status (status, ep)
      unsigned short status;
      struct env387 *ep;
@@ -124,7 +125,6 @@ print_387_status (status, ep)
   int bothstatus;
   int top;
   int fpreg;
   int bothstatus;
   int top;
   int fpreg;
-  unsigned char *p;
   
   bothstatus = ((status != 0) && (ep->status != 0));
   if (status != 0) 
   
   bothstatus = ((status != 0) && (ep->status != 0));
   if (status != 0) 
index 353c6c4ee3f417c72515397fdb3f257c5ef6ed4c..56dc0e679244583dc115239e57c3a0ae569746cf 100644 (file)
@@ -1,5 +1,5 @@
 /* Low level interface to ptrace, for GDB when running under Unix.
 /* Low level interface to ptrace, for GDB when running under Unix.
-   Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
+   Copyright 1986, 1987, 1989, 1991, 1992, 1995 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
 
 This file is part of GDB.
 
@@ -27,10 +27,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "target.h"
 #include "thread.h"
 
 #include "target.h"
 #include "thread.h"
 
+#include <string.h>
 #include <signal.h>
 #include <fcntl.h>
 
 #include <signal.h>
 #include <fcntl.h>
 
-#if !defined (HAVE_TERMIOS) && !defined (HAVE_TERMIO) && !defined (HAVE_SGTTY) && !defined (__GO32__)
+#if !defined (HAVE_TERMIOS) && !defined (HAVE_TERMIO) && !defined (HAVE_SGTTY) && !defined (__GO32__) && !defined(WIN32)
 #define HAVE_SGTTY
 #endif
 
 #define HAVE_SGTTY
 #endif
 
@@ -483,7 +484,7 @@ new_tty ()
 
   if (inferior_thisrun_terminal == 0)
     return;
 
   if (inferior_thisrun_terminal == 0)
     return;
-#if !defined(__GO32__)
+#if !defined(__GO32__) && !defined(WIN32)
 #ifdef TIOCNOTTY
   /* Disconnect the child process from our controlling terminal.  On some
      systems (SVR4 for example), this may cause a SIGTTOU, so temporarily
 #ifdef TIOCNOTTY
   /* Disconnect the child process from our controlling terminal.  On some
      systems (SVR4 for example), this may cause a SIGTTOU, so temporarily
@@ -522,7 +523,7 @@ new_tty ()
     { close (2); dup (tty); }
   if (tty > 2)
     close(tty);
     { close (2); dup (tty); }
   if (tty > 2)
     close(tty);
-#endif /* !go32 */
+#endif /* !go32 && !win32*/
 }
 \f
 /* Kill the inferior process.  Make us have no inferior.  */
 }
 \f
 /* Kill the inferior process.  Make us have no inferior.  */
@@ -533,7 +534,11 @@ kill_command (arg, from_tty)
      char *arg;
      int from_tty;
 {
      char *arg;
      int from_tty;
 {
-  if (!target_has_execution)
+  /* FIXME:  This should not really be inferior_pid (or target_has_execution).
+     It should be a distinct flag that indicates that a target is active, cuz
+     some targets don't have processes! */
+
+  if (inferior_pid == 0)
     error ("The program is not being run.");
   if (!query ("Kill the program being debugged? "))
     error ("Not confirmed.");
     error ("The program is not being run.");
   if (!query ("Kill the program being debugged? "))
     error ("Not confirmed.");
@@ -568,13 +573,19 @@ static void (*osig)();
 void
 set_sigint_trap()
 {
 void
 set_sigint_trap()
 {
-  osig = (void (*) ()) signal (SIGINT, pass_signal);
+  if (attach_flag || inferior_thisrun_terminal)
+    {
+      osig = (void (*) ()) signal (SIGINT, pass_signal);
+    }
 }
 
 void
 clear_sigint_trap()
 {
 }
 
 void
 clear_sigint_trap()
 {
-  signal (SIGINT, osig);
+  if (attach_flag || inferior_thisrun_terminal)
+    {
+      signal (SIGINT, osig);
+    }
 }
 \f
 #if defined (SIGIO) && defined (FASYNC) && defined (FD_SET) && defined (F_SETOWN)
 }
 \f
 #if defined (SIGIO) && defined (FASYNC) && defined (FD_SET) && defined (F_SETOWN)
index 228d62ce0c1b4494a6e4be69e22651293ea7f236..150b066b721c44a5d76d6859e2d9cca613366a9a 100644 (file)
@@ -1,5 +1,5 @@
 /* Top level stuff for GDB, the GNU debugger.
 /* Top level stuff for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
    Free Software Foundation, Inc.
 
 This file is part of GDB.
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -32,8 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <ctype.h>
 
 #include <string.h>
 #include <ctype.h>
 
 #include <string.h>
-/* R_OK lives in either unistd.h or sys/file.h.  */
-#ifdef USG
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #ifndef        NO_SYS_FILE
 #include <unistd.h>
 #endif
 #ifndef        NO_SYS_FILE
@@ -104,15 +103,13 @@ main (argc, argv)
 
   long time_at_startup = get_run_time ();
 
 
   long time_at_startup = get_run_time ();
 
-/* start-sanitize-mpw */
+  START_PROGRESS (argv[0], 0);
+
 #ifdef MPW
 #ifdef MPW
-  /* Drop into MacsBug, but only if the executable is specially named. */
-  if (strcmp(argv[0], "DEBUGGDB") == 0)
-    DebugStr("\pat start of GDB main");
   /* Do all Mac-specific setup. */
   mac_init ();
 #endif /* MPW */
   /* Do all Mac-specific setup. */
   mac_init ();
 #endif /* MPW */
-/* end-sanitize-mpw */
+
   /* This needs to happen before the first use of malloc.  */
   init_malloc ((PTR) NULL);
 
   /* This needs to happen before the first use of malloc.  */
   init_malloc ((PTR) NULL);
 
@@ -143,6 +140,7 @@ main (argc, argv)
   current_directory = gdb_dirbuf;
 
   /* Parse arguments and options.  */
   current_directory = gdb_dirbuf;
 
   /* Parse arguments and options.  */
+#ifndef WIN32
   {
     int c;
     /* When var field is 0, use flag field to record the equivalent
   {
     int c;
     /* When var field is 0, use flag field to record the equivalent
@@ -233,6 +231,8 @@ main (argc, argv)
            break;
          case 'f':
            annotation_level = 1;
            break;
          case 'f':
            annotation_level = 1;
+/* We have probably been invoked from emacs.  Disable window interface.  */
+           use_windows = 0;
            break;
          case 's':
            symarg = optarg;
            break;
          case 's':
            symarg = optarg;
@@ -319,6 +319,7 @@ main (argc, argv)
       quiet = 1;
   }
 
       quiet = 1;
   }
 
+#endif
   gdb_init ();
 
   /* Do these (and anything which might call wrap_here or *_filtered)
   gdb_init ();
 
   /* Do these (and anything which might call wrap_here or *_filtered)
@@ -344,12 +345,6 @@ main (argc, argv)
 
       /* But don't use *_filtered here.  We don't want to prompt for continue
         no matter how small the screen or how much we're going to print.  */
 
       /* But don't use *_filtered here.  We don't want to prompt for continue
         no matter how small the screen or how much we're going to print.  */
-/* start-sanitize-mpw */
-/* For reasons too ugly to describe... */
-#ifdef MPW_C
-      fputs_unfiltered ("This is the GNU debugger.\n", gdb_stdout);
-#else
-/* end-sanitize-mpw */
       fputs_unfiltered ("\
 This is the GNU debugger.  Usage:\n\
     gdb [options] [executable-file [core-file or process-id]]\n\
       fputs_unfiltered ("\
 This is the GNU debugger.  Usage:\n\
     gdb [options] [executable-file [core-file or process-id]]\n\
@@ -358,24 +353,27 @@ Options:\n\
   --quiet            Do not print version number on startup.\n\
   --fullname         Output information used by emacs-GDB interface.\n\
   --epoch            Output information used by epoch emacs-GDB interface.\n\
   --quiet            Do not print version number on startup.\n\
   --fullname         Output information used by emacs-GDB interface.\n\
   --epoch            Output information used by epoch emacs-GDB interface.\n\
+", gdb_stdout);
+      fputs_unfiltered ("\
   --batch            Exit after processing options.\n\
   --nx               Do not read .gdbinit file.\n\
   --tty=TTY          Use TTY for input/output by the program being debugged.\n\
   --cd=DIR           Change current directory to DIR.\n\
   --directory=DIR    Search for source files in DIR.\n\
   --batch            Exit after processing options.\n\
   --nx               Do not read .gdbinit file.\n\
   --tty=TTY          Use TTY for input/output by the program being debugged.\n\
   --cd=DIR           Change current directory to DIR.\n\
   --directory=DIR    Search for source files in DIR.\n\
+", gdb_stdout);
+      fputs_unfiltered ("\
   --command=FILE     Execute GDB commands from FILE.\n\
   --symbols=SYMFILE  Read symbols from SYMFILE.\n\
   --exec=EXECFILE    Use EXECFILE as the executable.\n\
   --se=FILE          Use FILE as symbol file and executable file.\n\
   --command=FILE     Execute GDB commands from FILE.\n\
   --symbols=SYMFILE  Read symbols from SYMFILE.\n\
   --exec=EXECFILE    Use EXECFILE as the executable.\n\
   --se=FILE          Use FILE as symbol file and executable file.\n\
+", gdb_stdout);
+      fputs_unfiltered ("\
   --core=COREFILE    Analyze the core dump COREFILE.\n\
   -b BAUDRATE        Set serial port baud rate used for remote debugging.\n\
   --mapped           Use mapped symbol files if supported on this system.\n\
   --readnow          Fully read symbol files on first access.\n\
   --nw              Do not use a window interface.\n\
 ", gdb_stdout);
   --core=COREFILE    Analyze the core dump COREFILE.\n\
   -b BAUDRATE        Set serial port baud rate used for remote debugging.\n\
   --mapped           Use mapped symbol files if supported on this system.\n\
   --readnow          Fully read symbol files on first access.\n\
   --nw              Do not use a window interface.\n\
 ", gdb_stdout);
-/* start-sanitize-mpw */
-#endif /* MPW_C */
-/* end-sanitize-mpw */
 #ifdef ADDITIONAL_OPTION_HELP
       fputs_unfiltered (ADDITIONAL_OPTION_HELP, gdb_stdout);
 #endif
 #ifdef ADDITIONAL_OPTION_HELP
       fputs_unfiltered (ADDITIONAL_OPTION_HELP, gdb_stdout);
 #endif
@@ -398,6 +396,8 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
     }
 
   error_pre_print = "\n\n";
     }
 
   error_pre_print = "\n\n";
+  quit_pre_print = error_pre_print;
+
   /* We may get more than one warning, don't double space all of them... */
   warning_pre_print = "\nwarning: ";
 
   /* We may get more than one warning, don't double space all of them... */
   warning_pre_print = "\nwarning: ";
 
@@ -478,6 +478,7 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
   if (!quiet)
     printf_filtered ("\n");
   error_pre_print = "\n";
   if (!quiet)
     printf_filtered ("\n");
   error_pre_print = "\n";
+  quit_pre_print = error_pre_print;
   warning_pre_print = "\nwarning: ";
 
   if (corearg != NULL)
   warning_pre_print = "\nwarning: ";
 
   if (corearg != NULL)
@@ -497,7 +498,8 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
 #endif
 
   /* Error messages should no longer be distinguished with extra output. */
 #endif
 
   /* Error messages should no longer be distinguished with extra output. */
-  error_pre_print = 0;
+  error_pre_print = NULL;
+  quit_pre_print = NULL;
   warning_pre_print = "warning: ";
 
   /* Read the .gdbinit file in the current directory, *if* it isn't
   warning_pre_print = "warning: ";
 
   /* Read the .gdbinit file in the current directory, *if* it isn't
@@ -541,6 +543,8 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
   BEFORE_MAIN_LOOP_HOOK;
 #endif
 
   BEFORE_MAIN_LOOP_HOOK;
 #endif
 
+  END_PROGRESS (argv[0]);
+
   /* Show time and/or space usage.  */
 
   if (display_time)
   /* Show time and/or space usage.  */
 
   if (display_time)
@@ -560,8 +564,10 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
                         (long) (lim - (char *) &environ));
     }
 
                         (long) (lim - (char *) &environ));
     }
 
-  /* The command loop.  */
-
+  /* The default command loop. 
+     The WIN32 Gui calls this main to set up gdb's state, and 
+     has its own command loop. */
+#if !defined (WIN32)
   while (1)
     {
       if (!SET_TOP_LEVEL ())
   while (1)
     {
       if (!SET_TOP_LEVEL ())
@@ -577,7 +583,10 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
           quit_command ((char *)0, instream == stdin);
        }
     }
           quit_command ((char *)0, instream == stdin);
        }
     }
+
   /* No exit -- exit is through quit_command.  */
   /* No exit -- exit is through quit_command.  */
+#endif
+
 }
 \f
 void
 }
 \f
 void
index 7f822ecfd9c8163ab18ddfacfa4165d556e6811f..c82431756a51decfa53062a3788d5387c54eff12 100644 (file)
@@ -33,6 +33,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "expression.h" /* For language.h */
 #include "language.h"
 
 #include "expression.h" /* For language.h */
 #include "language.h"
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 static void maintenance_command PARAMS ((char *, int));
 
 static void maintenance_dump_me PARAMS ((char *, int));
 static void maintenance_command PARAMS ((char *, int));
 
 static void maintenance_dump_me PARAMS ((char *, int));
index caa595c04d1e2026fd8d5585eced6c169b262e43..80ec2b6d9ff6860f45683c7630ddc91fdd13612b 100644 (file)
@@ -33,6 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <obstack.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <obstack.h>
+#include <string.h>
 
 /* Prototypes for local functions */
 
 
 /* Prototypes for local functions */
 
index f42f24eae9906cda167140dc48b1a937350e3fa0..2548e62d99f34363458eb56e92fb9d5d514e0fc0 100644 (file)
@@ -1,5 +1,6 @@
 /* Handle SunOS and SVR4 shared libraries for GDB, the GNU Debugger.
 /* Handle SunOS and SVR4 shared libraries for GDB, the GNU Debugger.
-   Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995
+   Free Software Foundation, Inc.
    
 This file is part of GDB.
 
    
 This file is part of GDB.
 
@@ -23,20 +24,19 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <sys/types.h>
 #include <signal.h>
 #include <string.h>
 #include <sys/types.h>
 #include <signal.h>
 #include <string.h>
-#include <link.h>
 #include <sys/param.h>
 #include <fcntl.h>
 #include <sys/param.h>
 #include <fcntl.h>
+#include <unistd.h>
 
 #ifndef SVR4_SHARED_LIBS
  /* SunOS shared libs need the nlist structure.  */
 #include <a.out.h> 
 #else
 
 #ifndef SVR4_SHARED_LIBS
  /* SunOS shared libs need the nlist structure.  */
 #include <a.out.h> 
 #else
-#include "libelf.h"
-#ifndef DT_MIPS_RLD_MAP
-#include "elf/mips.h"
-#endif
+#include "elf/external.h"
 #endif
 
 #endif
 
+#include <link.h>
+
 #include "symtab.h"
 #include "bfd.h"
 #include "symfile.h"
 #include "symtab.h"
 #include "bfd.h"
 #include "symfile.h"
@@ -48,6 +48,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "regex.h"
 #include "inferior.h"
 #include "language.h"
 #include "regex.h"
 #include "inferior.h"
 #include "language.h"
+#include "gdbcmd.h"
 
 #define MAX_PATH_SIZE 256              /* FIXME: Should be dynamic */
 
 
 #define MAX_PATH_SIZE 256              /* FIXME: Should be dynamic */
 
@@ -79,12 +80,29 @@ static char *bkpt_names[] = {
 #ifndef SVR4_SHARED_LIBS
 static char *debug_base_symbols[] = {
   "_DYNAMIC",
 #ifndef SVR4_SHARED_LIBS
 static char *debug_base_symbols[] = {
   "_DYNAMIC",
+  "_DYNAMIC__MGC",
   NULL
 };
 #endif
 
   NULL
 };
 #endif
 
+static char *main_name_list[] = {
+  "main_$main",
+  NULL
+};
+
 /* local data declarations */
 
 /* local data declarations */
 
+/* If true, then shared library symbols will be added automatically
+   when the inferior is created.  This is almost always what users
+   will want to have happen; but for very large programs, the startup
+   time will be excessive, and so if this is a problem, the user can
+   clear this flag and then add the shared library symbols as needed.
+   Note that there is a potential for confusion, since if the shared
+   library symbols are not loaded, commands like "info fun" will *not*
+   report all the functions that are actually present.  */
+   
+int auto_solib_add_at_startup = 1;
+
 #ifndef SVR4_SHARED_LIBS
 
 #define LM_ADDR(so) ((so) -> lm.lm_addr)
 #ifndef SVR4_SHARED_LIBS
 
 #define LM_ADDR(so) ((so) -> lm.lm_addr)
@@ -172,7 +190,10 @@ elf_locate_base PARAMS ((void));
 #else
 
 static void
 #else
 
 static void
-solib_add_common_symbols PARAMS ((struct rtc_symb *, struct objfile *));
+allocate_rt_common_objfile PARAMS ((void));
+
+static void
+solib_add_common_symbols PARAMS ((struct rtc_symb *));
 
 #endif
 
 
 #endif
 
@@ -270,26 +291,50 @@ solib_map_sections (so)
   do_cleanups (old_chain);
 }
 
   do_cleanups (old_chain);
 }
 
-/* Read all dynamically loaded common symbol definitions from the inferior
-   and add them to the minimal symbol table for the shared library objfile.  */
-
 #ifndef SVR4_SHARED_LIBS
 
 #ifndef SVR4_SHARED_LIBS
 
-/* In GDB 4.9 this routine was a real performance hog.  According to
-   some gprof data which mtranle@paris.IntelliCorp.COM (Minh Tran-Le)
-   sent, almost all the time spend in solib_add (up to 20 minutes with
-   35 shared libraries) was spent here, with 5/6 in
-   lookup_minimal_symbol and 1/6 in read_memory.
+/* Allocate the runtime common object file.  */
+
+static void
+allocate_rt_common_objfile ()
+{
+  struct objfile *objfile;
+  struct objfile *last_one;
+
+  objfile = (struct objfile *) xmalloc (sizeof (struct objfile));
+  memset (objfile, 0, sizeof (struct objfile));
+  objfile -> md = NULL;
+  obstack_specify_allocation (&objfile -> psymbol_obstack, 0, 0, xmalloc,
+                             free);
+  obstack_specify_allocation (&objfile -> symbol_obstack, 0, 0, xmalloc,
+                             free);
+  obstack_specify_allocation (&objfile -> type_obstack, 0, 0, xmalloc,
+                             free);
+  objfile -> name = mstrsave (objfile -> md, "rt_common");
+
+  /* Add this file onto the tail of the linked list of other such files. */
+
+  objfile -> next = NULL;
+  if (object_files == NULL)
+    object_files = objfile;
+  else
+    {
+      for (last_one = object_files;
+          last_one -> next;
+          last_one = last_one -> next);
+      last_one -> next = objfile;
+    }
+
+  rt_common_objfile = objfile;
+}
 
 
-   To fix this, we moved the call to special_symbol_handling out of the
-   loop in solib_add, so this only gets called once, rather than once
-   for every shared library, and also removed the call to lookup_minimal_symbol
-   in this routine.  */
+/* Read all dynamically loaded common symbol definitions from the inferior
+   and put them into the minimal symbol table for the runtime common
+   objfile.  */
 
 static void
 
 static void
-solib_add_common_symbols (rtc_symp, objfile)
+solib_add_common_symbols (rtc_symp)
     struct rtc_symb *rtc_symp;
     struct rtc_symb *rtc_symp;
-    struct objfile *objfile;
 {
   struct rtc_symb inferior_rtc_symb;
   struct nlist inferior_rtc_nlist;
 {
   struct rtc_symb inferior_rtc_symb;
   struct nlist inferior_rtc_nlist;
@@ -297,6 +342,17 @@ solib_add_common_symbols (rtc_symp, objfile)
   char *name;
   char *origname;
 
   char *name;
   char *origname;
 
+  /* Remove any runtime common symbols from previous runs.  */
+
+  if (rt_common_objfile != NULL && rt_common_objfile -> minimal_symbol_count)
+    {
+      obstack_free (&rt_common_objfile -> symbol_obstack, 0);
+      obstack_specify_allocation (&rt_common_objfile -> symbol_obstack, 0, 0,
+                                 xmalloc, free);
+      rt_common_objfile -> minimal_symbol_count = 0;
+      rt_common_objfile -> msymbols = NULL;
+    }
+
   init_minimal_symbol_collection ();
   make_cleanup (discard_minimal_symbols, 0);
 
   init_minimal_symbol_collection ();
   make_cleanup (discard_minimal_symbols, 0);
 
@@ -318,38 +374,23 @@ solib_add_common_symbols (rtc_symp, objfile)
          origname = name = xmalloc (len);
          read_memory ((CORE_ADDR) inferior_rtc_nlist.n_un.n_name, name, len);
 
          origname = name = xmalloc (len);
          read_memory ((CORE_ADDR) inferior_rtc_nlist.n_un.n_name, name, len);
 
-         /* Don't enter the symbol twice if the target is re-run. */
+         /* Allocate the runtime common objfile if necessary. */
+         if (rt_common_objfile == NULL)
+           allocate_rt_common_objfile ();
 
 
-         if (name[0] == bfd_get_symbol_leading_char (objfile->obfd))
-           {
-             name++;
-           }
-
-#if 0
-         /* I think this is unnecessary, GDB can probably deal with
-            duplicate minimal symbols, more or less.  And the duplication
-            which used to happen because this was called for each shared
-            library is gone now that we are just called once.  */
-         /* FIXME:  Do we really want to exclude symbols which happen
-            to match symbols for other locations in the inferior's
-            address space, even when they are in different linkage units? */
-         if (lookup_minimal_symbol (name, (struct objfile *) NULL) == NULL)
-#endif
-           {
-             name = obsavestring (name, strlen (name),
-                                  &objfile -> symbol_obstack);
-             prim_record_minimal_symbol (name, inferior_rtc_nlist.n_value,
-                                         mst_bss, objfile);
-           }
+         name = obsavestring (name, strlen (name),
+                              &rt_common_objfile -> symbol_obstack);
+         prim_record_minimal_symbol (name, inferior_rtc_nlist.n_value,
+                                     mst_bss, rt_common_objfile);
          free (origname);
        }
       rtc_symp = inferior_rtc_symb.rtc_next;
     }
 
   /* Install any minimal symbols that have been collected as the current
          free (origname);
        }
       rtc_symp = inferior_rtc_symb.rtc_next;
     }
 
   /* Install any minimal symbols that have been collected as the current
-     minimal symbols for this objfile. */
+     minimal symbols for the runtime common objfile.  */
 
 
-  install_minimal_symbols (objfile);
+  install_minimal_symbols (rt_common_objfile);
 }
 
 #endif /* SVR4_SHARED_LIBS */
 }
 
 #endif /* SVR4_SHARED_LIBS */
@@ -501,6 +542,8 @@ look_for_base (fd, baseaddr)
     }
   if (!bfd_check_format (interp_bfd, bfd_object))
     {
     }
   if (!bfd_check_format (interp_bfd, bfd_object))
     {
+      /* FIXME-leak: on failure, might not free all memory associated with
+        interp_bfd.  */
       bfd_close (interp_bfd);
       return (0);
     }
       bfd_close (interp_bfd);
       return (0);
     }
@@ -518,6 +561,8 @@ look_for_base (fd, baseaddr)
     }
   if (address == 0)
     {
     }
   if (address == 0)
     {
+      /* FIXME-leak: on failure, might not free all memory associated with
+        interp_bfd.  */
       bfd_close (interp_bfd);
       return (0);
     }
       bfd_close (interp_bfd);
       return (0);
     }
@@ -535,6 +580,8 @@ look_for_base (fd, baseaddr)
       address += baseaddr;
     }
   debug_base = address;
       address += baseaddr;
     }
   debug_base = address;
+  /* FIXME-leak: on failure, might not free all memory associated with
+     interp_bfd.  */
   bfd_close (interp_bfd);
   return (1);
 }
   bfd_close (interp_bfd);
   return (1);
 }
@@ -567,20 +614,20 @@ DESCRIPTION
 static CORE_ADDR
 elf_locate_base ()
 {
 static CORE_ADDR
 elf_locate_base ()
 {
-  struct elf_internal_shdr *dyninfo_sect;
+  sec_ptr dyninfo_sect;
   int dyninfo_sect_size;
   CORE_ADDR dyninfo_addr;
   char *buf;
   char *bufend;
 
   /* Find the start address of the .dynamic section.  */
   int dyninfo_sect_size;
   CORE_ADDR dyninfo_addr;
   char *buf;
   char *bufend;
 
   /* Find the start address of the .dynamic section.  */
-  dyninfo_sect = bfd_elf_find_section (exec_bfd, ".dynamic");
+  dyninfo_sect = bfd_get_section_by_name (exec_bfd, ".dynamic");
   if (dyninfo_sect == NULL)
     return 0;
   if (dyninfo_sect == NULL)
     return 0;
-  dyninfo_addr = dyninfo_sect->sh_addr;
+  dyninfo_addr = bfd_section_vma (exec_bfd, dyninfo_sect);
 
   /* Read in .dynamic section, silently ignore errors.  */
 
   /* Read in .dynamic section, silently ignore errors.  */
-  dyninfo_sect_size = dyninfo_sect->sh_size;
+  dyninfo_sect_size = bfd_section_size (exec_bfd, dyninfo_sect);
   buf = alloca (dyninfo_sect_size);
   if (target_read_memory (dyninfo_addr, buf, dyninfo_sect_size))
     return 0;
   buf = alloca (dyninfo_sect_size);
   if (target_read_memory (dyninfo_addr, buf, dyninfo_sect_size))
     return 0;
@@ -606,6 +653,7 @@ elf_locate_base ()
          dyn_ptr = bfd_h_get_32 (exec_bfd, (bfd_byte *) x_dynp->d_un.d_ptr);
          return dyn_ptr;
        }
          dyn_ptr = bfd_h_get_32 (exec_bfd, (bfd_byte *) x_dynp->d_un.d_ptr);
          return dyn_ptr;
        }
+#ifdef DT_MIPS_RLD_MAP
       else if (dyn_tag == DT_MIPS_RLD_MAP)
        {
          char pbuf[TARGET_PTR_BIT / HOST_CHAR_BIT];
       else if (dyn_tag == DT_MIPS_RLD_MAP)
        {
          char pbuf[TARGET_PTR_BIT / HOST_CHAR_BIT];
@@ -617,6 +665,7 @@ elf_locate_base ()
            return 0;
          return extract_unsigned_integer (pbuf, sizeof (pbuf));
        }
            return 0;
          return extract_unsigned_integer (pbuf, sizeof (pbuf));
        }
+#endif
     }
 
   /* DT_DEBUG entry not found.  */
     }
 
   /* DT_DEBUG entry not found.  */
@@ -678,7 +727,7 @@ locate_base ()
 
   for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++)
     {
 
   for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++)
     {
-      msymbol = lookup_minimal_symbol (*symbolp, symfile_objfile);
+      msymbol = lookup_minimal_symbol (*symbolp, NULL, symfile_objfile);
       if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
        {
          address = SYMBOL_VALUE_ADDRESS (msymbol);
       if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
        {
          address = SYMBOL_VALUE_ADDRESS (msymbol);
@@ -887,6 +936,23 @@ symbol_add_stub (arg)
   return (1);
 }
 
   return (1);
 }
 
+/* This function will check the so name to see if matches the main list.
+   In some system the main object is in the list, which we want to exclude */
+
+static int match_main (soname)
+    char *soname;
+{
+char **mainp;
+
+for (mainp = main_name_list; *mainp != NULL; mainp++)
+  {
+    if (strcmp (soname, *mainp) == 0)
+       return (1);
+  }
+
+return (0);
+}
+
 /*
 
 GLOBAL FUNCTION
 /*
 
 GLOBAL FUNCTION
@@ -931,7 +997,7 @@ solib_add (arg_string, from_tty, target)
       count = 0;
       while ((so = find_solib (so)) != NULL)
        {
       count = 0;
       while ((so = find_solib (so)) != NULL)
        {
-         if (so -> so_name[0])
+         if (so -> so_name[0] && !match_main (so -> so_name))
            {
              count += so -> sections_end - so -> sections;
            }
            {
              count += so -> sections_end - so -> sections;
            }
@@ -973,7 +1039,8 @@ solib_add (arg_string, from_tty, target)
   /* Now add the symbol files.  */
   while ((so = find_solib (so)) != NULL)
     {
   /* Now add the symbol files.  */
   while ((so = find_solib (so)) != NULL)
     {
-      if (so -> so_name[0] && re_exec (so -> so_name))
+      if (so -> so_name[0] && re_exec (so -> so_name) && 
+      !match_main (so -> so_name))
        {
          so -> from_tty = from_tty;
          if (so -> symbols_loaded)
        {
          so -> from_tty = from_tty;
          if (so -> symbols_loaded)
@@ -999,16 +1066,6 @@ solib_add (arg_string, from_tty, target)
   if (so_last)
     reinit_frame_cache ();
 
   if (so_last)
     reinit_frame_cache ();
 
-  /* Calling this once at the end means that we put all the minimal
-     symbols for commons into the objfile for the last shared library.
-     Since they are in common, this should not be a problem.  If we
-     delete the objfile with the minimal symbols, we can put all the
-     symbols into a new objfile (and will on the next call to solib_add).
-
-     An alternate approach would be to create an objfile just for
-     common minsyms, thus not needing any objfile argument to
-     solib_add_common_symbols.  */
-
   if (so_last)
     special_symbol_handling (so_last);
 }
   if (so_last)
     special_symbol_handling (so_last);
 }
@@ -1131,7 +1188,9 @@ clear_solib()
       if (so_list_head -> abfd)
        {
          bfd_filename = bfd_get_filename (so_list_head -> abfd);
       if (so_list_head -> abfd)
        {
          bfd_filename = bfd_get_filename (so_list_head -> abfd);
-         bfd_close (so_list_head -> abfd);
+         if (!bfd_close (so_list_head -> abfd))
+           warning ("cannot close \"%s\": %s",
+                    bfd_filename, bfd_errmsg (bfd_get_error ()));
        }
       else
        /* This happens for the executable on SVR4.  */
        }
       else
        /* This happens for the executable on SVR4.  */
@@ -1303,7 +1362,7 @@ enable_break ()
   breakpoint_addr = 0;
   for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++)
     {
   breakpoint_addr = 0;
   for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++)
     {
-      msymbol = lookup_minimal_symbol (*bkpt_namep, symfile_objfile);
+      msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile);
       if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
        {
          bkpt_addr = SYMBOL_VALUE_ADDRESS (msymbol);
       if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
        {
          bkpt_addr = SYMBOL_VALUE_ADDRESS (msymbol);
@@ -1444,7 +1503,8 @@ solib_create_inferior_hook()
       warning ("shared library handler failed to disable breakpoint");
     }
 
       warning ("shared library handler failed to disable breakpoint");
     }
 
-  solib_add ((char *) 0, 0, (struct target_ops *) 0);
+  if (auto_solib_add_at_startup)
+    solib_add ((char *) 0, 0, (struct target_ops *) 0);
 }
 
 /*
 }
 
 /*
@@ -1463,9 +1523,9 @@ DESCRIPTION
        way, we are called to do any system specific symbol handling that 
        is needed.
 
        way, we are called to do any system specific symbol handling that 
        is needed.
 
-       For Suns, this consists of grunging around in the dynamic linkers
-       structures to find symbol definitions for "common" symbols and 
-       adding them to the minimal symbol table for the corresponding
+       For SunOS4, this consists of grunging around in the dynamic
+       linkers structures to find symbol definitions for "common" symbols
+       and adding them to the minimal symbol table for the runtime common
        objfile.
 
 */
        objfile.
 
 */
@@ -1508,7 +1568,7 @@ struct so_list *so;
 
   if (debug_copy.ldd_cp)
     {
 
   if (debug_copy.ldd_cp)
     {
-      solib_add_common_symbols (debug_copy.ldd_cp, so -> objfile);
+      solib_add_common_symbols (debug_copy.ldd_cp);
     }
 
 #endif /* !SVR4_SHARED_LIBS */
     }
 
 #endif /* !SVR4_SHARED_LIBS */
@@ -1546,4 +1606,14 @@ _initialize_solib()
           "Load shared object library symbols for files matching REGEXP.");
   add_info ("sharedlibrary", info_sharedlibrary_command, 
            "Status of loaded shared object libraries.");
           "Load shared object library symbols for files matching REGEXP.");
   add_info ("sharedlibrary", info_sharedlibrary_command, 
            "Status of loaded shared object libraries.");
+
+  add_show_from_set
+    (add_set_cmd ("auto-solib-add", class_support, var_zinteger,
+                 (char *) &auto_solib_add_at_startup,
+                 "Set autoloading of shared library symbols at startup.\n\
+If nonzero, symbols from all shared object libraries will be loaded\n\
+automatically when the inferior begins execution.  Otherwise, symbols\n\
+must be loaded manually, using `sharedlibrary'.",
+                 &setlist),
+     &showlist);
 }
 }
index 59f8de0ad0a6815ab7a8dfe85c974bb7a17ed64e..b2c4a5628c0afe7d912858c170b77e6f1d0931e8 100644 (file)
@@ -31,6 +31,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include "gdbcore.h"
 #include "regex.h"
 #include "symfile.h"
 #include "gdbcore.h"
 #include "regex.h"
 #include "symfile.h"
@@ -38,10 +41,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "annotate.h"
 #include "gdbtypes.h"
 
 #include "annotate.h"
 #include "gdbtypes.h"
 
-#ifndef DIRNAME_SEPARATOR
-#define DIRNAME_SEPARATOR ':'
-#endif
-
 /* Prototypes for local functions. */
 
 static int open_source_file PARAMS ((struct symtab *));
 /* Prototypes for local functions. */
 
 static int open_source_file PARAMS ((struct symtab *));
@@ -248,7 +247,7 @@ directory_command (dirname, from_tty)
   /* FIXME, this goes to "delete dir"... */
   if (dirname == 0)
     {
   /* FIXME, this goes to "delete dir"... */
   if (dirname == 0)
     {
-      if (query ("Reinitialize source path to empty? ", ""))
+      if (query ("Reinitialize source path to empty? "))
        {
          free (source_path);
          init_source_path ();
        {
          free (source_path);
          init_source_path ();
@@ -307,7 +306,7 @@ mod_path (dirname, which_path)
          }
       }
 
          }
       }
 
-      if (p[-1] == '/')
+      if (SLASH_P (p[-1]))
        /* Sigh. "foo/" => "foo" */
        --p;
       *p = '\0';
        /* Sigh. "foo/" => "foo" */
        --p;
       *p = '\0';
@@ -320,7 +319,7 @@ mod_path (dirname, which_path)
              name = current_directory;
              goto append;
            }
              name = current_directory;
              goto append;
            }
-         else if (p[-2] == '/')
+         else if (SLASH_P (p[-2]))
            {
              if (p - name == 2)
                {
            {
              if (p - name == 2)
                {
@@ -342,8 +341,8 @@ mod_path (dirname, which_path)
 
       if (name[0] == '~')
        name = tilde_expand (name);
 
       if (name[0] == '~')
        name = tilde_expand (name);
-      else if (name[0] != '/' && name[0] != '$')
-       name = concat (current_directory, "/", name, NULL);
+      else if (!SLASH_P (name[0]) && name[0] != '$') 
+         name = concat (current_directory, SLASH_STRING, name, NULL);
       else
        name = savestring (name, p - name);
       make_cleanup (free, name);
       else
        name = savestring (name, p - name);
       make_cleanup (free, name);
@@ -365,7 +364,7 @@ mod_path (dirname, which_path)
            fprintf_unfiltered (gdb_stderr, "Warning: ");
            print_sys_errmsg (name, save_errno);
          }
            fprintf_unfiltered (gdb_stderr, "Warning: ");
            print_sys_errmsg (name, save_errno);
          }
-       else if ((st.st_mode & S_IFMT) != S_IFDIR)
+       else if (!S_ISDIR(st.st_mode))
          warning ("%s is not a directory.", name);
       }
 
          warning ("%s is not a directory.", name);
       }
 
@@ -490,16 +489,20 @@ openp (path, try_cwd_first, string, mode, prot, filename_opened)
   if (!path)
     path = ".";
 
   if (!path)
     path = ".";
 
-  if (try_cwd_first || string[0] == '/')
+  if (try_cwd_first || SLASH_P (string[0]))
     {
     {
+      int i;
       filename = string;
       fd = open (filename, mode, prot);
       filename = string;
       fd = open (filename, mode, prot);
-      if (fd >= 0 || string[0] == '/' || strchr (string, '/'))
+      if (fd >= 0)
+       goto done;
+      for (i = 0; string[i]; i++)
+       if (SLASH_P(string[0]))
        goto done;
     }
 
   /* ./foo => foo */
        goto done;
     }
 
   /* ./foo => foo */
-  while (string[0] == '.' && string[1] == '/')
+  while (string[0] == '.' && SLASH_P (string[1]))
     string += 2;
 
   alloclen = strlen (path) + strlen (string) + 2;
     string += 2;
 
   alloclen = strlen (path) + strlen (string) + 2;
@@ -533,10 +536,10 @@ openp (path, try_cwd_first, string, mode, prot, filename_opened)
       }
 
       /* Remove trailing slashes */
       }
 
       /* Remove trailing slashes */
-      while (len > 0 && filename[len-1] == '/')
+      while (len > 0 && SLASH_P (filename[len-1]))
        filename[--len] = 0;
 
        filename[--len] = 0;
 
-      strcat (filename+len, "/");
+      strcat (filename+len, SLASH_STRING);
       strcat (filename, string);
 
       fd = open (filename, mode);
       strcat (filename, string);
 
       fd = open (filename, mode);
@@ -548,18 +551,19 @@ openp (path, try_cwd_first, string, mode, prot, filename_opened)
     {
       if (fd < 0)
        *filename_opened = (char *) 0;
     {
       if (fd < 0)
        *filename_opened = (char *) 0;
-      else if (filename[0] == '/')
+      else if (ROOTED_P (filename))
        *filename_opened = savestring (filename, strlen (filename));
       else
        {
          /* Beware the // my son, the Emacs barfs, the botch that catch... */
          
          *filename_opened = concat (current_directory, 
        *filename_opened = savestring (filename, strlen (filename));
       else
        {
          /* Beware the // my son, the Emacs barfs, the botch that catch... */
          
          *filename_opened = concat (current_directory, 
-                                    '/' == current_directory[strlen(current_directory)-1]? "": "/",
+                                    SLASH_CHAR
+                                    == current_directory[strlen(current_directory)-1] 
+                                    ? "": SLASH_STRING,
                                     filename, NULL);
         }
     }
                                     filename, NULL);
         }
     }
-/* start-sanitize-mpw */
 #ifdef MPW
   /* This is a debugging hack that can go away when all combinations
      of Mac and Unix names are handled reasonably.  */
 #ifdef MPW
   /* This is a debugging hack that can go away when all combinations
      of Mac and Unix names are handled reasonably.  */
@@ -575,8 +579,7 @@ openp (path, try_cwd_first, string, mode, prot, filename_opened)
        printf("\n");
       }
   }
        printf("\n");
       }
   }
-#endif
-/* end-sanitize-mpw */
+#endif /* MPW */
 
   return fd;
 }
 
   return fd;
 }
@@ -633,7 +636,6 @@ open_source_file (s)
       if (p != s->filename)
        result = openp (path, 0, p, O_RDONLY, 0, &s->fullname);
     }
       if (p != s->filename)
        result = openp (path, 0, p, O_RDONLY, 0, &s->fullname);
     }
-/* start-sanitize-mpw */
 #ifdef MPW
   if (result < 0)
     {
 #ifdef MPW
   if (result < 0)
     {
@@ -650,7 +652,7 @@ open_source_file (s)
        result = openp (path, 0, p, O_RDONLY, 0, &s->fullname);
     }
 #endif /* MPW */
        result = openp (path, 0, p, O_RDONLY, 0, &s->fullname);
     }
 #endif /* MPW */
-/* end-sanitize-mpw */
+
   if (result >= 0)
     {
       fullname = s->fullname;
   if (result >= 0)
     {
       fullname = s->fullname;
index 4d84dafda10ac6c50054aa3fdd389feb50298699..71e74ade80ed5a7fe844320532f84e662d5ef93d 100644 (file)
@@ -1,5 +1,6 @@
 /* Print and select stack frames for GDB, the GNU debugger.
 /* Print and select stack frames for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
+   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994
+   Free Software Foundation, Inc.
 
 This file is part of GDB.
 
 
 This file is part of GDB.
 
@@ -17,6 +18,7 @@ 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.  */
 
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
+#include <string.h>
 #include "defs.h"
 #include "value.h"
 #include "symtab.h"
 #include "defs.h"
 #include "value.h"
 #include "symtab.h"
@@ -30,61 +32,47 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "breakpoint.h"
 #include "demangle.h"
 #include "inferior.h"
 #include "breakpoint.h"
 #include "demangle.h"
 #include "inferior.h"
+#include "annotate.h"
 
 
-static void
-return_command PARAMS ((char *, int));
+static void return_command PARAMS ((char *, int));
 
 
-static void
-down_command PARAMS ((char *, int));
+static void down_command PARAMS ((char *, int));
 
 
-static void
-down_silently_command PARAMS ((char *, int));
+static void down_silently_command PARAMS ((char *, int));
 
 
-static void
-up_command PARAMS ((char *, int));
+static void up_command PARAMS ((char *, int));
 
 
-static void
-up_silently_command PARAMS ((char *, int));
+static void up_silently_command PARAMS ((char *, int));
 
 
-static void
-frame_command PARAMS ((char *, int));
+static void frame_command PARAMS ((char *, int));
 
 
-static void
-select_frame_command PARAMS ((char *, int));
+static void select_frame_command PARAMS ((char *, int));
 
 
-static void
-args_info PARAMS ((char *, int));
+static void args_info PARAMS ((char *, int));
 
 
-static void
-print_frame_arg_vars PARAMS ((FRAME, GDB_FILE *));
-
-static void
-catch_info PARAMS ((char *, int));
+static void print_frame_arg_vars PARAMS ((struct frame_info *, GDB_FILE *));
 
 
-static void
-locals_info PARAMS ((char *, int));
+static void catch_info PARAMS ((char *, int));
 
 
-static void
-print_frame_label_vars PARAMS ((FRAME, int, GDB_FILE *));
+static void locals_info PARAMS ((char *, int));
 
 
-static void
-print_frame_local_vars PARAMS ((FRAME, GDB_FILE *));
+static void print_frame_label_vars PARAMS ((struct frame_info *, int,
+                                           GDB_FILE *));
 
 
-static int
-print_block_frame_labels PARAMS ((struct block *, int *, GDB_FILE *));
+static void print_frame_local_vars PARAMS ((struct frame_info *, GDB_FILE *));
 
 
-static int
-print_block_frame_locals PARAMS ((struct block *, FRAME, GDB_FILE *));
+static int print_block_frame_labels PARAMS ((struct block *, int *,
+                                            GDB_FILE *));
 
 
-static void
-backtrace_command PARAMS ((char *, int));
+static int print_block_frame_locals PARAMS ((struct block *,
+                                            struct frame_info *,
+                                            GDB_FILE *));
 
 
-static FRAME
-parse_frame_specification PARAMS ((char *));
+static void backtrace_command PARAMS ((char *, int));
 
 
-static void
-frame_info PARAMS ((char *, int));
+static struct frame_info *parse_frame_specification PARAMS ((char *));
 
 
+static void frame_info PARAMS ((char *, int));
 
 extern int addressprint;       /* Print addresses, or stay symbolic only? */
 extern int info_verbose;       /* Verbosity of symbol reading msgs */
 
 extern int addressprint;       /* Print addresses, or stay symbolic only? */
 extern int info_verbose;       /* Verbosity of symbol reading msgs */
@@ -93,7 +81,7 @@ extern int lines_to_list;     /* # of lines "list" command shows by default */
 /* The "selected" stack frame is used by default for local and arg access.
    May be zero, for no selected frame.  */
 
 /* The "selected" stack frame is used by default for local and arg access.
    May be zero, for no selected frame.  */
 
-FRAME selected_frame;
+struct frame_info *selected_frame;
 
 /* Level of the selected frame:
    0 for innermost, 1 for its caller, ...
 
 /* Level of the selected frame:
    0 for innermost, 1 for its caller, ...
@@ -125,11 +113,12 @@ print_stack_frame_stub (args)
      char *args;
 {
   struct print_stack_frame_args *p = (struct print_stack_frame_args *)args;
      char *args;
 {
   struct print_stack_frame_args *p = (struct print_stack_frame_args *)args;
+
   print_frame_info (p->fi, p->level, p->source, p->args);
   return 0;
 }
 
   print_frame_info (p->fi, p->level, p->source, p->args);
   return 0;
 }
 
-/* Print a stack frame briefly.  FRAME should be the frame id
+/* Print a stack frame briefly.  FRAME_INFI should be the frame info
    and LEVEL should be its level in the stack (or -1 for level not defined).
    This prints the level, the function executing, the arguments,
    and the file name and line number.
    and LEVEL should be its level in the stack (or -1 for level not defined).
    This prints the level, the function executing, the arguments,
    and the file name and line number.
@@ -140,14 +129,14 @@ print_stack_frame_stub (args)
    If SOURCE is -1, print ONLY the source line.  */
 
 void
    If SOURCE is -1, print ONLY the source line.  */
 
 void
-print_stack_frame (frame, level, source)
-     FRAME frame;
+print_stack_frame (fi, level, source)
+     struct frame_info *fi;
      int level;
      int source;
 {
   struct print_stack_frame_args args;
 
      int level;
      int source;
 {
   struct print_stack_frame_args args;
 
-  args.fi = get_frame_info (frame);
+  args.fi = fi;
   args.level = level;
   args.source = source;
   args.args = 1;
   args.level = level;
   args.source = source;
   args.args = 1;
@@ -163,17 +152,22 @@ struct print_args_args {
 static int print_args_stub PARAMS ((char *));
 
 /* Pass the args the way catch_errors wants them.  */
 static int print_args_stub PARAMS ((char *));
 
 /* Pass the args the way catch_errors wants them.  */
+
 static int
 print_args_stub (args)
      char *args;
 {
   int numargs;
   struct print_args_args *p = (struct print_args_args *)args;
 static int
 print_args_stub (args)
      char *args;
 {
   int numargs;
   struct print_args_args *p = (struct print_args_args *)args;
+
   FRAME_NUM_ARGS (numargs, (p->fi));
   print_frame_args (p->func, p->fi, numargs, gdb_stdout);
   return 0;
 }
 
   FRAME_NUM_ARGS (numargs, (p->fi));
   print_frame_args (p->func, p->fi, numargs, gdb_stdout);
   return 0;
 }
 
+/* LEVEL is the level of the frame, or -1 if it is the innermost frame
+   but we don't want to print the level.  */
+
 void
 print_frame_info (fi, level, source, args)
      struct frame_info *fi;
 void
 print_frame_info (fi, level, source, args)
      struct frame_info *fi;
@@ -185,10 +179,11 @@ print_frame_info (fi, level, source, args)
   struct symbol *func;
   register char *funname = 0;
   enum language funlang = language_unknown;
   struct symbol *func;
   register char *funname = 0;
   enum language funlang = language_unknown;
+
+#if 0
   char buf[MAX_REGISTER_RAW_SIZE];
   CORE_ADDR sp;
 
   char buf[MAX_REGISTER_RAW_SIZE];
   CORE_ADDR sp;
 
-#if 0
   /* On the 68k, this spends too much time in m68k_find_saved_regs.  */
 
   /* Get the value of SP_REGNUM relative to the frame.  */
   /* On the 68k, this spends too much time in m68k_find_saved_regs.  */
 
   /* Get the value of SP_REGNUM relative to the frame.  */
@@ -205,20 +200,28 @@ print_frame_info (fi, level, source, args)
   if (frame_in_dummy (fi))
 #endif
     {
   if (frame_in_dummy (fi))
 #endif
     {
+      annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
+
       /* Do this regardless of SOURCE because we don't have any source
         to list for this frame.  */
       if (level >= 0)
        printf_filtered ("#%-2d ", level);
       /* Do this regardless of SOURCE because we don't have any source
         to list for this frame.  */
       if (level >= 0)
        printf_filtered ("#%-2d ", level);
+      annotate_function_call ();
       printf_filtered ("<function called from gdb>\n");
       printf_filtered ("<function called from gdb>\n");
+      annotate_frame_end ();
       return;
     }
   if (fi->signal_handler_caller)
     {
       return;
     }
   if (fi->signal_handler_caller)
     {
+      annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
+
       /* Do this regardless of SOURCE because we don't have any source
         to list for this frame.  */
       if (level >= 0)
        printf_filtered ("#%-2d ", level);
       /* Do this regardless of SOURCE because we don't have any source
         to list for this frame.  */
       if (level >= 0)
        printf_filtered ("#%-2d ", level);
+      annotate_signal_handler_caller ();
       printf_filtered ("<signal handler called>\n");
       printf_filtered ("<signal handler called>\n");
+      annotate_frame_end ();
       return;
     }
 
       return;
     }
 
@@ -290,17 +293,23 @@ print_frame_info (fi, level, source, args)
 
   if (source >= 0 || !sal.symtab)
     {
 
   if (source >= 0 || !sal.symtab)
     {
+      annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
+
       if (level >= 0)
        printf_filtered ("#%-2d ", level);
       if (addressprint)
        if (fi->pc != sal.pc || !sal.symtab)
          {
       if (level >= 0)
        printf_filtered ("#%-2d ", level);
       if (addressprint)
        if (fi->pc != sal.pc || !sal.symtab)
          {
+           annotate_frame_address ();
            print_address_numeric (fi->pc, 1, gdb_stdout);
            print_address_numeric (fi->pc, 1, gdb_stdout);
+           annotate_frame_address_end ();
            printf_filtered (" in ");
          }
            printf_filtered (" in ");
          }
+      annotate_frame_function_name ();
       fprintf_symbol_filtered (gdb_stdout, funname ? funname : "??", funlang,
                               DMGL_ANSI);
       wrap_here ("   ");
       fprintf_symbol_filtered (gdb_stdout, funname ? funname : "??", funlang,
                               DMGL_ANSI);
       wrap_here ("   ");
+      annotate_frame_args ();
       fputs_filtered (" (", gdb_stdout);
       if (args)
        {
       fputs_filtered (" (", gdb_stdout);
       if (args)
        {
@@ -312,18 +321,28 @@ print_frame_info (fi, level, source, args)
       printf_filtered (")");
       if (sal.symtab && sal.symtab->filename)
        {
       printf_filtered (")");
       if (sal.symtab && sal.symtab->filename)
        {
+         annotate_frame_source_begin ();
           wrap_here ("   ");
           wrap_here ("   ");
-         printf_filtered (" at %s:%d", sal.symtab->filename, sal.line);
+         printf_filtered (" at ");
+         annotate_frame_source_file ();
+         printf_filtered ("%s", sal.symtab->filename);
+         annotate_frame_source_file_end ();
+         printf_filtered (":");
+         annotate_frame_source_line ();
+         printf_filtered ("%d", sal.line);
+         annotate_frame_source_end ();
        }
 
 #ifdef PC_LOAD_SEGMENT
      /* If we couldn't print out function name but if can figure out what
         load segment this pc value is from, at least print out some info
        about its load segment. */
        }
 
 #ifdef PC_LOAD_SEGMENT
      /* If we couldn't print out function name but if can figure out what
         load segment this pc value is from, at least print out some info
        about its load segment. */
-      if (!funname) {
-       wrap_here ("  ");
-       printf_filtered (" from %s", PC_LOAD_SEGMENT (fi->pc));
-      }
+      if (!funname)
+       {
+         annotate_frame_where ();
+         wrap_here ("  ");
+         printf_filtered (" from %s", PC_LOAD_SEGMENT (fi->pc));
+       }
 #endif
       printf_filtered ("\n");
     }
 #endif
       printf_filtered ("\n");
     }
@@ -342,22 +361,26 @@ print_frame_info (fi, level, source, args)
              print_address_numeric (fi->pc, 1, gdb_stdout);
              printf_filtered ("\t");
            }
              print_address_numeric (fi->pc, 1, gdb_stdout);
              printf_filtered ("\t");
            }
-         print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
+         if (print_frame_info_listing_hook)
+           print_frame_info_listing_hook (sal.symtab, sal.line, sal.line + 1, 0);
+         else
+           print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
        }
       current_source_line = max (sal.line - lines_to_list/2, 1);
     }
   if (source != 0)
     set_default_breakpoint (1, fi->pc, sal.symtab, sal.line);
 
        }
       current_source_line = max (sal.line - lines_to_list/2, 1);
     }
   if (source != 0)
     set_default_breakpoint (1, fi->pc, sal.symtab, sal.line);
 
+  annotate_frame_end ();
+
   gdb_flush (gdb_stdout);
 }
 
   gdb_flush (gdb_stdout);
 }
 
-/*
- * Read a frame specification in whatever the appropriate format is.
- * Call error() if the specification is in any way invalid (i.e.
- * this function never returns NULL).
- */
-static FRAME
+/* Read a frame specification in whatever the appropriate format is.
+   Call error() if the specification is in any way invalid (i.e.
+   this function never returns NULL).  */
+
+static struct frame_info *
 parse_frame_specification (frame_exp)
      char *frame_exp;
 {
 parse_frame_specification (frame_exp)
      char *frame_exp;
 {
@@ -403,8 +426,9 @@ parse_frame_specification (frame_exp)
     case 1:
       {
        int level = args[0];
     case 1:
       {
        int level = args[0];
-       FRAME fid = find_relative_frame (get_current_frame (), &level);
-       FRAME tfid;
+       struct frame_info *fid =
+         find_relative_frame (get_current_frame (), &level);
+       struct frame_info *tfid;
 
        if (level == 0)
          /* find_relative_frame was successful */
 
        if (level == 0)
          /* find_relative_frame was successful */
@@ -430,13 +454,13 @@ parse_frame_specification (frame_exp)
           (s)he gets.  Still, give the highest one that matches.  */
 
        for (fid = get_current_frame ();
           (s)he gets.  Still, give the highest one that matches.  */
 
        for (fid = get_current_frame ();
-            fid && FRAME_FP (fid) != args[0];
+            fid && fid->frame != args[0];
             fid = get_prev_frame (fid))
          ;
 
        if (fid)
          while ((tfid = get_prev_frame (fid)) &&
             fid = get_prev_frame (fid))
          ;
 
        if (fid)
          while ((tfid = get_prev_frame (fid)) &&
-                (FRAME_FP (tfid) == args[0]))
+                (tfid->frame == args[0]))
            fid = tfid;
          
        /* We couldn't identify the frame as an existing frame, but
            fid = tfid;
          
        /* We couldn't identify the frame as an existing frame, but
@@ -476,30 +500,28 @@ frame_info (addr_exp, from_tty)
      char *addr_exp;
      int from_tty;
 {
      char *addr_exp;
      int from_tty;
 {
-  FRAME frame;
   struct frame_info *fi;
   struct frame_saved_regs fsr;
   struct symtab_and_line sal;
   struct symbol *func;
   struct symtab *s;
   struct frame_info *fi;
   struct frame_saved_regs fsr;
   struct symtab_and_line sal;
   struct symbol *func;
   struct symtab *s;
-  FRAME calling_frame;
-  int i, count;
+  struct frame_info *calling_frame_info;
+  int i, count, numregs;
   char *funname = 0;
   enum language funlang = language_unknown;
 
   if (!target_has_stack)
     error ("No stack.");
 
   char *funname = 0;
   enum language funlang = language_unknown;
 
   if (!target_has_stack)
     error ("No stack.");
 
-  frame = parse_frame_specification (addr_exp);
-  if (!frame)
+  fi = parse_frame_specification (addr_exp);
+  if (fi == NULL)
     error ("Invalid frame specified.");
 
     error ("Invalid frame specified.");
 
-  fi = get_frame_info (frame);
   sal = find_pc_line (fi->pc,
                      fi->next != NULL
                      && !fi->next->signal_handler_caller
                      && !frame_in_dummy (fi->next));
   sal = find_pc_line (fi->pc,
                      fi->next != NULL
                      && !fi->next->signal_handler_caller
                      && !frame_in_dummy (fi->next));
-  func = get_frame_function (frame);
+  func = get_frame_function (fi);
   s = find_pc_symtab(fi->pc);
   if (func)
     {
   s = find_pc_symtab(fi->pc);
   if (func)
     {
@@ -515,22 +537,21 @@ frame_info (addr_exp, from_tty)
          funlang = SYMBOL_LANGUAGE (msymbol);
        }
     }
          funlang = SYMBOL_LANGUAGE (msymbol);
        }
     }
-  calling_frame = get_prev_frame (frame);
+  calling_frame_info = get_prev_frame (fi);
 
   if (!addr_exp && selected_frame_level >= 0)
     {
       printf_filtered ("Stack level %d, frame at ", selected_frame_level);
 
   if (!addr_exp && selected_frame_level >= 0)
     {
       printf_filtered ("Stack level %d, frame at ", selected_frame_level);
-      print_address_numeric (FRAME_FP(frame), 1, gdb_stdout);
+      print_address_numeric (fi->frame, 1, gdb_stdout);
       printf_filtered (":\n");
     }
   else
     {
       printf_filtered ("Stack frame at ");
       printf_filtered (":\n");
     }
   else
     {
       printf_filtered ("Stack frame at ");
-      print_address_numeric (FRAME_FP(frame), 1, gdb_stdout);
+      print_address_numeric (fi->frame, 1, gdb_stdout);
       printf_filtered (":\n");
     }
       printf_filtered (":\n");
     }
-  printf_filtered (" %s = ",
-                  reg_names[PC_REGNUM]);
+  printf_filtered (" %s = ", reg_names[PC_REGNUM]);
   print_address_numeric (fi->pc, 1, gdb_stdout);
 
   wrap_here ("   ");
   print_address_numeric (fi->pc, 1, gdb_stdout);
 
   wrap_here ("   ");
@@ -546,7 +567,7 @@ frame_info (addr_exp, from_tty)
   puts_filtered ("; ");
   wrap_here ("    ");
   printf_filtered ("saved %s ", reg_names[PC_REGNUM]);
   puts_filtered ("; ");
   wrap_here ("    ");
   printf_filtered ("saved %s ", reg_names[PC_REGNUM]);
-  print_address_numeric (FRAME_SAVED_PC (frame), 1, gdb_stdout);
+  print_address_numeric (FRAME_SAVED_PC (fi), 1, gdb_stdout);
   printf_filtered ("\n");
 
   {
   printf_filtered ("\n");
 
   {
@@ -558,12 +579,12 @@ frame_info (addr_exp, from_tty)
       printf_filtered (" (FRAMELESS),");
   }
 
       printf_filtered (" (FRAMELESS),");
   }
 
-  if (calling_frame)
+  if (calling_frame_info)
     {
       printf_filtered (" called by frame at ");
     {
       printf_filtered (" called by frame at ");
-      print_address_numeric (FRAME_FP (calling_frame), 1, gdb_stdout);
+      print_address_numeric (calling_frame_info->frame, 1, gdb_stdout);
     }
     }
-  if (fi->next && calling_frame)
+  if (fi->next && calling_frame_info)
     puts_filtered (",");
   wrap_here ("   ");
   if (fi->next)
     puts_filtered (",");
   wrap_here ("   ");
   if (fi->next)
@@ -571,7 +592,7 @@ frame_info (addr_exp, from_tty)
       printf_filtered (" caller of frame at ");
       print_address_numeric (fi->next->frame, 1, gdb_stdout);
     }
       printf_filtered (" caller of frame at ");
       print_address_numeric (fi->next->frame, 1, gdb_stdout);
     }
-  if (fi->next || calling_frame)
+  if (fi->next || calling_frame_info)
     puts_filtered ("\n");
   if (s)
     printf_filtered (" source language %s.\n", language_str (s->language));
     puts_filtered ("\n");
   if (s)
     printf_filtered (" source language %s.\n", language_str (s->language));
@@ -629,7 +650,8 @@ frame_info (addr_exp, from_tty)
   print_address_numeric (fsr.regs[SP_REGNUM], 1, gdb_stdout);
   printf_filtered ("\n");
   count = 0;
   print_address_numeric (fsr.regs[SP_REGNUM], 1, gdb_stdout);
   printf_filtered ("\n");
   count = 0;
-  for (i = 0; i < NUM_REGS; i++)
+  numregs = ARCH_NUM_REGS;
+  for (i = 0; i < numregs; i++)
     if (fsr.regs[i] && i != SP_REGNUM)
       {
        if (count == 0)
     if (fsr.regs[i] && i != SP_REGNUM)
       {
        if (count == 0)
@@ -644,6 +666,10 @@ frame_info (addr_exp, from_tty)
   if (count)
     puts_filtered ("\n");
 #else  /* Have FRAME_FIND_SAVED_REGS.  */
   if (count)
     puts_filtered ("\n");
 #else  /* Have FRAME_FIND_SAVED_REGS.  */
+  /* We could get some information about saved registers by calling
+     get_saved_register on each register.  Which info goes with which frame
+     is necessarily lost, however, and I suspect that the users don't care
+     whether they get the info.  */
   puts_filtered ("\n");
 #endif /* Have FRAME_FIND_SAVED_REGS.  */
 }
   puts_filtered ("\n");
 #endif /* Have FRAME_FIND_SAVED_REGS.  */
 }
@@ -688,9 +714,8 @@ backtrace_command (count_exp, from_tty)
 {
   struct frame_info *fi;
   register int count;
 {
   struct frame_info *fi;
   register int count;
-  register FRAME frame;
   register int i;
   register int i;
-  register FRAME trailing;
+  register struct frame_info *trailing;
   register int trailing_level;
 
   if (!target_has_stack)
   register int trailing_level;
 
   if (!target_has_stack)
@@ -707,7 +732,7 @@ backtrace_command (count_exp, from_tty)
       count = parse_and_eval_address (count_exp);
       if (count < 0)
        {
       count = parse_and_eval_address (count_exp);
       if (count < 0)
        {
-         FRAME current;
+         struct frame_info *current;
 
          count = -count;
 
 
          count = -count;
 
@@ -744,24 +769,22 @@ backtrace_command (count_exp, from_tty)
         if people have strong opinions against reading symbols for
         backtrace this may have to be an option.  */
       i = count;
         if people have strong opinions against reading symbols for
         backtrace this may have to be an option.  */
       i = count;
-      for (frame = trailing;
-          frame != NULL && i--;
-          frame = get_prev_frame (frame))
+      for (fi = trailing;
+          fi != NULL && i--;
+          fi = get_prev_frame (fi))
        {
          QUIT;
        {
          QUIT;
-         fi = get_frame_info (frame);
          ps = find_pc_psymtab (fi->pc);
          if (ps)
            PSYMTAB_TO_SYMTAB (ps);     /* Force syms to come in */
        }
     }
 
          ps = find_pc_psymtab (fi->pc);
          if (ps)
            PSYMTAB_TO_SYMTAB (ps);     /* Force syms to come in */
        }
     }
 
-  for (i = 0, frame = trailing;
-       frame && count--;
-       i++, frame = get_prev_frame (frame))
+  for (i = 0, fi = trailing;
+       fi && count--;
+       i++, fi = get_prev_frame (fi))
     {
       QUIT;
     {
       QUIT;
-      fi = get_frame_info (frame);
 
       /* Don't use print_stack_frame; if an error() occurs it probably
         means further attempts to backtrace would fail (on the other
 
       /* Don't use print_stack_frame; if an error() occurs it probably
         means further attempts to backtrace would fail (on the other
@@ -771,7 +794,7 @@ backtrace_command (count_exp, from_tty)
     }
 
   /* If we've stopped before the end, mention that.  */
     }
 
   /* If we've stopped before the end, mention that.  */
-  if (frame && from_tty)
+  if (fi && from_tty)
     printf_filtered ("(More stack frames follow...)\n");
 }
 \f
     printf_filtered ("(More stack frames follow...)\n");
 }
 \f
@@ -779,9 +802,9 @@ backtrace_command (count_exp, from_tty)
    Return 1 if any variables were printed; 0 otherwise.  */
 
 static int
    Return 1 if any variables were printed; 0 otherwise.  */
 
 static int
-print_block_frame_locals (b, frame, stream)
+print_block_frame_locals (b, fi, stream)
      struct block *b;
      struct block *b;
-     register FRAME frame;
+     register struct frame_info *fi;
      register GDB_FILE *stream;
 {
   int nsyms;
      register GDB_FILE *stream;
 {
   int nsyms;
@@ -803,7 +826,7 @@ print_block_frame_locals (b, frame, stream)
          values_printed = 1;
          fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream);
          fputs_filtered (" = ", stream);
          values_printed = 1;
          fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream);
          fputs_filtered (" = ", stream);
-         print_variable_value (sym, frame, stream);
+         print_variable_value (sym, fi, stream);
          fprintf_filtered (stream, "\n");
          break;
 
          fprintf_filtered (stream, "\n");
          break;
 
@@ -866,11 +889,11 @@ print_block_frame_labels (b, have_default, stream)
    on the function running in FRAME.  */
 
 static void
    on the function running in FRAME.  */
 
 static void
-print_frame_local_vars (frame, stream)
-     register FRAME frame;
+print_frame_local_vars (fi, stream)
+     register struct frame_info *fi;
      register GDB_FILE *stream;
 {
      register GDB_FILE *stream;
 {
-  register struct block *block = get_frame_block (frame);
+  register struct block *block = get_frame_block (fi);
   register int values_printed = 0;
 
   if (block == 0)
   register int values_printed = 0;
 
   if (block == 0)
@@ -881,7 +904,7 @@ print_frame_local_vars (frame, stream)
   
   while (block != 0)
     {
   
   while (block != 0)
     {
-      if (print_block_frame_locals (block, frame, stream))
+      if (print_block_frame_locals (block, fi, stream))
        values_printed = 1;
       /* After handling the function's top-level block, stop.
         Don't continue to its superblock, the block of
        values_printed = 1;
       /* After handling the function's top-level block, stop.
         Don't continue to its superblock, the block of
@@ -900,17 +923,16 @@ print_frame_local_vars (frame, stream)
 /* Same, but print labels.  */
 
 static void
 /* Same, but print labels.  */
 
 static void
-print_frame_label_vars (frame, this_level_only, stream)
-     register FRAME frame;
+print_frame_label_vars (fi, this_level_only, stream)
+     register struct frame_info *fi;
      int this_level_only;
      register GDB_FILE *stream;
 {
   register struct blockvector *bl;
      int this_level_only;
      register GDB_FILE *stream;
 {
   register struct blockvector *bl;
-  register struct block *block = get_frame_block (frame);
+  register struct block *block = get_frame_block (fi);
   register int values_printed = 0;
   int index, have_default = 0;
   char *blocks_printed;
   register int values_printed = 0;
   int index, have_default = 0;
   char *blocks_printed;
-  struct frame_info *fi = get_frame_info (frame);
   CORE_ADDR pc = fi->pc;
 
   if (block == 0)
   CORE_ADDR pc = fi->pc;
 
   if (block == 0)
@@ -992,11 +1014,11 @@ catch_info (ignore, from_tty)
 }
 
 static void
 }
 
 static void
-print_frame_arg_vars (frame, stream)
-     register FRAME frame;
+print_frame_arg_vars (fi, stream)
+     register struct frame_info *fi;
      register GDB_FILE *stream;
 {
      register GDB_FILE *stream;
 {
-  struct symbol *func = get_frame_function (frame);
+  struct symbol *func = get_frame_function (fi);
   register struct block *b;
   int nsyms;
   register int i;
   register struct block *b;
   int nsyms;
   register int i;
@@ -1040,7 +1062,7 @@ print_frame_arg_vars (frame, stream)
 
          sym2 = lookup_symbol (SYMBOL_NAME (sym),
                        b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
 
          sym2 = lookup_symbol (SYMBOL_NAME (sym),
                        b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
-         print_variable_value (sym2, frame, stream);
+         print_variable_value (sym2, fi, stream);
          fprintf_filtered (stream, "\n");
          break;
 
          fprintf_filtered (stream, "\n");
          break;
 
@@ -1066,24 +1088,24 @@ args_info (ignore, from_tty)
   print_frame_arg_vars (selected_frame, gdb_stdout);
 }
 \f
   print_frame_arg_vars (selected_frame, gdb_stdout);
 }
 \f
-/* Select frame FRAME, and note that its stack level is LEVEL.
+/* Select frame FI, and note that its stack level is LEVEL.
    LEVEL may be -1 if an actual level number is not known.  */
 
 void
    LEVEL may be -1 if an actual level number is not known.  */
 
 void
-select_frame (frame, level)
-     FRAME frame;
+select_frame (fi, level)
+     struct frame_info *fi;
      int level;
 {
   register struct symtab *s;
 
      int level;
 {
   register struct symtab *s;
 
-  selected_frame = frame;
+  selected_frame = fi;
   selected_frame_level = level;
 
   /* Ensure that symbols for this frame are read in.  Also, determine the
      source language of this frame, and switch to it if desired.  */
   selected_frame_level = level;
 
   /* Ensure that symbols for this frame are read in.  Also, determine the
      source language of this frame, and switch to it if desired.  */
-  if (frame)
+  if (fi)
   {
   {
-    s = find_pc_symtab (get_frame_info (frame)->pc);
+    s = find_pc_symtab (fi->pc);
     if (s 
        && s->language != current_language->la_language
        && s->language != language_unknown
     if (s 
        && s->language != current_language->la_language
        && s->language != language_unknown
@@ -1098,10 +1120,10 @@ select_frame (frame, level)
 
 void
 record_selected_frame (frameaddrp, levelp)
 
 void
 record_selected_frame (frameaddrp, levelp)
-     FRAME_ADDR *frameaddrp;
+     CORE_ADDR *frameaddrp;
      int *levelp;
 {
      int *levelp;
 {
-  *frameaddrp = selected_frame ? FRAME_FP (selected_frame) : 0;
+  *frameaddrp = selected_frame ? selected_frame->frame : 0;
   *levelp = selected_frame_level;
 }
 
   *levelp = selected_frame_level;
 }
 
@@ -1128,13 +1150,13 @@ get_selected_block ()
    but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates
    how much farther the original request asked to go.  */
 
    but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates
    how much farther the original request asked to go.  */
 
-FRAME
+struct frame_info *
 find_relative_frame (frame, level_offset_ptr)
 find_relative_frame (frame, level_offset_ptr)
-     register FRAME frame;
-     register intlevel_offset_ptr;
+     register struct frame_info *frame;
+     register int *level_offset_ptr;
 {
 {
-  register FRAME prev;
-  register FRAME frame1;
+  register struct frame_info *prev;
+  register struct frame_info *frame1;
 
   /* Going up is simple: just do get_prev_frame enough times
      or until initial frame is reached.  */
 
   /* Going up is simple: just do get_prev_frame enough times
      or until initial frame is reached.  */
@@ -1172,7 +1194,7 @@ select_frame_command (level_exp, from_tty)
      char *level_exp;
      int from_tty;
 {
      char *level_exp;
      int from_tty;
 {
-  register FRAME frame, frame1;
+  register struct frame_info *frame, *frame1;
   unsigned int level = 0;
 
   if (!target_has_stack)
   unsigned int level = 0;
 
   if (!target_has_stack)
@@ -1218,7 +1240,7 @@ up_silently_command (count_exp, from_tty)
      char *count_exp;
      int from_tty;
 {
      char *count_exp;
      int from_tty;
 {
-  register FRAME frame;
+  register struct frame_info *fi;
   int count = 1, count1;
   if (count_exp)
     count = parse_and_eval_address (count_exp);
   int count = 1, count1;
   if (count_exp)
     count = parse_and_eval_address (count_exp);
@@ -1227,10 +1249,10 @@ up_silently_command (count_exp, from_tty)
   if (target_has_stack == 0 || selected_frame == 0)
     error ("No stack.");
 
   if (target_has_stack == 0 || selected_frame == 0)
     error ("No stack.");
 
-  frame = find_relative_frame (selected_frame, &count1);
+  fi = find_relative_frame (selected_frame, &count1);
   if (count1 != 0 && count_exp == 0)
     error ("Initial frame selected; you cannot go up.");
   if (count1 != 0 && count_exp == 0)
     error ("Initial frame selected; you cannot go up.");
-  select_frame (frame, selected_frame_level + count - count1);
+  select_frame (fi, selected_frame_level + count - count1);
 }
 
 static void
 }
 
 static void
@@ -1251,7 +1273,7 @@ down_silently_command (count_exp, from_tty)
      char *count_exp;
      int from_tty;
 {
      char *count_exp;
      int from_tty;
 {
-  register FRAME frame;
+  register struct frame_info *frame;
   int count = -1, count1;
   if (count_exp)
     count = - parse_and_eval_address (count_exp);
   int count = -1, count1;
   if (count_exp)
     count = - parse_and_eval_address (count_exp);
@@ -1291,23 +1313,32 @@ return_command (retval_exp, from_tty)
      int from_tty;
 {
   struct symbol *thisfun;
      int from_tty;
 {
   struct symbol *thisfun;
-  FRAME_ADDR selected_frame_addr;
+  CORE_ADDR selected_frame_addr;
   CORE_ADDR selected_frame_pc;
   CORE_ADDR selected_frame_pc;
-  FRAME frame;
+  struct frame_info *frame;
   value_ptr return_value = NULL;
 
   if (selected_frame == NULL)
     error ("No selected frame.");
   thisfun = get_frame_function (selected_frame);
   selected_frame_addr = FRAME_FP (selected_frame);
   value_ptr return_value = NULL;
 
   if (selected_frame == NULL)
     error ("No selected frame.");
   thisfun = get_frame_function (selected_frame);
   selected_frame_addr = FRAME_FP (selected_frame);
-  selected_frame_pc = (get_frame_info (selected_frame))->pc;
+  selected_frame_pc = selected_frame->pc;
 
   /* Compute the return value (if any -- possibly getting errors here).  */
 
   if (retval_exp)
     {
 
   /* Compute the return value (if any -- possibly getting errors here).  */
 
   if (retval_exp)
     {
+      struct type *return_type = NULL;
+
       return_value = parse_and_eval (retval_exp);
 
       return_value = parse_and_eval (retval_exp);
 
+      /* Cast return value to the return type of the function.  */
+      if (thisfun != NULL)
+       return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
+      if (return_type == NULL)
+       return_type = builtin_type_int;
+      return_value = value_cast (return_type, return_value);
+
       /* Make sure we have fully evaluated it, since
         it might live in the stack frame we're about to pop.  */
       if (VALUE_LAZY (return_value))
       /* Make sure we have fully evaluated it, since
         it might live in the stack frame we're about to pop.  */
       if (VALUE_LAZY (return_value))
@@ -1336,8 +1367,8 @@ return_command (retval_exp, from_tty)
      a POP_FRAME.  The pc comparison makes this work even if the
      selected frame shares its fp with another frame.  */
 
      a POP_FRAME.  The pc comparison makes this work even if the
      selected frame shares its fp with another frame.  */
 
-  while ( selected_frame_addr != FRAME_FP (frame = get_current_frame())
-       || selected_frame_pc   != (get_frame_info (frame))->pc  )
+  while (selected_frame_addr != (frame = get_current_frame())->frame
+        || selected_frame_pc != frame->pc)
     POP_FRAME;
 
   /* Then pop that frame.  */
     POP_FRAME;
 
   /* Then pop that frame.  */
@@ -1356,27 +1387,26 @@ return_command (retval_exp, from_tty)
     frame_command ("0", 1);
 }
 
     frame_command ("0", 1);
 }
 
-/* Gets the language of the current frame. */
+/* Gets the language of the current frame.  */
+
 enum language
 get_frame_language()
 {
 enum language
 get_frame_language()
 {
-   register struct symtab *s;
-   FRAME fr;
-   enum language flang;                /* The language of the current frame */
+  register struct symtab *s;
+  enum language flang;         /* The language of the current frame */
    
    
-   fr = get_frame_info(selected_frame);
-   if(fr)
-   {
-      s = find_pc_symtab(fr->pc);
-      if(s)
-        flang = s->language;
+  if (selected_frame)
+    {
+      s = find_pc_symtab(selected_frame->pc);
+      if (s)
+       flang = s->language;
       else
       else
-        flang = language_unknown;
-   }
-   else
-      flang = language_unknown;
+       flang = language_unknown;
+    }
+  else
+    flang = language_unknown;
 
 
-   return flang;
+  return flang;
 }
 \f
 void
 }
 \f
 void
index 24e7c6e3f625b667288bf18292c9dfc77787fc79..6a14c248a4e4606d3aacd0f044a5630d836a7116 100644 (file)
@@ -42,6 +42,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <string.h>
 #include <sys/stat.h>
 #include <ctype.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <ctype.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #ifndef O_BINARY
 #define O_BINARY 0
 
 #ifndef O_BINARY
 #define O_BINARY 0
@@ -312,9 +315,14 @@ entry_point_address()
 }
 
 /* Remember the lowest-addressed loadable section we've seen.  
 }
 
 /* Remember the lowest-addressed loadable section we've seen.  
-   This function is called via bfd_map_over_sections.  */
+   This function is called via bfd_map_over_sections. 
+
+   In case of equal vmas, the section with the largest size becomes the
+   lowest-addressed loadable section.
+
+   If the vmas and sizes are equal, the last section is considered the
+   lowest-addressed loadable section.  */
 
 
-#if 0  /* Not used yet */
 static void
 find_lowest_section (abfd, sect, obj)
      bfd *abfd;
 static void
 find_lowest_section (abfd, sect, obj)
      bfd *abfd;
@@ -327,10 +335,13 @@ find_lowest_section (abfd, sect, obj)
     return;
   if (!*lowest)
     *lowest = sect;            /* First loadable section */
     return;
   if (!*lowest)
     *lowest = sect;            /* First loadable section */
-  else if (bfd_section_vma (abfd, *lowest) >= bfd_section_vma (abfd, sect))
+  else if (bfd_section_vma (abfd, *lowest) > bfd_section_vma (abfd, sect))
     *lowest = sect;            /* A lower loadable section */
     *lowest = sect;            /* A lower loadable section */
+  else if (bfd_section_vma (abfd, *lowest) == bfd_section_vma (abfd, sect)
+          && (bfd_section_size (abfd, (*lowest))
+              <= bfd_section_size (abfd, sect)))
+    *lowest = sect;
 }
 }
-#endif 
 
 /* Process a symbol file, as either the main file or as a dynamically
    loaded file.
 
 /* Process a symbol file, as either the main file or as a dynamically
    loaded file.
@@ -387,8 +398,7 @@ syms_from_objfile (objfile, addr, mainline, verbo)
   /* Convert addr into an offset rather than an absolute address.
      We find the lowest address of a loaded segment in the objfile,
      and assume that <addr> is where that got loaded.  Due to historical
   /* Convert addr into an offset rather than an absolute address.
      We find the lowest address of a loaded segment in the objfile,
      and assume that <addr> is where that got loaded.  Due to historical
-     precedent, we warn if that doesn't happen to be the ".text"
-     segment.  */
+     precedent, we warn if that doesn't happen to be a text segment.  */
 
   if (mainline)
     {
 
   if (mainline)
     {
@@ -397,18 +407,15 @@ syms_from_objfile (objfile, addr, mainline, verbo)
   else
     {
       lowest_sect = bfd_get_section_by_name (objfile->obfd, ".text");
   else
     {
       lowest_sect = bfd_get_section_by_name (objfile->obfd, ".text");
-#if 0
-      lowest_sect = 0;
-      bfd_map_over_sections (objfile->obfd, find_lowest_section,
-                            (PTR) &lowest_sect);
-#endif
+      if (lowest_sect == NULL)
+       bfd_map_over_sections (objfile->obfd, find_lowest_section,
+                              (PTR) &lowest_sect);
 
 
-      if (lowest_sect == 0)
+      if (lowest_sect == NULL)
        warning ("no loadable sections found in added symbol-file %s",
                 objfile->name);
        warning ("no loadable sections found in added symbol-file %s",
                 objfile->name);
-      else if (0 == bfd_get_section_name (objfile->obfd, lowest_sect)
-              || !STREQ (".text",
-                             bfd_get_section_name (objfile->obfd, lowest_sect)))
+      else if ((bfd_get_section_flags (objfile->obfd, lowest_sect) & SEC_CODE)
+              == 0)
        /* FIXME-32x64--assumes bfd_vma fits in long.  */
        warning ("Lowest section in %s is %s at 0x%lx",
                 objfile->name,
        /* FIXME-32x64--assumes bfd_vma fits in long.  */
        warning ("Lowest section in %s is %s at 0x%lx",
                 objfile->name,
@@ -794,6 +801,9 @@ symfile_bfd_open (name)
 
   if (!bfd_check_format (sym_bfd, bfd_object))
     {
 
   if (!bfd_check_format (sym_bfd, bfd_object))
     {
+      /* FIXME: should be checking for errors from bfd_close (for one thing,
+        on error it does not free all the storage associated with the
+        bfd).  */
       bfd_close (sym_bfd);     /* This also closes desc */
       make_cleanup (free, name);
       error ("\"%s\": can't read symbols: %s.", name,
       bfd_close (sym_bfd);     /* This also closes desc */
       make_cleanup (free, name);
       error ("\"%s\": can't read symbols: %s.", name,
@@ -885,6 +895,9 @@ generic_load (filename, from_tty)
       perror_with_name (filename);
       return;
     }
       perror_with_name (filename);
       return;
     }
+  /* FIXME: should be checking for errors from bfd_close (for one thing,
+     on error it does not free all the storage associated with the
+     bfd).  */
   old_cleanups = make_cleanup (bfd_close, loadfile_bfd);
 
   if (!bfd_check_format (loadfile_bfd, bfd_object)) 
   old_cleanups = make_cleanup (bfd_close, loadfile_bfd);
 
   if (!bfd_check_format (loadfile_bfd, bfd_object)) 
@@ -1107,7 +1120,8 @@ reread_symbols ()
             BFD without closing the descriptor.  */
          obfd_filename = bfd_get_filename (objfile->obfd);
          if (!bfd_close (objfile->obfd))
             BFD without closing the descriptor.  */
          obfd_filename = bfd_get_filename (objfile->obfd);
          if (!bfd_close (objfile->obfd))
-           error ("Can't close BFD for %s.", objfile->name);
+           error ("Can't close BFD for %s: %s", objfile->name,
+                  bfd_errmsg (bfd_get_error ()));
          objfile->obfd = bfd_openr (obfd_filename, gnutarget);
          if (objfile->obfd == NULL)
            error ("Can't open %s to read symbols.", objfile->name);
          objfile->obfd = bfd_openr (obfd_filename, gnutarget);
          if (objfile->obfd == NULL)
            error ("Can't open %s to read symbols.", objfile->name);
@@ -1239,7 +1253,7 @@ deduce_language_from_filename (filename)
   else if (STREQ (c, ".c"))
     return language_c;
   else if (STREQ (c, ".cc") || STREQ (c, ".C") || STREQ (c, ".cxx")
   else if (STREQ (c, ".c"))
     return language_c;
   else if (STREQ (c, ".cc") || STREQ (c, ".C") || STREQ (c, ".cxx")
-          || STREQ (c, ".cpp") || STREQ (c, ".cp"))
+          || STREQ (c, ".cpp") || STREQ (c, ".cp") || STREQ (c, ".c++"))
     return language_cplus;
   else if (STREQ (c, ".ch") || STREQ (c, ".c186") || STREQ (c, ".c286"))
     return language_chill;
     return language_cplus;
   else if (STREQ (c, ".ch") || STREQ (c, ".c186") || STREQ (c, ".c286"))
     return language_chill;
@@ -1650,6 +1664,39 @@ add_psymbol_addr_to_list (name, namelength, namespace, class, list, val,
 
 #endif /* !INLINE_ADD_PSYMBOL */
 
 
 #endif /* !INLINE_ADD_PSYMBOL */
 
+/* Initialize storage for partial symbols.  */
+
+void
+init_psymbol_list (objfile, total_symbols)
+     struct objfile *objfile;
+     int total_symbols;
+{
+  /* Free any previously allocated psymbol lists.  */
+  
+  if (objfile -> global_psymbols.list)
+    {
+      mfree (objfile -> md, (PTR)objfile -> global_psymbols.list);
+    }
+  if (objfile -> static_psymbols.list)
+    {
+      mfree (objfile -> md, (PTR)objfile -> static_psymbols.list);
+    }
+  
+  /* Current best guess is that approximately a twentieth
+     of the total symbols (in a debugging file) are global or static
+     oriented symbols */
+  
+  objfile -> global_psymbols.size = total_symbols / 10;
+  objfile -> static_psymbols.size = total_symbols / 10;
+  objfile -> global_psymbols.next =
+    objfile -> global_psymbols.list = (struct partial_symbol *)
+      xmmalloc (objfile -> md, objfile -> global_psymbols.size
+                            * sizeof (struct partial_symbol));
+  objfile -> static_psymbols.next =
+    objfile -> static_psymbols.list = (struct partial_symbol *)
+      xmmalloc (objfile -> md, objfile -> static_psymbols.size
+                            * sizeof (struct partial_symbol));
+}
 \f
 void
 _initialize_symfile ()
 \f
 void
 _initialize_symfile ()
index 3e07508368b1ee6478de737658d187631f3b8be4..72fa4642765057720c1811b7d162561a166d4b21 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -43,8 +43,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #undef savestring
 
 #include <sys/types.h>
 #undef savestring
 
 #include <sys/types.h>
-#ifdef USG
-/* What is this for?  X_OK?  */
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
 #include <unistd.h>
 #endif
 
index ed764e5c0b2df7083c2c21841ce2af962557846a..fdf793820a53d66064d98f9b438e0426c9057c68 100644 (file)
@@ -30,6 +30,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #endif
 #include <ctype.h>
 #include <string.h>
 #endif
 #include <ctype.h>
 #include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #include "signals.h"
 #include "gdbcmd.h"
 
 #include "signals.h"
 #include "gdbcmd.h"
@@ -304,27 +307,31 @@ error_begin ()
 NORETURN void
 error (char *string, ...)
 #else
 NORETURN void
 error (char *string, ...)
 #else
+void
 error (va_alist)
      va_dcl
 #endif
 {
 error (va_alist)
      va_dcl
 #endif
 {
-#ifdef ANSI_PROTOTYPES
   va_list args;
   va_list args;
+#ifdef ANSI_PROTOTYPES
   va_start (args, string);
 #else
   va_start (args);
 #endif
   if (error_hook)
   va_start (args, string);
 #else
   va_start (args);
 #endif
   if (error_hook)
-    error_hook();
+    (*error_hook) ();
   else 
     {
   else 
     {
-      char *string1;
       error_begin ();
 #ifdef ANSI_PROTOTYPES
       vfprintf_filtered (gdb_stderr, string, args);
 #else
       error_begin ();
 #ifdef ANSI_PROTOTYPES
       vfprintf_filtered (gdb_stderr, string, args);
 #else
-      string1 = va_arg (args, char *);
-      vfprintf_filtered (gdb_stderr, string1, args);
+      {
+       char *string1;
+
+       string1 = va_arg (args, char *);
+       vfprintf_filtered (gdb_stderr, string1, args);
+      }
 #endif
       fprintf_filtered (gdb_stderr, "\n");
       va_end (args);
 #endif
       fprintf_filtered (gdb_stderr, "\n");
       va_end (args);