* 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.
+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
#include "value.h"
#include <ctype.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
/* Prototypes for local functions */
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=
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
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; }
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; }
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; }
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; }
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; }
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; }
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
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
AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM
+AC_CHECK_HEADERS(unistd.h)
dnl Handle optional features that can be enabled.
ENABLE_CFLAGS=
#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
#include "thread.h"
#include <signal.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
extern char **environ;
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 "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
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;
+#endif
adr -= 4;
}
}
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;
- struct frame_info *fi;
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;
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
CORE_ADDR
i386v4_sigtramp_saved_pc (frame)
- FRAME frame;
+ struct frame_info *frame;
{
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"))
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;
+}
#ifdef FLOAT_INFO
+#include "language.h" /* for local_hex_string */
#include "floatformat.h"
#include <sys/param.h>
unsigned char regs[8][10];
};
-static
+static void
print_387_status (status, ep)
unsigned short status;
struct env387 *ep;
int bothstatus;
int top;
int fpreg;
- unsigned char *p;
bothstatus = ((status != 0) && (ep->status != 0));
if (status != 0)
/* 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.
#include "target.h"
#include "thread.h"
+#include <string.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
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
{ close (2); dup (tty); }
if (tty > 2)
close(tty);
-#endif /* !go32 */
+#endif /* !go32 && !win32*/
}
\f
/* Kill the inferior process. Make us have no inferior. */
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.");
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()
{
- signal (SIGINT, osig);
+ if (attach_flag || inferior_thisrun_terminal)
+ {
+ signal (SIGINT, osig);
+ }
}
\f
#if defined (SIGIO) && defined (FASYNC) && defined (FD_SET) && defined (F_SETOWN)
/* 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.
#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
long time_at_startup = get_run_time ();
-/* start-sanitize-mpw */
+ START_PROGRESS (argv[0], 0);
+
#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 */
-/* end-sanitize-mpw */
+
/* This needs to happen before the first use of malloc. */
init_malloc ((PTR) NULL);
current_directory = gdb_dirbuf;
/* Parse arguments and options. */
+#ifndef WIN32
{
int c;
/* When var field is 0, use flag field to record the equivalent
break;
case 'f':
annotation_level = 1;
+/* We have probably been invoked from emacs. Disable window interface. */
+ use_windows = 0;
break;
case 's':
symarg = optarg;
quiet = 1;
}
+#endif
gdb_init ();
/* Do these (and anything which might call wrap_here or *_filtered)
/* 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\
--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\
+", 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\
+", 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);
-/* start-sanitize-mpw */
-#endif /* MPW_C */
-/* end-sanitize-mpw */
#ifdef ADDITIONAL_OPTION_HELP
fputs_unfiltered (ADDITIONAL_OPTION_HELP, gdb_stdout);
#endif
}
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: ";
if (!quiet)
printf_filtered ("\n");
error_pre_print = "\n";
+ quit_pre_print = error_pre_print;
warning_pre_print = "\nwarning: ";
if (corearg != NULL)
#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
BEFORE_MAIN_LOOP_HOOK;
#endif
+ END_PROGRESS (argv[0]);
+
/* Show time and/or space usage. */
if (display_time)
(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 ())
quit_command ((char *)0, instream == stdin);
}
}
+
/* No exit -- exit is through quit_command. */
+#endif
+
}
\f
void
#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));
#include <sys/stat.h>
#include <fcntl.h>
#include <obstack.h>
+#include <string.h>
/* Prototypes for local functions */
/* 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.
#include <sys/types.h>
#include <signal.h>
#include <string.h>
-#include <link.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
-#include "libelf.h"
-#ifndef DT_MIPS_RLD_MAP
-#include "elf/mips.h"
-#endif
+#include "elf/external.h"
#endif
+#include <link.h>
+
#include "symtab.h"
#include "bfd.h"
#include "symfile.h"
#include "regex.h"
#include "inferior.h"
#include "language.h"
+#include "gdbcmd.h"
#define MAX_PATH_SIZE 256 /* FIXME: Should be dynamic */
#ifndef SVR4_SHARED_LIBS
static char *debug_base_symbols[] = {
"_DYNAMIC",
+ "_DYNAMIC__MGC",
NULL
};
#endif
+static char *main_name_list[] = {
+ "main_$main",
+ NULL
+};
+
/* 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)
#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
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
-/* 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
-solib_add_common_symbols (rtc_symp, objfile)
+solib_add_common_symbols (rtc_symp)
struct rtc_symb *rtc_symp;
- struct objfile *objfile;
{
struct rtc_symb inferior_rtc_symb;
struct nlist inferior_rtc_nlist;
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);
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
- 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 */
}
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);
}
}
if (address == 0)
{
+ /* FIXME-leak: on failure, might not free all memory associated with
+ interp_bfd. */
bfd_close (interp_bfd);
return (0);
}
address += baseaddr;
}
debug_base = address;
+ /* FIXME-leak: on failure, might not free all memory associated with
+ interp_bfd. */
bfd_close (interp_bfd);
return (1);
}
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. */
- 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;
- dyninfo_addr = dyninfo_sect->sh_addr;
+ dyninfo_addr = bfd_section_vma (exec_bfd, dyninfo_sect);
/* 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;
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];
return 0;
return extract_unsigned_integer (pbuf, sizeof (pbuf));
}
+#endif
}
/* DT_DEBUG entry not found. */
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);
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
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;
}
/* 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)
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_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. */
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);
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);
}
/*
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.
*/
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 */
"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);
}
#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 "annotate.h"
#include "gdbtypes.h"
-#ifndef DIRNAME_SEPARATOR
-#define DIRNAME_SEPARATOR ':'
-#endif
-
/* Prototypes for local functions. */
static int open_source_file PARAMS ((struct symtab *));
/* 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 ();
}
}
- if (p[-1] == '/')
+ if (SLASH_P (p[-1]))
/* Sigh. "foo/" => "foo" */
--p;
*p = '\0';
name = current_directory;
goto append;
}
- else if (p[-2] == '/')
+ else if (SLASH_P (p[-2]))
{
if (p - name == 2)
{
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);
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);
}
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);
- 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 */
- while (string[0] == '.' && string[1] == '/')
+ while (string[0] == '.' && SLASH_P (string[1]))
string += 2;
alloclen = strlen (path) + strlen (string) + 2;
}
/* Remove trailing slashes */
- while (len > 0 && filename[len-1] == '/')
+ while (len > 0 && SLASH_P (filename[len-1]))
filename[--len] = 0;
- strcat (filename+len, "/");
+ strcat (filename+len, SLASH_STRING);
strcat (filename, string);
fd = open (filename, mode);
{
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,
- '/' == current_directory[strlen(current_directory)-1]? "": "/",
+ SLASH_CHAR
+ == current_directory[strlen(current_directory)-1]
+ ? "": SLASH_STRING,
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. */
printf("\n");
}
}
-#endif
-/* end-sanitize-mpw */
+#endif /* MPW */
return fd;
}
if (p != s->filename)
result = openp (path, 0, p, O_RDONLY, 0, &s->fullname);
}
-/* start-sanitize-mpw */
#ifdef MPW
if (result < 0)
{
result = openp (path, 0, p, O_RDONLY, 0, &s->fullname);
}
#endif /* MPW */
-/* end-sanitize-mpw */
+
if (result >= 0)
{
fullname = s->fullname;
/* 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.
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 "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 */
/* 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, ...
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 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.
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;
- args.fi = get_frame_info (frame);
+ args.fi = fi;
args.level = level;
args.source = source;
args.args = 1;
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;
+
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;
struct symbol *func;
register char *funname = 0;
enum language funlang = language_unknown;
+
+#if 0
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. */
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);
+ annotate_function_call ();
printf_filtered ("<function called from gdb>\n");
+ annotate_frame_end ();
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);
+ annotate_signal_handler_caller ();
printf_filtered ("<signal handler called>\n");
+ annotate_frame_end ();
return;
}
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)
{
+ annotate_frame_address ();
print_address_numeric (fi->pc, 1, gdb_stdout);
+ annotate_frame_address_end ();
printf_filtered (" in ");
}
+ annotate_frame_function_name ();
fprintf_symbol_filtered (gdb_stdout, funname ? funname : "??", funlang,
DMGL_ANSI);
wrap_here (" ");
+ annotate_frame_args ();
fputs_filtered (" (", gdb_stdout);
if (args)
{
printf_filtered (")");
if (sal.symtab && sal.symtab->filename)
{
+ annotate_frame_source_begin ();
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. */
- 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");
}
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);
+ annotate_frame_end ();
+
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;
{
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 */
(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)) &&
- (FRAME_FP (tfid) == args[0]))
+ (tfid->frame == args[0]))
fid = tfid;
/* We couldn't identify the frame as an existing frame, but
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;
- 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.");
- frame = parse_frame_specification (addr_exp);
- if (!frame)
+ fi = parse_frame_specification (addr_exp);
+ if (fi == NULL)
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));
- func = get_frame_function (frame);
+ func = get_frame_function (fi);
s = find_pc_symtab(fi->pc);
if (func)
{
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);
- 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 ");
- print_address_numeric (FRAME_FP(frame), 1, gdb_stdout);
+ print_address_numeric (fi->frame, 1, gdb_stdout);
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 (" ");
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 (" (FRAMELESS),");
}
- if (calling_frame)
+ if (calling_frame_info)
{
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)
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));
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 (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. */
}
{
struct frame_info *fi;
register int count;
- register FRAME frame;
register int i;
- register FRAME trailing;
+ register struct frame_info *trailing;
register int trailing_level;
if (!target_has_stack)
count = parse_and_eval_address (count_exp);
if (count < 0)
{
- FRAME current;
+ struct frame_info *current;
count = -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;
- fi = get_frame_info (frame);
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;
- 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
}
/* 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
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;
- register FRAME frame;
+ register struct frame_info *fi;
register GDB_FILE *stream;
{
int nsyms;
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;
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 struct block *block = get_frame_block (frame);
+ register struct block *block = get_frame_block (fi);
register int values_printed = 0;
if (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
/* 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;
- 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;
- struct frame_info *fi = get_frame_info (frame);
CORE_ADDR pc = fi->pc;
if (block == 0)
}
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;
{
- struct symbol *func = get_frame_function (frame);
+ struct symbol *func = get_frame_function (fi);
register struct block *b;
int nsyms;
register int i;
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;
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
-select_frame (frame, level)
- FRAME frame;
+select_frame (fi, level)
+ struct frame_info *fi;
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. */
- 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
void
record_selected_frame (frameaddrp, levelp)
- FRAME_ADDR *frameaddrp;
+ CORE_ADDR *frameaddrp;
int *levelp;
{
- *frameaddrp = selected_frame ? FRAME_FP (selected_frame) : 0;
+ *frameaddrp = selected_frame ? selected_frame->frame : 0;
*levelp = selected_frame_level;
}
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)
- register FRAME frame;
- register int* level_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. */
char *level_exp;
int from_tty;
{
- register FRAME frame, frame1;
+ register struct frame_info *frame, *frame1;
unsigned int level = 0;
if (!target_has_stack)
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);
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.");
- select_frame (frame, selected_frame_level + count - count1);
+ select_frame (fi, selected_frame_level + count - count1);
}
static void
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 from_tty;
{
struct symbol *thisfun;
- FRAME_ADDR selected_frame_addr;
+ CORE_ADDR selected_frame_addr;
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);
- 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)
{
+ struct type *return_type = NULL;
+
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))
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. */
frame_command ("0", 1);
}
-/* Gets the language of the current frame. */
+/* Gets the language of the current frame. */
+
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
- flang = language_unknown;
- }
- else
- flang = language_unknown;
+ flang = language_unknown;
+ }
+ else
+ flang = language_unknown;
- return flang;
+ return flang;
}
\f
void
#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
}
/* 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;
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 */
+ 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.
/* 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)
{
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);
- 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,
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,
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))
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);
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;
#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 ()
#undef savestring
#include <sys/types.h>
-#ifdef USG
-/* What is this for? X_OK? */
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
#include <ctype.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include "signals.h"
#include "gdbcmd.h"
NORETURN void
error (char *string, ...)
#else
+void
error (va_alist)
va_dcl
#endif
{
-#ifdef ANSI_PROTOTYPES
va_list args;
+#ifdef ANSI_PROTOTYPES
va_start (args, string);
#else
va_start (args);
#endif
if (error_hook)
- error_hook();
+ (*error_hook) ();
else
{
- char *string1;
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);