public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: frysk@sourceware.org
Subject: Re: [patch] Add debug_frame parsing
Date: Sun, 20 Jan 2008 15:08:00 -0000	[thread overview]
Message-ID: <1200740772.12412.22.camel@localhost.localdomain> (raw)
In-Reply-To: <1200568336.2470.18.camel@dijkstra.wildebeest.org>

[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]

Hi,

On Thu, 2008-01-17 at 12:12 +0100, Mark Wielaard wrote:
> Although it does find the right fde covering the ip ranges, it doesn't
> always run the cfi program correctly.

Because it was using the wrong address space... duh.
So this small patch records and makes sure the right one is always used
(debug_frame lives in our, not in the inferior address space).

frysk-imports/libunwind/ChangeLog
2008-01-18  Mark Wielaard  <mwielaard@redhat.com>
    
       * include/dwarf.h (dwarf_cie_info): Add as and as_arg members.
       * src/dwarf/Gfde.c (dwarf_extract_proc_info_from_fde): Set dci
       as and as_arg when not local only.
       * src/dwarf/Gparser.c (run_cfi_program): Use dci as and as_arg
       when not local only.
    
frysk-sys/lib/unwind/ChangeLog
2008-01-18  Mark Wielaard  <mwielaard@redhat.com>
    
       * cni/UnwindH.hxx (get_eh_frame_hdr_addr): Prefer debug_frame.

The patch is small, but it does enable using debug_frame in preference
to eh_frame when found (but currently only in the main executable, a
follow up patch should make sure that libdwfl is always used to get at
the debug_frame). All tests now PASS with this enabled.

Cheers,

Mark

[-- Attachment #2: cfi_as.patch --]
[-- Type: text/x-patch, Size: 2533 bytes --]

diff --git a/frysk-imports/libunwind/include/dwarf.h b/frysk-imports/libunwind/include/dwarf.h
index cf8a74a..3a17c87 100644
--- a/frysk-imports/libunwind/include/dwarf.h
+++ b/frysk-imports/libunwind/include/dwarf.h
@@ -252,6 +252,10 @@ dwarf_reg_state_t;
 
 typedef struct dwarf_cie_info
   {
+#ifndef UNW_LOCAL_ONLY
+    unw_addr_space_t as;        /* reference to frame address-space */
+    void *as_arg;               /* argument to address-space callbacks */
+#endif
     unw_word_t cie_instr_start;	/* start addr. of CIE "initial_instructions" */
     unw_word_t cie_instr_end;	/* end addr. of CIE "initial_instructions" */
     unw_word_t fde_instr_start;	/* start addr. of FDE "instructions" */
diff --git a/frysk-imports/libunwind/src/dwarf/Gfde.c b/frysk-imports/libunwind/src/dwarf/Gfde.c
index de2b193..a9c36f4 100644
--- a/frysk-imports/libunwind/src/dwarf/Gfde.c
+++ b/frysk-imports/libunwind/src/dwarf/Gfde.c
@@ -351,7 +351,10 @@ dwarf_extract_proc_info_from_fde (unw_addr_space_t as, unw_accessors_t *a,
       else
 	dci.fde_instr_start = addr;
       dci.fde_instr_end = fde_end_addr;
-
+#ifndef UNW_LOCAL_ONLY
+      dci.as = as;
+      dci.as_arg = arg;
+#endif
       memcpy (pi->unwind_info, &dci, sizeof (dci));
     }
   return 0;
diff --git a/frysk-imports/libunwind/src/dwarf/Gparser.c b/frysk-imports/libunwind/src/dwarf/Gparser.c
index ada82d9..441cf9b 100644
--- a/frysk-imports/libunwind/src/dwarf/Gparser.c
+++ b/frysk-imports/libunwind/src/dwarf/Gparser.c
@@ -71,8 +71,13 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
   void *arg;
   int ret;
 
+#ifndef UNW_LOCAL_ONLY
+  as = dci->as;
+  arg = dci->as_arg;
+#else
   as = c->as;
   arg = c->as_arg;
+#endif
   a = unw_get_accessors (as);
   curr_ip = c->pi.start_ip;
 
diff --git a/frysk-sys/lib/unwind/cni/UnwindH.hxx b/frysk-sys/lib/unwind/cni/UnwindH.hxx
index 08c8ce1..f56d16b 100644
--- a/frysk-sys/lib/unwind/cni/UnwindH.hxx
+++ b/frysk-sys/lib/unwind/cni/UnwindH.hxx
@@ -567,11 +567,7 @@ get_eh_frame_hdr_addr(unw_proc_info_t *pi, char *image, size_t size,
   *peh_vaddr = peh_hdr.p_vaddr;
 
   char *hdr;
-  // FIXME. Currently we prefer eh_frame, but we should switch to
-  // prefer debug_frame when all bugs have been squashed out of that
-  // in libunwind.
-  if (peh_hdr_ndx == -1
-      && debug_frame_data != NULL && debug_frame_data->d_buf != NULL
+  if (debug_frame_data != NULL && debug_frame_data->d_buf != NULL
       && debug_frame_data->d_size != 0)
     {
       pi->format = UNW_INFO_FORMAT_TABLE;

      parent reply	other threads:[~2008-01-20 15:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-17 11:12 Mark Wielaard
2008-01-17 14:34 ` Andrew Cagney
2008-01-20 15:08 ` Mark Wielaard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1200740772.12412.22.camel@localhost.localdomain \
    --to=mark@klomp.org \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).