This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Let dwarf2 CFI's execute_stack_op be used outside of CFI


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 <dan@dberlin.org> 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  <dan@dberlin.org>
> >
> >       * 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  <dan@dberlin.org>
> > +
> > +     * 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]