From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: Randolph Chung Cc: gdb-patches@sources.redhat.com Subject: Re: [patch/rfa/hppa] Use frame pointer for unwinding Date: Mon, 17 May 2004 15:23:00 -0000 Message-id: <40A8D8E5.9000506@gnu.org> References: <20040516020703.GZ566@tausq.org> <40A78B63.9020102@gnu.org> <20040516170257.GM566@tausq.org> <20040517001310.GO566@tausq.org> <20040517023428.GP566@tausq.org> X-SW-Source: 2004-05/msg00489.html + /* Check to see if a frame pointer is available, and use it for + frame unwinding if it is. + + There are some situations where we need to rely on the frame + pointer to do stack unwinding. For example, if a function calls + alloca (), the stack pointer can get adjusted inside the body of + the function. In this case, the ABI requires that the compiler + maintain a frame pointer for the function. + + The unwind record has a flag (alloca_frame) that indicates that + a function has a variable frame; unfortunately, gcc/binutils + does not set this flag. Instead, whenever a frame pointer is used + and saved on the stack, the Save_SP flag is set. We use this to + decide whether to use the frame pointer for unwinding. */ + + fp = frame_unwind_register_unsigned (next_frame, HPPA_FP_REGNUM); + + if (frame_pc_unwind (next_frame) >= prologue_end + && u->Save_SP && fp != 0) fp will effectively always be non-zero here, so the ``fp != 0'' is a just-in-case? Suggest adding that, and the GCC bug-number, as additions to the comments. + { + cache->base = fp; + + if (hppa_debug) + fprintf_unfiltered (gdb_stdlog, " (base=0x%s) [frame pointer] }", + paddr_nz (cache->base)); + } + else if (frame_pc_unwind (next_frame) >= prologue_end) otherwize ok Andrew