< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java

Print this page




1893       } catch(IOException exp) {
1894          return genHTMLErrorMessage(exp);
1895       }
1896    }
1897 
1898    protected String genJavaStackTraceTitle(JavaThread thread) {
1899       Formatter buf = new Formatter(genHTML);
1900       buf.append("Java Stack Trace for ");
1901       buf.append(thread.getThreadName());
1902       return buf.toString();
1903    }
1904 
1905    public String genHTMLForJavaStackTrace(JavaThread thread) {
1906       Formatter buf = new Formatter(genHTML);
1907       buf.genHTMLPrologue(genJavaStackTraceTitle(thread));
1908 
1909       buf.append("Thread state = ");
1910       buf.append(thread.getThreadState().toString());
1911       buf.br();
1912       buf.beginTag("pre");

1913       for (JavaVFrame vf = thread.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) {
1914          Method method = vf.getMethod();
1915          buf.append(" - ");
1916          buf.append(genMethodLink(method));
1917          buf.append(" @bci = " + vf.getBCI());
1918 
1919          int lineNumber = method.getLineNumberFromBCI(vf.getBCI());
1920          if (lineNumber != -1) {
1921             buf.append(", line = ");
1922             buf.append(lineNumber);
1923          }
1924 
1925          sun.jvm.hotspot.debugger.Address pc = vf.getFrame().getPC();
1926          if (pc != null) {
1927             buf.append(", pc = ");
1928             buf.link(genPCHref(addressToLong(pc)), pc.toString());
1929          }
1930 
1931          if (!method.isStatic() && !method.isNative()) {
1932             try {


1937                   buf.append(oopHandle.toString());
1938                }
1939             } catch (WrongTypeException e) {
1940               // Do nothing.
1941               // It might be caused by JIT'ed inline frame.
1942             }
1943          }
1944 
1945          if (vf.isCompiledFrame()) {
1946             buf.append(" (Compiled");
1947          }
1948          else if (vf.isInterpretedFrame()) {
1949             buf.append(" (Interpreted");
1950          }
1951 
1952          if (vf.mayBeImpreciseDbg()) {
1953             buf.append("; information may be imprecise");
1954          }
1955          buf.append(")");
1956          buf.br();













1957       }
1958 
1959       buf.endTag("pre");
1960       buf.genHTMLEpilogue();
1961       return buf.toString();
1962    }
1963 
1964    public String genHTMLForHyperlink(String href) {
1965       if (href.startsWith("klass=")) {
1966          href = href.substring(href.indexOf('=') + 1);
1967          Klass k = getKlassAtAddress(href);
1968          if (Assert.ASSERTS_ENABLED) {
1969             Assert.that(k instanceof InstanceKlass, "class= href with improper InstanceKlass!");
1970          }
1971          return genHTML((InstanceKlass) k);
1972       } else if (href.startsWith("method=")) {
1973          href = href.substring(href.indexOf('=') + 1);
1974          Method obj = getMethodAtAddress(href);
1975          if (Assert.ASSERTS_ENABLED) {
1976             Assert.that(obj instanceof Method, "method= href with improper Method!");




1893       } catch(IOException exp) {
1894          return genHTMLErrorMessage(exp);
1895       }
1896    }
1897 
1898    protected String genJavaStackTraceTitle(JavaThread thread) {
1899       Formatter buf = new Formatter(genHTML);
1900       buf.append("Java Stack Trace for ");
1901       buf.append(thread.getThreadName());
1902       return buf.toString();
1903    }
1904 
1905    public String genHTMLForJavaStackTrace(JavaThread thread) {
1906       Formatter buf = new Formatter(genHTML);
1907       buf.genHTMLPrologue(genJavaStackTraceTitle(thread));
1908 
1909       buf.append("Thread state = ");
1910       buf.append(thread.getThreadState().toString());
1911       buf.br();
1912       buf.beginTag("pre");
1913       int count = 0;
1914       for (JavaVFrame vf = thread.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) {
1915          Method method = vf.getMethod();
1916          buf.append(" - ");
1917          buf.append(genMethodLink(method));
1918          buf.append(" @bci = " + vf.getBCI());
1919 
1920          int lineNumber = method.getLineNumberFromBCI(vf.getBCI());
1921          if (lineNumber != -1) {
1922             buf.append(", line = ");
1923             buf.append(lineNumber);
1924          }
1925 
1926          sun.jvm.hotspot.debugger.Address pc = vf.getFrame().getPC();
1927          if (pc != null) {
1928             buf.append(", pc = ");
1929             buf.link(genPCHref(addressToLong(pc)), pc.toString());
1930          }
1931 
1932          if (!method.isStatic() && !method.isNative()) {
1933             try {


1938                   buf.append(oopHandle.toString());
1939                }
1940             } catch (WrongTypeException e) {
1941               // Do nothing.
1942               // It might be caused by JIT'ed inline frame.
1943             }
1944          }
1945 
1946          if (vf.isCompiledFrame()) {
1947             buf.append(" (Compiled");
1948          }
1949          else if (vf.isInterpretedFrame()) {
1950             buf.append(" (Interpreted");
1951          }
1952 
1953          if (vf.mayBeImpreciseDbg()) {
1954             buf.append("; information may be imprecise");
1955          }
1956          buf.append(")");
1957          buf.br();
1958 
1959          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
1960          PrintStream printStream = new PrintStream(bytes);
1961          try (printStream) {
1962              vf.printLockInfo(printStream, count++);
1963              for (String line : bytes.toString().split("\n")) {
1964                  if (genHTML) {
1965                      line = line.replace("<", "&lt;").replace(">", "&gt;");
1966                  }
1967                  buf.append(line);
1968                  buf.br();
1969              }
1970          }
1971       }
1972 
1973       buf.endTag("pre");
1974       buf.genHTMLEpilogue();
1975       return buf.toString();
1976    }
1977 
1978    public String genHTMLForHyperlink(String href) {
1979       if (href.startsWith("klass=")) {
1980          href = href.substring(href.indexOf('=') + 1);
1981          Klass k = getKlassAtAddress(href);
1982          if (Assert.ASSERTS_ENABLED) {
1983             Assert.that(k instanceof InstanceKlass, "class= href with improper InstanceKlass!");
1984          }
1985          return genHTML((InstanceKlass) k);
1986       } else if (href.startsWith("method=")) {
1987          href = href.substring(href.indexOf('=') + 1);
1988          Method obj = getMethodAtAddress(href);
1989          if (Assert.ASSERTS_ENABLED) {
1990             Assert.that(obj instanceof Method, "method= href with improper Method!");


< prev index next >