From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3422 invoked by alias); 27 Mar 2002 15:50:02 -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 3338 invoked from network); 27 Mar 2002 15:50:00 -0000 Received: from unknown (HELO tetsuo.nj.caldera.com) (63.124.204.226) by sources.redhat.com with SMTP; 27 Mar 2002 15:50:00 -0000 Received: from caldera.com (localhost.localdomain [127.0.0.1]) by tetsuo.nj.caldera.com (8.11.6/8.11.6) with ESMTP id g2RFuBq02107; Wed, 27 Mar 2002 10:56:11 -0500 Message-ID: <3CA1EB9B.914D9864@caldera.com> Date: Wed, 27 Mar 2002 07:50:00 -0000 From: Petr Sorfa Organization: Caldera X-Accept-Language: en MIME-Version: 1.0 To: Jim Blandy CC: Daniel Berlin , gdb-patches@sources.redhat.com Subject: Re: [PATCH] Let dwarf2 CFI's execute_stack_op be used outside of CFI References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-03/txt/msg00539.txt.bz2 Hi Jim, > Actually, Daniel, I'm sorry --- I've re-read the change more > carefully, and I've gotten more confused than I was before. > > You've changed the Dwarf 2 location expression evaluator to consult > the current register values --- not the values of the registers with > respect to a specific stack frame. I can't think of any situations in > which this the correct behavior. Can you explain more about the > contexts in which this change is useful? It seems to me that it's > wrong in most of the cases I can think of. It really needs to take a > frame argument, or at the very least, read registers from the selected > frame (although that's kind of gross and global-variable-ish). I agree with you Jim. It needs to be frame relative. Petr > > Daniel Berlin writes: > > > This patch simply adds an external entry point (dwarf2_execute_stack_op), > > that doesn't require the CFA context. It also adds code so that when the > > context passed to execute_stack_op is NULL, we use read_register_gen to > > get registers. > > > > Along the way, I made an obvious fix to DW_OP_deref_size that i'll commit > > separately, but included in the changelog/patch because i didn't want to > > hand edit it out. > > > > > > I also added my name to the top of the file, since in reality, it's based > > on code I sent Jiri. > > > > --Dan > > 2002-03-25 Daniel Berlin > > > > * dwarf2cfi.c (dwarf2_execute_stack_op): New function, external > > entry point to execute_stack_op that doesn't require context. > > (execute_stack_op): If context is NULL, don't use get_reg, use > > read_register_gen. > > Also fix bug in DW_OP_deref_size. > > > > * dwarf2cfi.h (dwarf2_execute_stack_op): New prototype. > > Index: dwarf2cfi.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v > > retrieving revision 1.1 > > diff -c -3 -p -w -B -b -r1.1 dwarf2cfi.c > > *** dwarf2cfi.c 2001/12/07 12:10:15 1.1 > > --- dwarf2cfi.c 2002/03/25 23:50:16 > > *************** > > *** 1,7 **** > > /* Stack unwinding code based on dwarf2 frame info for GDB, the GNU debugger. > > ! Copyright 2001 > > Free Software Foundation, Inc. > > Contributed by Jiri Smid, SuSE Labs. > > > > This file is part of GDB. > > > > --- 1,8 ---- > > /* Stack unwinding code based on dwarf2 frame info for GDB, the GNU debugger. > > ! Copyright 2001, 2002 > > Free Software Foundation, Inc. > > Contributed by Jiri Smid, SuSE Labs. > > + Based on code written by Daniel Berlin (dan@dberlin.org) > > > > This file is part of GDB. > > > > *************** get_reg (char *reg, struct context *cont > > *** 840,845 **** > > --- 841,854 ---- > > } > > } > > > > + /* External entry point for executing dwarf2 stack operations. */ > > + CORE_ADDR > > + dwarf2_execute_stack_op (struct objfile *objfile, char *op_ptr, > > + char *op_end, CORE_ADDR initial) > > + { > > + return execute_stack_op (objfile, op_ptr, op_end, NULL, initial); > > + } > > + > > /* Decode a DW_OP stack program. Return the top of stack. Push INITIAL > > onto the stack to start. */ > > static CORE_ADDR > > *************** execute_stack_op (struct objfile *objfil > > *** 963,973 **** > > --- 972,989 ---- > > case DW_OP_reg29: > > case DW_OP_reg30: > > case DW_OP_reg31: > > + if (context) > > get_reg ((char *) &result, context, op - DW_OP_reg0); > > + else > > + read_register_gen (op - DW_OP_reg0, (char *)&result); > > + > > break; > > case DW_OP_regx: > > reg = read_uleb128 (objfile->obfd, &op_ptr); > > + if (context) > > get_reg ((char *) &result, context, reg); > > + else > > + read_register_gen (reg, (char *)&result); > > break; > > > > case DW_OP_breg0: > > *************** execute_stack_op (struct objfile *objfil > > *** 1003,1015 **** > > --- 1019,1038 ---- > > case DW_OP_breg30: > > case DW_OP_breg31: > > offset = read_sleb128 (objfile->obfd, &op_ptr); > > + if (context) > > get_reg ((char *) &result, context, op - DW_OP_breg0); > > + else > > + read_register_gen (op - DW_OP_breg0, (char *)&result); > > + > > result += offset; > > break; > > case DW_OP_bregx: > > reg = read_uleb128 (objfile->obfd, &op_ptr); > > offset = read_sleb128 (objfile->obfd, &op_ptr); > > + if (context) > > get_reg ((char *) &result, context, reg); > > + else > > + read_register_gen (reg, (char *)&result); > > result += offset; > > break; > > > > *************** execute_stack_op (struct objfile *objfil > > *** 1067,1080 **** > > { > > case DW_OP_deref: > > { > > ! char *ptr = (char *) result; > > result = read_pointer (objfile->obfd, &ptr); > > } > > break; > > > > case DW_OP_deref_size: > > { > > ! char *ptr = (char *) result; > > switch (*op_ptr++) > > { > > case 1: > > --- 1090,1103 ---- > > { > > case DW_OP_deref: > > { > > ! char *ptr = (char *) &result; > > result = read_pointer (objfile->obfd, &ptr); > > } > > break; > > > > case DW_OP_deref_size: > > { > > ! char *ptr = (char *) &result; > > switch (*op_ptr++) > > { > > case 1: > > Index: dwarf2cfi.h > > =================================================================== > > RCS file: /cvs/src/src/gdb/dwarf2cfi.h,v > > retrieving revision 1.1 > > diff -c -3 -p -w -B -b -r1.1 dwarf2cfi.h > > *** dwarf2cfi.h 2001/12/07 12:10:15 1.1 > > --- dwarf2cfi.h 2002/03/25 23:50:16 > > *************** void cfi_get_saved_register (char *raw_b > > *** 63,66 **** > > --- 63,72 ---- > > void cfi_virtual_frame_pointer (CORE_ADDR pc, int *frame_regnum, > > LONGEST * frame_offset); > > > > + /* Execute a set of DWARF2 stack operations, starting with INITIAL > > + as the address on the stack. */ > > + CORE_ADDR dwarf2_execute_stack_op (struct objfile *objfile, > > + char *op_ptr, char *op_end, > > + CORE_ADDR initial); > > + > > #endif > > Index: ChangeLog > > =================================================================== > > RCS file: /cvs/src/src/gdb/ChangeLog,v > > retrieving revision 1.2349 > > diff -c -3 -p -w -B -b -r1.2349 ChangeLog > > *** ChangeLog 2002/03/25 19:47:39 1.2349 > > --- ChangeLog 2002/03/25 23:50:17 > > *************** > > *** 1,3 **** > > --- 1,12 ---- > > + 2002-03-25 Daniel Berlin > > + > > + * dwarf2cfi.c (dwarf2_execute_stack_op): New function, external > > + entry point to execute_stack_op that doesn't require context. > > + (execute_stack_op): If context is NULL, don't use get_reg, use > > + read_register_gen. > > + > > + * dwarf2cfi.h (dwarf2_execute_stack_op): New prototype. > > + > > 2002-03-25 Jeff Law (law@redhat.com) > > > > * linux-proc.c (read_mapping): Scan up to end of line for filename.