public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: swagiaal@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: swagiaal: implemented and tested look up of static member variables.
Date: Wed, 12 Dec 2007 20:33:00 -0000	[thread overview]
Message-ID: <20071212203308.12924.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  75155ba51e20e84ea19a4417c545bcec4a9cc184 (commit)
      from  6499eead93919efbff6580cc9713b1b465648b53 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 75155ba51e20e84ea19a4417c545bcec4a9cc184
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Wed Dec 12 15:22:30 2007 -0500

    swagiaal: implemented and tested look up of static member variables.
    
    frysk-core/frysk/debuginfo/ChangeLog
    +2007-12-11  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +       * TestObjectDeclarationSearchEngine.java (testFindFirstScopesClass): New test.
    +
    +       CompositeType.java (StaticMember.StaticMember): Constructor now
    +       takes a LocationExpression object.
    +       Updated add methods.
    +       * TypeEntry.java: Updated.
    +
    
    frysk-core/frysk/scopes/ChangeLog
    +2007-12-11  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +       * Subprogram.java (getDeclaredObjectByName): Now searches
    +       owning class/structure.
    +       * Composite.java (getDeclaredObjectByName): New.
    +
    
    frysk-core/frysk/value/ChangeLog
    +2007-12-11  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +        * CompositeType.java (StaticMember.StaticMember): Constructor now
    +        takes a LocationExpression object.
    +        Updated add methods.
    +        (Member): now extends object declaration.
    +

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/debuginfo/ChangeLog               |    9 +++
 .../TestObjectDeclarationSearchEngine.java         |   21 +++++---
 frysk-core/frysk/debuginfo/TypeEntry.java          |   16 ++++--
 frysk-core/frysk/scopes/ChangeLog                  |    6 ++
 frysk-core/frysk/scopes/Composite.java             |   13 ++++-
 frysk-core/frysk/scopes/Subprogram.java            |   20 +++++--
 frysk-core/frysk/value/ChangeLog                   |    7 +++
 frysk-core/frysk/value/CompositeType.java          |   58 ++++++++++++++++----
 8 files changed, 122 insertions(+), 28 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog
index e82cb97..aef00ea 100644
--- a/frysk-core/frysk/debuginfo/ChangeLog
+++ b/frysk-core/frysk/debuginfo/ChangeLog
@@ -5,6 +5,15 @@
 	
 2007-12-11  Sami Wagiaalla  <swagiaal@redhat.com>
 
+	* TestObjectDeclarationSearchEngine.java (testFindFirstScopesClass): New test.
+	
+	CompositeType.java (StaticMember.StaticMember): Constructor now
+	takes a LocationExpression object.
+	Updated add methods.
+	* TypeEntry.java: Updated.
+	
+2007-12-11  Sami Wagiaalla  <swagiaal@redhat.com>
+
 	CompositeType constructors and add functions now take LineColPair argument.
 	* TypeEntry.java: Updated.
 
diff --git a/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngine.java b/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngine.java
index 804e8bd..aec571f 100644
--- a/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngine.java
+++ b/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngine.java
@@ -114,7 +114,6 @@ public class TestObjectDeclarationSearchEngine extends TestLib{
     
     public void testFindTwoScopesEnum(){
 	
-	
 	String variableName = "two"; 
 	String fileName = "funit-c-scopes-enum";
 	
@@ -128,7 +127,14 @@ public class TestObjectDeclarationSearchEngine extends TestLib{
 
     }
     
-    
+    public void testFindFirstScopesClass(){
+	String variableName = "first"; 
+	String variableToken = "*this*"; 
+	String fileName = "funit-cpp-scopes-class";
+	String srcPath = Config.getPkgLibSrcDir() + fileName + ".cxx";
+	
+	verifyVariable(variableName, variableToken, fileName, srcPath);
+    }
     
     
     /**
@@ -160,15 +166,16 @@ public class TestObjectDeclarationSearchEngine extends TestLib{
 	Task task = (new DaemonBlockedAtSignal(fileName)).getMainTask();
 	DebugInfoFrame frame = DebugInfoStackFactory.createVirtualStackTrace(task);
 	objectDeclarationSearchEngine = new ObjectDeclarationSearchEngine(frame);
-	Variable variable = (Variable) objectDeclarationSearchEngine.getVariable(variableName);
+	ObjectDeclaration objectDeclaration = (ObjectDeclaration) objectDeclarationSearchEngine.getVariable(variableName);
 
-	assertNotNull("Variable found", variable);
-	assertTrue("Found the correct variable", variable.getLineNumber() == variableLine);
+	assertNotNull("Variable found", objectDeclaration);
+	assertEquals("Correct name", variableName, objectDeclaration.getName() );
+	assertEquals("Found the correct variable on the correct line ", variableLine, objectDeclaration.getLineCol().getLine());
 	
 	//Negative test:
 	try {
-	    variable = (Variable) objectDeclarationSearchEngine.getVariable("NOT"+variableName);
-	    assertTrue("Exception was thrown", false);
+	    objectDeclaration = (Variable) objectDeclarationSearchEngine.getVariable("NOT"+variableName);
+	    assertTrue("Exception was not thrown", false);
 	} catch (ObjectDeclaratioinNotFoundException e) {
 	    // exception was thrown
 	}
diff --git a/frysk-core/frysk/debuginfo/TypeEntry.java b/frysk-core/frysk/debuginfo/TypeEntry.java
index 97ac24e..8d8391a 100644
--- a/frysk-core/frysk/debuginfo/TypeEntry.java
+++ b/frysk-core/frysk/debuginfo/TypeEntry.java
@@ -128,6 +128,8 @@ public class TypeEntry
      */
     public GccStructOrClassType getGccStructOrClassType(DwarfDie classDie, String name) {
 	
+	LocationExpression locationExpression = null;
+
 	dumpDie("classDie=", classDie);
 
 	GccStructOrClassType classType = new GccStructOrClassType(name, getByteSize(classDie));
@@ -145,6 +147,12 @@ public class TypeEntry
 	    } catch (DwAttributeNotFoundException de) {
 		offset = 0; // union
 		staticMember = true;
+		if(member.isDeclaration()){
+		    locationExpression = new LocationExpression(member.getDefinition());
+		}else{
+		    locationExpression = new LocationExpression(member);
+		}
+
 	    }
 	    
 	    LineColPair lineColPair;
@@ -166,7 +174,7 @@ public class TypeEntry
 		if(hasArtifitialParameter(member)){
 		    classType.addMember(member.getName(), lineColPair, v.getType(), offset, access);
 		}else{
-		    classType.addStaticMember(member.getName(), lineColPair, v.getType(), offset, access);
+		    classType.addStaticMember(locationExpression, member.getName(), lineColPair, v.getType(), offset, access);
 		}
 		continue;
 	    }
@@ -184,7 +192,7 @@ public class TypeEntry
 		    int bitOffset = member
 		    .getAttrConstant(DwAt.BIT_OFFSET);
 		    if(staticMember){
-			classType.addStaticBitFieldMember(member.getName(), lineColPair, memberType, offset, access,
+			classType.addStaticBitFieldMember(locationExpression, member.getName(), lineColPair, memberType, offset, access,
 				    bitOffset, bitSize);
 		    }else{
 			classType.addBitFieldMember(member.getName(), lineColPair, memberType, offset, access,
@@ -193,7 +201,7 @@ public class TypeEntry
 		}
 		else{
 		    if(staticMember){
-			classType.addStaticMember(member.getName(), lineColPair, memberType, offset, access);
+			classType.addStaticMember(locationExpression, member.getName(), lineColPair, memberType, offset, access);
 		    }else{
 			classType.addMember(member.getName(), lineColPair, memberType, offset, access);
 		    }
@@ -203,7 +211,7 @@ public class TypeEntry
 	    }
 	    else{
 		if(staticMember){
-		    classType.addStaticMember(member.getName(), lineColPair, new UnknownType(member
+		    classType.addStaticMember(locationExpression, member.getName(), lineColPair, new UnknownType(member
 			.getName()), offset, access);
 		}else{
 		    classType.addMember(member.getName(), lineColPair, new UnknownType(member
diff --git a/frysk-core/frysk/scopes/ChangeLog b/frysk-core/frysk/scopes/ChangeLog
index 4615e8a..3422528 100644
--- a/frysk-core/frysk/scopes/ChangeLog
+++ b/frysk-core/frysk/scopes/ChangeLog
@@ -1,5 +1,11 @@
 2007-12-11  Sami Wagiaalla  <swagiaal@redhat.com>
 
+	* Subprogram.java (getDeclaredObjectByName): Now searches
+	owning class/structure.
+	* Composite.java (getDeclaredObjectByName): New.
+
+2007-12-11  Sami Wagiaalla  <swagiaal@redhat.com>
+
 	* LineColPair.java: New.
 
 2007-12-10  Sami Wagiaalla  <swagiaal@redhat.com>
diff --git a/frysk-core/frysk/scopes/Composite.java b/frysk-core/frysk/scopes/Composite.java
index f344ce3..7c02cbd 100644
--- a/frysk-core/frysk/scopes/Composite.java
+++ b/frysk-core/frysk/scopes/Composite.java
@@ -39,10 +39,11 @@
 
 package frysk.scopes;
 
+import lib.dwfl.DwarfDie;
 import frysk.debuginfo.TypeEntry;
 import frysk.value.CompositeType;
+import frysk.value.ObjectDeclaration;
 import frysk.value.Type;
-import lib.dwfl.DwarfDie;
 
 /**
  * A Composite object is a scope to wich a function can belong:
@@ -65,4 +66,14 @@ public class Composite extends Scope {
     public Type getType(){
 	return this.compositeType;
     }
+    
+    public ObjectDeclaration getDeclaredObjectByName(String name) {
+	ObjectDeclaration objectDeclaration;
+	
+	objectDeclaration = this.compositeType.getDeclaredObjectByName(name);
+	
+	return objectDeclaration;
+    }
+	 
+    
 }
diff --git a/frysk-core/frysk/scopes/Subprogram.java b/frysk-core/frysk/scopes/Subprogram.java
index 3871187..d56ffb4 100644
--- a/frysk-core/frysk/scopes/Subprogram.java
+++ b/frysk-core/frysk/scopes/Subprogram.java
@@ -130,17 +130,27 @@ public class Subprogram extends Subroutine
     }
     
     public ObjectDeclaration getDeclaredObjectByName(String name) {
-	Variable variable = null;
+	ObjectDeclaration objectDeclaration = null;
 
 	Iterator iterator = this.parameters.iterator();
 	while (iterator.hasNext()) {
-	    variable = (Variable) iterator.next();
-	    if (variable.getName().equals(name)) {
-		return variable;
+	    ObjectDeclaration tempObjectDeclaration = (Variable) iterator.next();
+	    if (tempObjectDeclaration.getName().equals(name)) {
+		objectDeclaration = tempObjectDeclaration;
+		continue;
 	    }
 	}
 	
-	return super.getDeclaredObjectByName(name);
+	Composite composite = this.getComposite();
+	if(composite != null){
+	    objectDeclaration = composite.getDeclaredObjectByName(name);
+	}
+	
+	if(objectDeclaration == null){
+	    objectDeclaration =  super.getDeclaredObjectByName(name);
+	}
+	
+	return objectDeclaration;
     }
 
 }
diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog
index 968ef85..40ece2c 100644
--- a/frysk-core/frysk/value/ChangeLog
+++ b/frysk-core/frysk/value/ChangeLog
@@ -1,3 +1,10 @@
+2007-12-11  Sami Wagiaalla  <swagiaal@redhat.com>
+ 
+        * CompositeType.java (StaticMember.StaticMember): Constructor now
+        takes a LocationExpression object.
+        Updated add methods.
+        (Member): now extends object declaration.
+ 
 2007-12-11  Stan Cox  <scox@redhat.com>
 
 	* Type.java (toPrint(StringBuilder, int)): Change signature from
diff --git a/frysk-core/frysk/value/CompositeType.java b/frysk-core/frysk/value/CompositeType.java
index 3a26ecb..a1dbfe9 100644
--- a/frysk-core/frysk/value/CompositeType.java
+++ b/frysk-core/frysk/value/CompositeType.java
@@ -48,6 +48,10 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import frysk.debuginfo.DebugInfoFrame;
+import frysk.debuginfo.LocationExpression;
+import frysk.debuginfo.PieceLocation;
+import frysk.isa.ISA;
 import frysk.scopes.LineColPair;
 
 /**
@@ -57,7 +61,8 @@ public abstract class CompositeType
     extends Type
 {
     
-    public static class Member{
+    public static abstract class Member extends ObjectDeclaration {
+	
 	private final LineColPair lineColPair;
 	final int index;
 	final String name;
@@ -83,19 +88,35 @@ public abstract class CompositeType
 	    return this.name;
 	}
 	
-	public LineColPair getLinCol(){
+	public LineColPair getLineCol() {
 	    return this.lineColPair;
 	}
+
+	public Type getType(ISA isa) {
+	    return this.type;
+	}
+
+	public abstract Value getValue(DebugInfoFrame frame);
+	
     }
     
     public static class StaticMember extends Member{
-	
-	public StaticMember(int index, String name, LineColPair lineColPair, Type type, Access access,
+	private final LocationExpression locationExpression;
+	public StaticMember(LocationExpression locationExpression, int index, String name, LineColPair lineColPair, Type type, Access access,
 		int bitOffset, int bitSize,
 		boolean inheritance) {
-	    super(index, name, lineColPair, type, access, bitOffset, bitSize, inheritance);
+           super(index, name, lineColPair, type, access, bitOffset, bitSize, inheritance);
+           this.locationExpression = locationExpression;
+       }
+	     
+	public Value getValue(DebugInfoFrame frame) {
+	    ISA isa = frame.getTask().getISA();
+	    PieceLocation pieceLocation
+	    = new PieceLocation(locationExpression.decode(frame, this.getType(isa)
+	                                                                     .getSize()));
+	    Value value = new Value(this.getType(isa), pieceLocation);
+	    return value;
 	}
-
     }
     
     /**
@@ -127,7 +148,17 @@ public abstract class CompositeType
 	private Value getValue (Value v) {
 	    int off = (int)offset;
 	    return new Value(type, v.getLocation().slice(off, type.getSize()));
-	}   
+	}
+
+	/**
+	 * @deprecated
+	 */
+	public Value getValue(DebugInfoFrame frame) {
+	    //this should not be used. without an instance non static members
+	    // do not have a value.
+	    throw new NullPointerException("trying to get a value of a non static member");
+	}
+
     }
     /**
      * A mapping from NAME to Member; only useful for named members.
@@ -201,18 +232,18 @@ public abstract class CompositeType
 	return addMemberToMap(member);
     }
     
-    public CompositeType addStaticMember(String name, LineColPair lineColPair, Type type, long offset,
+    public CompositeType addStaticMember(LocationExpression locationExpression, String name, LineColPair lineColPair, Type type, long offset,
 		   Access access){
-	StaticMember member = new StaticMember(members.size(), name, lineColPair, type,
+	StaticMember member = new StaticMember(locationExpression, members.size(), name, lineColPair, type,
 		   access, -1, -1, false);
 	return addMemberToMap(member);
     }
     
-    public CompositeType addStaticBitFieldMember(String name, LineColPair lineColPair, Type type, long offset,
+    public CompositeType addStaticBitFieldMember(LocationExpression locationExpression, String name, LineColPair lineColPair, Type type, long offset,
 		   Access access, int bitOffset,
 		   int bitLength) {
 	type = type.pack(bitOffset, bitLength);
-	StaticMember member = new StaticMember(members.size(), name, lineColPair, type,
+	StaticMember member = new StaticMember(locationExpression, members.size(), name, lineColPair, type,
 		   access, -1, -1, false);
 	return addMemberToMap(member);
     }
@@ -375,4 +406,9 @@ public abstract class CompositeType
 	}
 	return completions > 0;
     }
+    
+    public ObjectDeclaration getDeclaredObjectByName(String name){
+	return (ObjectDeclaration) nameToMember.get(name);
+    }
+	 
 }


hooks/post-receive
--
frysk system monitor/debugger


                 reply	other threads:[~2007-12-12 20:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20071212203308.12924.qmail@sourceware.org \
    --to=swagiaal@sourceware.org \
    --cc=frysk-cvs@sourceware.org \
    --cc=frysk@sourceware.org \
    /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).