org.erights.e.develop.trace
Class TraceCaller

java.lang.Object
  |
  +--org.erights.e.develop.trace.TraceCaller

public class TraceCaller
extends Object

Untamed: This class finds the user method that posted a trace message and provides accessors to useful information.

DANGER: it is HIGHLY dependent on the particular way the implementation prints stack traces. The installation tests ($ROOT/Install) help you check if your VM does things differently. If you change this code, please update the tests (=Tests/TestTraceCaller.java).

For reference, here's the current expected format. (There's more about this in the code.)

 java.lang.Exception
  at Trace.debugm(Trace.java:217)
  at Test.go(Test.java:25)
  at Test.main(Test.java:20)
 

Stack frames from jit-ed code (compiled on the fly) look like: at Trace.debugm(Compiled Code) or at Trace.debugm(TraceBuffer.java, Compiled Code)

Some VMs use <> pairs instead of parentheses. Some seem to use tabs (?)

If the implementation runs into an odd format, it should leave accessors it's not sure of with their initial values.


Field Summary
 String fileName
          Enabled: The file that method is in.
 String lineNumber
          Enabled: The line number the trace call is on.
 String methodName
          Enabled: The name of the method running in the targeted frame.
private  String targetMethod
           
 
Constructor Summary
TraceCaller(Exception exception)
          Enabled: Collect an earlier frame's data based on data in the Exception.
TraceCaller(String dump)
          Enabled: String dump is a stack dump as retrieved with getStackDump.
 
Method Summary
private  void advance(String stackDump, org.erights.e.develop.trace.TraceCaller.Line line)
          Destructively move the line forward to the next line.
private  org.erights.e.develop.trace.TraceCaller.Line findTargetLineBounds(String stackDump)
           
private  String getStackDump(Exception exception)
           
private  org.erights.e.develop.trace.TraceCaller.Line lineFromPoint(String stackDump, int middle)
           
private  void parse(String dump)
           
private  void parseLine(String stackDump, org.erights.e.develop.trace.TraceCaller.Line line)
           
private  void quitIf(boolean b)
           
 String toString()
          Suppressed:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

methodName

public String methodName
Enabled: The name of the method running in the targeted frame. It is partly qualified, consisting of the last element of the classname plus the method name (for example, "String.indexOf").


fileName

public String fileName
Enabled: The file that method is in. The full pathname is not available.


lineNumber

public String lineNumber
Enabled: The line number the trace call is on.


targetMethod

private final String targetMethod
Constructor Detail

TraceCaller

public TraceCaller(Exception exception)
Enabled: Collect an earlier frame's data based on data in the Exception. If aboveCount is 0, the data from the frame that created the exception is collected. If 1, the data is from the frame above that, and so on.

Leaves fields set to their to original "?" values if it can't parse the stack.


TraceCaller

public TraceCaller(String dump)
Enabled: String dump is a stack dump as retrieved with getStackDump. Construct the frame data as in previous constructor. This is used for testing (which is why it's public).

Method Detail

getStackDump

private String getStackDump(Exception exception)

parse

private void parse(String dump)

findTargetLineBounds

private org.erights.e.develop.trace.TraceCaller.Line findTargetLineBounds(String stackDump)
                                                                   throws Exception
Exception

lineFromPoint

private org.erights.e.develop.trace.TraceCaller.Line lineFromPoint(String stackDump,
                                                                   int middle)
                                                            throws Exception
Exception

advance

private void advance(String stackDump,
                     org.erights.e.develop.trace.TraceCaller.Line line)
              throws Exception
Destructively move the line forward to the next line.

Exception

parseLine

private void parseLine(String stackDump,
                       org.erights.e.develop.trace.TraceCaller.Line line)
                throws Exception
Exception

quitIf

private void quitIf(boolean b)
             throws Exception
Exception

toString

public String toString()
Suppressed:

Overrides:
toString in class Object
Returns:
a string representation of the object.


comments?