Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4259542

HPROF: -Xrunhprof:cpu=times,... doesn't work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P5 P5
    • None
    • 1.2.1, 1.3.0
    • tools
    • x86, sparc
    • solaris_2.6, windows_nt

      RACE 4:
      ORG/oclc/xmlber/Arguments.main(Arguments.java:Compiled method)
      TRACE 2:

      java/security/AccessController.getStackAccessControlContext(AccessController
      .java:Native method)
      java/security/AccessController.getContext(AccessController.java:358)
      java/lang/Thread.init(Thread.java:270)
      TRACE 19:
      java/lang/Object.<init>(Object.java:Unknown line)
      java/util/Hashtable$Entry.<init>(Hashtable.java:Unknown line)
      java/util/Hashtable.put(Hashtable.java:Unknown line)
      sun/io/CharacterEncoding.<clinit>(CharacterEncoding.java:Unknown
      line)
      TRACE 8:
      sun/misc/Launcher$AppClassLoader.getContext(Launcher.java:Unknown
      line)

      sun/misc/Launcher$AppClassLoader.getAppClassLoader(Launcher.java:Unknown
      line)
      sun/misc/Launcher.<init>(Launcher.java:Unknown line)
      sun/misc/Launcher$1.run(Launcher.java:Unknown line)
      TRACE 7:
      java/lang/String.hashCode(String.java:Unknown line)
      java/util/Hashtable.put(Hashtable.java:Unknown line)
      sun/io/CharacterEncoding.<clinit>(CharacterEncoding.java:Unknown
      line)
      sun/io/Converters.getConverterClass(Converters.java:Unknown line)
      TRACE 3:
      java/lang/System.initProperties(System.java:Native method)
      java/lang/System.initializeSystemClass(System.java:783)
      CPU TIME (ms) BEGIN (total = 200) Wed Aug 04 11:03:13 1999
      rank self accum count trace method
         1 5.00% 5.00% 1 20 java/lang/System.setProperty
         2 5.00% 10.00% 2 11 java/lang/String.<init>
         3 5.00% 15.00% 1 17 java/lang/Character.<clinit>
         4 5.00% 20.00% 1 24 java/security/AccessController.getContext
         5 5.00% 25.00% 1 15 java/util/jar/JarFile.getBytes
         6 5.00% 30.00% 1 23 java/io/FileInputStream.open
         7 5.00% 35.00% 2 10 java/util/jar/Attributes.putValue
         8 5.00% 40.00% 1 9 java/lang/Runtime.<clinit>
         9 5.00% 45.00% 1 13 java/lang/Integer.<clinit>
        10 5.00% 50.00% 1 14 sun/misc/Launcher$ExtClassLoader.getExtDirs
        11 5.00% 55.00% 1 18 java/lang/Class.forName0
        12 5.00% 60.00% 1 6 java/lang/Class.forName0
        13 5.00% 65.00% 1 22 sun/io/Converters.getConverterClass
        14 5.00% 70.00% 1 12 sun/security/provider/PolicyFile.<clinit>
        15 5.00% 75.00% 1 21 java/lang/System.initializeSystemClass
        16 5.00% 80.00% 315 16 java/lang/String.charAt
        17 5.00% 85.00% 5808 5 java/lang/String.charAt
        18 5.00% 90.00% 444 7 java/lang/String.hashCode
        19 5.00% 95.00% 444 19 java/lang/Object.<init>
        20 5.00% 100.00% 1 8
      sun/misc/Launcher$AppClassLoader.getContext
      CPU TIME (ms) END
      ---------- end dump.prof --------------------------------------------------

      FYI, I'm running on a Gateway 450 MHz machine with 128 MB RAM under the
      Windows NT 4.0 OS. I'm also using the Cygwin B20 bash shell.

      My initiali impression is that it may generate this message when it throws
      an exception. My application can throw many exceptions during the course of
      its running.


      (Review ID: 93177)
      ======================================================================


      Name: rlT66838 Date: 08/04/99


      When I run my code with:

          java -Xrunhprof:cpu=times,format=a,file=xyz.prof ...

      It generates a large number of

      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..

      I have also seen it access a "forbidden memory" cell and crash
      when running large applications.

      I do not see this problem when running with "...cpu=samples,..."
      argument to Xrunhprof.
      ============================

      Here's a fairly small Java source file which exhibits the problems mentioned
      below. It exhibits this behavior when compiled with either the 1.1.8 or
      1.2.1 compilers.


      --------------------- begin Arguments.java ---------------------------
      package ORG.oclc.xmlber;

      import java.lang.*;
      import java.util.Enumeration;
      import java.util.Hashtable;
      import java.util.Vector;

      /**
       * Arguments provide a standard means of parsing arguments.
       */
      public class Arguments {

        /**
         * This hashtable maps options to their value
         */
        Hashtable args;

        /**
         * This vector contains the remaining parameters of the argument list.
         */
        Vector params;

        /**
         * Create a new Arguments object.
         * @param argStrings array of strings given on the command line.
         * @param options a string containing valid option characters.
         */
        public Arguments( String [] argStrings, String options ) throws
      EvalException {
          // create the hashtable and vector for the options and
          args = new Hashtable();
          params = new Vector();

          /*
           * loop through the arguments, matching the arguments to the allowable
           * options
           */
          int i = 0;
          for ( ; i < argStrings.length; i++ ) {
            if ( argStrings[i].startsWith( "-" )) {
      char opt = argStrings[i].charAt( 1 );
      if ( opt == '-' ) {
      i++;
      break;
      }
      int index = options.indexOf( opt );
      if ( index == -1 ) {
      throw new EvalException( "Unknown argument: " + opt );
      }
      if ( index+1 < options.length() && options.charAt(index+1) == ':' )
      {
      if ( argStrings.length > i+1 ) {
      String value = argStrings[i+1];
      if ( value != null && value.charAt(0) != '-' ) {
      args.put( new Character( opt ), value );
      } else {
      throw new EvalException( "Missing value for option " + opt );
      }
      i++;
      } else {
      throw new EvalException( "Missing value for option " + opt );
      }
      } else {
      args.put( new Character( opt ), new String( "true" ));
      }
            } else {
      break;
            }
          }

          /*
           * put all of the rest of the strings into the parameters vector
           */
          for ( ; i < argStrings.length; i++ ) {
            params.addElement( argStrings[i] );
          }
          params.trimToSize();
        }

        /**
         * getArg returns the value associated with given option
         * @param key the option to retrieve
         */
        public String getArg( char key ) {
          return (String) args.get( new Character( key ));
        }

        /**
         * getArgArgs returns arguments from the parameter list
         */
        public static String getArgArgs( String arg ) {
          int startParen = arg.indexOf( '(' );
          int endParen = arg.lastIndexOf( ')' );

          if ( startParen > 0 && endParen > 0 && endParen - 1 > startParen + 1 )
      {
            return arg.substring( startParen+1, endParen );
          } else {
            return null;
          }
        }

        /**
         * getArgBase returns just the argument without its parameters
         */
        public static String getArgBase( String arg ) {
          int startParen = arg.indexOf( '(' );

          if ( startParen > 0 ) {
            return arg.substring( 0, startParen );
          } else {
            return arg;
          }
        }

        /**
         * getParams returns the parameter vectors
         */
        public Vector getParams() {
          return params;
        }

        public static void main( String [] argStrings ) {
          try {
            Arguments args = new Arguments( argStrings, "i:o:x:ws:c:" );

            String input = args.getArg( 'i' );
            String output = args.getArg( 'o' );
            String xFile = args.getArg( 'x' );
            String warn = args.getArg( 'w' );
            String skip = args.getArg( 's' );
            String count = args.getArg( 'c' );

            if ( input != null ) {
      System.out.println( "Input File: " + input );
            }
            if ( output != null ) {
      System.out.println( "Output File: " + output );
            }
            if ( xFile != null ) {
      System.out.println( "X-File: " + xFile );
            }
            if ( warn != null ) {
      System.out.println( "WARN of unhandled incoming tags" );
            }
            if ( skip != null ) {
      System.out.println( "Skip " + skip + " records before starting
      conversion" );
            }
            if ( count != null ) {
      System.out.println( "Process " + count + " records." );
            }

            Vector param = args.getParams();
            Enumeration parmEnum = param.elements();
            if ( parmEnum.hasMoreElements()) {
      System.out.println( "Parameters:" );
      while ( parmEnum.hasMoreElements()) {
      System.out.println( " " + (String) parmEnum.nextElement() );
      }
            }
          } catch ( EvalException e ) {
            System.err.println( "Exception: " + e.getMessage() );
          }
        }
      }
      --------------------- end Arguments.java -----------------------------
      --------------------- begin EvalException.java -----------------------
      /**
       * This exception is thrown when the data transformation program
       * encounters an evaulation error.
       */

      package ORG.oclc.xmlber;

      public class EvalException extends Exception {

        public EvalException() {
          super();
        }

        public EvalException( String message ) {
          super(message);
        }
      }
      --------------------- end EvalException.java -------------------------

      When run using the command line:

      java -Xrunhprof:cpu=times,format=a,file=dump.prof ORG.oclc.xmlber.Arguments
      -i xyz -o abc 2>&1 | tee dump.out

      I get the following in dump.out:

      ---------- begin dump.out -------------------------------------------
      Input File: xyz Output File: abc HPROF ERROR: method on stack top != method
      exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      HPROF ERROR: method on stack top != method exiting..
      Dumping CPU usage by timing methods ... done.
      ---------- end dump.out ----------------------------------------------

      I also get the following in the dump.prof file:

      ---------- begin dump.prof -------------------------------------------
      JAVA PROFILE 1.0.1, created Wed Aug 04 11:03:12 1999

      Header for -Xhprof ASCII Output

      Copyright 1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto,
      California, 94303, U.S.A. All Rights Reserved.

      WARNING! This file format is under development, and is subject to
      change without notice.

      This file contains the following types of records:

      THREAD START
      THREAD END mark the lifetime of Java threads

      TRACE represents a Java stack trace. Each trace consists
                      of a series of stack frames. Other records refer to
                      TRACEs to identify (1) where object allocations have
                      taken place, (2) the frames in which GC roots were
                      found, and (3) frequently executed methods.

      HEAP DUMP is a complete snapshot of all live objects in the Java
                      heap. Following distinctions are made:

                      ROOT root set as determined by GC
                      CLS classes
                      OBJ instances
                      ARR arrays

      SITES is a sorted list of allocation sites. This identifies
                      the most heavily allocated object types, and the TRACE
                      at which those allocations occurred.

      CPU SAMPLES is a statistical profile of program execution. The VM
                      periodically samples all running threads, and assigns
                      a quantum to active TRACEs in those threads. Entries
                      in this record are TRACEs ranked by the percentage of
                      total quanta they consumed; top-ranked TRACEs are
                      typically hot spots in the program.

      CPU TIME is a profile of program execution obtained by measuring
                      the time spent in individual methods (excluding the time
                      spent in callees), as well as by counting the number of
                      times each method is called. Entries in this record are
                      TRACEs ranked by the percentage of total CPU time. The
                      "count" field indicates the number of times each TRACE
                      is invoked.

      MONITOR TIME is a profile of monitor contention obtained by measuring
      the time spent by a thread waiting to enter a monitor.
      Entries in this record are TRACEs ranked by the percentage
      of total monitor contention time and a brief description
      of the monitor. The "count" field indicates the number of
      times the monitor was contended at that TRACE.

      MONITOR DUMP is a complete snapshot of all the monitors and threads in
      the System.

      HEAP DUMP, SITES, CPU SAMPLES|TIME and MONITOR DUMP|TIME records are
      generated
      at program exit. They can also be obtained during program execution by
      typing
      Ctrl-\ (on Solaris) or by typing Ctrl-Break (on Win32).

      --------

      THREAD START (obj=8342c0, id = 2, name="Signal dispatcher", group="system")
      THREAD START (obj=8352c0, id = 3, name="Reference Handler", group="system")
      THREAD START (obj=838440, id = 4, name="Finalizer", group="system")
      THREAD START (obj=865b40, id = 1, name="main", group="main")
      THREAD END (id = 1)
      THREAD START (obj=89de40, id = 5, name="Thread-0", group="main")
      THREAD END (id = 5)
      TRACE 1:
      <empty>
      TRACE 11:
      java/lang/String.<init>(String.java:Unknown line)
      java/lang/StringBuffer.toString(StringBuffer.java:Unknown line)
      sun/misc/Launcher.getFileURL(Launcher.java:Unknown line)
      sun/misc/Launcher.pathToURLs(Launcher.java:Unknown line)
      TRACE 17:
      java/lang/Character.<clinit>(Character.java:Unknown line)
      java/util/Locale.toLowerCase(Locale.java:Unknown line)
      java/util/Locale.<init>(Locale.java:Unknown line)
      java/util/Locale.<clinit>(Locale.java:Unknown line)
      TRACE 24:

      java/security/AccessController.getContext(AccessController.java:Unknown
      line)
      java/lang/Thread.init(Thread.java:Unknown line)
      java/lang/Thread.<init>(Thread.java:Unknown line)
      TRACE 15:
      java/util/jar/JarFile.getBytes(JarFile.java:Unknown line)
      java/util/jar/JarFile.getManifest(JarFile.java:Unknown line)

      sun/misc/URLClassPath$JarLoader.getClassPath(URLClassPath.java:Unknown line)
      sun/misc/URLClassPath.getLoader(URLClassPath.java:Unknown line)
      TRACE 23:
      java/io/FileInputStream.open(FileInputStream.java:Unknown line)
      java/io/FileInputStream.<init>(FileInputStream.java:Unknown line)
      java/io/FileInputStream.<init>(FileInputStream.java:Unknown line)
      java/security/Security.initialize(Security.java:Unknown line)
      TRACE 10:
      java/util/jar/Attributes.putValue(Attributes.java:Unknown line)
      java/util/jar/Attributes.read(Attributes.java:Unknown line)
      java/util/jar/Manifest.read(Manifest.java:Unknown line)
      java/util/jar/Manifest.<init>(Manifest.java:Unknown line)
      TRACE 9:
      java/lang/Runtime.<clinit>(Runtime.java:Unknown line)
      java/lang/System.loadLibrary(System.java:Unknown line)

      sun/security/action/LoadLibraryAction.run(LoadLibraryAction.java:Unknown
      line)

      java/security/AccessController.doPrivileged(AccessController.java:Unknown
      line)
      TRACE 13:
      java/lang/Integer.<clinit>(Integer.java:Unknown line)
      java/lang/String.valueOf(String.java:Unknown line)
      java/lang/StringBuffer.append(StringBuffer.java:Unknown line)
      java/security/Security.loadProviders(Security.java:Unknown line)
      TRACE 14:
      sun/misc/Launcher$ExtClassLoader.getExtDirs(Launcher.java:Unknown
      line)

      sun/misc/Launcher$ExtClassLoader.getExtClassLoader(Launcher.java:Unknown
      line)
      sun/misc/Launcher.<init>(Launcher.java:Unknown line)
      sun/misc/Launcher$1.run(Launcher.java:Unknown line)
      TRACE 18:
      java/lang/Class.forName0(Class.java:Unknown line)
      java/lang/Class.forName(Class.java:Unknown line)
      sun/io/Converters.getConverterClass(Converters.java:Unknown line)
      sun/io/Converters.getDefaultConverterClass(Converters.java:Unknown
      line)
      TRACE 6:
      java/lang/Class.forName0(Class.java:Unknown line)
      java/lang/Class.forName(Class.java:Unknown line)

      sun/misc/Launcher$Factory.createURLStreamHandler(Launcher.java:Unknown line)
      sun/misc/Launcher.getFileURL(Launcher.java:Unknown line)
      TRACE 20:
      java/lang/System.setProperty(System.java:Unknown line)
      java/lang/Compiler.<clinit>(Compiler.java:Unknown line)
      TRACE 12:
      sun/security/provider/PolicyFile.<clinit>(PolicyFile.java:Unknown
      line)
      java/lang/Class.forName0(Class.java:Unknown line)
      java/lang/Class.forName(Class.java:Unknown line)
      java/security/Policy.getPolicyNoCheck(Policy.java:Unknown line)
      TRACE 21:
      java/lang/System.initializeSystemClass(System.java:Unknown line)
      TRACE 16:
      java/lang/String.charAt(String.java:Unknown line)
      java/util/Properties.load(Properties.java:Unknown line)
      java/security/Security.initialize(Security.java:Unknown line)
      java/security/Security.access$0(Security.java:Unknown line)
      TRACE 5:
      java/lang/String.charAt(String.java:Unknown line)
      java/lang/Character.<clinit>(Character.java:Unknown line)
      java/util/Locale.toLowerCase(Locale.java:Unknown line)
      java/util/Locale.<init>(Locale.java:Unknown line)
      TRACE 22:
      sun/io/Converters.getConverterClass(Converters.java:Unknown line)
      sun/io/Converters.getDefaultConverterClass(Converters.java:Unknown
      line)
      sun/io/Converters.newDefaultConverter(Converters.java:Unknown line)

      sun/io/CharToByteConverter.getDefault(CharToByteConverter.java:Unknown line)
      T

            ohair Kelly Ohair (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: