if (vmentl != nullptr)
{
- printf_filtered (_("Mapped address spaces:\n\n"));
-#ifdef __LP64__
- printf_filtered (" %18s %18s %10s %10s %9s %s\n",
- "Start Addr",
- " End Addr",
- " Size", " Offset", "Flags ", "File");
-#else
- printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
- "Start Addr",
- " End Addr",
- " Size", " Offset", "Flags ", "File");
-#endif
+ int addr_bit = TARGET_CHAR_BIT * sizeof (void *);
+ fbsd_info_proc_mappings_header (addr_bit);
struct kinfo_vmentry *kve = vmentl.get ();
for (int i = 0; i < nvment; i++, kve++)
- {
- ULONGEST start, end;
-
- start = kve->kve_start;
- end = kve->kve_end;
-#ifdef __LP64__
- printf_filtered (" %18s %18s %10s %10s %9s %s\n",
- hex_string (start),
- hex_string (end),
- hex_string (end - start),
- hex_string (kve->kve_offset),
- fbsd_vm_map_entry_flags (kve->kve_flags,
- kve->kve_protection),
- kve->kve_path);
-#else
- printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
- hex_string (start),
- hex_string (end),
- hex_string (end - start),
- hex_string (kve->kve_offset),
- fbsd_vm_map_entry_flags (kve->kve_flags,
- kve->kve_protection),
- kve->kve_path);
-#endif
- }
+ fbsd_info_proc_mappings_entry (addr_bit, kve->kve_start,
+ kve->kve_end, kve->kve_offset,
+ kve->kve_flags, kve->kve_protection,
+ kve->kve_path);
}
else
warning (_("unable to fetch virtual memory map"));
/* Helper function to generate mappings flags for a single VM map
entry in 'info proc mappings'. */
-const char *
+static const char *
fbsd_vm_map_entry_flags (int kve_flags, int kve_protection)
{
static char vm_flags[9];
return vm_flags;
}
+/* See fbsd-tdep.h. */
+
+void
+fbsd_info_proc_mappings_header (int addr_bit)
+{
+ printf_filtered (_("Mapped address spaces:\n\n"));
+ if (addr_bit == 64)
+ {
+ printf_filtered (" %18s %18s %10s %10s %9s %s\n",
+ "Start Addr",
+ " End Addr",
+ " Size", " Offset", "Flags ", "File");
+ }
+ else
+ {
+ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
+ "Start Addr",
+ " End Addr",
+ " Size", " Offset", "Flags ", "File");
+ }
+}
+
+/* See fbsd-tdep.h. */
+
+void
+fbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
+ ULONGEST kve_end, ULONGEST kve_offset,
+ int kve_flags, int kve_protection,
+ const void *kve_path)
+{
+ if (addr_bit == 64)
+ {
+ printf_filtered (" %18s %18s %10s %10s %9s %s\n",
+ hex_string (kve_start),
+ hex_string (kve_end),
+ hex_string (kve_end - kve_start),
+ hex_string (kve_offset),
+ fbsd_vm_map_entry_flags (kve_flags, kve_protection),
+ reinterpret_cast<const char *> (kve_path));
+ }
+ else
+ {
+ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
+ hex_string (kve_start),
+ hex_string (kve_end),
+ hex_string (kve_end - kve_start),
+ hex_string (kve_offset),
+ fbsd_vm_map_entry_flags (kve_flags, kve_protection),
+ reinterpret_cast<const char *> (kve_path));
+ }
+}
+
/* Implement "info proc mappings" for a corefile. */
static void
/* Skip over the structure size. */
descdata += 4;
- printf_filtered (_("Mapped address spaces:\n\n"));
- if (gdbarch_addr_bit (gdbarch) == 64)
- {
- printf_filtered (" %18s %18s %10s %10s %9s %s\n",
- "Start Addr",
- " End Addr",
- " Size", " Offset", "Flags ", "File");
- }
- else
- {
- printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
- "Start Addr",
- " End Addr",
- " Size", " Offset", "Flags ", "File");
- }
-
+ fbsd_info_proc_mappings_header (gdbarch_addr_bit (gdbarch));
while (descdata + KVE_PATH < descend)
{
- ULONGEST start, end, offset, flags, prot, structsize;
-
- structsize = bfd_get_32 (core_bfd, descdata + KVE_STRUCTSIZE);
+ ULONGEST structsize = bfd_get_32 (core_bfd, descdata + KVE_STRUCTSIZE);
if (structsize < KVE_PATH)
error (_("malformed core note - vmmap entry too small"));
- start = bfd_get_64 (core_bfd, descdata + KVE_START);
- end = bfd_get_64 (core_bfd, descdata + KVE_END);
- offset = bfd_get_64 (core_bfd, descdata + KVE_OFFSET);
- flags = bfd_get_32 (core_bfd, descdata + KVE_FLAGS);
- prot = bfd_get_32 (core_bfd, descdata + KVE_PROTECTION);
- if (gdbarch_addr_bit (gdbarch) == 64)
- {
- printf_filtered (" %18s %18s %10s %10s %9s %s\n",
- paddress (gdbarch, start),
- paddress (gdbarch, end),
- hex_string (end - start),
- hex_string (offset),
- fbsd_vm_map_entry_flags (flags, prot),
- descdata + KVE_PATH);
- }
- else
- {
- printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
- paddress (gdbarch, start),
- paddress (gdbarch, end),
- hex_string (end - start),
- hex_string (offset),
- fbsd_vm_map_entry_flags (flags, prot),
- descdata + KVE_PATH);
- }
+ 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);
+ fbsd_info_proc_mappings_entry (gdbarch_addr_bit (gdbarch), start, end,
+ offset, flags, prot, descdata + KVE_PATH);
descdata += structsize;
}
const void *kf_sa_peer,
const void *kf_path);
-/* Helper function to generate mappings flags for a single VM map
- entry in 'info proc mappings'. The KVE_FLAGS and KVE_PROTECTION
- parameters should contain the values of the corresponding fields in
- a 'struct kinfo_vmentry'. */
-
-extern const char *fbsd_vm_map_entry_flags (int kve_flags, int kve_protection);
+/* Output the header for "info proc mappings". ADDR_BIT is the size
+ of a virtual address in bits. */
+
+extern void fbsd_info_proc_mappings_header (int addr_bit);
+
+/* Output description of a single memory range for "info proc
+ mappings". ADDR_BIT is the size of a virtual address in bits. The
+ KVE_START, KVE_END, KVE_OFFSET, KVE_FLAGS, and KVE_PROTECTION
+ parameters should contain the value of the corresponding fields in
+ a 'struct kinfo_vmentry'. The KVE_PATH parameter should contain a
+ pointer to the 'kve_path' field in a 'struct kinfo_vmentry'. */
+
+extern void fbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
+ ULONGEST kve_end,
+ ULONGEST kve_offset,
+ int kve_flags, int kve_protection,
+ const void *kve_path);
#endif /* fbsd-tdep.h */