/* Work with core dump and executable files, for GDB.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <signal.h>
#include <fcntl.h>
#include "defs.h"
-#include "param.h"
#include "frame.h" /* required by inferior.h */
#include "inferior.h"
#include "symtab.h"
filename = tilde_expand (filename);
if (filename[0] != '/') {
- temp = concat (current_directory, "/", filename);
+ temp = concat (current_directory, "/", filename, NULL);
free (filename);
filename = temp;
}
if (!bfd_check_format (temp_bfd, bfd_core))
{
- bfd_close (temp_bfd);
- error ("\"%s\" does not appear to be a core dump", filename);
+ make_cleanup (bfd_close, temp_bfd); /* Do it after the err msg */
+ error ("\"%s\" is not a core dump: %s", filename, bfd_errmsg(bfd_error));
}
/* Looks semi-reasonable. Toss the old core file and work on the new. */
p = bfd_core_file_failing_command (core_bfd);
if (p)
- printf ("Core file invoked as `%s'.\n", p);
+ printf ("Core was generated by `%s'.\n", p);
siggy = bfd_core_file_failing_signal (core_bfd);
if (siggy > 0)
{
struct section_table *p;
- printf ("\tCore file `%s'.\n", bfd_get_filename(core_bfd));
+ printf_filtered ("\t`%s', ", bfd_get_filename(core_bfd));
+ wrap_here (" ");
+ printf_filtered ("file type %s.\n", bfd_get_target(core_bfd));
for (p = t->sections; p < t->sections_end; p++) {
- printf(p->bfd == core_bfd? "\tcore file ": "\tshared lib ");
- printf("from %s", local_hex_string_custom (p->addr, "08"));
- printf(" to %s", local_hex_string_custom (p->endaddr, "08"));
+ printf_filtered ("\t%s", local_hex_string_custom (p->addr, "08"));
+ printf_filtered (" - %s is %s",
+ local_hex_string_custom (p->endaddr, "08"),
+ bfd_section_name (p->bfd, p->sec_ptr));
if (p->bfd != core_bfd) {
- printf(" is %s in %s",
- bfd_section_name (p->bfd, p->sec_ptr),
- bfd_get_filename (p->bfd));
+ printf_filtered (" in %s", bfd_get_filename (p->bfd));
}
- printf ("\n");
+ printf_filtered ("\n");
}
}
\f
char *the_regs;
reg_sec = bfd_get_section_by_name (core_bfd, ".reg");
+ if (!reg_sec) goto cant;
size = bfd_section_size (core_bfd, reg_sec);
the_regs = alloca (size);
- if (bfd_get_section_contents (core_bfd, reg_sec, the_regs,
- (unsigned)0, size))
+ if (bfd_get_section_contents (core_bfd, reg_sec, the_regs, (file_ptr)0, size))
{
- fetch_core_registers (the_regs, size, 0);
+ fetch_core_registers (the_regs, size, 0,
+ (unsigned) bfd_section_vma (abfd,reg_sec));
}
else
{
+cant:
fprintf (stderr, "Couldn't fetch registers from core file: %s\n",
bfd_errmsg (bfd_error));
}
if (reg_sec) {
size = bfd_section_size (core_bfd, reg_sec);
the_regs = alloca (size);
- if (bfd_get_section_contents (core_bfd, reg_sec, the_regs,
- (unsigned)0, size))
+ if (bfd_get_section_contents (core_bfd, reg_sec, the_regs, (file_ptr)0,
+ size))
{
- fetch_core_registers (the_regs, size, 2);
+ fetch_core_registers (the_regs, size, 2,
+ (unsigned) bfd_section_vma (abfd,reg_sec));
}
else
{