From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25731 invoked by alias); 20 Jan 2008 15:08:27 -0000 Received: (qmail 25657 invoked by uid 22791); 20 Jan 2008 15:08:25 -0000 X-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,DATE_IN_PAST_24_48,J_CHICKENPOX_32 X-Spam-Check-By: sourceware.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (83.160.170.119) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 20 Jan 2008 15:08:02 +0000 Received: from wildebeest.demon.nl ([83.160.170.119] helo=[127.0.0.1]) by gnu.wildebeest.org with esmtp (Exim 4.63) (envelope-from ) id 1JGbmA-00028i-L7 for frysk@sourceware.org; Sun, 20 Jan 2008 16:07:59 +0100 Subject: Re: [patch] Add debug_frame parsing From: Mark Wielaard To: frysk@sourceware.org In-Reply-To: <1200568336.2470.18.camel@dijkstra.wildebeest.org> References: <1200568336.2470.18.camel@dijkstra.wildebeest.org> Content-Type: multipart/mixed; boundary="=-aBKsqVNhwgm6UtRidA/P" Date: Sun, 20 Jan 2008 15:08:00 -0000 Message-Id: <1200740772.12412.22.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.12.2 (2.12.2-3.fc8) X-Spam-Score: -3.3 (---) X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2008-q1/txt/msg00036.txt.bz2 --=-aBKsqVNhwgm6UtRidA/P Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1177 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 * 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 * 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 --=-aBKsqVNhwgm6UtRidA/P Content-Disposition: inline; filename=cfi_as.patch Content-Type: text/x-patch; name=cfi_as.patch; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 2533 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; --=-aBKsqVNhwgm6UtRidA/P--