This is the mail archive of the
frysk@sourceware.org
mailing list for the frysk project.
bug 5518 patch
- From: Nurdin Premji <npremji at redhat dot com>
- To: frysk <frysk at sourceware dot org>
- Date: Fri, 04 Jan 2008 21:25:43 -0500
- Subject: bug 5518 patch
The attached patch fixes:
http://sourceware.org/bugzilla/show_bug.cgi?id=5518
I'll be committing (or I guess pushing is a better term using git) it on
Monday but here it is for anyone who wants to play with it early.
Nurdin.
>From e2f86f873919686652c5a6b8c30ad9fa54b12a0d Mon Sep 17 00:00:00 2001
From: Nurdin Premji <nurdin@localhost.localdomain>
Date: Fri, 4 Jan 2008 20:41:04 -0500
Subject: [PATCH] For Bugzilla 5518 Compiler support DWTag.CLASS_TYPE
---
frysk-core/frysk/debuginfo/ChangeLog | 10 +
frysk-core/frysk/debuginfo/TypeEntry.java | 279 +++++++++++++-------
frysk-core/frysk/pkglibdir/ChangeLog | 12 +-
frysk-core/frysk/pkglibdir/funit-complex-class.cxx | 20 ++
.../frysk/pkglibdir/funit-complex-struct.cxx | 16 ++
.../frysk/pkglibdir/funit-inherited-struct.cxx | 21 ++
frysk-core/frysk/pkglibdir/funit-simple-class.cxx | 16 ++
frysk-core/frysk/pkglibdir/funit-simple-struct.cxx | 15 +
frysk-core/frysk/value/ChangeLog | 5 +
frysk-core/frysk/value/ClassType.java | 2 +-
frysk-core/frysk/value/TestClass.java | 132 +++++++++
frysk-sys/frysk/ChangeLog | 7 +-
frysk-sys/frysk/CompilerVersion.java | 9 +
frysk-sys/frysk/cni/CompilerVersion.cxx | 63 +++++
frysk-sys/frysk/junit/ChangeLog | 4 +-
frysk-sys/frysk/junit/TestCase.java | 15 +
frysk-sys/lib/dwfl/ChangeLog | 7 +-
frysk-sys/lib/dwfl/DwarfDie.java | 11 +
frysk-sys/lib/dwfl/cni/DwarfDie.cxx | 19 ++
19 files changed, 565 insertions(+), 98 deletions(-)
create mode 100644 frysk-core/frysk/pkglibdir/funit-complex-class.cxx
create mode 100644 frysk-core/frysk/pkglibdir/funit-complex-struct.cxx
create mode 100644 frysk-core/frysk/pkglibdir/funit-inherited-struct.cxx
create mode 100644 frysk-core/frysk/pkglibdir/funit-simple-class.cxx
create mode 100644 frysk-core/frysk/pkglibdir/funit-simple-struct.cxx
create mode 100644 frysk-core/frysk/value/TestClass.java
create mode 100644 frysk-sys/frysk/CompilerVersion.java
create mode 100644 frysk-sys/frysk/cni/CompilerVersion.cxx
diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog
index c38d9f8..e4bf05c 100644
--- a/frysk-core/frysk/debuginfo/ChangeLog
+++ b/frysk-core/frysk/debuginfo/ChangeLog
@@ -1,3 +1,13 @@
+2008-01-04 Nurdin Premji <npremji@redhat.com>
+
+ * TypeEntry.java: Added rsl loggers.
+ (addMembers): New.
+ (compilerSupportsClassType): New
+ (getClassType): New.
+ (getStructOrClassType): Return composite type, use addMembers, check for
+ compiler supporting ClassType.
+ (getType): Added support for compilers supporting DWTag.CLASS_TYPE_
+
2007-12-13 Sami Wagiaalla <swagiaal@redhat.com>
* TypeEntry.java: Use SourceLocation instead of LineColPair.
diff --git a/frysk-core/frysk/debuginfo/TypeEntry.java b/frysk-core/frysk/debuginfo/TypeEntry.java
index 9d9ed3b..8d3fa5f 100644
--- a/frysk-core/frysk/debuginfo/TypeEntry.java
+++ b/frysk-core/frysk/debuginfo/TypeEntry.java
@@ -40,10 +40,14 @@
package frysk.debuginfo;
import frysk.isa.ISA;
+import frysk.rsl.Level;
+import frysk.rsl.Log;
import frysk.scopes.SourceLocation;
import frysk.value.Access;
import frysk.value.ArrayType;
import frysk.value.CharType;
+import frysk.value.ClassType;
+import frysk.value.CompositeType;
import frysk.value.ConstType;
import frysk.value.EnumType;
import frysk.value.FloatingPointType;
@@ -52,6 +56,7 @@ import frysk.value.GccStructOrClassType;
import frysk.value.PointerType;
import frysk.value.ReferenceType;
import frysk.value.SignedType;
+import frysk.value.StructType;
import frysk.value.Type;
import frysk.value.TypeDef;
import frysk.value.UnionType;
@@ -74,6 +79,8 @@ import lib.dwfl.DwarfDie;
public class TypeEntry
{
+ static protected Log fine = Log.get(TypeEntry.class, Level.FINE);
+ static protected Log finest = Log.get(TypeEntry.class, Level.FINEST);
private final ByteOrder byteorder;
private final HashMap dieHash;
@@ -118,7 +125,98 @@ public class TypeEntry
arrayType = new ArrayType(type, elementCount * typeSize, dims);
return arrayType;
}
+
+
+ private void addMembers(DwarfDie classDie, CompositeType classType) {
+ LocationExpression locationExpression = null;
+
+ for (DwarfDie member = classDie.getChild();
+ member != null;
+ member = member.getSibling()) {
+
+ dumpDie("member=", member);
+
+ boolean staticMember = false;
+ long offset;
+ try {
+ offset = member.getDataMemberLocation();
+ } catch (DwAttributeNotFoundException de) {
+ offset = 0; // union
+ staticMember = true;
+ if(member.isDeclaration()){
+ locationExpression = new LocationExpression(member.getDefinition());
+ }else{
+ locationExpression = new LocationExpression(member);
+ }
+ }
+
+ SourceLocation sourceLocation;
+ try{
+ sourceLocation = new SourceLocation(member.getDeclFile(), member.getDeclLine(), member.getDeclColumn());
+ }catch(DwAttributeNotFoundException e){
+ sourceLocation = SourceLocation.UNKNOWN;
+ }
+
+ Access access = null;
+ switch (member.getAttrConstant(DwAt.ACCESSIBILITY)) {
+ case DwAccess.PUBLIC_: access = Access.PUBLIC; break;
+ case DwAccess.PROTECTED_: access = Access.PROTECTED; break;
+ case DwAccess.PRIVATE_: access = Access.PRIVATE; break;
+ }
+
+ if (member.getTag() == DwTag.SUBPROGRAM) {
+ Value v = getSubprogramValue(member);
+ if(hasArtifitialParameter(member)){
+ classType.addMember(member.getName(), sourceLocation, v.getType(), offset, access);
+ }else{
+ classType.addStaticMember(locationExpression, member.getName(), sourceLocation, v.getType(), offset, access);
+ }
+ continue;
+ }
+
+// DwarfDie memberDieType = member.getUltimateType();
+// if (memberDieType == null)
+// continue;
+
+ Type memberType = getType (member.getType());
+ if (memberType instanceof UnknownType == false) {
+ // System V ABI Supplements discuss bit field layout
+ int bitSize = member
+ .getAttrConstant(DwAt.BIT_SIZE);
+ if (bitSize != -1) {
+ int bitOffset = member
+ .getAttrConstant(DwAt.BIT_OFFSET);
+ if(staticMember){
+ classType.addStaticBitFieldMember(locationExpression, member.getName(), sourceLocation, memberType, offset, access,
+ bitOffset, bitSize);
+ }else{
+ classType.addBitFieldMember(member.getName(), sourceLocation, memberType, offset, access,
+ bitOffset, bitSize);
+ }
+ }
+ else{
+ if(staticMember){
+ classType.addStaticMember(locationExpression, member.getName(), sourceLocation, memberType, offset, access);
+ }else{
+ classType.addMember(member.getName(), sourceLocation, memberType, offset, access);
+ }
+
+ }
+ continue;
+ }
+ else{
+ if(staticMember){
+ classType.addStaticMember(locationExpression, member.getName(), sourceLocation, new UnknownType(member
+ .getName()), offset, access);
+ }else{
+ classType.addMember(member.getName(), sourceLocation, new UnknownType(member
+ .getName()), offset, access);
+ }
+ }
+}
+ }
+
/**
* @param classDie
* A struct die
@@ -126,100 +224,95 @@ public class TypeEntry
* Name of the struct
* @return GccStructOrClassType for the struct
*/
- public GccStructOrClassType getGccStructOrClassType(DwarfDie classDie, String name) {
-
- LocationExpression locationExpression = null;
+ public CompositeType getGccStructOrClassType(DwarfDie classDie, String name) {
+ dumpDie("structOrClassDie=", classDie);
- dumpDie("classDie=", classDie);
+ CompositeType type;
+ // XXX: Maybe store compiler version for each program somewhere so this
+ // test doesn't need to be done multiple times.
- GccStructOrClassType classType = new GccStructOrClassType(name, getByteSize(classDie));
-
- for (DwarfDie member = classDie.getChild();
- member != null;
- member = member.getSibling()) {
-
- dumpDie("member=", member);
-
- boolean staticMember = false;
- long offset;
- try {
- offset = member.getDataMemberLocation();
- } catch (DwAttributeNotFoundException de) {
- offset = 0; // union
- staticMember = true;
- if(member.isDeclaration()){
- locationExpression = new LocationExpression(member.getDefinition());
- }else{
- locationExpression = new LocationExpression(member);
- }
+ String compiler = classDie.getProducer();
+ boolean compilerSupport = compilerSupportsClassType(compiler);
+ fine.log("Compiler support determined as:" + compilerSupport);
- }
-
- SourceLocation sourceLocation;
- try{
- sourceLocation = new SourceLocation(member.getDeclFile(), member.getDeclLine(), member.getDeclColumn());
- }catch(DwAttributeNotFoundException e){
- sourceLocation = SourceLocation.UNKNOWN;
- }
-
- Access access = null;
- switch (member.getAttrConstant(DwAt.ACCESSIBILITY)) {
- case DwAccess.PUBLIC_: access = Access.PUBLIC; break;
- case DwAccess.PROTECTED_: access = Access.PROTECTED; break;
- case DwAccess.PRIVATE_: access = Access.PRIVATE; break;
- }
-
- if (member.getTag() == DwTag.SUBPROGRAM) {
- Value v = getSubprogramValue(member);
- if(hasArtifitialParameter(member)){
- classType.addMember(member.getName(), sourceLocation, v.getType(), offset, access);
- }else{
- classType.addStaticMember(locationExpression, member.getName(), sourceLocation, v.getType(), offset, access);
- }
- continue;
- }
-
-// DwarfDie memberDieType = member.getUltimateType();
-// if (memberDieType == null)
-// continue;
+ /*
+ * If the compiler supported class types and this was a class, it would
+ * have been detected as a ClassType. Since it was not, it must be a
+ * struct
+ */
+ if (compilerSupport)
+ type = new StructType(name, getByteSize(classDie));
+ else
+ type = new GccStructOrClassType(name, getByteSize(classDie));
- Type memberType = getType (member.getType());
- if (memberType instanceof UnknownType == false) {
- // System V ABI Supplements discuss bit field layout
- int bitSize = member
- .getAttrConstant(DwAt.BIT_SIZE);
- if (bitSize != -1) {
- int bitOffset = member
- .getAttrConstant(DwAt.BIT_OFFSET);
- if(staticMember){
- classType.addStaticBitFieldMember(locationExpression, member.getName(), sourceLocation, memberType, offset, access,
- bitOffset, bitSize);
- }else{
- classType.addBitFieldMember(member.getName(), sourceLocation, memberType, offset, access,
- bitOffset, bitSize);
- }
- }
- else{
- if(staticMember){
- classType.addStaticMember(locationExpression, member.getName(), sourceLocation, memberType, offset, access);
- }else{
- classType.addMember(member.getName(), sourceLocation, memberType, offset, access);
- }
-
- }
- continue;
- }
- else{
- if(staticMember){
- classType.addStaticMember(locationExpression, member.getName(), sourceLocation, new UnknownType(member
- .getName()), offset, access);
- }else{
- classType.addMember(member.getName(), sourceLocation, new UnknownType(member
- .getName()), offset, access);
- }
- }
- }
+ addMembers(classDie, type);
+ return type;
+ }
+
+
+ // XXX: Perhaps make factory with multiple compilers that support ClassType.
+ private boolean compilerSupportsClassType(String compiler)
+ {
+ //XXX: GNU C specific.
+ fine.log("Found compiler: ", compiler);
+
+ //String looks like: GNU C 4.1.2 20070925 (Red Hat 4.1.2-33)
+ if (!compiler.contains("GNU C"))
+ return false;
+
+ finest.log("Compiler is GNU C");
+
+ String preCompilerVersion = "(Red Hat ";
+
+ String compilerVersion = compiler.substring(compiler.indexOf(preCompilerVersion)
+ + preCompilerVersion.length(), compiler.lastIndexOf(')'));
+
+ String[] versions = compilerVersion.split("\\.");
+
+ if (versions.length < 3)
+ return false;
+
+ finest.log("Version string has 3 sections");
+
+ if (Integer.parseInt(versions[0]) < 4)
+ return false;
+
+ finest.log("Major Version is >= 4");
+
+ if (Integer.parseInt(versions[1]) < 1)
+ return false;
+
+ finest.log("Minor Version is >= 1");
+
+ String [] minorVersions = versions[2].split("-");
+
+ if (Integer.parseInt(minorVersions[0]) < 2)
+ return false;
+
+ finest.log("More minor version is >= 2");
+
+ if (Integer.parseInt(minorVersions[1]) < 37)
+ return false;
+
+ finest.log("Most Minor version is >= 37");
+
+ return true;
+ }
+
+ /**
+ *
+ * @param classDie
+ * A class die
+ * @param name
+ * Name of the class
+ * @return ClassType for the class.
+ */
+ public ClassType getClassType(DwarfDie classDie, String name) {
+ dumpDie("classDie=", classDie);
+
+ ClassType classType = new ClassType(name, getByteSize(classDie));
+ addMembers(classDie, classType);
return classType;
}
@@ -403,11 +496,17 @@ public class TypeEntry
break;
}
case DwTag.STRUCTURE_TYPE_: {
- GccStructOrClassType classType =
+ CompositeType classType =
getGccStructOrClassType(type, typeDie.getName());
returnType = classType;
break;
}
+ case DwTag.CLASS_TYPE_: {
+ ClassType classType =
+ getClassType(type, typeDie.getName());
+ returnType = classType;
+ break;
+ }
case DwTag.ENUMERATION_TYPE_: {
DwarfDie subrange = type.getChild();
EnumType enumType = new EnumType(typeDie.getName(),
diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog
index 21191c8..4b1f933 100644
--- a/frysk-core/frysk/pkglibdir/ChangeLog
+++ b/frysk-core/frysk/pkglibdir/ChangeLog
@@ -1,7 +1,13 @@
-2008-01-02 Tim Moore <timoore@redhat.com>
+2007-01-04 Nurdin Premji <npremji@redhat.com>
+ * funit-complex-class.cxx: New
+ * funit-complex-struct.cxx: New
+ * funit-inherited-struct.cxx: New
+ * funit-simple-class.cxx: New
+ * funit-simple-struct.cxx: New
- * funit-structmember.c: New test with structure member and function
- that share a name.
+2008-01-02 Tim Moore <timoore@redhat.com>
+ * funit-structmember.c: New test with structure member and function
+ that share a name.
2007-12-21 Petr Machata <pmachata@redhat.com>
diff --git a/frysk-core/frysk/pkglibdir/funit-complex-class.cxx b/frysk-core/frysk/pkglibdir/funit-complex-class.cxx
new file mode 100644
index 0000000..6d310a3
--- /dev/null
+++ b/frysk-core/frysk/pkglibdir/funit-complex-class.cxx
@@ -0,0 +1,20 @@
+class ComplexClass {
+ private:
+ int x;
+ int y;
+ public:
+ int getX(void) { return x;}
+ int getY(void) {return y;}
+ void setX(int a) {x = a;}
+ void setY(int a) {y = a;}
+};
+
+int main()
+{
+ ComplexClass complex;
+ complex.setX(1);
+ complex.setY(2);
+ char *a = 0;
+ a[0] = 0;
+ return 0;
+}
diff --git a/frysk-core/frysk/pkglibdir/funit-complex-struct.cxx b/frysk-core/frysk/pkglibdir/funit-complex-struct.cxx
new file mode 100644
index 0000000..9974b66
--- /dev/null
+++ b/frysk-core/frysk/pkglibdir/funit-complex-struct.cxx
@@ -0,0 +1,16 @@
+struct complexStruct {
+ int x;
+ int y;
+ private:
+ int z;
+};
+
+int main()
+{
+ complexStruct complex;
+ complex.x = 1;
+ complex.y = 2;
+ char *a = 0;
+ a[0] = 0;
+ return 0;
+}
diff --git a/frysk-core/frysk/pkglibdir/funit-inherited-struct.cxx b/frysk-core/frysk/pkglibdir/funit-inherited-struct.cxx
new file mode 100644
index 0000000..54adb5a
--- /dev/null
+++ b/frysk-core/frysk/pkglibdir/funit-inherited-struct.cxx
@@ -0,0 +1,21 @@
+struct Base
+{
+ int a;
+};
+
+struct Derivative: public Base {
+ int b;
+};
+
+
+int
+main()
+{
+ Derivative der;
+ der.b = 2;
+ der.a = 1;
+
+ char *a = 0;
+ a[0] = 0;
+ return 0;
+}
diff --git a/frysk-core/frysk/pkglibdir/funit-simple-class.cxx b/frysk-core/frysk/pkglibdir/funit-simple-class.cxx
new file mode 100644
index 0000000..60ba760
--- /dev/null
+++ b/frysk-core/frysk/pkglibdir/funit-simple-class.cxx
@@ -0,0 +1,16 @@
+class SimpleClass {
+ int x;
+ int y;
+};
+
+void doSomethingWithSimple(SimpleClass s)
+{
+}
+
+int main() {
+ SimpleClass simple;
+ doSomethingWithSimple(simple);
+ char* a = 0;
+ a[0] = 0;
+ return 0;
+}
diff --git a/frysk-core/frysk/pkglibdir/funit-simple-struct.cxx b/frysk-core/frysk/pkglibdir/funit-simple-struct.cxx
new file mode 100644
index 0000000..1e13352
--- /dev/null
+++ b/frysk-core/frysk/pkglibdir/funit-simple-struct.cxx
@@ -0,0 +1,15 @@
+struct simpleStruct {
+ int x;
+ int y;
+};
+
+
+int main()
+{
+ simpleStruct simple;
+ simple.x = 1;
+ simple.y = 2;
+ char *a = 0;
+ a[0] = 0;
+ return 0;
+}
diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog
index 4de81cb..0b36d72 100644
--- a/frysk-core/frysk/value/ChangeLog
+++ b/frysk-core/frysk/value/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-04 Nurdin Premji <npremji@redhat.com>
+
+ * TestClass.java: New
+ * ClassType.java: Fix comment typo.
+
2007-12-14 Sami Wagiaalla <swagiaal@redhat.com>
* Variable.java (Variable): Handles DwAttributeNotFoundException.
diff --git a/frysk-core/frysk/value/ClassType.java b/frysk-core/frysk/value/ClassType.java
index 33fda82..b75f63b 100644
--- a/frysk-core/frysk/value/ClassType.java
+++ b/frysk-core/frysk/value/ClassType.java
@@ -40,7 +40,7 @@
package frysk.value;
/**
- * Type for a union
+ * Type for a class
*/
public class ClassType
extends CompositeType
diff --git a/frysk-core/frysk/value/TestClass.java b/frysk-core/frysk/value/TestClass.java
new file mode 100644
index 0000000..cb6c64f
--- /dev/null
+++ b/frysk-core/frysk/value/TestClass.java
@@ -0,0 +1,132 @@
+package frysk.value;
+
+import frysk.debuginfo.DebugInfoFrame;
+import frysk.debuginfo.DebugInfoStackFactory;
+import frysk.debuginfo.ObjectDeclarationSearchEngine;
+import frysk.isa.ISA;
+import frysk.junit.TestCase;
+import frysk.proc.Task;
+import frysk.testbed.DaemonBlockedAtSignal;
+
+public class TestClass extends TestCase {
+
+ private CompositeType getType(Variable variable, ISA isa) {
+ Type type = variable.getType(isa);
+ CompositeType compType = null;
+
+ try {
+ compType = (CompositeType) type;
+ } catch (ClassCastException e) {
+ fail("Not a composite type");
+ }
+
+ return compType;
+ }
+
+ public void testSimpleClass() {
+ String fileName = "funit-simple-class";
+ Task task = (new DaemonBlockedAtSignal(fileName)).getMainTask();
+ DebugInfoFrame frame = DebugInfoStackFactory
+ .createDebugInfoStackTrace(task);
+ ObjectDeclarationSearchEngine objectDeclarationSearchEngine = new ObjectDeclarationSearchEngine(
+ frame);
+
+ Variable variable = (Variable) objectDeclarationSearchEngine
+ .getVariable("simple");
+
+ assertNotNull("Variable found", variable);
+
+ CompositeType type = getType(variable, frame.getTask().getISA());
+
+ assertEquals("Variable is a class", type.getPrefix(), "class");
+ }
+
+ public void testComplexClass() {
+ String fileName = "funit-complex-class";
+ Task task = (new DaemonBlockedAtSignal(fileName)).getMainTask();
+ DebugInfoFrame frame = DebugInfoStackFactory
+ .createDebugInfoStackTrace(task);
+ ObjectDeclarationSearchEngine objectDeclarationSearchEngine = new ObjectDeclarationSearchEngine(
+ frame);
+
+ Variable variable = (Variable) objectDeclarationSearchEngine
+ .getVariable("complex");
+
+ assertNotNull("Variable found", variable);
+
+ CompositeType type = getType(variable, frame.getTask().getISA());
+
+ if (unresolvedCompilerNoSupportForAT_CLASS())
+ return;
+
+ assertEquals("Variable is a class", type.getPrefix(), "class");
+ }
+
+ public void testSimpleStruct() {
+ String fileName = "funit-simple-struct";
+ Task task = (new DaemonBlockedAtSignal(fileName)).getMainTask();
+ DebugInfoFrame frame = DebugInfoStackFactory
+ .createDebugInfoStackTrace(task);
+ ObjectDeclarationSearchEngine objectDeclarationSearchEngine = new ObjectDeclarationSearchEngine(
+ frame);
+
+ Variable variable = (Variable) objectDeclarationSearchEngine
+ .getVariable("simple");
+
+ assertNotNull("Variable found", variable);
+
+ CompositeType type = getType(variable, frame.getTask().getISA());
+
+ assertEquals("Variable is a struct", type.getPrefix(), "struct");
+
+ }
+
+ public void testComplexStruct() {
+ String fileName = "funit-complex-struct";
+ Task task = (new DaemonBlockedAtSignal(fileName)).getMainTask();
+ DebugInfoFrame frame = DebugInfoStackFactory
+ .createDebugInfoStackTrace(task);
+ ObjectDeclarationSearchEngine objectDeclarationSearchEngine = new ObjectDeclarationSearchEngine(
+ frame);
+
+ Variable variable = (Variable) objectDeclarationSearchEngine
+ .getVariable("complex");
+
+ assertNotNull("Variable found", variable);
+
+ CompositeType type = getType(variable, frame.getTask().getISA());
+
+ // Check the type of the variable, new compiler says struct, old
+ // compiler says class.
+ if (unresolvedCompilerNoSupportForAT_CLASS())
+ assertEquals("Variable is considered a class", type.getPrefix(),
+ "class");
+ else
+ assertEquals("Variable is a struct", type.getPrefix(), "struct");
+
+ }
+
+ public void testInheritedStruct() {
+ String fileName = "funit-inherited-struct";
+ Task task = (new DaemonBlockedAtSignal(fileName)).getMainTask();
+ DebugInfoFrame frame = DebugInfoStackFactory
+ .createDebugInfoStackTrace(task);
+ ObjectDeclarationSearchEngine objectDeclarationSearchEngine = new ObjectDeclarationSearchEngine(
+ frame);
+
+ Variable variable = (Variable) objectDeclarationSearchEngine
+ .getVariable("der");
+
+ assertNotNull("Variable found", variable);
+
+ CompositeType type = getType(variable, frame.getTask().getISA());
+
+ // Check the type of the variable, new compiler says struct, old
+ // compiler says class.
+ if (unresolvedCompilerNoSupportForAT_CLASS())
+ assertEquals("Variable is considered a class", type.getPrefix(), "class");
+ else
+ assertEquals("Variable is a struct", type.getPrefix(), "struct");
+ }
+
+}
diff --git a/frysk-sys/frysk/ChangeLog b/frysk-sys/frysk/ChangeLog
index 9ac5273..d2b06bb 100644
--- a/frysk-sys/frysk/ChangeLog
+++ b/frysk-sys/frysk/ChangeLog
@@ -1,5 +1,8 @@
-2007-12-28 Andrew Cagney <cagney@redhat.com>
+2008-01-04 Nurdin Premji <npremji@redhat.com>
+ * CompilerVersion.java: New.
+ * cni/CompilerVersion.cxx: New.
+2007-12-28 Andrew Cagney <cagney@redhat.com>
* cni/Config.cxx-in (Config::createInstallConfig)
(Config::createInstallConfig32, Config::createInstallConfig64)
(Config::createBuildConfig, Config::createBuildConfig32)
@@ -17,7 +20,7 @@
(testBuild32On64Dirs()): Delete.
(testInstallDirs(), testBuildDirs()): Update.
-2007-12-17 cagney <cagney@redhat.com>
+2007-12-17 Andrew Cagney <cagney@redhat.com>
* EventLogger.java (addConsoleOptions(Parser)): Add LogOption.
diff --git a/frysk-sys/frysk/CompilerVersion.java b/frysk-sys/frysk/CompilerVersion.java
new file mode 100644
index 0000000..7144831
--- /dev/null
+++ b/frysk-sys/frysk/CompilerVersion.java
@@ -0,0 +1,9 @@
+package frysk;
+
+public class CompilerVersion {
+
+ public static native int getVersion();
+ public static native int getMinorVersion();
+ public static native int getPatchLevel();
+ public static native int getRHRelease();
+}
diff --git a/frysk-sys/frysk/cni/CompilerVersion.cxx b/frysk-sys/frysk/cni/CompilerVersion.cxx
new file mode 100644
index 0000000..81a4a65
--- /dev/null
+++ b/frysk-sys/frysk/cni/CompilerVersion.cxx
@@ -0,0 +1,63 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 2008, Red Hat Inc.
+//
+// FRYSK is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+
+#include <gcj/cni.h>
+
+#include "frysk/CompilerVersion.h"
+
+jint
+frysk::CompilerVersion::getVersion() {
+ return (jint) __GNUC__;
+}
+
+
+jint
+frysk::CompilerVersion::getMinorVersion() {
+ return (jint) __GNUC_MINOR__;
+}
+
+jint
+frysk::CompilerVersion::getPatchLevel() {
+ return (jint) __GNUC_PATCHLEVEL__;
+}
+
+jint
+frysk::CompilerVersion::getRHRelease() {
+ return (jint) __GNUC_RH_RELEASE__;
+}
diff --git a/frysk-sys/frysk/junit/ChangeLog b/frysk-sys/frysk/junit/ChangeLog
index 1fef743..9c12bd3 100644
--- a/frysk-sys/frysk/junit/ChangeLog
+++ b/frysk-sys/frysk/junit/ChangeLog
@@ -1,5 +1,7 @@
-2007-12-28 Andrew Cagney <cagney@redhat.com>
+2008-01-04 Nurdin Premji <npremji@redhat.com>
+ * TestCase.java (unresolvedCompilerNoSupportForAT_CLASS): New.
+2007-12-28 Andrew Cagney <cagney@redhat.com>
* TestCase.java (unresolvedOn32On64()): New.
* TestCase.java (missing32or64()): Rename skip32on64(); check both
diff --git a/frysk-sys/frysk/junit/TestCase.java b/frysk-sys/frysk/junit/TestCase.java
index 8ceb981..6b802b1 100644
--- a/frysk-sys/frysk/junit/TestCase.java
+++ b/frysk-sys/frysk/junit/TestCase.java
@@ -39,6 +39,7 @@
package frysk.junit;
+import frysk.CompilerVersion;
import frysk.Config;
import frysk.sys.Uname;
import java.math.BigInteger;
@@ -184,6 +185,20 @@ public class TestCase
}
});
}
+
+ /**
+ * A method that returns true, and prints UNRESOLVED, when the compiler
+ * does not support AT_CLASS
+ */
+ protected static boolean unresolvedCompilerNoSupportForAT_CLASS() {
+
+ boolean compilerNoSupportForAT_CLASS = CompilerVersion.getVersion() <= 4
+ && CompilerVersion.getMinorVersion() <= 1 && CompilerVersion.getPatchLevel() <= 2 &&
+ CompilerVersion.getRHRelease() < 37;
+
+ Runner.unresolved(5518, compilerNoSupportForAT_CLASS);
+ return compilerNoSupportForAT_CLASS;
+ }
/**
* A method that returns true, and prints UNRESOLVED, when the
diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog
index ad8aa0c..9be27e5 100644
--- a/frysk-sys/lib/dwfl/ChangeLog
+++ b/frysk-sys/lib/dwfl/ChangeLog
@@ -1,5 +1,10 @@
-2008-01-02 Tim Moore <timoore@redhat.com>
+2007-01-04 Nurdin Premji <npremji@redhat.com>
+ * DwarfDie.java (getProducer): New.
+ (getAttrString): New.
+ (get_attr_string): New.
+ * cni/DwarfDie.cxx (DwarfDie::get_attr_string): New.
+2008-01-02 Tim Moore <timoore@redhat.com>
* cni/DwarfDie.cxx (iterate_decl): Don't descend into struture and
union types.
diff --git a/frysk-sys/lib/dwfl/DwarfDie.java b/frysk-sys/lib/dwfl/DwarfDie.java
index b040237..7f9d038 100644
--- a/frysk-sys/lib/dwfl/DwarfDie.java
+++ b/frysk-sys/lib/dwfl/DwarfDie.java
@@ -91,6 +91,10 @@ abstract public class DwarfDie {
public String getName () {
return get_diename();
}
+
+ public String getProducer () {
+ return getCompilationUnit().getAttrString(DwAt.PRODUCER);
+ }
public File getDeclFile() {
File file = null;
@@ -266,10 +270,15 @@ abstract public class DwarfDie {
public boolean getAttrBoolean(DwAt attr) {
return get_attr_boolean(this.getPointer(), attr.hashCode());
}
+
+ public String getAttrString(DwAt attr) {
+ return get_attr_string(this.getPointer(), attr.hashCode());
+ }
public DwTag getTag() {
return DwTag.valueOf(get_tag(this.getPointer()));
}
+
/**
* @return The upper bound for this subrange die.
@@ -489,6 +498,8 @@ abstract public class DwarfDie {
private native boolean get_attr_boolean (long addr, int attr);
private native int get_attr_constant (long addr, int attr);
+
+ private native String get_attr_string (long addr, int attr);
private native long get_offset (long addr);
diff --git a/frysk-sys/lib/dwfl/cni/DwarfDie.cxx b/frysk-sys/lib/dwfl/cni/DwarfDie.cxx
index 9274ea8..0d5a07e 100644
--- a/frysk-sys/lib/dwfl/cni/DwarfDie.cxx
+++ b/frysk-sys/lib/dwfl/cni/DwarfDie.cxx
@@ -429,6 +429,25 @@ lib::dwfl::DwarfDie::get_attr_constant (jlong die_p, jint attr)
return -1;
}
+
+jstring
+lib::dwfl::DwarfDie::get_attr_string (jlong die_p, jint attr)
+{
+ Dwarf_Die *die = (Dwarf_Die*) die_p;
+ Dwarf_Attribute type_attr;
+ if (dwarf_attr_integrate(die, attr, &type_attr))
+ {
+ const char *name = dwarf_formstring(&type_attr);
+ if (name != NULL)
+ return JvNewStringUTF (name);
+ else
+ return JvNewStringUTF ("");
+ }
+
+ return NULL;
+
+}
+
jlong
lib::dwfl::DwarfDie::get_offset (jlong var_die)
{
--
1.5.3.7