Author: sewardj
Date: 2008-02-26 17:23:54 +0000 (Tue, 26 Feb 2008)
New Revision: 7478

Log:
In ML_(evaluate_Dwarf3_Expr): apply the relevant .data segment bias
when evaluating DW_OP_addr.  This makes variable identification work
much better in shared libraries (which have nonzero biases).  Most of
the change is merely plumbing, to get the data_bias to the place where
it is needed.



Modified:
   branches/DATASYMS/coregrind/m_debuginfo/d3basics.c
   branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c
   branches/DATASYMS/coregrind/m_debuginfo/priv_d3basics.h
   branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c
   branches/DATASYMS/coregrind/m_debuginfo/tytypes.c


Modified: branches/DATASYMS/coregrind/m_debuginfo/d3basics.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/d3basics.c  2008-02-26 16:07:41 UTC 
(rev 7477)
+++ branches/DATASYMS/coregrind/m_debuginfo/d3basics.c  2008-02-26 17:23:54 UTC 
(rev 7478)
@@ -402,6 +402,7 @@
    priv_d3basics.h. */
 GXResult ML_(evaluate_Dwarf3_Expr) ( UChar* expr, UWord exprszB, 
                                      GExpr* fbGX, RegSummary* regs,
+                                     Addr data_bias,
                                      Bool push_initial_zero )
 {
 #  define N_EXPR_STACK 20
@@ -496,16 +497,19 @@
       opcode = *expr++;
       switch (opcode) {
          case DW_OP_addr:
-            /* FIXME: surely this is an svma?  Should be t- or d-
-               biased before being pushed? */
-            PUSH( *(Addr*)expr ); 
+            /* Presumably what is given in the Dwarf3 is a SVMA (how
+               could it be otherwise?)  So we add the data bias on
+               before pushing the result.  FIXME: how can we be sure
+               the data bias is intended, not the text bias?  I don't
+               know. */
+            PUSH( *(Addr*)expr + data_bias ); 
             expr += sizeof(Addr);
             break;
          case DW_OP_fbreg:
             if (!fbGX)
                FAIL("evaluate_Dwarf3_Expr: DW_OP_fbreg with "
                     "no expr for fbreg present");
-            fbval = ML_(evaluate_GX)(fbGX, NULL, regs);
+            fbval = ML_(evaluate_GX)(fbGX, NULL, regs, data_bias);
             /* Convert fbval into something we can use.  If we got a
                Value, no problem.  However, as per D3 spec sec 3.3.5
                (Low Level Information) sec 2, we could also get a
@@ -599,7 +603,8 @@
 
 /* Evaluate a so-called Guarded (DWARF3) expression.  See detailed
    description in priv_d3basics.h. */
-GXResult ML_(evaluate_GX)( GExpr* gx, GExpr* fbGX, RegSummary* regs )
+GXResult ML_(evaluate_GX)( GExpr* gx, GExpr* fbGX,
+                           RegSummary* regs, Addr data_bias )
 {
    GXResult res;
    Addr     aMin, aMax;
@@ -631,7 +636,7 @@
          /* Assert this is the first guard. */
          vg_assert(nGuards == 1);
          res = ML_(evaluate_Dwarf3_Expr)(
-                  p, (UWord)nbytes, fbGX, regs,
+                  p, (UWord)nbytes, fbGX, regs, data_bias,
                   False/*push_initial_zero*/ );
          /* Now check there are no more guards. */
          p += (UWord)nbytes;
@@ -641,7 +646,7 @@
          if (aMin <= regs->ip && regs->ip <= aMax) {
             /* found a matching range.  Evaluate the expression. */
             return ML_(evaluate_Dwarf3_Expr)(
-                      p, (UWord)nbytes, fbGX, regs,
+                      p, (UWord)nbytes, fbGX, regs, data_bias,
                       False/*push_initial_zero*/ );
          }
       }

Modified: branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c 2008-02-26 16:07:41 UTC 
(rev 7477)
+++ branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c 2008-02-26 17:23:54 UTC 
(rev 7478)
@@ -1595,7 +1595,8 @@
 static Bool data_address_is_in_var ( /*OUT*/UWord* offset,
                                      DiVariable*   var,
                                      RegSummary*   regs,
-                                     Addr          data_addr )
+                                     Addr          data_addr,
+                                     Addr          data_bias )
 {
    MaybeUWord muw;
    SizeT      var_szB;
@@ -1626,7 +1627,7 @@
       return False;
    }
 
-   res = ML_(evaluate_GX)( var->gexpr, var->fbGX, regs );
+   res = ML_(evaluate_GX)( var->gexpr, var->fbGX, regs, data_bias );
 
    if (show) {
       VG_(printf)("VVVV: -> ");
@@ -1897,7 +1898,8 @@
       for (j = 0; j < VG_(sizeXA)( vars ); j++) {
          DiVariable* var = (DiVariable*)VG_(indexXA)( vars, j );
          SizeT       offset;
-         if (data_address_is_in_var( &offset, var, &regs, data_addr )) {
+         if (data_address_is_in_var( &offset, var, &regs, data_addr,
+                                     di->data_bias )) {
             OffT residual_offset = 0;
             XArray* described = ML_(describe_type)( &residual_offset,
                                                     var->type, offset );
@@ -1996,7 +1998,7 @@
             fail. */
          if (data_address_is_in_var( &offset, var, 
                                      NULL/* RegSummary* */, 
-                                     data_addr )) {
+                                     data_addr, di->data_bias )) {
             OffT residual_offset = 0;
             XArray* described = ML_(describe_type)( &residual_offset,
                                                     var->type, offset );

Modified: branches/DATASYMS/coregrind/m_debuginfo/priv_d3basics.h
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/priv_d3basics.h     2008-02-26 
16:07:41 UTC (rev 7477)
+++ branches/DATASYMS/coregrind/m_debuginfo/priv_d3basics.h     2008-02-26 
17:23:54 UTC (rev 7478)
@@ -621,7 +621,8 @@
    computed, then fbGX can provide an expression for it.  If fbGX is
    NULL but the frame base is still needed, then evaluation of gx as a
    whole will fail. */
-GXResult ML_(evaluate_GX)( GExpr* gx, GExpr* fbGX, RegSummary* regs );
+GXResult ML_(evaluate_GX)( GExpr* gx, GExpr* fbGX,
+                           RegSummary* regs, Addr data_bias );
 
 /* This is a subsidiary of ML_(evaluate_GX), which just evaluates a
    single standard DWARF3 expression.  Conventions w.r.t regs and fbGX
@@ -632,6 +633,7 @@
    recursive. */
 GXResult ML_(evaluate_Dwarf3_Expr) ( UChar* expr, UWord exprszB, 
                                      GExpr* fbGX, RegSummary* regs,
+                                     Addr data_bias,
                                      Bool push_initial_zero );
 
 #endif /* ndef __PRIV_D3BASICS_H */

Modified: branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c        2008-02-26 
16:07:41 UTC (rev 7477)
+++ branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c        2008-02-26 
17:23:54 UTC (rev 7478)
@@ -84,6 +84,13 @@
    different DIEs (generally a declarer and a definer).  We punt on
    these.  Could do better here.
 
+   The 'data_bias' argument passed to the expression evaluator
+   (ML_(evaluate_Dwarf3_Expr)) should really be changed to a
+   MaybeUWord, to make it clear when we do vs don't know what it is
+   for the evaluation of an expression.  At the moment zero is passed
+   for this parameter in the don't know case.  That's a bit fragile
+   and obscure; using a MaybeUWord would be clearer.
+
    POTENTIAL PERFORMANCE IMPROVEMENTS:
 
    The number of type entities that end up in the list of TyAdmins

Modified: branches/DATASYMS/coregrind/m_debuginfo/tytypes.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/tytypes.c   2008-02-26 16:07:41 UTC 
(rev 7477)
+++ branches/DATASYMS/coregrind/m_debuginfo/tytypes.c   2008-02-26 17:23:54 UTC 
(rev 7478)
@@ -473,10 +473,18 @@
                field = *(TyField**)VG_(indexXA)( fields, i );
                vg_assert(field);
                vg_assert(field->loc);
+               /* Re data_bias in this call, we should really send in
+                  a legitimate value.  But the expression is expected
+                  to be a constant expression, evaluation of which
+                  will not need to use DW_OP_addr and hence we can
+                  avoid the trouble of plumbing the data bias through
+                  to this point (if, indeed, it has any meaning; from
+                  which DebugInfo would we take the data bias? */
                res = ML_(evaluate_Dwarf3_Expr)(
                        field->loc->bytes, field->loc->nbytes,
                        NULL/*fbGX*/, NULL/*RegSummary*/,
-                       True/*push_initial_zero*/ );
+                       0/*data_bias*/,
+                       True/*push_initial_zero*/);
                if (0) {
                   VG_(printf)("QQQ ");
                   ML_(pp_GXResult)(res);


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to