]> sourceware.org Git - systemtap.git/commitdiff
Properly read eh_frame and pass is_ehframe correctly.
authorMark Wielaard <mjw@redhat.com>
Wed, 20 May 2009 21:11:43 +0000 (23:11 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 20 May 2009 21:11:43 +0000 (23:11 +0200)
* runtime/unwind.c (adjustStartLoc): Add extra dbug_unwind.
  (_stp_search_unwind_hdr): Always pass true for is_ehframe.
  (unwind_frame): Properly pass through is_ehframe to adjustStartLoc().
  (unwind): Add extra dbug_unwind.
* translate.cxx (dump_unwindsyms): Output and use correct eh_frame
  and eh_len.

runtime/unwind.c
translate.cxx

index 97a99fda8a9623dd5f3a0acf4135111c194650db..43bda717605542928936262051cb2ecaa3621f87 100644 (file)
@@ -485,8 +485,8 @@ adjustStartLoc (unsigned long startLoc,
 {
   /* XXX - some, or all, of this should really be done by
      _stp_module_relocate and/or read_pointer. */
-  dbug_unwind(2, "adjustStartLoc=%lx, ptrType=%s, m=%s, s=%s\n",
-             startLoc, _stp_eh_enc_name(ptrType), m->name, s->name);
+  dbug_unwind(2, "adjustStartLoc=%lx, ptrType=%s, m=%s, s=%s eh=%d\n",
+             startLoc, _stp_eh_enc_name(ptrType), m->name, s->name, is_ehframe);
   if (startLoc == 0
       || strcmp (m->name, "kernel")  == 0
       || (strcmp (s->name, ".absolute") == 0 && !is_ehframe))
@@ -494,6 +494,7 @@ adjustStartLoc (unsigned long startLoc,
 
   /* eh_frame data has been loaded in the kernel, so readjust offset. */
   if (is_ehframe) {
+    dbug_unwind(2, "eh_frame=%lx, eh_frame_addr=%lx\n", (unsigned long) m->eh_frame, m->eh_frame_addr);
     if ((ptrType & DW_EH_PE_ADJUST) == DW_EH_PE_pcrel) {
       startLoc -= (unsigned long) m->eh_frame;
       startLoc += m->eh_frame_addr;
@@ -571,7 +572,7 @@ static u32 *_stp_search_unwind_hdr(unsigned long pc,
                }
        } while (startLoc && num > 1);
 
-       if (num == 1 && (startLoc = adjustStartLoc(read_pointer(&ptr, ptr + tableSize, hdr[3]), m, s, hdr[3], false)) != 0 && pc >= startLoc)
+       if (num == 1 && (startLoc = adjustStartLoc(read_pointer(&ptr, ptr + tableSize, hdr[3]), m, s, hdr[3], true)) != 0 && pc >= startLoc)
                fde = (void *)read_pointer(&ptr, ptr + tableSize, hdr[3]);
 
        dbug_unwind(1, "returning fde=%lx startLoc=%lx", fde, startLoc);
@@ -610,7 +611,7 @@ static int unwind_frame(struct unwind_frame_info *frame,
                        ptr = (const u8 *)(fde + 2);
                        ptrType = fde_pointer_type(cie);
                        startLoc = read_pointer(&ptr, (const u8 *)(fde + 1) + *fde, ptrType);
-                       startLoc = adjustStartLoc(startLoc, m, s, ptrType, false);
+                       startLoc = adjustStartLoc(startLoc, m, s, ptrType, is_ehframe);
 
                        dbug_unwind(2, "startLoc=%lx, ptrType=%s\n", startLoc, _stp_eh_enc_name(ptrType));
                        if (!(ptrType & DW_EH_PE_indirect))
@@ -641,7 +642,7 @@ static int unwind_frame(struct unwind_frame_info *frame,
 
                        ptr = (const u8 *)(fde + 2);
                        startLoc = read_pointer(&ptr, (const u8 *)(fde + 1) + *fde, ptrType);
-                       startLoc = adjustStartLoc(startLoc, m, s, ptrType, false);
+                       startLoc = adjustStartLoc(startLoc, m, s, ptrType, is_ehframe);
                        dbug_unwind(2, "startLoc=%lx, ptrType=%s\n", startLoc, _stp_eh_enc_name(ptrType));
                        if (!startLoc)
                                continue;
@@ -876,11 +877,14 @@ static int unwind(struct unwind_frame_info *frame, struct task_struct *tsk)
                return -EINVAL;
        }
 
+       dbug_unwind(1, "trying debug_frame\n");
        res = unwind_frame (frame, m, s, m->debug_frame,
                            m->debug_frame_len, false);
-       if (res != 0)
+       if (res != 0) {
+         dbug_unwind(1, "debug_frame failed: %d, trying eh_frame\n", res);
          res = unwind_frame (frame, m, s, m->eh_frame,
                              m->eh_frame_len, true);
+       }
 
        return res;
 }
index eaa2e942b3e63245864d22d3f3be0a65cb84595b..62c71aeb7639eec56eb661ac3258b16040f75e84 100644 (file)
@@ -4724,9 +4724,9 @@ dump_unwindsyms (Dwfl_Module *m,
       c->output << "static uint8_t _stp_module_" << stpmod_idx
                << "_eh_frame[] = \n";
       c->output << "  {";
-      for (size_t i = 0; i < debug_len; i++)
+      for (size_t i = 0; i < eh_len; i++)
        {
-         int h = ((uint8_t *)debug_frame)[i];
+         int h = ((uint8_t *)eh_frame)[i];
          c->output << "0x" << hex << h << dec << ",";
          if ((i + 1) % 16 == 0)
            c->output << "\n" << "   ";
This page took 0.044235 seconds and 5 git commands to generate.