public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@redhat.com>
To: Sami Wagiaalla <swagiaal@redhat.com>
Cc: Teresa Thomas <tthomas@redhat.com>, frysk <frysk@sourceware.org>
Subject: Re: LocationExpression patch
Date: Wed, 28 Nov 2007 14:55:00 -0000	[thread overview]
Message-ID: <474D8157.7030208@redhat.com> (raw)
In-Reply-To: <474C8CA7.2020305@redhat.com>

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_);
>  	    }
>  	}
>   

  reply	other threads:[~2007-11-28 14:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 21:31 Sami Wagiaalla
2007-11-28 14:55 ` Andrew Cagney [this message]
2007-11-28 16:03 ` Teresa Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=474D8157.7030208@redhat.com \
    --to=cagney@redhat.com \
    --cc=frysk@sourceware.org \
    --cc=swagiaal@redhat.com \
    --cc=tthomas@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).