This is the mail archive of the frysk@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: StackFrame.toString()


>>>>> "Mark" == Mark Wielaard <mark@klomp.org> writes:

Mark> Could you provide some more info on what you
Mark> are seeing. Or maybe just report a bug with the output of:
Mark> ./TestRunner -c FINE frysk.proc.TestBreakpoints

I updated, rebuilt, and re-ran the test suite.
This time it all worked.

I've appended my updated patch.

* Adds toString
* Removes default sourceFile
* Fixes some javadoc things in StackFrame
* Corrects a misspelling

Ok?

Tom

Index: frysk-core/frysk/rt/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* StackFrame.java (toString): New method.
	(StackFrame): Don't initialize sourceFile if file is not known.
	(startOffset): Renamed.
	(getStartOffset): Likewise.
	(setFunction): Javadoc fixes.
	(getFunction): Likewise.
	(getData): Likewise.
	(getMethodName): Likewise.
	(getSourceFile): Likewise.
	(getLineNumber): Likewise.
	(getColumn): Likewise.
	(getAddress): Likewise.
	(getMyTask): Likewise.
	(getUnwindData): Likewise.
	(getInner): Likewise.
	(getOuter): Likewise.
	(getIsSignalFrame): Likewise.

Index: frysk-core/frysk/rt/StackFrame.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/rt/StackFrame.java,v
retrieving revision 1.6
diff -u -r1.6 StackFrame.java
--- frysk-core/frysk/rt/StackFrame.java 19 Sep 2006 14:18:00 -0000 1.6
+++ frysk-core/frysk/rt/StackFrame.java 19 Sep 2006 21:59:56 -0000
@@ -61,7 +61,7 @@
 
   private int endLine;
 
-  private int startOffsset;
+  private int startOffset;
 
   private int endOffset;
 
@@ -132,16 +132,12 @@
             this.lineNum = line.getLineNum();
             this.startLine = this.lineNum;
             this.endLine = this.lineNum;
-            this.startOffsset = 0;
+            this.startOffset = 0;
             this.endOffset = -1;
             this.sourceFile = line.getSourceFile();
             this.column = line.getColumn();
           }
       }
-    else
-      {
-        this.sourceFile = "<Unknown file>";
-      }
   }
   
   /**
@@ -151,8 +147,10 @@
   private native void initialize ();
   
   /**
-   * Sets func to the incoming DOMFunction representing the function which
-   * is in turn represented by this StackFrame. 
+   * Sets the DOMFunction representing the function which is in turn
+   * represented by this StackFrame.  This method also calls
+   * {@link setData} using the function's source as an argument; if
+   * the function does not have a source, then null is used.
    * 
    * @param f   The DOMFunction for this StackFrame.
    */
@@ -166,8 +164,8 @@
   }
   
   /**
-   * Sets data to the incoming DOMSource, representing the source code of
-   * the executable.
+   * Sets the DOMSource, representing the source code of the
+   * executable.
    * 
    * @param s   The DOMSource for the executable this StackFrame belongs to.
    */
@@ -177,9 +175,10 @@
   }
   
   /**
-   * Returns this StackFrame's function.
+   * Returns this StackFrame's function.  If no function was
+   * previously set using {@link setFunction}, this will return null.
    * 
-   * @return func   This StackFrame's function.
+   * @return This StackFrame's function.
    */
   public DOMFunction getFunction()
   {
@@ -187,9 +186,10 @@
   }
   
   /**
-   * Returns this StackFrame's source code.
+   * Returns this StackFrame's source code.  If no source was
+   * previously set using {@link setData}, null is returned.
    * 
-   * @return data   This StackFrame's source code.
+   * @return This StackFrame's source code.
    */
   public DOMSource getData()
   {
@@ -197,9 +197,8 @@
   }
 
   /**
-   * Returns this StackFrame's method name.
-   * 
-   * @return methodName  This StackFrame's method name.
+   * Return the name of the function associated with this stack frame.
+   * This will return null if the function's name is not known.
    */
   public String getMethodName ()
   {
@@ -207,10 +206,8 @@
   }
 
   /**
-   * Returns the name of the source file represented by this StackFrame
-   * 
-   * @return sourceFile The name of the SourceFile represented by this 
-   * StackFrame.
+   * Return the name of the source file associated with this stack
+   * frame.  If the source file is not known, this will return null.
    */
   public String getSourceFile ()
   {
@@ -218,9 +215,9 @@
   }
 
   /**
-   * Returns the current line number of this StackFrame.
-   * 
-   * @return lineNum    The current line number of this Stackframe.
+   * Return the line number of the source code associated with this
+   * stack frame.  Line numbers begin at 1.  If the source line number
+   * is not known, this will return 0.
    */
   public int getLineNumber ()
   {
@@ -230,7 +227,7 @@
   /**
    * Returns the column in the currently executing line in the source file.
    * 
-   * @return column The column in the currently executing source file line. 
+   * @return The column in the currently executing source file line. 
    */
   public int getColumn ()
   {
@@ -240,7 +237,7 @@
   /**
    * Returns the program counter for this StackFrame.
    * 
-   * @return address    The program counter for this StackFrame.
+   * @return The program counter for this StackFrame.
    */
   public long getAddress ()
   {
@@ -250,7 +247,7 @@
   /**
    * Returns the Task this StackFrame belongs to.
    * 
-   * @return myTask The Task this StackFrame belongs to.
+   * @return The Task this StackFrame belongs to.
    */
   public Task getMyTask ()
   {
@@ -260,7 +257,7 @@
   /**
    * Returns the RawDataManaged  which represents this StackFrame's cursor.
    * 
-   * @return unwind_data    This StackFrame's cursor.
+   * @return This StackFrame's cursor.
    */
   protected RawDataManaged getUnwindData ()
   {
@@ -270,7 +267,7 @@
   /**
    * Returns this StackFrame's inner frame.
    * 
-   * @return inner  This StackFrame's inner frame.
+   * @return This StackFrame's inner frame.
    */
   public StackFrame getInner ()
   {
@@ -280,19 +277,52 @@
   /**
    * Returns this StackFrame's outer frame.
    * 
-   * @return outer  This StackFrame's outer frame.
+   * @return This StackFrame's outer frame.
    */
   public StackFrame getOuter ()
   {
     return outer;
   }
+
+  /**
+   * Return a string representation of this stack frame.
+   * The returned string is suitable for display to the user.
+   */
+  public String toString ()
+  {
+    StringBuffer builder = new StringBuffer("0x");
+    builder.append(Long.toHexString(getAddress()));
+    String mn = getMethodName();
+    if (mn != null && ! "".equals(mn))
+      {
+	builder.append(" in function: ");
+	builder.append(getMethodName());
+      }
+    String sf = getSourceFile();
+    int line = getLineNumber();
+    if (sf != null || line != 0)
+      {
+	builder.append(" (");
+	if (sf != null)
+	  builder.append(sf);
+	else
+	  builder.append("Unknown source");
+	if (line != 0)
+	  {
+	    builder.append(":");
+	    builder.append(line);
+	  }
+	builder.append(")");
+      }
+    return builder.toString();
+  }
   
   public int getEndLine ()
   {
     return endLine;
   }
   
-  public void setEndLine (int i )
+  public void setEndLine (int i)
   {
     this.endLine = i;
   }
@@ -312,9 +342,9 @@
     this.startLine = i;
   }
 
-  public int getStartOffsset ()
+  public int getStartOffset ()
   {
-    return startOffsset;
+    return startOffset;
   }
   
   /**
@@ -332,7 +362,7 @@
   /**
    * Returns whether or not this frame is a signal frame.
    * 
-   * @return isSignalFrame  Whether or not this frame is a signal frame.
+   * @return Whether or not this frame is a signal frame.
    */
   public boolean getIsSignalFrame()
   {
Index: frysk-gui/frysk/gui/srcwin/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* CurrentLineSection.java (startOffset): Renamed.
	(CurrentLineSection): Updated.
	(getStartOffset): Renamed.
	(setStartOffset): Likewise.
	* SourceBuffer.java (setCurrentLine): Use renamed getStartOffset.

Index: frysk-gui/frysk/gui/srcwin/CurrentLineSection.java
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/srcwin/CurrentLineSection.java,v
retrieving revision 1.3
diff -u -r1.3 CurrentLineSection.java
--- frysk-gui/frysk/gui/srcwin/CurrentLineSection.java 8 Sep 2006 18:19:36 -0000 1.3
+++ frysk-gui/frysk/gui/srcwin/CurrentLineSection.java 19 Sep 2006 21:59:57 -0000
@@ -46,7 +46,7 @@
 
   private int endLine;
 
-  private int startOffsset;
+  private int startOffset;
 
   private int endOffset;
 
@@ -59,7 +59,7 @@
   {
     startLine = lineStart;
     endLine = lineEnd;
-    startOffsset = colStart;
+    startOffset = colStart;
     endOffset = colEnd;
   }
 
@@ -113,13 +113,13 @@
     this.startLine = startLine;
   }
 
-  public int getStartOffsset ()
+  public int getStartOffset ()
   {
-    return startOffsset;
+    return startOffset;
   }
 
-  public void setStartOffsset (int startOffsset)
+  public void setStartOffset (int startOffset)
   {
-    this.startOffsset = startOffsset;
+    this.startOffset = startOffset;
   }
 }
Index: frysk-gui/frysk/gui/srcwin/SourceBuffer.java
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/srcwin/SourceBuffer.java,v
retrieving revision 1.69
diff -u -r1.69 SourceBuffer.java
--- frysk-gui/frysk/gui/srcwin/SourceBuffer.java 18 Sep 2006 15:52:09 -0000 1.69
+++ frysk-gui/frysk/gui/srcwin/SourceBuffer.java 19 Sep 2006 21:59:57 -0000
@@ -267,7 +267,7 @@
   {
 
     int startLine = frame.getStartLine();
-    int startCol = frame.getStartOffsset();
+    int startCol = frame.getStartOffset();
     int endLine = frame.getEndLine();
     int endCol = frame.getEndOffset();
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]