From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20849 invoked by alias); 24 Apr 2004 06:17:03 -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 20837 invoked from network); 24 Apr 2004 06:17:02 -0000 Received: from unknown (HELO pippin.tausq.org) (64.81.244.94) by sources.redhat.com with SMTP; 24 Apr 2004 06:17:02 -0000 Received: by pippin.tausq.org (Postfix, from userid 1000) id C9FBCCD299; Fri, 23 Apr 2004 23:17:01 -0700 (PDT) Date: Sat, 24 Apr 2004 06:17:00 -0000 From: Randolph Chung To: gdb-patches@sources.redhat.com Subject: Re: [patch/rfa] hppa stub unwinder Message-ID: <20040424061701.GA2923@tausq.org> Reply-To: Randolph Chung References: <20040423040108.GD17279@tausq.org> <40892745.8010807@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40892745.8010807@gnu.org> X-GPG: for GPG key, see http://www.tausq.org/gpg.txt User-Agent: Mutt/1.5.5.1+cvs20040105i X-SW-Source: 2004-04/txt/msg00595.txt.bz2 > It's ok as is (with coding tweaks). One option, though is to instead of: Final version attached. 2004-04-23 Randolph Chung * hppa-tdep.c (hppa_stub_unwind_cache, hppa_stub_frame_unwind_cache) (hppa_stub_frame_this_id, hppa_stub_frame_prev_register) (hppa_stub_frame_unwind, hppa_stub_unwind_sniffer): New stub unwinder for handling stackless frames. (hppa_gdbarch_init): Link in hppa_stub_unwind_sniffer. Index: hppa-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.c,v retrieving revision 1.150 diff -u -p -r1.150 hppa-tdep.c --- hppa-tdep.c 24 Apr 2004 06:10:01 -0000 1.150 +++ hppa-tdep.c 24 Apr 2004 06:12:43 -0000 @@ -1898,6 +1898,84 @@ hppa_frame_base_sniffer (struct frame_in return &hppa_frame_base; } +/* Stub frames, used for all kinds of call stubs. */ +struct hppa_stub_unwind_cache +{ + CORE_ADDR base; + struct trad_frame_saved_reg *saved_regs; +}; + +static struct hppa_stub_unwind_cache * +hppa_stub_frame_unwind_cache (struct frame_info *next_frame, + void **this_cache) +{ + struct gdbarch *gdbarch = get_frame_arch (next_frame); + struct hppa_stub_unwind_cache *info; + + if (*this_cache) + return *this_cache; + + info = FRAME_OBSTACK_ZALLOC (struct hppa_stub_unwind_cache); + *this_cache = info; + info->saved_regs = trad_frame_alloc_saved_regs (next_frame); + + info->saved_regs[PCOQ_HEAD_REGNUM].realreg = RP_REGNUM; + info->base = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM); + + return info; +} + +static void +hppa_stub_frame_this_id (struct frame_info *next_frame, + void **this_prologue_cache, + struct frame_id *this_id) +{ + struct hppa_stub_unwind_cache *info + = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache); + *this_id = frame_id_build (info->base, frame_pc_unwind (next_frame)); +} + +static void +hppa_stub_frame_prev_register (struct frame_info *next_frame, + void **this_prologue_cache, + int regnum, int *optimizedp, + enum lval_type *lvalp, CORE_ADDR *addrp, + int *realnump, void *bufferp) +{ + struct hppa_stub_unwind_cache *info + = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache); + int pcoqt = (regnum == PCOQ_TAIL_REGNUM); + struct gdbarch *gdbarch = get_frame_arch (next_frame); + int regsize = register_size (gdbarch, PCOQ_HEAD_REGNUM); + + if (pcoqt) + regnum = PCOQ_HEAD_REGNUM; + + trad_frame_prev_register (next_frame, info->saved_regs, regnum, + optimizedp, lvalp, addrp, realnump, bufferp); + + if (pcoqt) + store_unsigned_integer (bufferp, regsize, + extract_unsigned_integer (bufferp, regsize) + 4); +} + +static const struct frame_unwind hppa_stub_frame_unwind = { + NORMAL_FRAME, + hppa_stub_frame_this_id, + hppa_stub_frame_prev_register +}; + +static const struct frame_unwind * +hppa_stub_unwind_sniffer (struct frame_info *next_frame) +{ + CORE_ADDR pc = frame_pc_unwind (next_frame); + + if (IN_SOLIB_CALL_TRAMPOLINE (pc, NULL) + || IN_SOLIB_RETURN_TRAMPOLINE (pc, NULL)) + return &hppa_stub_frame_unwind; + return NULL; +} + static struct frame_id hppa_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame) { @@ -2267,16 +2345,18 @@ hppa_gdbarch_init (struct gdbarch_info i default: internal_error (__FILE__, __LINE__, "bad switch"); } - + set_gdbarch_breakpoint_from_pc (gdbarch, hppa_breakpoint_from_pc); + set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read); /* Frame unwind methods. */ set_gdbarch_unwind_dummy_id (gdbarch, hppa_unwind_dummy_id); set_gdbarch_unwind_pc (gdbarch, hppa_unwind_pc); + + /* Hook in the default unwinders. */ + frame_unwind_append_sniffer (gdbarch, hppa_stub_unwind_sniffer); frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer); frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer); - - set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read); /* Hook in ABI-specific overrides, if they have been registered. */ gdbarch_init_osabi (info, gdbarch);