Class DebugFrameImpl

  • All Implemented Interfaces:
    org.htmlunit.corejs.javascript.debug.DebugFrame

    public class DebugFrameImpl
    extends DebugFrameAdapter

    HtmlUnit's implementation of the DebugFrame interface, which logs stack entries as well as exceptions. All logging is done at the TRACE level. This class does a fairly good job of guessing names for anonymous functions when they are referenced by name from an existing object. See the Rhino documentation or the interface source code for more information on the DebugFrame interface and its uses.

    Please note that this class is intended mainly to aid in the debugging and development of HtmlUnit itself, rather than the debugging and development of web applications.

    See Also:
    DebuggerImpl
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.htmlunit.corejs.javascript.debug.DebuggableScript functionOrScript_  
      private static java.lang.String KEY_LAST_LINE  
      private static java.lang.String KEY_LAST_SOURCE  
      private static org.apache.commons.logging.Log LOG  
    • Constructor Summary

      Constructors 
      Constructor Description
      DebugFrameImpl​(org.htmlunit.corejs.javascript.debug.DebuggableScript functionOrScript)
      Creates a new debug frame.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String getFirstLine​(org.htmlunit.corejs.javascript.Context cx)
      Returns the line number of the first line in this frame's function or script, or ??? if it cannot be determined.
      private java.lang.String getFunctionName​(org.htmlunit.corejs.javascript.Scriptable thisObj)
      Returns the name of the function corresponding to this frame, if it is a function and it has a name.
      private java.lang.String getParamName​(int index)
      Returns the name of the parameter at the specified index, or ??? if there is no corresponding name.
      private static java.lang.String getSourceName​(org.htmlunit.corejs.javascript.Context cx)
      Returns the name of this frame's source.
      void onEnter​(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable activation, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args)
      void onExceptionThrown​(org.htmlunit.corejs.javascript.Context cx, java.lang.Throwable t)
      void onLineChange​(org.htmlunit.corejs.javascript.Context cx, int lineNumber)
      private static java.lang.String stringValue​(java.lang.Object arg)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • functionOrScript_

        private final org.htmlunit.corejs.javascript.debug.DebuggableScript functionOrScript_
    • Constructor Detail

      • DebugFrameImpl

        public DebugFrameImpl​(org.htmlunit.corejs.javascript.debug.DebuggableScript functionOrScript)
        Creates a new debug frame.
        Parameters:
        functionOrScript - the function or script to which this frame corresponds
    • Method Detail

      • onEnter

        public void onEnter​(org.htmlunit.corejs.javascript.Context cx,
                            org.htmlunit.corejs.javascript.Scriptable activation,
                            org.htmlunit.corejs.javascript.Scriptable thisObj,
                            java.lang.Object[] args)
        Specified by:
        onEnter in interface org.htmlunit.corejs.javascript.debug.DebugFrame
        Overrides:
        onEnter in class DebugFrameAdapter
      • stringValue

        private static java.lang.String stringValue​(java.lang.Object arg)
      • onExceptionThrown

        public void onExceptionThrown​(org.htmlunit.corejs.javascript.Context cx,
                                      java.lang.Throwable t)
        Specified by:
        onExceptionThrown in interface org.htmlunit.corejs.javascript.debug.DebugFrame
        Overrides:
        onExceptionThrown in class DebugFrameAdapter
      • onLineChange

        public void onLineChange​(org.htmlunit.corejs.javascript.Context cx,
                                 int lineNumber)
        Specified by:
        onLineChange in interface org.htmlunit.corejs.javascript.debug.DebugFrame
        Overrides:
        onLineChange in class DebugFrameAdapter
      • getFunctionName

        private java.lang.String getFunctionName​(org.htmlunit.corejs.javascript.Scriptable thisObj)
        Returns the name of the function corresponding to this frame, if it is a function and it has a name. If the function does not have a name, this method will try to return the name under which it was referenced. See this page for a good explanation of how the thisObj plays into this guess.
        Parameters:
        thisObj - the object via which the function was referenced, used to try to guess a function name if the function is anonymous
        Returns:
        the name of the function corresponding to this frame
      • getParamName

        private java.lang.String getParamName​(int index)
        Returns the name of the parameter at the specified index, or ??? if there is no corresponding name.
        Parameters:
        index - the index of the parameter whose name is to be returned
        Returns:
        the name of the parameter at the specified index, or ??? if there is no corresponding name
      • getSourceName

        private static java.lang.String getSourceName​(org.htmlunit.corejs.javascript.Context cx)
        Returns the name of this frame's source.
        Returns:
        the name of this frame's source
      • getFirstLine

        private static java.lang.String getFirstLine​(org.htmlunit.corejs.javascript.Context cx)
        Returns the line number of the first line in this frame's function or script, or ??? if it cannot be determined. This is necessary because the line numbers provided by Rhino are unordered.
        Returns:
        the line number of the first line in this frame's function or script, or ??? if it cannot be determined