From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3669 invoked by alias); 10 Apr 2008 18:16:05 -0000 Received: (qmail 3644 invoked by uid 9561); 10 Apr 2008 18:16:04 -0000 Date: Thu, 10 Apr 2008 18:16:00 -0000 Message-ID: <20080410181604.3629.qmail@sourceware.org> From: swagiaal@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: swagiaal: created NamedScope; created and used SourceLocationFactory. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 6c1e5b547ed853726943c21251b13336d5c48016 X-Git-Newrev: c1c9ca07e98bf3b6c93ce970c09c7612634a7a97 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q2/txt/msg00078.txt.bz2 The branch, master has been updated via c1c9ca07e98bf3b6c93ce970c09c7612634a7a97 (commit) from 6c1e5b547ed853726943c21251b13336d5c48016 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit c1c9ca07e98bf3b6c93ce970c09c7612634a7a97 Author: Sami Wagiaalla Date: Thu Apr 10 14:15:43 2008 -0400 swagiaal: created NamedScope; created and used SourceLocationFactory. frysk-core/frysk/debuginfo/ChangeLog +2008-04-10 Sami Wagiaalla + + * TypeFactory.java: Use SourceLocationFactory + * DebugInfoFrame.java: ditto. + +++ b/frysk-core/frysk/scopes/ChangeLog +2008-04-10 Sami Wagiaalla + + * NamedScope.java: New class. + * Subroutine.java: implemented getType() + implemented getValue(). + * Subprogram.java: Removed name initialization. + * Variable.java: Now uses SourceLocationFactory. + * SourceLocationFactory.java: New. + ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/debuginfo/ChangeLog | 5 ++ frysk-core/frysk/debuginfo/DebugInfoFrame.java | 26 +------- frysk-core/frysk/debuginfo/TypeFactory.java | 21 ++----- frysk-core/frysk/scopes/ChangeLog | 9 +++ .../{SourceLocation.java => NamedScope.java} | 48 +++++---------- frysk-core/frysk/scopes/Scope.java | 6 ++ frysk-core/frysk/scopes/SourceLocation.java | 2 +- ...rceLocation.java => SourceLocationFactory.java} | 62 ++++++++++---------- frysk-core/frysk/scopes/Subprogram.java | 3 - frysk-core/frysk/scopes/Subroutine.java | 26 ++++++++- frysk-core/frysk/scopes/Variable.java | 11 +--- 11 files changed, 105 insertions(+), 114 deletions(-) copy frysk-core/frysk/scopes/{SourceLocation.java => NamedScope.java} (76%) copy frysk-core/frysk/scopes/{SourceLocation.java => SourceLocationFactory.java} (64%) First 500 lines of diff: diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index e8d90ce..605f21a 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,3 +1,8 @@ +2008-04-10 Sami Wagiaalla + + * TypeFactory.java: Use SourceLocationFactory + * DebugInfoFrame.java: ditto. + 2008-04-09 Sami Wagiaalla * ObjectDeclarationSearchEngine.java: Renamed getVariable to diff --git a/frysk-core/frysk/debuginfo/DebugInfoFrame.java b/frysk-core/frysk/debuginfo/DebugInfoFrame.java index 0881150..e208812 100644 --- a/frysk-core/frysk/debuginfo/DebugInfoFrame.java +++ b/frysk-core/frysk/debuginfo/DebugInfoFrame.java @@ -39,25 +39,22 @@ package frysk.debuginfo; -import java.io.File; import java.io.PrintWriter; import java.util.LinkedList; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; import lib.dwfl.DwflDieBias; -import lib.dwfl.DwflLine; import frysk.dwfl.DwflCache; import frysk.rt.LineXXX; -import frysk.scopes.SourceLocation; import frysk.scopes.Scope; import frysk.scopes.ScopeFactory; +import frysk.scopes.SourceLocation; +import frysk.scopes.SourceLocationFactory; import frysk.scopes.Subprogram; import frysk.scopes.Subroutine; import frysk.stack.Frame; import frysk.stack.FrameDecorator; -import frysk.sysroot.SysRoot; -import frysk.sysroot.SysRootCache; public class DebugInfoFrame extends FrameDecorator { @@ -169,24 +166,7 @@ public class DebugInfoFrame extends FrameDecorator { */ public SourceLocation getLine() { if (this.line == null) { - Dwfl dwfl = DwflCache.getDwfl(this.getTask()); - SysRoot sysRoot = new SysRoot(SysRootCache.getSysRoot(this.getTask())); - // The innermost frame and frames which were - // interrupted during execution use their PC to get - // the line in source. All other frames have their PC - // set to the line after the inner frame call and must - // be decremented by one. - DwflLine dwflLine = dwfl.getSourceLine(getAdjustedAddress()); - if (dwflLine != null) { - File f = sysRoot.getSourcePathViaSysRoot - (new File(dwflLine.getCompilationDir()), - new File(dwflLine.getSourceFile())).getSysRootedFile(); - this.line = new SourceLocation(f, dwflLine.getLineNum(), - dwflLine.getColumn()); - } - // If the fetch failed, mark it as unknown. - if (this.line == null) - this.line = SourceLocation.UNKNOWN; + this.line = SourceLocationFactory.getSourceLocation(getTask(), getAdjustedAddress()); } return this.line; } diff --git a/frysk-core/frysk/debuginfo/TypeFactory.java b/frysk-core/frysk/debuginfo/TypeFactory.java index 6911d40..f59d4e6 100644 --- a/frysk-core/frysk/debuginfo/TypeFactory.java +++ b/frysk-core/frysk/debuginfo/TypeFactory.java @@ -43,6 +43,7 @@ import frysk.isa.ISA; import frysk.rsl.Log; import frysk.rsl.LogFactory; import frysk.scopes.SourceLocation; +import frysk.scopes.SourceLocationFactory; import frysk.value.Access; import frysk.value.ArrayType; import frysk.value.CharType; @@ -152,14 +153,8 @@ public class TypeFactory { } - SourceLocation sourceLocation; - try { - sourceLocation = new SourceLocation(member.getDeclFile(), - member.getDeclLine(), member.getDeclColumn()); - } catch (DwAttributeNotFoundException e) { - sourceLocation = SourceLocation.UNKNOWN; - } - + SourceLocation sourceLocation = SourceLocationFactory.getSourceLocation(member); + Access access = null; switch (member.getAttrConstant(DwAt.ACCESSIBILITY)) { case DwAccess.PUBLIC_: @@ -336,14 +331,8 @@ public class TypeFactory { offset = 0; // union } - SourceLocation lineColPair; - try { - lineColPair = new SourceLocation(member.getDeclFile(), member - .getDeclLine(), member.getDeclColumn()); - } catch (DwAttributeNotFoundException e) { - lineColPair = SourceLocation.UNKNOWN; - } - + SourceLocation lineColPair = SourceLocationFactory.getSourceLocation(member); + Access access = null; switch (member.getAttrConstant(DwAt.ACCESSIBILITY)) { case DwAccess.PUBLIC_: diff --git a/frysk-core/frysk/scopes/ChangeLog b/frysk-core/frysk/scopes/ChangeLog index f2c43ab..7f2db03 100644 --- a/frysk-core/frysk/scopes/ChangeLog +++ b/frysk-core/frysk/scopes/ChangeLog @@ -1,5 +1,14 @@ 2008-04-10 Sami Wagiaalla + * NamedScope.java: New class. + * Subroutine.java: implemented getType() + implemented getValue(). + * Subprogram.java: Removed name initialization. + * Variable.java: Now uses SourceLocationFactory. + * SourceLocationFactory.java: New. + +2008-04-10 Sami Wagiaalla + Changed ObjectDeclaration from abstract class to interface * Variable.java: Updated. diff --git a/frysk-core/frysk/scopes/SourceLocation.java b/frysk-core/frysk/scopes/NamedScope.java similarity index 76% copy from frysk-core/frysk/scopes/SourceLocation.java copy to frysk-core/frysk/scopes/NamedScope.java index 5fd14a7..915ab59 100644 --- a/frysk-core/frysk/scopes/SourceLocation.java +++ b/frysk-core/frysk/scopes/NamedScope.java @@ -39,42 +39,28 @@ package frysk.scopes; -import java.io.File; +import lib.dwfl.DwarfDie; +import frysk.debuginfo.TypeFactory; +import frysk.value.ObjectDeclaration; /** - * The source-code line information. + * This class is a root for all scopes which can have a name + * and can there for be queried for. + * Eg: + * function + * class + * namespace */ - -public class SourceLocation { - - /** - * The LINE is unknown; this is used instead of "null" to denote - * missing line information. - */ - public static final SourceLocation UNKNOWN = new SourceLocation(null, 0, 0); - - private final File file; - - private final int line; - - private final int column; - - public SourceLocation(File file, int line, int column) { - this.file = file; - this.line = line; - this.column = column; - } - - public File getFile () { - return file; - } +public abstract class NamedScope extends Scope implements ObjectDeclaration { + + String name; - public int getLine () { - return line; + public NamedScope(DwarfDie die, TypeFactory typeFactory) { + super(die, typeFactory); + this.name = die.getName(); } - public int getColumn () { - return column; + public String getName(){ + return this.name; } - } diff --git a/frysk-core/frysk/scopes/Scope.java b/frysk-core/frysk/scopes/Scope.java index b9fff92..e753ef2 100644 --- a/frysk-core/frysk/scopes/Scope.java +++ b/frysk-core/frysk/scopes/Scope.java @@ -81,11 +81,13 @@ public class Scope LinkedList collections; final TypeFactory typeFactory; + private final SourceLocation sourceLocation; public Scope(DwarfDie die, TypeFactory typeFactory){ this.die = die; this.scopes = new LinkedList(); this.typeFactory = typeFactory; + this.sourceLocation = SourceLocationFactory.getSourceLocation(die); } public Scope getOuter(){ @@ -126,6 +128,10 @@ public class Scope return variables; } + public SourceLocation getSourceLocation(){ + return this.sourceLocation; + } + public LinkedList getEnums(){ if(this.collections == null){ this.collections = new LinkedList(); diff --git a/frysk-core/frysk/scopes/SourceLocation.java b/frysk-core/frysk/scopes/SourceLocation.java index 5fd14a7..74ef428 100644 --- a/frysk-core/frysk/scopes/SourceLocation.java +++ b/frysk-core/frysk/scopes/SourceLocation.java @@ -59,7 +59,7 @@ public class SourceLocation { private final int column; - public SourceLocation(File file, int line, int column) { + protected SourceLocation(File file, int line, int column) { this.file = file; this.line = line; this.column = column; diff --git a/frysk-core/frysk/scopes/SourceLocation.java b/frysk-core/frysk/scopes/SourceLocationFactory.java similarity index 64% copy from frysk-core/frysk/scopes/SourceLocation.java copy to frysk-core/frysk/scopes/SourceLocationFactory.java index 5fd14a7..17e7f3a 100644 --- a/frysk-core/frysk/scopes/SourceLocation.java +++ b/frysk-core/frysk/scopes/SourceLocationFactory.java @@ -41,40 +41,40 @@ package frysk.scopes; import java.io.File; -/** - * The source-code line information. - */ +import frysk.dwfl.DwflCache; +import frysk.proc.Task; +import frysk.sysroot.SysRoot; +import frysk.sysroot.SysRootCache; +import lib.dwfl.DwAttributeNotFoundException; +import lib.dwfl.DwarfDie; +import lib.dwfl.Dwfl; +import lib.dwfl.DwflLine; -public class SourceLocation { +public class SourceLocationFactory { - /** - * The LINE is unknown; this is used instead of "null" to denote - * missing line information. - */ - public static final SourceLocation UNKNOWN = new SourceLocation(null, 0, 0); - - private final File file; - - private final int line; - - private final int column; - - public SourceLocation(File file, int line, int column) { - this.file = file; - this.line = line; - this.column = column; - } - - public File getFile () { - return file; + public static SourceLocation getSourceLocation(DwarfDie variableDie){ + SourceLocation sourceLocation; + try{ + sourceLocation = new SourceLocation(variableDie.getDeclFile(),variableDie.getDeclLine(), variableDie.getDeclColumn()); + }catch(DwAttributeNotFoundException e){ + sourceLocation = SourceLocation.UNKNOWN; + } + return sourceLocation; } - public int getLine () { - return line; - } - - public int getColumn () { - return column; + public static SourceLocation getSourceLocation(Task task, long address){ + Dwfl dwfl = DwflCache.getDwfl(task); + SysRoot sysRoot = new SysRoot(SysRootCache.getSysRoot(task)); + DwflLine dwflLine = dwfl.getSourceLine(address); + if (dwflLine != null) { + File f = sysRoot.getSourcePathViaSysRoot + (new File(dwflLine.getCompilationDir()), + new File(dwflLine.getSourceFile())).getSysRootedFile(); + + + return new SourceLocation(f, dwflLine.getLineNum(), dwflLine.getColumn()); + } + + return SourceLocation.UNKNOWN; } - } diff --git a/frysk-core/frysk/scopes/Subprogram.java b/frysk-core/frysk/scopes/Subprogram.java index f2c9ef5..c661029 100644 --- a/frysk-core/frysk/scopes/Subprogram.java +++ b/frysk-core/frysk/scopes/Subprogram.java @@ -64,11 +64,8 @@ public class Subprogram extends Subroutine FunctionType functionType; LinkedList parameters; - private String name; - public Subprogram(DwarfDie die, TypeFactory typeFactory) { super(die, typeFactory); - this.name = die.getName(); parameters = new LinkedList(); die = die.getChild(); diff --git a/frysk-core/frysk/scopes/Subroutine.java b/frysk-core/frysk/scopes/Subroutine.java index 90f410e..e70a7f8 100644 --- a/frysk-core/frysk/scopes/Subroutine.java +++ b/frysk-core/frysk/scopes/Subroutine.java @@ -39,7 +39,13 @@ package frysk.scopes; +import frysk.debuginfo.DebugInfoFrame; +import frysk.debuginfo.LocationExpression; +import frysk.debuginfo.PieceLocation; import frysk.debuginfo.TypeFactory; +import frysk.isa.ISA; +import frysk.value.Type; +import frysk.value.Value; import lib.dwfl.DwAt; import lib.dwfl.DwInl; import lib.dwfl.DwTag; @@ -49,12 +55,16 @@ import lib.dwfl.DwarfDie; * In DWARF a subroutine is used to refer to an entity that can either be a * concrete function (Subprogram) or an inlined function (InlinedSubprogram). */ -public class Subroutine extends Scope { +public class Subroutine extends NamedScope { Composite struct; + Type type; + private LocationExpression locationExpression; public Subroutine(DwarfDie die, TypeFactory typeFactory) { super(die, typeFactory); + this.type = typeFactory.getType(die); + locationExpression = new LocationExpression(die); } /** @@ -117,4 +127,18 @@ public class Subroutine extends Scope { throw new RuntimeException("Unhandled case DwTag: " + dwTag + " inline attribute " + inlineAttribute); } + + public Type getType(ISA isa) { + return this.type; + } + + 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; + + } } diff --git a/frysk-core/frysk/scopes/Variable.java b/frysk-core/frysk/scopes/Variable.java index 1fdfb4a..6aa55ef 100644 --- a/frysk-core/frysk/scopes/Variable.java +++ b/frysk-core/frysk/scopes/Variable.java @@ -40,7 +40,7 @@ package frysk.scopes; import java.io.PrintWriter; -import lib.dwfl.DwAttributeNotFoundException; + import lib.dwfl.DwException; import lib.dwfl.DwarfDie; import frysk.debuginfo.DebugInfoFrame; @@ -52,10 +52,10 @@ import frysk.debuginfo.VariableOptimizedOutException; import frysk.isa.ISA; import frysk.rsl.Log; import frysk.rsl.LogFactory; +import frysk.value.Format; import frysk.value.ObjectDeclaration; import frysk.value.Type; import frysk.value.Value; -import frysk.value.Format; /** * This class contains the static information corresponding to a @@ -79,12 +79,7 @@ public class Variable implements ObjectDeclaration { this.variableDie = variableDie; this.name = variableDie.getName(); locationExpression = new LocationExpression(variableDie); - try{ - this.sourceLocation = new SourceLocation(variableDie.getDeclFile(),variableDie.getDeclLine(), variableDie.getDeclColumn()); - }catch(DwAttributeNotFoundException e){ - this.sourceLocation = SourceLocation.UNKNOWN; - } - + sourceLocation = SourceLocationFactory.getSourceLocation(variableDie); } public DwarfDie getVariableDie() { hooks/post-receive -- frysk system monitor/debugger