From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12689 invoked by alias); 1 Mar 2004 01:05:34 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 12674 invoked from network); 1 Mar 2004 01:05:32 -0000 Received: from unknown (HELO localhost.redhat.com) (216.129.200.20) by sources.redhat.com with SMTP; 1 Mar 2004 01:05:32 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 87CBD2B92; Sun, 29 Feb 2004 20:05:28 -0500 (EST) Message-ID: <40428C58.1020506@gnu.org> Date: Fri, 19 Mar 2004 00:09:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Jason R Thorpe Cc: gdb-patches@sources.redhat.com Subject: [rfa:NetBSD/ppc] Implement signal trampoline unwinder Content-Type: multipart/mixed; boundary="------------090405080102050807060708" X-SW-Source: 2004-03/txt/msg00001.txt.bz2 This is a multi-part message in MIME format. --------------090405080102050807060708 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 378 It appears to work (but doesn't have much effect without an rs6000 unwinder). One question (and to follow up my earlier post) is there a better way of doing this: + if (frame_pc_unwind (next_frame) > 0x7f000000) + /* Assume anything that is vaguely on the stack is a signal + trampoline. */ + return &ppcnbsd_sigtramp_unwind; ok?, eventually for 6.1? Andrew --------------090405080102050807060708 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 3939 2004-02-29 Andrew Cagney * ppcnbsd-tdep.c: Include "trad-frame.h", and "frame-unwind.h". (struct ppcnbsd_sigtramp_cache, ppcnbsd_sigtramp_this_id) (ppcnbsd_sigtramp_prev_register, ppcnbsd_sigtramp_cache) (ppcnbsd_sigtramp_sniffer, ppcnbsd_sigtramp_unwind) (ppcnbsd_init_abi): Implement a NetBSD/PPC signal trampline unwinder, register. Index: ppcnbsd-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v retrieving revision 1.11 diff -u -r1.11 ppcnbsd-tdep.c --- ppcnbsd-tdep.c 10 Nov 2003 22:47:28 -0000 1.11 +++ ppcnbsd-tdep.c 1 Mar 2004 00:58:20 -0000 @@ -26,6 +26,8 @@ #include "breakpoint.h" #include "value.h" #include "osabi.h" +#include "trad-frame.h" +#include "frame-unwind.h" #include "ppc-tdep.h" #include "ppcnbsd-tdep.h" @@ -227,6 +229,89 @@ readbuf, writebuf); } +struct ppcnbsd_sigtramp_cache +{ + CORE_ADDR base; + struct trad_frame_saved_reg *saved_regs; +}; + +static struct ppcnbsd_sigtramp_cache * +ppcnbsd_sigtramp_cache (struct frame_info *next_frame, void **this_cache) +{ + CORE_ADDR offset; + int i; + struct ppcnbsd_sigtramp_cache *cache; + struct gdbarch *gdbarch = get_frame_arch (next_frame); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if ((*this_cache) != NULL) + return (*this_cache); + cache = FRAME_OBSTACK_ZALLOC (struct ppcnbsd_sigtramp_cache); + (*this_cache) = cache; + cache->saved_regs = trad_frame_alloc_saved_regs (next_frame); + + cache->base = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + offset = cache->base + 0x18 + 2 * tdep->wordsize; + for (i = 0; i < 32; i++) + { + int regnum = i + tdep->ppc_gp0_regnum; + cache->saved_regs[regnum].addr = offset; + offset += tdep->wordsize; + } + cache->saved_regs[tdep->ppc_lr_regnum].addr = offset; + offset += tdep->wordsize; + cache->saved_regs[tdep->ppc_cr_regnum].addr = offset; + offset += tdep->wordsize; + cache->saved_regs[tdep->ppc_xer_regnum].addr = offset; + offset += tdep->wordsize; + cache->saved_regs[tdep->ppc_ctr_regnum].addr = offset; + offset += tdep->wordsize; + cache->saved_regs[PC_REGNUM].addr = offset; /* SRR0? */ + offset += tdep->wordsize; + return cache; +} + +static void +ppcnbsd_sigtramp_this_id (struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct ppcnbsd_sigtramp_cache *info = ppcnbsd_sigtramp_cache (next_frame, + this_cache); + (*this_id) = frame_id_build (info->base, frame_pc_unwind (next_frame)); +} + +static void +ppcnbsd_sigtramp_prev_register (struct frame_info *next_frame, + void **this_cache, + int regnum, int *optimizedp, + enum lval_type *lvalp, CORE_ADDR *addrp, + int *realnump, void *valuep) +{ + struct ppcnbsd_sigtramp_cache *info = ppcnbsd_sigtramp_cache (next_frame, + this_cache); + trad_frame_prev_register (next_frame, info->saved_regs, regnum, + optimizedp, lvalp, addrp, realnump, valuep); +} + +static const struct frame_unwind ppcnbsd_sigtramp_unwind = +{ + SIGTRAMP_FRAME, + ppcnbsd_sigtramp_this_id, + ppcnbsd_sigtramp_prev_register +}; + +static const struct frame_unwind * +ppcnbsd_sigtramp_sniffer (struct frame_info *next_frame) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (next_frame)); + if (frame_pc_unwind (next_frame) > 0x7f000000) + /* Assume anything that is vaguely on the stack is a signal + trampoline. */ + return &ppcnbsd_sigtramp_unwind; + else + return NULL; +} + static void ppcnbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) @@ -237,6 +322,7 @@ set_gdbarch_return_value (gdbarch, ppcnbsd_return_value); set_solib_svr4_fetch_link_map_offsets (gdbarch, nbsd_ilp32_solib_svr4_fetch_link_map_offsets); + frame_unwind_append_sniffer (gdbarch, ppcnbsd_sigtramp_sniffer); } void --------------090405080102050807060708-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12689 invoked by alias); 1 Mar 2004 01:05:34 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 12674 invoked from network); 1 Mar 2004 01:05:32 -0000 Received: from unknown (HELO localhost.redhat.com) (216.129.200.20) by sources.redhat.com with SMTP; 1 Mar 2004 01:05:32 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 87CBD2B92; Sun, 29 Feb 2004 20:05:28 -0500 (EST) Message-ID: <40428C58.1020506@gnu.org> Date: Mon, 01 Mar 2004 01:05:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Jason R Thorpe Cc: gdb-patches@sources.redhat.com Subject: [rfa:NetBSD/ppc] Implement signal trampoline unwinder Content-Type: multipart/mixed; boundary="------------090405080102050807060708" X-SW-Source: 2004-03.o/txt/msg00001.txt Message-ID: <20040301010500.iN1UQpwfDn-6funnNc5RFAymaCO28I3eBzhj5au0vsU@z> This is a multi-part message in MIME format. --------------090405080102050807060708 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 378 It appears to work (but doesn't have much effect without an rs6000 unwinder). One question (and to follow up my earlier post) is there a better way of doing this: + if (frame_pc_unwind (next_frame) > 0x7f000000) + /* Assume anything that is vaguely on the stack is a signal + trampoline. */ + return &ppcnbsd_sigtramp_unwind; ok?, eventually for 6.1? Andrew --------------090405080102050807060708 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 3939 2004-02-29 Andrew Cagney * ppcnbsd-tdep.c: Include "trad-frame.h", and "frame-unwind.h". (struct ppcnbsd_sigtramp_cache, ppcnbsd_sigtramp_this_id) (ppcnbsd_sigtramp_prev_register, ppcnbsd_sigtramp_cache) (ppcnbsd_sigtramp_sniffer, ppcnbsd_sigtramp_unwind) (ppcnbsd_init_abi): Implement a NetBSD/PPC signal trampline unwinder, register. Index: ppcnbsd-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v retrieving revision 1.11 diff -u -r1.11 ppcnbsd-tdep.c --- ppcnbsd-tdep.c 10 Nov 2003 22:47:28 -0000 1.11 +++ ppcnbsd-tdep.c 1 Mar 2004 00:58:20 -0000 @@ -26,6 +26,8 @@ #include "breakpoint.h" #include "value.h" #include "osabi.h" +#include "trad-frame.h" +#include "frame-unwind.h" #include "ppc-tdep.h" #include "ppcnbsd-tdep.h" @@ -227,6 +229,89 @@ readbuf, writebuf); } +struct ppcnbsd_sigtramp_cache +{ + CORE_ADDR base; + struct trad_frame_saved_reg *saved_regs; +}; + +static struct ppcnbsd_sigtramp_cache * +ppcnbsd_sigtramp_cache (struct frame_info *next_frame, void **this_cache) +{ + CORE_ADDR offset; + int i; + struct ppcnbsd_sigtramp_cache *cache; + struct gdbarch *gdbarch = get_frame_arch (next_frame); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if ((*this_cache) != NULL) + return (*this_cache); + cache = FRAME_OBSTACK_ZALLOC (struct ppcnbsd_sigtramp_cache); + (*this_cache) = cache; + cache->saved_regs = trad_frame_alloc_saved_regs (next_frame); + + cache->base = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + offset = cache->base + 0x18 + 2 * tdep->wordsize; + for (i = 0; i < 32; i++) + { + int regnum = i + tdep->ppc_gp0_regnum; + cache->saved_regs[regnum].addr = offset; + offset += tdep->wordsize; + } + cache->saved_regs[tdep->ppc_lr_regnum].addr = offset; + offset += tdep->wordsize; + cache->saved_regs[tdep->ppc_cr_regnum].addr = offset; + offset += tdep->wordsize; + cache->saved_regs[tdep->ppc_xer_regnum].addr = offset; + offset += tdep->wordsize; + cache->saved_regs[tdep->ppc_ctr_regnum].addr = offset; + offset += tdep->wordsize; + cache->saved_regs[PC_REGNUM].addr = offset; /* SRR0? */ + offset += tdep->wordsize; + return cache; +} + +static void +ppcnbsd_sigtramp_this_id (struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct ppcnbsd_sigtramp_cache *info = ppcnbsd_sigtramp_cache (next_frame, + this_cache); + (*this_id) = frame_id_build (info->base, frame_pc_unwind (next_frame)); +} + +static void +ppcnbsd_sigtramp_prev_register (struct frame_info *next_frame, + void **this_cache, + int regnum, int *optimizedp, + enum lval_type *lvalp, CORE_ADDR *addrp, + int *realnump, void *valuep) +{ + struct ppcnbsd_sigtramp_cache *info = ppcnbsd_sigtramp_cache (next_frame, + this_cache); + trad_frame_prev_register (next_frame, info->saved_regs, regnum, + optimizedp, lvalp, addrp, realnump, valuep); +} + +static const struct frame_unwind ppcnbsd_sigtramp_unwind = +{ + SIGTRAMP_FRAME, + ppcnbsd_sigtramp_this_id, + ppcnbsd_sigtramp_prev_register +}; + +static const struct frame_unwind * +ppcnbsd_sigtramp_sniffer (struct frame_info *next_frame) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (next_frame)); + if (frame_pc_unwind (next_frame) > 0x7f000000) + /* Assume anything that is vaguely on the stack is a signal + trampoline. */ + return &ppcnbsd_sigtramp_unwind; + else + return NULL; +} + static void ppcnbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) @@ -237,6 +322,7 @@ set_gdbarch_return_value (gdbarch, ppcnbsd_return_value); set_solib_svr4_fetch_link_map_offsets (gdbarch, nbsd_ilp32_solib_svr4_fetch_link_map_offsets); + frame_unwind_append_sniffer (gdbarch, ppcnbsd_sigtramp_sniffer); } void --------------090405080102050807060708--