diff options
Diffstat (limited to 'gdb/fbsd-proc.c')
-rw-r--r-- | gdb/fbsd-proc.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/gdb/fbsd-proc.c b/gdb/fbsd-proc.c index 16813a9a1c8..f021d275b9a 100644 --- a/gdb/fbsd-proc.c +++ b/gdb/fbsd-proc.c @@ -22,22 +22,23 @@ #include "defs.h" #include "gdbcore.h" #include "inferior.h" -#include "gdb_string.h" +#include "regcache.h" +#include "regset.h" +#include "gdb_assert.h" +#include "gdb_string.h" #include <sys/procfs.h> #include <sys/types.h> #include "elf-bfd.h" -#include "gregset.h" - char * child_pid_to_exec_file (int pid) { char *path; char *buf; - xasprintf (&path, "/proc/%d/file", pid); + path = xstrprintf ("/proc/%d/file", pid); buf = xcalloc (MAXPATHLEN, sizeof (char)); make_cleanup (xfree, path); make_cleanup (xfree, buf); @@ -81,7 +82,7 @@ fbsd_find_memory_regions (int (*func) (CORE_ADDR, unsigned long, char protection[4]; int read, write, exec; - xasprintf (&mapfilename, "/proc/%ld/map", (long) pid); + mapfilename = xstrprintf ("/proc/%ld/map", (long) pid); mapfile = fopen (mapfilename, "r"); if (mapfile == NULL) error ("Couldn't open %s\n", mapfilename); @@ -120,21 +121,35 @@ fbsd_find_memory_regions (int (*func) (CORE_ADDR, unsigned long, static char * fbsd_make_corefile_notes (bfd *obfd, int *note_size) { + struct gdbarch *gdbarch = current_gdbarch; + const struct regcache *regcache = current_regcache; gregset_t gregs; fpregset_t fpregs; char *note_data = NULL; Elf_Internal_Ehdr *i_ehdrp; + const struct regset *regset; + size_t size; /* Put a "FreeBSD" label in the ELF header. */ i_ehdrp = elf_elfheader (obfd); i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; - fill_gregset (&gregs, -1); + gdb_assert (gdbarch_regset_from_core_section_p (gdbarch)); + + size = sizeof gregs; + regset = gdbarch_regset_from_core_section (gdbarch, ".reg", size); + gdb_assert (regset && regset->collect_regset); + regset->collect_regset (regset, regcache, -1, &gregs, size); + note_data = elfcore_write_prstatus (obfd, note_data, note_size, ptid_get_pid (inferior_ptid), stop_signal, &gregs); - fill_fpregset (&fpregs, -1); + size = sizeof fpregs; + regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", size); + gdb_assert (regset && regset->collect_regset); + regset->collect_regset (regset, regcache, -1, &fpregs, size); + note_data = elfcore_write_prfpreg (obfd, note_data, note_size, &fpregs, sizeof (fpregs)); |