public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* LocationExpression patch
@ 2007-11-27 21:31 Sami Wagiaalla
  2007-11-28 14:55 ` Andrew Cagney
  2007-11-28 16:03 ` Teresa Thomas
  0 siblings, 2 replies; 3+ messages in thread
From: Sami Wagiaalla @ 2007-11-27 21:31 UTC (permalink / raw)
  To: Andrew Cagney, Teresa Thomas; +Cc: frysk

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

Cagney, Teresa,

What do you think of the attached path.
This will help me reduce dependence on DwarfDie. If the information can 
be extracted from DwarfDie at construction time then that will eliminate 
the need to keep a ref to the die around.

This is an issure for Variable and CompositeType::StatickMember

Sami

[-- Attachment #2: LocationExpression.patch --]
[-- Type: text/x-patch, Size: 7000 bytes --]

diff --git a/frysk-core/frysk/debuginfo/LocationExpression.java b/frysk-core/frysk/debuginfo/LocationExpression.java
index 48c9258..d61b7c0 100644
--- a/frysk-core/frysk/debuginfo/LocationExpression.java
+++ b/frysk-core/frysk/debuginfo/LocationExpression.java
@@ -39,45 +39,38 @@
 
 package frysk.debuginfo;
 
-import java.lang.Math;
-
-import java.util.LinkedList;
 import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.List;
 
-import frysk.isa.ISA;
-import frysk.isa.Register;
-import frysk.stack.Frame;
+import lib.dwfl.DwAt;
+import lib.dwfl.DwOp;
 import lib.dwfl.DwarfDie;
 import lib.dwfl.DwarfOp;
-import lib.dwfl.DwOp;
-import lib.dwfl.DwAt;
+import frysk.isa.Register;
+import frysk.stack.Frame;
 
 public class LocationExpression {
     public final static int locationTypeRegDisp = 1,
     locationTypeAddress = 2,
     locationTypeReg = 3;
-    private final Frame frame;
     DwarfDie die;
     List ops;
     int locationType;
     LinkedList stack;
-    private final ISA isa;
 
-    public LocationExpression(Frame frame, DwarfDie die, List ops) {
+    public LocationExpression(DwarfDie die, List ops) {
 	locationType = 0;
-	this.frame = frame;
 	this.die = die;
 	this.ops = ops;
 	this.stack = null;
-	this.isa = frame.getTask().getISA();
     }
 
     /**
      *  Decode a location list and return the value.
      *
      */
-    public long decode () {
+    public long decode (Frame frame) {
 	stack = new LinkedList();
 	int nops = ops.size();
 
@@ -162,7 +155,7 @@ public class LocationExpression {
 	    case DwOp.REG31_:
 		if (locationType == 0) 
 		    locationType = locationTypeReg;
-		Register register = DwarfRegisterMapFactory.getRegisterMap(isa)
+		Register register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
 		.getRegister(operator - DwOp.REG0_);
 		long regval = frame.getRegister(register);
 		stack.addFirst(new Long(regval));
@@ -201,7 +194,7 @@ public class LocationExpression {
 	    case DwOp.BREG30_:
 	    case DwOp.BREG31_:
 		locationType = locationTypeRegDisp;
-		register = DwarfRegisterMapFactory.getRegisterMap(isa)
+		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
 		.getRegister(operator - DwOp.BREG0_);
 		regval = frame.getRegister(register);
 		stack.addFirst(new Long(operand1 + regval));
@@ -209,7 +202,7 @@ public class LocationExpression {
 
 
 	    case DwOp.REGX_:
-		register = DwarfRegisterMapFactory.getRegisterMap(isa)
+		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
 		.getRegister((int)operand1);
 		regval = frame.getRegister(register);
 		stack.addFirst(new Long(regval));
@@ -224,8 +217,8 @@ public class LocationExpression {
 	    case DwOp.FBREG_:
 		locationType = locationTypeRegDisp;
 		long pc = frame.getAdjustedAddress();
-		LocationExpression frameBaseOps = new LocationExpression (frame, die, die.getFrameBase(pc));
-		stack.addFirst(new Long(operand1 + frameBaseOps.decode()));
+		LocationExpression frameBaseOps = new LocationExpression (die, die.getFrameBase(pc));
+		stack.addFirst(new Long(operand1 + frameBaseOps.decode(frame)));
 		break;
 
 		// ??? unsigned not properly handled (use bignum?) See DwarfDie.java
@@ -408,7 +401,7 @@ public class LocationExpression {
      * @param size - Size of variable 
      * @return List of memory or register pieces
      */
-    public List decode (int size)
+    public List decode (Frame frame, int size)
     {
 	stack = new LinkedList();
 	int nops = ops.size();
@@ -501,7 +494,7 @@ public class LocationExpression {
 	    case DwOp.REG31_:
 		if (locationType == 0) 
 		    locationType = locationTypeReg;
-		Register register = DwarfRegisterMapFactory.getRegisterMap(isa)
+		Register register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
 		.getRegister(operator - DwOp.REG0_);
 		// Push the register onto the dwfl stack
 		stack.addFirst(register);
@@ -540,7 +533,7 @@ public class LocationExpression {
 	    case DwOp.BREG30_:
 	    case DwOp.BREG31_:
 		locationType = locationTypeRegDisp;
-		register = DwarfRegisterMapFactory.getRegisterMap(isa)
+		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
 		.getRegister(operator - DwOp.BREG0_);
 		long regval = frame.getRegister(register);
 		stack.addFirst(new Long(operand1 + regval));
@@ -549,14 +542,14 @@ public class LocationExpression {
 	    case DwOp.REGX_:
 		if (locationType == 0) 
 		    locationType = locationTypeReg;
-		register = DwarfRegisterMapFactory.getRegisterMap(isa)
+		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
 		.getRegister((int)operand1);
 		stack.addFirst(register);
 		break;
 
 	    case DwOp.BREGX_:
 		locationType = locationTypeRegDisp;
-		register = DwarfRegisterMapFactory.getRegisterMap(isa)
+		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
 		.getRegister((int)operand1);
 		regval = frame.getRegister(register);
 		stack.addFirst(new Long(operand2 + regval));
@@ -571,8 +564,8 @@ public class LocationExpression {
 	    case DwOp.FBREG_:
 		locationType = locationTypeRegDisp;
 		long pc = frame.getAdjustedAddress();
-		LocationExpression frameBaseOps = new LocationExpression (frame, die, die.getFrameBase(pc));
-		stack.addFirst(new Long(operand1 + frameBaseOps.decode()));
+		LocationExpression frameBaseOps = new LocationExpression (die, die.getFrameBase(pc));
+		stack.addFirst(new Long(operand1 + frameBaseOps.decode(frame)));
 		break;
 
 		// ??? unsigned not properly handled (use bignum?) See DwarfDie.java
@@ -760,7 +753,7 @@ public class LocationExpression {
 		    break;
 		}	
 		// Otherwise, check the type of element on stack top and add to list
-		addToList (pieces, operand1);	
+		addToList (frame, pieces, operand1);	
 		break;
 
 	    default:
@@ -774,7 +767,7 @@ public class LocationExpression {
 	 */
 	if (pieces.isEmpty())
 	{    
-	    addToList (pieces, size);
+	    addToList (frame, pieces, size);
 	}    
 
 	return pieces;
@@ -784,7 +777,7 @@ public class LocationExpression {
      * Function that checks the type of element on the stack top and adds it to the
      * list of location
      */
-    private void addToList (List pieces, long size)
+    private void addToList (Frame frame, List pieces, long size)
     {
 	/*
 	 * If stackTop is a Register, add it as a RegisterPiece to list pieces 
@@ -803,13 +796,13 @@ public class LocationExpression {
      *  Return register number for a one entry DW_OP_regX location list 
      *
      */
-    public Register getRegisterNumber () {
+    public Register getRegisterNumber (Frame frame) {
 	if (ops.size() == 1) {
 	    int operator = ((DwarfOp) ops.get(0)).operator;
 	    if (operator >= DwOp.REG0_
 		    || operator <=  DwOp.REG31_) {
 		locationType = locationTypeReg;
-		return DwarfRegisterMapFactory.getRegisterMap(isa)
+		return DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
 		.getRegister(operator - DwOp.REG0_);
 	    }
 	}

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

* Re: LocationExpression patch
  2007-11-27 21:31 LocationExpression patch Sami Wagiaalla
@ 2007-11-28 14:55 ` Andrew Cagney
  2007-11-28 16:03 ` Teresa Thomas
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2007-11-28 14:55 UTC (permalink / raw)
  To: Sami Wagiaalla; +Cc: Teresa Thomas, frysk

Sami Wagiaalla wrote:
> Cagney, Teresa,
>
> What do you think of the attached path.
> This will help me reduce dependence on DwarfDie. If the information 
> can be extracted from DwarfDie at construction time then that will 
> eliminate the need to keep a ref to the die around.
>
Doesn't phase me.

Andrew

> This is an issure for Variable and CompositeType::StatickMember
>
> Sami
> ------------------------------------------------------------------------
>
> diff --git a/frysk-core/frysk/debuginfo/LocationExpression.java b/frysk-core/frysk/debuginfo/LocationExpression.java
> index 48c9258..d61b7c0 100644
> --- a/frysk-core/frysk/debuginfo/LocationExpression.java
> +++ b/frysk-core/frysk/debuginfo/LocationExpression.java
> @@ -39,45 +39,38 @@
>  
>  package frysk.debuginfo;
>  
> -import java.lang.Math;
> -
> -import java.util.LinkedList;
>  import java.util.ArrayList;
> +import java.util.LinkedList;
>  import java.util.List;
>  
> -import frysk.isa.ISA;
> -import frysk.isa.Register;
> -import frysk.stack.Frame;
> +import lib.dwfl.DwAt;
> +import lib.dwfl.DwOp;
>  import lib.dwfl.DwarfDie;
>  import lib.dwfl.DwarfOp;
> -import lib.dwfl.DwOp;
> -import lib.dwfl.DwAt;
> +import frysk.isa.Register;
> +import frysk.stack.Frame;
>  
>  public class LocationExpression {
>      public final static int locationTypeRegDisp = 1,
>      locationTypeAddress = 2,
>      locationTypeReg = 3;
> -    private final Frame frame;
>      DwarfDie die;
>      List ops;
>      int locationType;
>      LinkedList stack;
> -    private final ISA isa;
>  
> -    public LocationExpression(Frame frame, DwarfDie die, List ops) {
> +    public LocationExpression(DwarfDie die, List ops) {
>  	locationType = 0;
> -	this.frame = frame;
>  	this.die = die;
>  	this.ops = ops;
>  	this.stack = null;
> -	this.isa = frame.getTask().getISA();
>      }
>  
>      /**
>       *  Decode a location list and return the value.
>       *
>       */
> -    public long decode () {
> +    public long decode (Frame frame) {
>  	stack = new LinkedList();
>  	int nops = ops.size();
>  
> @@ -162,7 +155,7 @@ public class LocationExpression {
>  	    case DwOp.REG31_:
>  		if (locationType == 0) 
>  		    locationType = locationTypeReg;
> -		Register register = DwarfRegisterMapFactory.getRegisterMap(isa)
> +		Register register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
>  		.getRegister(operator - DwOp.REG0_);
>  		long regval = frame.getRegister(register);
>  		stack.addFirst(new Long(regval));
> @@ -201,7 +194,7 @@ public class LocationExpression {
>  	    case DwOp.BREG30_:
>  	    case DwOp.BREG31_:
>  		locationType = locationTypeRegDisp;
> -		register = DwarfRegisterMapFactory.getRegisterMap(isa)
> +		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
>  		.getRegister(operator - DwOp.BREG0_);
>  		regval = frame.getRegister(register);
>  		stack.addFirst(new Long(operand1 + regval));
> @@ -209,7 +202,7 @@ public class LocationExpression {
>  
>  
>  	    case DwOp.REGX_:
> -		register = DwarfRegisterMapFactory.getRegisterMap(isa)
> +		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
>  		.getRegister((int)operand1);
>  		regval = frame.getRegister(register);
>  		stack.addFirst(new Long(regval));
> @@ -224,8 +217,8 @@ public class LocationExpression {
>  	    case DwOp.FBREG_:
>  		locationType = locationTypeRegDisp;
>  		long pc = frame.getAdjustedAddress();
> -		LocationExpression frameBaseOps = new LocationExpression (frame, die, die.getFrameBase(pc));
> -		stack.addFirst(new Long(operand1 + frameBaseOps.decode()));
> +		LocationExpression frameBaseOps = new LocationExpression (die, die.getFrameBase(pc));
> +		stack.addFirst(new Long(operand1 + frameBaseOps.decode(frame)));
>  		break;
>  
>  		// ??? unsigned not properly handled (use bignum?) See DwarfDie.java
> @@ -408,7 +401,7 @@ public class LocationExpression {
>       * @param size - Size of variable 
>       * @return List of memory or register pieces
>       */
> -    public List decode (int size)
> +    public List decode (Frame frame, int size)
>      {
>  	stack = new LinkedList();
>  	int nops = ops.size();
> @@ -501,7 +494,7 @@ public class LocationExpression {
>  	    case DwOp.REG31_:
>  		if (locationType == 0) 
>  		    locationType = locationTypeReg;
> -		Register register = DwarfRegisterMapFactory.getRegisterMap(isa)
> +		Register register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
>  		.getRegister(operator - DwOp.REG0_);
>  		// Push the register onto the dwfl stack
>  		stack.addFirst(register);
> @@ -540,7 +533,7 @@ public class LocationExpression {
>  	    case DwOp.BREG30_:
>  	    case DwOp.BREG31_:
>  		locationType = locationTypeRegDisp;
> -		register = DwarfRegisterMapFactory.getRegisterMap(isa)
> +		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
>  		.getRegister(operator - DwOp.BREG0_);
>  		long regval = frame.getRegister(register);
>  		stack.addFirst(new Long(operand1 + regval));
> @@ -549,14 +542,14 @@ public class LocationExpression {
>  	    case DwOp.REGX_:
>  		if (locationType == 0) 
>  		    locationType = locationTypeReg;
> -		register = DwarfRegisterMapFactory.getRegisterMap(isa)
> +		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
>  		.getRegister((int)operand1);
>  		stack.addFirst(register);
>  		break;
>  
>  	    case DwOp.BREGX_:
>  		locationType = locationTypeRegDisp;
> -		register = DwarfRegisterMapFactory.getRegisterMap(isa)
> +		register = DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
>  		.getRegister((int)operand1);
>  		regval = frame.getRegister(register);
>  		stack.addFirst(new Long(operand2 + regval));
> @@ -571,8 +564,8 @@ public class LocationExpression {
>  	    case DwOp.FBREG_:
>  		locationType = locationTypeRegDisp;
>  		long pc = frame.getAdjustedAddress();
> -		LocationExpression frameBaseOps = new LocationExpression (frame, die, die.getFrameBase(pc));
> -		stack.addFirst(new Long(operand1 + frameBaseOps.decode()));
> +		LocationExpression frameBaseOps = new LocationExpression (die, die.getFrameBase(pc));
> +		stack.addFirst(new Long(operand1 + frameBaseOps.decode(frame)));
>  		break;
>  
>  		// ??? unsigned not properly handled (use bignum?) See DwarfDie.java
> @@ -760,7 +753,7 @@ public class LocationExpression {
>  		    break;
>  		}	
>  		// Otherwise, check the type of element on stack top and add to list
> -		addToList (pieces, operand1);	
> +		addToList (frame, pieces, operand1);	
>  		break;
>  
>  	    default:
> @@ -774,7 +767,7 @@ public class LocationExpression {
>  	 */
>  	if (pieces.isEmpty())
>  	{    
> -	    addToList (pieces, size);
> +	    addToList (frame, pieces, size);
>  	}    
>  
>  	return pieces;
> @@ -784,7 +777,7 @@ public class LocationExpression {
>       * Function that checks the type of element on the stack top and adds it to the
>       * list of location
>       */
> -    private void addToList (List pieces, long size)
> +    private void addToList (Frame frame, List pieces, long size)
>      {
>  	/*
>  	 * If stackTop is a Register, add it as a RegisterPiece to list pieces 
> @@ -803,13 +796,13 @@ public class LocationExpression {
>       *  Return register number for a one entry DW_OP_regX location list 
>       *
>       */
> -    public Register getRegisterNumber () {
> +    public Register getRegisterNumber (Frame frame) {
>  	if (ops.size() == 1) {
>  	    int operator = ((DwarfOp) ops.get(0)).operator;
>  	    if (operator >= DwOp.REG0_
>  		    || operator <=  DwOp.REG31_) {
>  		locationType = locationTypeReg;
> -		return DwarfRegisterMapFactory.getRegisterMap(isa)
> +		return DwarfRegisterMapFactory.getRegisterMap(frame.getTask().getISA())
>  		.getRegister(operator - DwOp.REG0_);
>  	    }
>  	}
>   

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

* Re: LocationExpression patch
  2007-11-27 21:31 LocationExpression patch Sami Wagiaalla
  2007-11-28 14:55 ` Andrew Cagney
@ 2007-11-28 16:03 ` Teresa Thomas
  1 sibling, 0 replies; 3+ messages in thread
From: Teresa Thomas @ 2007-11-28 16:03 UTC (permalink / raw)
  To: Sami Wagiaalla; +Cc: Andrew Cagney, frysk

Sami Wagiaalla wrote:
> Cagney, Teresa,
>
> What do you think of the attached path.
> This will help me reduce dependence on DwarfDie. If the information 
> can be extracted from DwarfDie at construction time then that will 
> eliminate the need to keep a ref to the die around.
Sure. Looks good to me.

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

end of thread, other threads:[~2007-11-28 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-27 21:31 LocationExpression patch Sami Wagiaalla
2007-11-28 14:55 ` Andrew Cagney
2007-11-28 16:03 ` Teresa Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).