+static const struct frame_unwind hppa_linux_sigtramp_frame_unwind = {
+ SIGTRAMP_FRAME,
+ default_frame_unwind_stop_reason,
+ hppa_linux_sigtramp_frame_this_id,
+ hppa_linux_sigtramp_frame_prev_register,
+ NULL,
+ hppa_linux_sigtramp_frame_sniffer
+};
+
+/* Attempt to find (and return) the global pointer for the given
+ function.
+
+ This is a rather nasty bit of code searchs for the .dynamic section
+ in the objfile corresponding to the pc of the function we're trying
+ to call. Once it finds the addresses at which the .dynamic section
+ lives in the child process, it scans the Elf32_Dyn entries for a
+ DT_PLTGOT tag. If it finds one of these, the corresponding
+ d_un.d_ptr value is the global pointer. */
+
+static CORE_ADDR
+hppa_linux_find_global_pointer (struct gdbarch *gdbarch,
+ struct value *function)
+{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ struct obj_section *faddr_sect;
+ CORE_ADDR faddr;
+
+ faddr = value_as_address (function);
+
+ /* Is this a plabel? If so, dereference it to get the gp value. */
+ if (faddr & 2)
+ {
+ int status;
+ gdb_byte buf[4];
+
+ faddr &= ~3;
+
+ status = target_read_memory (faddr + 4, buf, sizeof (buf));
+ if (status == 0)
+ return extract_unsigned_integer (buf, sizeof (buf), byte_order);
+ }
+
+ /* If the address is in the plt section, then the real function hasn't
+ yet been fixed up by the linker so we cannot determine the gp of
+ that function. */
+ if (in_plt_section (faddr))
+ return 0;
+
+ faddr_sect = find_pc_section (faddr);
+ if (faddr_sect != NULL)
+ {
+ struct obj_section *osect;
+
+ ALL_OBJFILE_OSECTIONS (faddr_sect->objfile, osect)
+ {
+ if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
+ break;
+ }
+
+ if (osect < faddr_sect->objfile->sections_end)
+ {
+ CORE_ADDR addr, endaddr;
+
+ addr = obj_section_addr (osect);
+ endaddr = obj_section_endaddr (osect);
+
+ while (addr < endaddr)
+ {
+ int status;
+ LONGEST tag;
+ gdb_byte buf[4];
+
+ status = target_read_memory (addr, buf, sizeof (buf));
+ if (status != 0)
+ break;
+ tag = extract_signed_integer (buf, sizeof (buf), byte_order);
+
+ if (tag == DT_PLTGOT)
+ {
+ CORE_ADDR global_pointer;
+
+ status = target_read_memory (addr + 4, buf, sizeof (buf));
+ if (status != 0)
+ break;
+ global_pointer = extract_unsigned_integer (buf, sizeof (buf),
+ byte_order);
+ /* The payoff... */
+ return global_pointer;
+ }
+
+ if (tag == DT_NULL)
+ break;
+
+ addr += 8;
+ }
+ }
+ }
+ return 0;
+}
+\f
+/*
+ * Registers saved in a coredump:
+ * gr0..gr31
+ * sr0..sr7
+ * iaoq0..iaoq1
+ * iasq0..iasq1
+ * sar, iir, isr, ior, ipsw
+ * cr0, cr24..cr31
+ * cr8,9,12,13
+ * cr10, cr15
+ */
+
+static const struct regcache_map_entry hppa_linux_gregmap[] =
+ {
+ { 32, HPPA_R0_REGNUM },
+ { 1, HPPA_SR4_REGNUM+1 },
+ { 1, HPPA_SR4_REGNUM+2 },
+ { 1, HPPA_SR4_REGNUM+3 },
+ { 1, HPPA_SR4_REGNUM+4 },
+ { 1, HPPA_SR4_REGNUM },
+ { 1, HPPA_SR4_REGNUM+5 },
+ { 1, HPPA_SR4_REGNUM+6 },
+ { 1, HPPA_SR4_REGNUM+7 },
+ { 1, HPPA_PCOQ_HEAD_REGNUM },
+ { 1, HPPA_PCOQ_TAIL_REGNUM },
+ { 1, HPPA_PCSQ_HEAD_REGNUM },
+ { 1, HPPA_PCSQ_TAIL_REGNUM },
+ { 1, HPPA_SAR_REGNUM },
+ { 1, HPPA_IIR_REGNUM },
+ { 1, HPPA_ISR_REGNUM },
+ { 1, HPPA_IOR_REGNUM },
+ { 1, HPPA_IPSW_REGNUM },
+ { 1, HPPA_RCR_REGNUM },
+ { 8, HPPA_TR0_REGNUM },
+ { 4, HPPA_PID0_REGNUM },
+ { 1, HPPA_CCR_REGNUM },
+ { 1, HPPA_EIEM_REGNUM },
+ { 0 }
+ };
+
+static const struct regcache_map_entry hppa_linux_fpregmap[] =
+ {
+ /* FIXME: Only works for 32-bit mode. In 64-bit mode there should
+ be 32 fpregs, 8 bytes each. */
+ { 64, HPPA_FP0_REGNUM, 4 },
+ { 0 }
+ };
+
+/* HPPA Linux kernel register set. */
+static const struct regset hppa_linux_regset =
+{
+ hppa_linux_gregmap,
+ regcache_supply_regset, regcache_collect_regset
+};
+
+static const struct regset hppa_linux_fpregset =
+{
+ hppa_linux_fpregmap,
+ regcache_supply_regset, regcache_collect_regset
+};
+
+static void
+hppa_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
+ iterate_over_regset_sections_cb *cb,
+ void *cb_data,
+ const struct regcache *regcache)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ cb (".reg", 80 * tdep->bytes_per_address, &hppa_linux_regset,
+ NULL, cb_data);
+ cb (".reg2", 64 * 4, &hppa_linux_fpregset, NULL, cb_data);
+}
+\f
+