#include "objfiles.h"
#include "hppa-tdep.h"
+static int hppa_debug = 0;
+
/* Some local constants. */
static const int hppa32_num_regs = 128;
static const int hppa64_num_regs = 96;
return 0;
}
-static CORE_ADDR low_text_segment_address;
-
static void
-record_text_segment_lowaddr (bfd *abfd, asection *section, void *ignored)
+record_text_segment_lowaddr (bfd *abfd, asection *section, void *data)
{
- if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
+ if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
== (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
- && section->vma < low_text_segment_address)
- low_text_segment_address = section->vma;
+ {
+ bfd_vma value = section->vma - section->filepos;
+ CORE_ADDR *low_text_segment_address = (CORE_ADDR *)data;
+
+ if (value < *low_text_segment_address)
+ *low_text_segment_address = value;
+ }
}
static void
{
/* We will read the unwind entries into temporary memory, then
fill in the actual unwind table. */
+
if (size > 0)
{
unsigned long tmp;
unsigned i;
char *buf = alloca (size);
+ CORE_ADDR low_text_segment_address;
- low_text_segment_address = -1;
-
- /* If addresses are 64 bits wide, then unwinds are supposed to
+ /* For ELF targets, then unwinds are supposed to
be segment relative offsets instead of absolute addresses.
Note that when loading a shared library (text_offset != 0) the
unwinds are already relative to the text_offset that will be
passed in. */
- if (TARGET_PTR_BIT == 64 && text_offset == 0)
+ if (gdbarch_tdep (current_gdbarch)->is_elf && text_offset == 0)
{
+ low_text_segment_address = -1;
+
bfd_map_over_sections (objfile->obfd,
- record_text_segment_lowaddr, NULL);
+ record_text_segment_lowaddr,
+ &low_text_segment_address);
- /* ?!? Mask off some low bits. Should this instead subtract
- out the lowest section's filepos or something like that?
- This looks very hokey to me. */
- low_text_segment_address &= ~0xfff;
- text_offset += low_text_segment_address;
+ text_offset = low_text_segment_address;
}
bfd_get_section_contents (objfile->obfd, section, buf, 0, size);
struct objfile *objfile;
struct hppa_objfile_private *priv;
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "{ find_unwind_entry 0x%s -> ",
+ paddr_nz (pc));
+
/* A function at address 0? Not in HP-UX! */
if (pc == (CORE_ADDR) 0)
- return NULL;
+ {
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "NULL }\n");
+ return NULL;
+ }
ALL_OBJFILES (objfile)
{
if (ui->cache
&& pc >= ui->cache->region_start
&& pc <= ui->cache->region_end)
- return ui->cache;
+ {
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "0x%s (cached) }\n",
+ paddr_nz ((CORE_ADDR) ui->cache));
+ return ui->cache;
+ }
/* Not in the cache, do a binary search */
&& pc <= ui->table[middle].region_end)
{
ui->cache = &ui->table[middle];
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "0x%s }\n",
+ paddr_nz ((CORE_ADDR) ui->cache));
return &ui->table[middle];
}
first = middle + 1;
}
} /* ALL_OBJFILES() */
+
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "NULL (not found) }\n");
+
return NULL;
}
struct unwind_table_entry *u;
int i;
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "{ hppa_frame_cache (frame=%d) -> ",
+ frame_relative_level(next_frame));
+
if ((*this_cache) != NULL)
- return (*this_cache);
+ {
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "base=0x%s (cached) }",
+ paddr_nz (((struct hppa_frame_cache *)*this_cache)->base));
+ return (*this_cache);
+ }
cache = FRAME_OBSTACK_ZALLOC (struct hppa_frame_cache);
(*this_cache) = cache;
cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
/* Yow! */
u = find_unwind_entry (frame_func_unwind (next_frame));
if (!u)
- return (*this_cache);
+ {
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "base=NULL (no unwind entry) }");
+ return (*this_cache);
+ }
/* Turn the Entry_GR field into a bitmask. */
saved_gr_mask = 0;
}
}
+ if (hppa_debug)
+ fprintf_unfiltered (gdb_stdlog, "base=0x%s }",
+ paddr_nz (((struct hppa_frame_cache *)*this_cache)->base));
return (*this_cache);
}
return addr;
}
+static void
+hppa_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+ int regnum, void *buf)
+{
+ ULONGEST tmp;
+
+ regcache_raw_read_unsigned (regcache, regnum, &tmp);
+ if (regnum == PCOQ_HEAD_REGNUM || regnum == PCOQ_TAIL_REGNUM)
+ tmp &= ~0x3;
+ store_unsigned_integer (buf, sizeof(tmp), tmp);
+}
+
/* Here is a table of C type sizes on hppa with various compiles
and options. I measured this on PA 9000/800 with HP-UX 11.11
and these compilers:
return (arches->gdbarch);
/* If none found, then allocate and initialize one. */
- tdep = XMALLOC (struct gdbarch_tdep);
+ tdep = XZALLOC (struct gdbarch_tdep);
gdbarch = gdbarch_alloc (&info, tdep);
/* Determine from the bfd_arch_info structure if we are dealing with
frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer);
frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer);
+ set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);
+
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
static void
hppa_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
{
- /* Nothing to print for the moment. */
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+ fprintf_unfiltered (file, "bytes_per_address = %d\n",
+ tdep->bytes_per_address);
+ fprintf_unfiltered (file, "elf = %s\n", tdep->is_elf ? "yes" : "no");
}
void
break_at_finish_at_depth_command,
"Set breakpoint at procedure exit. Either there should\n\
be no argument or the argument must be a depth.\n"), NULL);
+
+ /* Debug this files internals. */
+ add_show_from_set (add_set_cmd ("hppa", class_maintenance, var_zinteger,
+ &hppa_debug, "Set hppa debugging.\n\
+When non-zero, hppa specific debugging is enabled.", &setdebuglist), &showdebuglist);
}