gdb/gdbserver/
[deliverable/binutils-gdb.git] / gdb / hppa-hpux-tdep.c
index b434c0664ace1a8a982de3a651668f3fffeac69d..89d9e6d2a416a348cf8d405c5424555250a3eca0 100644 (file)
@@ -1,7 +1,6 @@
 /* Target-dependent code for HP-UX on PA-RISC.
 
-   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -164,7 +163,7 @@ hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
   /* PA64 has a completely different stub/trampoline scheme.  Is it
      better?  Maybe.  It's certainly harder to determine with any
      certainty that we are in a stub because we can not refer to the
-     unwinders to help. 
+     unwinders to help.
 
      The heuristic is simple.  Try to lookup the current PC value in th
      minimal symbol table.  If that fails, then assume we are not in a
@@ -192,7 +191,7 @@ hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
       return 0;
 
   /* We might be in a stub.  Peek at the instructions.  Stubs are 3
-     instructions long. */
+     instructions long.  */
   insn = read_memory_integer (pc, 4, byte_order);
 
   /* Find out where we think we are within the stub.  */
@@ -231,7 +230,7 @@ hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
 
 static int
 hppa_hpux_in_solib_return_trampoline (struct gdbarch *gdbarch,
-                                     CORE_ADDR pc, char *name)
+                                     CORE_ADDR pc, const char *name)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct unwind_table_entry *u;
@@ -325,7 +324,8 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
          the PLT entry for this function, not the address of the function
          itself.  Bit 31 has meaning too, but only for MPE.  */
       if (pc & 0x2)
-       pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size, byte_order);
+       pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size,
+                                             byte_order);
     }
   if (pc == hppa_symbol_address("$$dyncall_external"))
     {
@@ -344,25 +344,25 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
   /* If this isn't a linker stub, then return now.  */
   /* elz: attention here! (FIXME) because of a compiler/linker 
      error, some stubs which should have a non zero stub_unwind.stub_type 
-     have unfortunately a value of zero. So this function would return here
-     as if we were not in a trampoline. To fix this, we go look at the partial
+     have unfortunately a value of zero.  So this function would return here
+     as if we were not in a trampoline.  To fix this, we go look at the partial
      symbol information, which reports this guy as a stub.
      (FIXME): Unfortunately, we are not that lucky: it turns out that the 
-     partial symbol information is also wrong sometimes. This is because 
+     partial symbol information is also wrong sometimes.  This is because 
      when it is entered (somread.c::som_symtab_read()) it can happen that
      if the type of the symbol (from the som) is Entry, and the symbol is
-     in a shared library, then it can also be a trampoline.  This would
-     be OK, except that I believe the way they decide if we are ina shared library
-     does not work. SOOOO..., even if we have a regular function w/o trampolines
-     its minimal symbol can be assigned type mst_solib_trampoline.
+     in a shared library, then it can also be a trampoline.  This would be OK,
+     except that I believe the way they decide if we are ina shared library
+     does not work.  SOOOO..., even if we have a regular function w/o
+     trampolines its minimal symbol can be assigned type mst_solib_trampoline.
      Also, if we find that the symbol is a real stub, then we fix the unwind
      descriptor, and define the stub type to be EXPORT.
-     Hopefully this is correct most of the times. */
+     Hopefully this is correct most of the times.  */
   if (u->stub_unwind.stub_type == 0)
     {
 
 /* elz: NOTE (FIXME!) once the problem with the unwind information is fixed
-   we can delete all the code which appears between the lines */
+   we can delete all the code which appears between the lines */
 /*--------------------------------------------------------------------------*/
       msym = lookup_minimal_symbol_by_pc (pc);
 
@@ -375,10 +375,10 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
          struct minimal_symbol *msymbol;
          int function_found = 0;
 
-         /* go look if there is another minimal symbol with the same name as 
-            this one, but with type mst_text. This would happen if the msym
+         /* Go look if there is another minimal symbol with the same name as 
+            this one, but with type mst_text.  This would happen if the msym
             is an actual trampoline, in which case there would be another
-            symbol with the same name corresponding to the real function */
+            symbol with the same name corresponding to the real function */
 
          ALL_MSYMBOLS (objfile, msymbol)
          {
@@ -392,14 +392,14 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
          }
 
          if (function_found)
-           /* the type of msym is correct (mst_solib_trampoline), but
-              the unwind info is wrong, so set it to the correct value */
+           /* The type of msym is correct (mst_solib_trampoline), but
+              the unwind info is wrong, so set it to the correct value */
            u->stub_unwind.stub_type = EXPORT;
          else
-           /* the stub type info in the unwind is correct (this is not a
+           /* The stub type info in the unwind is correct (this is not a
               trampoline), but the msym type information is wrong, it
-              should be mst_text. So we need to fix the msym, and also
-              get out of this function */
+              should be mst_text.  So we need to fix the msym, and also
+              get out of this function */
            {
              MSYMBOL_TYPE (msym) = mst_text;
              return orig_pc == pc ? 0 : pc & ~0x3;
@@ -436,10 +436,12 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
          /* Yup.  See if the previous instruction loaded
             a value into %r1.  If so compute and return the jump address.  */
          if ((prev_inst & 0xffe00000) == 0x20200000)
-           return (hppa_extract_21 (prev_inst) + hppa_extract_17 (curr_inst)) & ~0x3;
+           return (hppa_extract_21 (prev_inst) 
+                   + hppa_extract_17 (curr_inst)) & ~0x3;
          else
            {
-             warning (_("Unable to find ldil X,%%r1 before ble Y(%%sr4,%%r1)."));
+             warning (_("Unable to find ldil X,%%r1 "
+                        "before ble Y(%%sr4,%%r1)."));
              return orig_pc == pc ? 0 : pc & ~0x3;
            }
        }
@@ -479,7 +481,8 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
              return orig_pc == pc ? 0 : pc & ~0x3;
            }
 
-         libsym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (stubsym), NULL, NULL);
+         libsym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (stubsym),
+                                         NULL, NULL);
          if (libsym == NULL)
            {
              warning (_("Unable to find library symbol for %s."),
@@ -574,7 +577,8 @@ hppa_skip_permanent_breakpoint (struct regcache *regcache)
   regcache_cooked_write_unsigned (regcache, HPPA_PCOQ_HEAD_REGNUM, pcoq_tail);
   regcache_cooked_write_unsigned (regcache, HPPA_PCSQ_HEAD_REGNUM, pcsq_tail);
 
-  regcache_cooked_write_unsigned (regcache, HPPA_PCOQ_TAIL_REGNUM, pcoq_tail + 4);
+  regcache_cooked_write_unsigned (regcache,
+                                 HPPA_PCOQ_TAIL_REGNUM, pcoq_tail + 4);
   /* We can leave the tail's space the same, since there's no jump.  */
 }
 
@@ -647,22 +651,22 @@ hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
 
   off = scptr;
 
-  /* See /usr/include/machine/save_state.h for the structure of the save_state_t
-     structure. */
+  /* See /usr/include/machine/save_state.h for the structure of the
+     save_state_t structure.  */
   
   flag = read_memory_unsigned_integer (scptr + HPPA_HPUX_SS_FLAGS_OFFSET,
                                       4, byte_order);
 
   if (!(flag & HPPA_HPUX_SS_WIDEREGS))
     {
-      /* Narrow registers. */
+      /* Narrow registers.  */
       off = scptr + HPPA_HPUX_SS_NARROW_OFFSET;
       incr = 4;
       szoff = 0;
     }
   else
     {
-      /* Wide registers. */
+      /* Wide registers.  */
       off = scptr + HPPA_HPUX_SS_WIDE_OFFSET + 8;
       incr = 8;
       szoff = (tdep->bytes_per_address == 4 ? 4 : 0);
@@ -708,7 +712,8 @@ hppa_hpux_sigtramp_frame_prev_register (struct frame_info *this_frame,
   struct hppa_hpux_sigtramp_unwind_cache *info
     = hppa_hpux_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
 
-  return hppa_frame_prev_register_helper (this_frame, info->saved_regs, regnum);
+  return hppa_frame_prev_register_helper (this_frame,
+                                         info->saved_regs, regnum);
 }
 
 static int
@@ -747,6 +752,7 @@ hppa_hpux_sigtramp_unwind_sniffer (const struct frame_unwind *self,
 
 static const struct frame_unwind hppa_hpux_sigtramp_frame_unwind = {
   SIGTRAMP_FRAME,
+  default_frame_unwind_stop_reason,
   hppa_hpux_sigtramp_frame_this_id,
   hppa_hpux_sigtramp_frame_prev_register,
   NULL,
@@ -950,7 +956,6 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
   struct hppa_objfile_private *priv;
   CORE_ADDR addr;
   struct minimal_symbol *msym;
-  int i;
 
   sec = find_pc_section (pc);
   obj = sec->objfile;
@@ -973,10 +978,10 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
      scheme; try to read in blocks of code, and look for a "bve,n (rp)" 
      instruction.  These are likely to occur at the end of functions, so
      we only look at the last two instructions of each function.  */
-  for (i = 0, msym = obj->msymbols; i < obj->minimal_symbol_count; i++, msym++)
+  ALL_OBJFILE_MSYMBOLS (obj, msym)
     {
       CORE_ADDR begin, end;
-      char *name;
+      const char *name;
       gdb_byte buf[2 * HPPA_INSN_SIZE];
       int offset;
 
@@ -1067,7 +1072,7 @@ static CORE_ADDR
 hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr)
 {
   /* In order for us to restore the space register to its starting state, 
-     we need the dummy trampoline to return to the an instruction address in 
+     we need the dummy trampoline to return to an instruction address in 
      the same space as where we started the call.  We used to place the 
      breakpoint near the current pc, however, this breaks nested dummy calls 
      as the nested call will hit the breakpoint address and terminate 
@@ -1081,13 +1086,12 @@ hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr)
   struct unwind_table_entry *u;
   struct minimal_symbol *msym;
   CORE_ADDR func;
-  int i;
 
   sec = find_pc_section (addr);
   if (sec)
     {
       /* First try the lowest address in the section; we can use it as long
-         as it is "regular" code (i.e. not a stub) */
+         as it is "regular" code (i.e. not a stub) */
       u = find_unwind_entry (obj_section_addr (sec));
       if (!u || u->stub_unwind.stub_type == 0)
         return obj_section_addr (sec);
@@ -1101,9 +1105,7 @@ hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr)
         work.  */
 
       find_pc_partial_function (addr, NULL, &func, NULL);
-      for (i = 0, msym = sec->objfile->msymbols;
-          i < sec->objfile->minimal_symbol_count;
-          i++, msym++)
+      ALL_OBJFILE_MSYMBOLS (sec->objfile, msym)
        {
          u = find_unwind_entry (SYMBOL_VALUE_ADDRESS (msym));
          if (func != SYMBOL_VALUE_ADDRESS (msym) 
@@ -1195,9 +1197,7 @@ hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
      - point the sequence at the trampoline
      - set the return address of the trampoline to the current space 
        (see hppa_hpux_find_dummy_call_bpaddr)
-     - set the continuing address of the "dummy code" as the sequence.
-
-*/
+     - set the continuing address of the "dummy code" as the sequence.  */
 
   if (IS_32BIT_TARGET (gdbarch))
     {
@@ -1446,8 +1446,8 @@ hppa_hpux_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
 /* Given the current value of the pc, check to see if it is inside a stub, and
    if so, change the value of the pc to point to the caller of the stub.
    THIS_FRAME is the current frame in the current list of frames.
-   BASE contains to stack frame base of the current frame. 
-   SAVE_REGS is the register file stored in the frame cache. */
+   BASE contains to stack frame base of the current frame.
+   SAVE_REGS is the register file stored in the frame cache.  */
 static void
 hppa_hpux_unwind_adjust_stub (struct frame_info *this_frame, CORE_ADDR base,
                              struct trad_frame_saved_reg *saved_regs)
This page took 0.028671 seconds and 4 git commands to generate.