From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4046 invoked by alias); 26 Mar 2002 22:43:05 -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 3995 invoked from network); 26 Mar 2002 22:43:03 -0000 Received: from unknown (HELO dberlin.org) (64.246.6.106) by sources.redhat.com with SMTP; 26 Mar 2002 22:43:03 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by dberlin.org (8.11.6/8.11.6) with ESMTP id g2QMh2m12405; Tue, 26 Mar 2002 17:43:02 -0500 Date: Tue, 26 Mar 2002 14:43:00 -0000 From: Daniel Berlin To: Jim Blandy cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH] Let dwarf2 CFI's execute_stack_op be used outside of CFI In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-03/txt/msg00507.txt.bz2 On 26 Mar 2002, Jim Blandy wrote: > > 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). Whoops. You're right. I must have merged it while on crack or something. I *meant* to add the frame argument, and only require *either* the context argument (Which is what it currently takes, a CFA context) or the frame, but it looks like I messed up. What it *should* look like is closer to the one from the WIP i sent. It should call get_saved_register with the frame argument if the context is null, or get_reg with the context argument if the context is not null. > > > 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. >