aboutsummaryrefslogtreecommitdiff
path: root/gdb/core.c
diff options
context:
space:
mode:
authorJohn Gilmore <gnu@cygnus>1991-09-04 07:43:50 +0000
committerJohn Gilmore <gnu@cygnus>1991-09-04 07:43:50 +0000
commitbdbd5f508635fa9581f85bd6ba7ec3620970674d (patch)
tree15b699530b87aa2ae144216c734ecd2bcb9c474a /gdb/core.c
parent7c589d2562b1b91366f01b95daa7b47a81ccb19d (diff)
downloadgdb-bdbd5f508635fa9581f85bd6ba7ec3620970674d.zip
gdb-bdbd5f508635fa9581f85bd6ba7ec3620970674d.tar.gz
gdb-bdbd5f508635fa9581f85bd6ba7ec3620970674d.tar.bz2
Make writing to files work properly. (Fixes to BFD are also needed.)
* core.c (core_open): Open file ourselves, read or r/w, depending on write_files. Use bfd_fdopenr. * gdbcore.h (write_files): New variable. * exec.c (write_files): Define variable, add set&show for it. (exec_file_command): Use write_files to open for read or r/write. Make shared library reading happen automatically. These changes are mostly from Peter Schauer <pes@regent.e-technik.tu-muenchen.de>. * inferior.h (stop_soon_quietly): Add to exported variables. * infrun.c (child_create_inferior): call solib hook, if defined. (child_attach): call solib hook, if defined. * solib.c: Include inferior.h. Add from_tty to so_list as kludge. (find_solib): Use lookup_misc_func rather than hand-rolled. (symbol_add_stub): New stub for catch_errors. (solib_add): Avoid output if !from_tty. Catch errors rather than just calling symbol_file_add and bombing. (solib_create_inferior_hook): Interface with the target process to let it read and alloc shared libs, then figure out what it did. * core.c (validate_files): Fix typo, soften warning. (Fix from Hiroto Kagotani <kagotani@cs.titech.ac.jp>.) * utils.c (fputs_demangled): Avoid duplicate printing if demangling is off. (Fix from J.T. Conklin <jtc@cayenne.com>.) * infrun.c (proceed): Cast -1 to (CORE_ADDR) before comparing. (Fix from pierre@la.tce.com (Pierre Willard).) * main.c (catch_errors): Change argument to a char * from an int, since a char * can point to a struct full of glop, but an int is not guaranteed to be able to hold a pointer. * breakpoint.c (breakpoint_cond_eval, bpstat_stop_status, breakpoint_re_set_one, breakpoint_re_set): Adapt. * core.c (core_open, solib_add_stub): Adapt. * remote-vx.c (symbol_stub, add_symbol_stub, callers): Adapt.
Diffstat (limited to 'gdb/core.c')
-rw-r--r--gdb/core.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/gdb/core.c b/gdb/core.c
index 89a417d..deaae4b 100644
--- a/gdb/core.c
+++ b/gdb/core.c
@@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <errno.h>
#include <signal.h>
+#include <fcntl.h>
#include "defs.h"
#include "param.h"
#include "frame.h" /* required by inferior.h */
@@ -79,9 +80,9 @@ core_close (quitting)
int
solib_add_stub (from_tty)
- int from_tty;
+ char *from_tty;
{
- SOLIB_ADD (NULL, from_tty, &core_ops);
+ SOLIB_ADD (NULL, (int)from_tty, &core_ops);
return 0;
}
#endif /* SOLIB_ADD */
@@ -99,6 +100,7 @@ core_open (filename, from_tty)
char *temp;
bfd *temp_bfd;
int ontop;
+ int scratch_chan;
target_preopen (from_tty);
if (!filename)
@@ -116,7 +118,12 @@ core_open (filename, from_tty)
}
old_chain = make_cleanup (free, filename);
- temp_bfd = bfd_openr (filename, NULL);
+
+ scratch_chan = open (filename, write_files? O_RDWR: O_RDONLY, 0);
+ if (scratch_chan < 0)
+ perror_with_name (filename);
+
+ temp_bfd = bfd_fdopenr (filename, NULL, scratch_chan);
if (temp_bfd == NULL)
{
perror_with_name (filename);
@@ -161,7 +168,7 @@ core_open (filename, from_tty)
/* Add symbols and section mappings for any shared libraries */
#ifdef SOLIB_ADD
- (void) catch_errors (solib_add_stub, from_tty, (char *)0);
+ (void) catch_errors (solib_add_stub, (char *)from_tty, (char *)0);
#endif
/* Now, set up the frame cache, and print the top of stack */
set_current_frame ( create_new_frame (read_register (FP_REGNUM),
@@ -242,8 +249,8 @@ validate_files ()
{
if (exec_bfd && core_bfd)
{
- if (core_file_matches_executable_p (core_bfd, exec_bfd))
- printf ("Warning: core file does not match specified executable file.\n");
+ if (!core_file_matches_executable_p (core_bfd, exec_bfd))
+ printf ("Warning: core file may not match specified executable file.\n");
else if (bfd_get_mtime(exec_bfd) > bfd_get_mtime(core_bfd))
printf ("Warning: exec file is newer than core file.\n");
}