diff options
author | Jason Molenda <jsm@bugshack.cygnus.com> | 1999-08-31 01:14:27 +0000 |
---|---|---|
committer | Jason Molenda <jsm@bugshack.cygnus.com> | 1999-08-31 01:14:27 +0000 |
commit | e833b7618213d242416d64171381f774f4353572 (patch) | |
tree | cc31f4b800ea8d4816388b9386b36b993c2f016d /gdb/solib.c | |
parent | 8ced9d34ff56ac4435c9176617e738a9a715cbd5 (diff) | |
download | gdb-e833b7618213d242416d64171381f774f4353572.tar.gz |
import gdb-1999-08-30 snapshot
Diffstat (limited to 'gdb/solib.c')
-rw-r--r-- | gdb/solib.c | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/gdb/solib.c b/gdb/solib.c index cfb230d6fb1..7f2f8ca53b1 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); |