aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib.c
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>1999-08-31 01:14:27 +0000
committerJason Molenda <jmolenda@apple.com>1999-08-31 01:14:27 +0000
commit104c1213b4821a4b8664e66db4643a951b461576 (patch)
treed77adb32fcf044a485e1d4e0bb58e9da0ce39671 /gdb/solib.c
parentfd485a97b145f7b8abe7c5f5ec63edd8268a4182 (diff)
downloadgdb-104c1213b4821a4b8664e66db4643a951b461576.zip
gdb-104c1213b4821a4b8664e66db4643a951b461576.tar.gz
gdb-104c1213b4821a4b8664e66db4643a951b461576.tar.bz2
import gdb-1999-08-30 snapshot
Diffstat (limited to 'gdb/solib.c')
-rw-r--r--gdb/solib.c77
1 files changed, 76 insertions, 1 deletions
diff --git a/gdb/solib.c b/gdb/solib.c
index cfb230d..7f2f8ca 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -31,7 +31,6 @@
#include "gdb_string.h"
#include <sys/param.h>
#include <fcntl.h>
-#include <unistd.h>
#ifndef SVR4_SHARED_LIBS
/* SunOS shared libs need the nlist structure. */
@@ -888,6 +887,70 @@ first_link_map_member ()
return (lm);
}
+#ifdef SVR4_SHARED_LIBS
+/*
+
+ LOCAL FUNCTION
+
+ open_exec_file_object
+
+ SYNOPSIS
+
+ void open_symbol_file_object (int from_tty)
+
+ DESCRIPTION
+
+ If no open symbol file, attempt to locate and open the main symbol
+ file. On SVR4 systems, this is the first link map entry. If its
+ name is here, we can open it. Useful when attaching to a process
+ without first loading its symbol file.
+
+ */
+
+int
+open_symbol_file_object (arg)
+ PTR arg;
+{
+ int from_tty = (int) arg; /* sneak past catch_errors */
+ struct link_map *lm, lmcopy;
+ char *filename;
+ int errcode;
+
+ if (symfile_objfile)
+ if (!query ("Attempt to reload symbols from process? "))
+ return 0;
+
+ if ((debug_base = locate_base ()) == 0)
+ return 0; /* failed somehow... */
+
+ /* First link map member should be the executable. */
+ if ((lm = first_link_map_member ()) == NULL)
+ return 0; /* failed somehow... */
+
+ /* Read from target memory to GDB. */
+ read_memory ((CORE_ADDR) lm, (void *) &lmcopy, sizeof (lmcopy));
+
+ if (lmcopy.l_name == 0)
+ return 0; /* no filename. */
+
+ /* Now fetch the filename from target memory. */
+ target_read_string ((CORE_ADDR) lmcopy.l_name, &filename,
+ MAX_PATH_SIZE - 1, &errcode);
+ if (errcode)
+ {
+ warning ("failed to read exec filename from attached file: %s",
+ safe_strerror (errcode));
+ return 0;
+ }
+
+ make_cleanup ((make_cleanup_func) free, (void *) filename);
+ /* Have a pathname: read the symbol file. */
+ symbol_file_command (filename, from_tty);
+
+ return 1;
+}
+#endif /* SVR4_SHARED_LIBS */
+
/*
LOCAL FUNCTION
@@ -1099,6 +1162,18 @@ solib_add (arg_string, from_tty, target)
int count;
int old;
+#ifdef SVR4_SHARED_LIBS
+ /* If we are attaching to a running process for which we
+ have not opened a symbol file, we may be able to get its
+ symbols now! */
+ if (attach_flag &&
+ symfile_objfile == NULL)
+ catch_errors (open_symbol_file_object, (PTR) from_tty,
+ "Error reading attached process's symbol file.\n",
+ RETURN_MASK_ALL);
+
+#endif SVR4_SHARED_LIBS
+
if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
{
error ("Invalid regexp: %s", re_err);