diff options
Diffstat (limited to 'gdb/fbsd-tdep.c')
-rw-r--r-- | gdb/fbsd-tdep.c | 160 |
1 files changed, 82 insertions, 78 deletions
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index d8fae07..e3ebcb8 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -563,16 +563,16 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr) extract the null-terminated name from the start of the note. */ thread_section_name section_name (".thrmisc", thr->ptid); + bfd *cbfd = current_program_space->core_bfd (); - section = bfd_get_section_by_name (core_bfd, section_name.c_str ()); + section = bfd_get_section_by_name (cbfd, section_name.c_str ()); if (section != NULL && bfd_section_size (section) > 0) { /* Truncate the name if it is longer than "buf". */ size = bfd_section_size (section); if (size > sizeof buf - 1) size = sizeof buf - 1; - if (bfd_get_section_contents (core_bfd, section, buf, (file_ptr) 0, - size) + if (bfd_get_section_contents (cbfd, section, buf, (file_ptr) 0, size) && buf[0] != '\0') { buf[size] = '\0'; @@ -581,7 +581,7 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr) as its thread name instead of an empty name if a name has not been set explicitly. Return a NULL name in that case. */ - if (strcmp (buf, elf_tdata (core_bfd)->core->program) != 0) + if (strcmp (buf, elf_tdata (cbfd)->core->program) != 0) return buf; } } @@ -606,12 +606,13 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, return -1; thread_section_name section_name (".note.freebsdcore.lwpinfo", inferior_ptid); - asection *section = bfd_get_section_by_name (core_bfd, section_name.c_str ()); + bfd *cbfd = current_program_space->core_bfd (); + asection *section = bfd_get_section_by_name (cbfd, section_name.c_str ()); if (section == NULL) return -1; gdb_byte buf[4]; - if (!bfd_get_section_contents (core_bfd, section, buf, + if (!bfd_get_section_contents (cbfd, section, buf, LWPINFO_OFFSET + LWPINFO_PL_FLAGS, 4)) return -1; @@ -628,7 +629,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, else siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO; - if (!bfd_get_section_contents (core_bfd, section, readbuf, + if (!bfd_get_section_contents (cbfd, section, readbuf, siginfo_offset + offset, len)) return -1; @@ -1021,8 +1022,8 @@ fbsd_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags, static void fbsd_core_info_proc_files (struct gdbarch *gdbarch) { - asection *section - = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.files"); + bfd *cbfd = current_program_space->core_bfd (); + asection *section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.files"); if (section == NULL) { warning (_("unable to find open files in core file")); @@ -1034,7 +1035,7 @@ fbsd_core_info_proc_files (struct gdbarch *gdbarch) error (_("malformed core note - too short for header")); gdb::def_vector<unsigned char> contents (note_size); - if (!bfd_get_section_contents (core_bfd, section, contents.data (), + if (!bfd_get_section_contents (cbfd, section, contents.data (), 0, note_size)) error (_("could not get core note contents")); @@ -1048,20 +1049,18 @@ fbsd_core_info_proc_files (struct gdbarch *gdbarch) while (descdata + KF_PATH < descend) { - ULONGEST structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE); + ULONGEST structsize = bfd_get_32 (cbfd, descdata + KF_STRUCTSIZE); if (structsize < KF_PATH) error (_("malformed core note - file structure too small")); - LONGEST type = bfd_get_signed_32 (core_bfd, descdata + KF_TYPE); - LONGEST fd = bfd_get_signed_32 (core_bfd, descdata + KF_FD); - LONGEST flags = bfd_get_signed_32 (core_bfd, descdata + KF_FLAGS); - LONGEST offset = bfd_get_signed_64 (core_bfd, descdata + KF_OFFSET); - LONGEST vnode_type = bfd_get_signed_32 (core_bfd, - descdata + KF_VNODE_TYPE); - LONGEST sock_domain = bfd_get_signed_32 (core_bfd, - descdata + KF_SOCK_DOMAIN); - LONGEST sock_type = bfd_get_signed_32 (core_bfd, descdata + KF_SOCK_TYPE); - LONGEST sock_protocol = bfd_get_signed_32 (core_bfd, + LONGEST type = bfd_get_signed_32 (cbfd, descdata + KF_TYPE); + LONGEST fd = bfd_get_signed_32 (cbfd, descdata + KF_FD); + LONGEST flags = bfd_get_signed_32 (cbfd, descdata + KF_FLAGS); + LONGEST offset = bfd_get_signed_64 (cbfd, descdata + KF_OFFSET); + LONGEST vnode_type = bfd_get_signed_32 (cbfd, descdata + KF_VNODE_TYPE); + LONGEST sock_domain = bfd_get_signed_32 (cbfd, descdata + KF_SOCK_DOMAIN); + LONGEST sock_type = bfd_get_signed_32 (cbfd, descdata + KF_SOCK_TYPE); + LONGEST sock_protocol = bfd_get_signed_32 (cbfd, descdata + KF_SOCK_PROTOCOL); fbsd_info_proc_files_entry (type, fd, flags, offset, vnode_type, sock_domain, sock_type, sock_protocol, @@ -1154,8 +1153,9 @@ fbsd_core_info_proc_mappings (struct gdbarch *gdbarch) asection *section; unsigned char *descdata, *descend; size_t note_size; + bfd *cbfd = current_program_space->core_bfd (); - section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.vmmap"); + section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.vmmap"); if (section == NULL) { warning (_("unable to find mappings in core file")); @@ -1167,8 +1167,7 @@ fbsd_core_info_proc_mappings (struct gdbarch *gdbarch) error (_("malformed core note - too short for header")); gdb::def_vector<unsigned char> contents (note_size); - if (!bfd_get_section_contents (core_bfd, section, contents.data (), - 0, note_size)) + if (!bfd_get_section_contents (cbfd, section, contents.data (), 0, note_size)) error (_("could not get core note contents")); descdata = contents.data (); @@ -1180,15 +1179,15 @@ fbsd_core_info_proc_mappings (struct gdbarch *gdbarch) fbsd_info_proc_mappings_header (gdbarch_addr_bit (gdbarch)); while (descdata + KVE_PATH < descend) { - ULONGEST structsize = bfd_get_32 (core_bfd, descdata + KVE_STRUCTSIZE); + ULONGEST structsize = bfd_get_32 (cbfd, descdata + KVE_STRUCTSIZE); if (structsize < KVE_PATH) error (_("malformed core note - vmmap entry too small")); - ULONGEST start = bfd_get_64 (core_bfd, descdata + KVE_START); - ULONGEST end = bfd_get_64 (core_bfd, descdata + KVE_END); - ULONGEST offset = bfd_get_64 (core_bfd, descdata + KVE_OFFSET); - LONGEST flags = bfd_get_signed_32 (core_bfd, descdata + KVE_FLAGS); - LONGEST prot = bfd_get_signed_32 (core_bfd, descdata + KVE_PROTECTION); + ULONGEST start = bfd_get_64 (cbfd, descdata + KVE_START); + ULONGEST end = bfd_get_64 (cbfd, descdata + KVE_END); + ULONGEST offset = bfd_get_64 (cbfd, descdata + KVE_OFFSET); + LONGEST flags = bfd_get_signed_32 (cbfd, descdata + KVE_FLAGS); + LONGEST prot = bfd_get_signed_32 (cbfd, descdata + KVE_PROTECTION); fbsd_info_proc_mappings_entry (gdbarch_addr_bit (gdbarch), start, end, offset, flags, prot, descdata + KVE_PATH); @@ -1205,8 +1204,9 @@ fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd) asection *section; unsigned char *descdata, *descend; size_t note_size; + bfd *cbfd = current_program_space->core_bfd (); - section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.files"); + section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.files"); if (section == NULL) return nullptr; @@ -1215,8 +1215,7 @@ fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd) error (_("malformed core note - too short for header")); gdb::def_vector<unsigned char> contents (note_size); - if (!bfd_get_section_contents (core_bfd, section, contents.data (), - 0, note_size)) + if (!bfd_get_section_contents (cbfd, section, contents.data (), 0, note_size)) error (_("could not get core note contents")); descdata = contents.data (); @@ -1229,12 +1228,12 @@ fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd) { ULONGEST structsize; - structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE); + structsize = bfd_get_32 (cbfd, descdata + KF_STRUCTSIZE); if (structsize < KF_PATH) error (_("malformed core note - file structure too small")); - if (bfd_get_32 (core_bfd, descdata + KF_TYPE) == KINFO_FILE_TYPE_VNODE - && bfd_get_signed_32 (core_bfd, descdata + KF_FD) == fd) + if (bfd_get_32 (cbfd, descdata + KF_TYPE) == KINFO_FILE_TYPE_VNODE + && bfd_get_signed_32 (cbfd, descdata + KF_FD) == fd) { char *path = (char *) descdata + KF_PATH; return make_unique_xstrdup (path); @@ -1251,20 +1250,22 @@ static void fbsd_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data, LONGEST &sec, ULONGEST &usec) { + bfd *cbfd = current_program_space->core_bfd (); + if (gdbarch_addr_bit (gdbarch) == 64) { - sec = bfd_get_signed_64 (core_bfd, data); - usec = bfd_get_64 (core_bfd, data + 8); + sec = bfd_get_signed_64 (cbfd, data); + usec = bfd_get_64 (cbfd, data + 8); } - else if (bfd_get_arch (core_bfd) == bfd_arch_i386) + else if (bfd_get_arch (cbfd) == bfd_arch_i386) { - sec = bfd_get_signed_32 (core_bfd, data); - usec = bfd_get_32 (core_bfd, data + 4); + sec = bfd_get_signed_32 (cbfd, data); + usec = bfd_get_32 (cbfd, data + 4); } else { - sec = bfd_get_signed_64 (core_bfd, data); - usec = bfd_get_32 (core_bfd, data + 8); + sec = bfd_get_signed_64 (cbfd, data); + usec = bfd_get_32 (cbfd, data + 8); } } @@ -1273,10 +1274,11 @@ fbsd_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data, static void fbsd_print_sigset (const char *descr, unsigned char *sigset) { + bfd *cbfd = current_program_space->core_bfd (); gdb_printf ("%s: ", descr); for (int i = 0; i < SIG_WORDS; i++) gdb_printf ("%08x ", - (unsigned int) bfd_get_32 (core_bfd, sigset + i * 4)); + (unsigned int) bfd_get_32 (cbfd, sigset + i * 4)); gdb_printf ("\n"); } @@ -1292,8 +1294,9 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch) size_t note_size; ULONGEST value; LONGEST sec; + bfd *cbfd = current_program_space->core_bfd (); - section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.proc"); + section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.proc"); if (section == NULL) { warning (_("unable to find process info in core file")); @@ -1303,7 +1306,7 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch) addr_bit = gdbarch_addr_bit (gdbarch); if (addr_bit == 64) kp = &kinfo_proc_layout_64; - else if (bfd_get_arch (core_bfd) == bfd_arch_i386) + else if (bfd_get_arch (cbfd) == bfd_arch_i386) kp = &kinfo_proc_layout_i386; else kp = &kinfo_proc_layout_32; @@ -1321,8 +1324,7 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch) error (_("malformed core note - too short")); gdb::def_vector<unsigned char> contents (note_size); - if (!bfd_get_section_contents (core_bfd, section, contents.data (), - 0, note_size)) + if (!bfd_get_section_contents (cbfd, section, contents.data (), 0, note_size)) error (_("could not get core note contents")); descdata = contents.data (); @@ -1331,7 +1333,7 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch) descdata += 4; /* Verify 'ki_layout' is 0. */ - if (bfd_get_32 (core_bfd, descdata + kp->ki_layout) != 0) + if (bfd_get_32 (cbfd, descdata + kp->ki_layout) != 0) { warning (_("unsupported process information in core file")); return; @@ -1339,13 +1341,13 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch) gdb_printf ("Name: %.19s\n", descdata + kp->ki_comm); gdb_printf ("Process ID: %s\n", - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pid))); + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_pid))); gdb_printf ("Parent process: %s\n", - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ppid))); + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_ppid))); gdb_printf ("Process group: %s\n", - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pgid))); + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_pgid))); gdb_printf ("Session id: %s\n", - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_sid))); + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_sid))); /* FreeBSD 12.0 and later store a 64-bit dev_t at 'ki_tdev'. Older kernels store a 32-bit dev_t at 'ki_tdev_freebsd11'. In older @@ -1353,38 +1355,38 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch) the structure that is cleared to zero. Assume that a zero value in ki_tdev indicates a core dump from an older kernel and use the value in 'ki_tdev_freebsd11' instead. */ - value = bfd_get_64 (core_bfd, descdata + kp->ki_tdev); + value = bfd_get_64 (cbfd, descdata + kp->ki_tdev); if (value == 0) - value = bfd_get_32 (core_bfd, descdata + kp->ki_tdev_freebsd11); + value = bfd_get_32 (cbfd, descdata + kp->ki_tdev_freebsd11); gdb_printf ("TTY: %s\n", pulongest (value)); gdb_printf ("TTY owner process group: %s\n", - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_tpgid))); + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_tpgid))); gdb_printf ("User IDs (real, effective, saved): %s %s %s\n", - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ruid)), - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_uid)), - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svuid))); + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_ruid)), + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_uid)), + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_svuid))); gdb_printf ("Group IDs (real, effective, saved): %s %s %s\n", - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_rgid)), - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_groups)), - pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svgid))); + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_rgid)), + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_groups)), + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_svgid))); gdb_printf ("Groups: "); - uint16_t ngroups = bfd_get_16 (core_bfd, descdata + kp->ki_ngroups); + uint16_t ngroups = bfd_get_16 (cbfd, descdata + kp->ki_ngroups); for (int i = 0; i < ngroups; i++) gdb_printf ("%s ", - pulongest (bfd_get_32 (core_bfd, + pulongest (bfd_get_32 (cbfd, descdata + kp->ki_groups + i * 4))); gdb_printf ("\n"); - value = bfd_get (long_bit, core_bfd, + value = bfd_get (long_bit, cbfd, descdata + kp->ki_rusage + kp->ru_minflt); gdb_printf ("Minor faults (no memory page): %s\n", pulongest (value)); - value = bfd_get (long_bit, core_bfd, + value = bfd_get (long_bit, cbfd, descdata + kp->ki_rusage_ch + kp->ru_minflt); gdb_printf ("Minor faults, children: %s\n", pulongest (value)); - value = bfd_get (long_bit, core_bfd, + value = bfd_get (long_bit, cbfd, descdata + kp->ki_rusage + kp->ru_majflt); gdb_printf ("Major faults (memory page faults): %s\n", pulongest (value)); - value = bfd_get (long_bit, core_bfd, + value = bfd_get (long_bit, cbfd, descdata + kp->ki_rusage_ch + kp->ru_majflt); gdb_printf ("Major faults, children: %s\n", pulongest (value)); fbsd_core_fetch_timeval (gdbarch, @@ -1408,22 +1410,22 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch) fbsd_core_fetch_timeval (gdbarch, descdata + kp->ki_start, sec, value); gdb_printf ("Start time: %s.%06d\n", plongest (sec), (int) value); gdb_printf ("Virtual memory size: %s kB\n", - pulongest (bfd_get (addr_bit, core_bfd, + pulongest (bfd_get (addr_bit, cbfd, descdata + kp->ki_size) / 1024)); gdb_printf ("Data size: %s pages\n", - pulongest (bfd_get (addr_bit, core_bfd, + pulongest (bfd_get (addr_bit, cbfd, descdata + kp->ki_dsize))); gdb_printf ("Stack size: %s pages\n", - pulongest (bfd_get (addr_bit, core_bfd, + pulongest (bfd_get (addr_bit, cbfd, descdata + kp->ki_ssize))); gdb_printf ("Text size: %s pages\n", - pulongest (bfd_get (addr_bit, core_bfd, + pulongest (bfd_get (addr_bit, cbfd, descdata + kp->ki_tsize))); gdb_printf ("Resident set size: %s pages\n", - pulongest (bfd_get (addr_bit, core_bfd, + pulongest (bfd_get (addr_bit, cbfd, descdata + kp->ki_rssize))); gdb_printf ("Maximum RSS: %s pages\n", - pulongest (bfd_get (long_bit, core_bfd, + pulongest (bfd_get (long_bit, cbfd, descdata + kp->ki_rusage + kp->ru_maxrss))); fbsd_print_sigset ("Ignored Signals", descdata + kp->ki_sigignore); @@ -1482,7 +1484,8 @@ fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args, return; } - pid = bfd_core_file_pid (core_bfd); + bfd *cbfd = current_program_space->core_bfd (); + pid = bfd_core_file_pid (cbfd); if (pid != 0) gdb_printf (_("process %d\n"), pid); @@ -1490,7 +1493,7 @@ fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args, { const char *cmdline; - cmdline = bfd_core_file_failing_command (core_bfd); + cmdline = bfd_core_file_failing_command (cbfd); if (cmdline) gdb_printf ("cmdline = '%s'\n", cmdline); else @@ -2321,7 +2324,8 @@ fbsd_vdso_range (struct gdbarch *gdbarch, struct mem_range *range) if (!target_has_execution ()) { /* Search for the ending address in the NT_PROCSTAT_VMMAP note. */ - asection *section = bfd_get_section_by_name (core_bfd, + bfd *cbfd = current_program_space->core_bfd (); + asection *section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.vmmap"); if (section == nullptr) return false; @@ -2331,7 +2335,7 @@ fbsd_vdso_range (struct gdbarch *gdbarch, struct mem_range *range) return false; gdb::def_vector<unsigned char> contents (note_size); - if (!bfd_get_section_contents (core_bfd, section, contents.data (), + if (!bfd_get_section_contents (cbfd, section, contents.data (), 0, note_size)) return false; |