Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: RFA/dwarf: Fix the GCC 2.95.3 store.exp regression for multi-register variables
@ 2003-04-04  6:42 Michael Elizabeth Chastain
  2003-04-10 18:01 ` Elena Zannoni
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Elizabeth Chastain @ 2003-04-04  6:42 UTC (permalink / raw)
  To: drow, ezannoni; +Cc: gdb-patches

My test bed says that this is okay.  It fixes the regression in
store.exp with gcc 2.95.3 -gdwarf-2 (gcc 2.95.3 is the only compiler
that puts this particular struct into a register).  And it doesn't
have any regressions with any gcc v2 or v3, dwarf-2 or stabs+,
on my native i686-pc-linux-gnu.

I have another PR for this, gdb/1107, that comes with a source file
and an executable file.  With this patch, gdb HEAD changes from
'new bad behavior' back to 'same bad behavior as 5.3'.  Specifically,
I have a structure which is in %ebx and %esi.  gdb 5.3 prints values
from %ebx and %esp (the next register in 'info registers').
gdb HEAD prints %ebx and something from god knows where, and
gdb HEAD + patch prints %ebx and %esp again.

(I really hate it when gdb prints the wrong numbers!)

With this patch gdb is better in the store.exp case and not any
worse in the gdb/1107 case.  What the heck, here's a table:

                    store.exp  gdb/1107
  gdb 5.3           okay       wrong
  gdb HEAD          wrong      wrong
  gdb HEAD + drow   okay       wrong

So ... recommended for approval.  If it goes in then we can maybe talk
about gdb/1107 some more.

Michael C

===

2003-03-12  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2expr.h (struct dwarf_expr_context): Remove extra arguments
	to read_reg and update its comment.  Remove regnum member.
	* dwarf2expr.c (execute_stack_op): Remove memaddr and expr_lval.
	Don't call read_reg when setting in_reg.  Call read_reg to get
	the frame base if it's in a register.  Return the register number
	on the stack instead of in the context.  Remove extra arguments
	to read_reg.
	* dwarf2loc.c (dwarf_expr_read_reg): Remove extra arguments.
	(dwarf2_evaluate_loc_desc): Call value_from_register.  Expect
	the register number on the expression stack.
	(needs_frame_read_reg): Remove extra arguments.


^ permalink raw reply	[flat|nested] 6+ messages in thread
* RFA/dwarf: Fix the GCC 2.95.3 store.exp regression for multi-register variables
@ 2003-03-12 20:41 Daniel Jacobowitz
  2003-03-13 21:39 ` Stephane Carrez
  2003-04-03 21:52 ` Elena Zannoni
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2003-03-12 20:41 UTC (permalink / raw)
  To: gdb-patches

This kills both a hack and the regression discussed on gdb@.  Instead of
returning the value of the register and the register number, if the
expression evaluator only returns the register number, we can use
value_from_register.  This way we share multi-register variable handling
with the non-LOC_COMPUTED case.

This patch removes a FIXME and an interface I didn't much like (the lval
argument to dwarf_expr_read_reg) so I'm pretty happy with it.  Everything
should go back to working that worked before.

Is this OK?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-03-12  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2expr.h (struct dwarf_expr_context): Remove extra arguments
	to read_reg and update its comment.  Remove regnum member.
	* dwarf2expr.c (execute_stack_op): Remove memaddr and expr_lval.
	Don't call read_reg when setting in_reg.  Call read_reg to get
	the frame base if it's in a register.  Return the register number
	on the stack instead of in the context.  Remove extra arguments
	to read_reg.
	* dwarf2loc.c (dwarf_expr_read_reg): Remove extra arguments.
	(dwarf2_evaluate_loc_desc): Call value_from_register.  Expect
	the register number on the expression stack.
	(needs_frame_read_reg): Remove extra arguments.

Index: dwarf2expr.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/dwarf2expr.c,v
retrieving revision 1.3
diff -u -p -r1.3 dwarf2expr.c
--- dwarf2expr.c	5 Mar 2003 18:00:02 -0000	1.3
+++ dwarf2expr.c	12 Mar 2003 20:31:06 -0000
@@ -231,11 +231,10 @@ execute_stack_op (struct dwarf_expr_cont
   while (op_ptr < op_end)
     {
       enum dwarf_location_atom op = *op_ptr++;
-      CORE_ADDR result, memaddr;
+      CORE_ADDR result;
       ULONGEST uoffset, reg;
       LONGEST offset;
       int bytes_read;
-      enum lval_type expr_lval;
 
       ctx->in_reg = 0;
 
@@ -361,19 +360,8 @@ execute_stack_op (struct dwarf_expr_cont
 	    error ("DWARF-2 expression error: DW_OP_reg operations must be "
 		   "used alone.");
 
-	  /* FIXME drow/2003-02-21: This call to read_reg could be pushed
-	     into the evaluator's caller by changing the semantics for in_reg.
-	     Then we wouldn't need to return an lval_type and a memaddr.  */
-	  result = (ctx->read_reg) (ctx->baton, op - DW_OP_reg0, &expr_lval,
-				    &memaddr);
-
-	  if (expr_lval == lval_register)
-	    {
-	      ctx->regnum = op - DW_OP_reg0;
-	      ctx->in_reg = 1;
-	    }
-	  else
-	    result = memaddr;
+	  result = op - DW_OP_reg0;
+	  ctx->in_reg = 1;
 
 	  break;
 
@@ -383,16 +371,8 @@ execute_stack_op (struct dwarf_expr_cont
 	    error ("DWARF-2 expression error: DW_OP_reg operations must be "
 		   "used alone.");
 
-	  result = (ctx->read_reg) (ctx->baton, reg, &expr_lval, &memaddr);
-
-	  if (expr_lval == lval_register)
-	    {
-	      ctx->regnum = reg;
-	      ctx->in_reg = 1;
-	    }
-	  else
-	    result = memaddr;
-
+	  result = reg;
+	  ctx->in_reg = 1;
 	  break;
 
 	case DW_OP_breg0:
@@ -429,8 +409,7 @@ execute_stack_op (struct dwarf_expr_cont
 	case DW_OP_breg31:
 	  {
 	    op_ptr = read_sleb128 (op_ptr, op_end, &offset);
-	    result = (ctx->read_reg) (ctx->baton, op - DW_OP_breg0,
-				      &expr_lval, &memaddr);
+	    result = (ctx->read_reg) (ctx->baton, op - DW_OP_breg0);
 	    result += offset;
 	  }
 	  break;
@@ -438,7 +417,7 @@ execute_stack_op (struct dwarf_expr_cont
 	  {
 	    op_ptr = read_uleb128 (op_ptr, op_end, &reg);
 	    op_ptr = read_sleb128 (op_ptr, op_end, &offset);
-	    result = (ctx->read_reg) (ctx->baton, reg, &expr_lval, &memaddr);
+	    result = (ctx->read_reg) (ctx->baton, reg);
 	    result += offset;
 	  }
 	  break;
@@ -457,7 +436,9 @@ execute_stack_op (struct dwarf_expr_cont
 	    (ctx->get_frame_base) (ctx->baton, &datastart, &datalen);
 	    dwarf_expr_eval (ctx, datastart, datalen);
 	    result = dwarf_expr_fetch (ctx, 0);
-	    if (! ctx->in_reg)
+	    if (ctx->in_reg)
+	      result = (ctx->read_reg) (ctx->baton, result);
+	    else
 	      {
 		char *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT);
 		int bytes_read;
Index: dwarf2expr.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/dwarf2expr.h,v
retrieving revision 1.2
diff -u -p -r1.2 dwarf2expr.h
--- dwarf2expr.h	28 Feb 2003 20:03:18 -0000	1.2
+++ dwarf2expr.h	12 Mar 2003 20:31:38 -0000
@@ -36,13 +36,8 @@ struct dwarf_expr_context
      to all of the callback functions.  */
   void *baton;
 
-  /* Return the value of register number REGNUM.  LVALP will be set
-     to the kind of lval this register is (generally lval_register
-     for the current frame's registers or lval_memory for a register
-     saved to the stack).  For lval_memory ADDRP will be set to the
-     saved location of the register.  */
-  CORE_ADDR (*read_reg) (void *baton, int regnum, enum lval_type *lvalp,
-			 CORE_ADDR *addrp);
+  /* Return the value of register number REGNUM.  */
+  CORE_ADDR (*read_reg) (void *baton, int regnum);
 
   /* Read LENGTH bytes at ADDR into BUF.  */
   void (*read_mem) (void *baton, char *buf, CORE_ADDR addr,
@@ -77,12 +72,8 @@ struct dwarf_expr_context
   int recursion_depth, max_recursion_depth;
 
   /* Non-zero if the result is in a register.  The register number
-     will be in REGNUM, and the result will be the contents of the
-     register.  */
+     will be on the expression stack.  */
   int in_reg;
-
-  /* If the result is in a register, the register number.  */
-  int regnum;
 };
 
 struct dwarf_expr_context *new_dwarf_expr_context ();
Index: dwarf2loc.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/dwarf2loc.c,v
retrieving revision 1.3
diff -u -p -r1.3 dwarf2loc.c
--- dwarf2loc.c	5 Mar 2003 18:00:02 -0000	1.3
+++ dwarf2loc.c	12 Mar 2003 20:33:59 -0000
@@ -54,11 +54,11 @@ struct dwarf_expr_baton
    type will be returned in LVALP, and for lval_memory the register
    save address will be returned in ADDRP.  */
 static CORE_ADDR
-dwarf_expr_read_reg (void *baton, int dwarf_regnum, enum lval_type *lvalp,
-		     CORE_ADDR *addrp)
+dwarf_expr_read_reg (void *baton, int dwarf_regnum)
 {
   struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
-  CORE_ADDR result;
+  CORE_ADDR result, save_addr;
+  enum lval_type lval_type;
   char *buf;
   int optimized, regnum, realnum, regsize;
 
@@ -66,8 +66,8 @@ dwarf_expr_read_reg (void *baton, int dw
   regsize = register_size (current_gdbarch, regnum);
   buf = (char *) alloca (regsize);
 
-  frame_register (debaton->frame, regnum, &optimized, lvalp, addrp, &realnum,
-		  buf);
+  frame_register (debaton->frame, regnum, &optimized, &lval_type, &save_addr,
+		  &realnum, buf);
   result = extract_address (buf, regsize);
 
   return result;
@@ -138,21 +138,15 @@ dwarf2_evaluate_loc_desc (struct symbol 
   ctx->get_tls_address = dwarf_expr_tls_address;
 
   dwarf_expr_eval (ctx, data, size);
-
-  retval = allocate_value (SYMBOL_TYPE (var));
-  VALUE_BFD_SECTION (retval) = SYMBOL_BFD_SECTION (var);
+  result = dwarf_expr_fetch (ctx, 0);
 
   if (ctx->in_reg)
-    {
-      store_unsigned_integer (VALUE_CONTENTS_RAW (retval),
-			      TYPE_LENGTH (SYMBOL_TYPE (var)),
-			      dwarf_expr_fetch (ctx, 0));
-      VALUE_LVAL (retval) = lval_register;
-      VALUE_REGNO (retval) = ctx->regnum;
-    }
+    retval = value_from_register (SYMBOL_TYPE (var), result, frame);
   else
     {
-      result = dwarf_expr_fetch (ctx, 0);
+      retval = allocate_value (SYMBOL_TYPE (var));
+      VALUE_BFD_SECTION (retval) = SYMBOL_BFD_SECTION (var);
+
       VALUE_LVAL (retval) = lval_memory;
       VALUE_LAZY (retval) = 1;
       VALUE_ADDRESS (retval) = result;
@@ -176,8 +170,7 @@ struct needs_frame_baton
 
 /* Reads from registers do require a frame.  */
 static CORE_ADDR
-needs_frame_read_reg (void *baton, int regnum, enum lval_type *lvalp,
-			    CORE_ADDR *addrp)
+needs_frame_read_reg (void *baton, int regnum)
 {
   struct needs_frame_baton *nf_baton = baton;
   nf_baton->needs_frame = 1;


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-04-13 15:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-04  6:42 RFA/dwarf: Fix the GCC 2.95.3 store.exp regression for multi-register variables Michael Elizabeth Chastain
2003-04-10 18:01 ` Elena Zannoni
2003-04-13 15:54   ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2003-03-12 20:41 Daniel Jacobowitz
2003-03-13 21:39 ` Stephane Carrez
2003-04-03 21:52 ` Elena Zannoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox