agent/doc/clhsdb.html

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 5029
7b23cb975cf2
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

aoqi@0 1 <html>
aoqi@0 2 <head>
aoqi@0 3 <title>
aoqi@0 4 Command line HSDB
aoqi@0 5 </title>
aoqi@0 6 </head>
aoqi@0 7 <body>
aoqi@0 8
aoqi@0 9 <h1>Command line HSDB</h1>
aoqi@0 10 <p>
aoqi@0 11 When debugging remote core dumps it is easier to work with command line tools instead of
aoqi@0 12 GUI tools. Command line HSDB (CLHSDB) tool is alternative to SA GUI tool HSDB.
aoqi@0 13 </p>
aoqi@0 14
aoqi@0 15 <p>
aoqi@0 16 There is also JavaScript based SA command line interface called <a href="jsdb.html">jsdb</a>.
aoqi@0 17 But, CLHSDB supports Unix shell-like (or dbx/gdb-like) command line interface with
aoqi@0 18 support for output redirection/appending (familiar &gt;, &gt;&gt;), command history and so on.
aoqi@0 19 Each CLHSDB command can have zero or more arguments and optionally end with output redirection
aoqi@0 20 (or append) to a file. Commands may be stored in a file and run using <b>source</b> command.
aoqi@0 21 <b>help</b> command prints usage message for all supported commands (or a specific command)
aoqi@0 22 </p>
aoqi@0 23
aoqi@0 24 <h3>Shell/batch scripts to run command line HSDB</h3>
aoqi@0 25
aoqi@0 26 <ul>
aoqi@0 27 <li>clhsdbproc.sh
aoqi@0 28 <li>clhsdbproc64.sh
aoqi@0 29 <li>clhsdbwindbg.bat
aoqi@0 30 <li>clhsdbwindbg64.bat
aoqi@0 31 </ul>
aoqi@0 32
aoqi@0 33 <h3>Annotated output of CLHSDB help command</h3>
aoqi@0 34
aoqi@0 35 <pre>
aoqi@0 36 <code>
aoqi@0 37 Available commands:
aoqi@0 38 assert true | false <font color="red">turn on/off asserts in SA code</font>
aoqi@0 39 attach pid | exec core <font color="red">attach SA to a process or core</font>
aoqi@0 40 buildreplayjars [all | boot | app] <font color="red">build jars for replay, boot.jar for bootclasses, app.jar for application classes</font>
aoqi@0 41 class name <font color="red">find a Java class from debuggee and print oop</font>
aoqi@0 42 classes <font color="red">print all loaded Java classes with Klass*</font>
aoqi@0 43 detach <font color="red">detach SA from current target</font>
aoqi@0 44 dis address [ length ] <font color="red">disassemble (sparc/x86) specified number of instructions from given address</font>
aoqi@0 45 dissemble address <font color="red">disassemble nmethod</font>
aoqi@0 46 dumpcfg -a | id <font color="red">Dump the PhaseCFG for every compiler thread that has one live</font>
aoqi@0 47 dumpclass { address | name } [ directory ] <font color="red">dump .class file for given Klass* or class name</font>
aoqi@0 48 dumpcodecache <font color="red">dump codecache contents</font>
aoqi@0 49 dumpheap [ file ] <font color="red">dump heap in hprof binary format</font>
aoqi@0 50 dumpideal -a | id <font color="red">dump ideal graph like debug flag -XX:+PrintIdeal</font>
aoqi@0 51 dumpilt -a | id <font color="red">dump inline tree for C2 compilation</font>
aoqi@0 52 dumpreplaydata &lt;address&gt; | -a | &lt;thread_id&gt; [&gt;replay.txt] <font color="red">dump replay data into a file</font>
aoqi@0 53 echo [ true | false ] <font color="red">turn on/off command echo mode</font>
aoqi@0 54 examine [ address/count ] | [ address,address] <font color="red">show contents of memory from given address</font>
aoqi@0 55 field [ type [ name fieldtype isStatic offset address ] ] <font color="red">print info about a field of HotSpot type</font>
aoqi@0 56 findpc address <font color="red">print info. about pointer location</font>
aoqi@0 57 flags [ flag ] <font color="red">show all -XX flag name value pairs. or just show given flag</font>
aoqi@0 58 help [ command ] <font color="red">print help message for all commands or just given command</font>
aoqi@0 59 history <font color="red">show command history. usual !command-number syntax works.</font>
aoqi@0 60 inspect expression <font color="red">inspect a given oop</font>
aoqi@0 61 intConstant [ name [ value ] ] <font color="red">print out hotspot integer constant(s)</font>
aoqi@0 62 jdis address <font color="red">show bytecode disassembly of a given Method*</font>
aoqi@0 63 jhisto <font color="red">show Java heap histogram</font>
aoqi@0 64 jseval script <font color="red">evaluate a given string as JavaScript code</font>
aoqi@0 65 jsload file <font color="red">load and evaluate a JavaScript file</font>
aoqi@0 66 jstack [-v] <font color="red">show Java stack trace of all Java threads. -v is verbose mode</font>
aoqi@0 67 livenmethods <font color="red">show all live nmethods</font>
aoqi@0 68 longConstant [ name [ value ] ] <font color="red">print out hotspot long constant(s)s</font>
aoqi@0 69 mem address [ length ] <font color="red">show contents of memory -- also shows closest ELF/COFF symbol if found</font>
aoqi@0 70 pmap <font color="red">show Solaris pmap-like output</font>
aoqi@0 71 print expression <font color="red">print given Klass*, Method* or arbitrary address</font>
aoqi@0 72 printas type expression <font color="red">print given address as given HotSpot type. eg. print JavaThread &lt;address&gt;</font>
aoqi@0 73 printmdo -a | expression <font color="red">print method data oop</font>
aoqi@0 74 printstatics [ type ] <font color="red">print static fields of given HotSpot type (or all types if none specified)</font>
aoqi@0 75 pstack [-v] <font color="red">show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode</font>
aoqi@0 76 quit <font color="red">quit CLHSDB tool</font>
aoqi@0 77 reattach <font color="red">detach and re-attach SA to current target</font>
aoqi@0 78 revptrs <font color="red">find liveness of oops</font>
aoqi@0 79 scanoops start end [ type ] <font color="red">scan a Oop from given start to end address</font>
aoqi@0 80 search [ heap | codecache | threads ] value <font color="red">search a value in heap or codecache or threads</font>
aoqi@0 81 source filename <font color="red">load and execute CLHSDB commands from given file</font>
aoqi@0 82 symbol name <font color="red">show address of a given ELF/COFF symbol</font>
aoqi@0 83 sysprops <font color="red">show all Java System properties</font>
aoqi@0 84 thread id <font color="red">show thread of id</font>
aoqi@0 85 threads <font color="red">show all Java threads</font>
aoqi@0 86 tokenize ...
aoqi@0 87 type [ type [ name super isOop isInteger isUnsigned size ] ] <font color="red">show info. on HotSpot type</font>
aoqi@0 88 universe <font color="red">print gc universe</font>
aoqi@0 89 vmstructsdump <font color="red">dump hotspot type library in text</font>
aoqi@0 90 verbose true | false <font color="red">turn on/off verbose mode</font>
aoqi@0 91 versioncheck [ true | false ] <font color="red">turn on/off debuggee VM version check</font>
aoqi@0 92 whatis address <font color="red">print info about any arbitrary address</font>
aoqi@0 93 where { -a | id } <font color="red">print Java stack trace of given Java thread or all Java threads (-a)</font>
aoqi@0 94 </code>
aoqi@0 95 </pre>
aoqi@0 96
aoqi@0 97 <h3>JavaScript integration</h3>
aoqi@0 98
aoqi@0 99 <p>Few CLHSDB commands are already implemented in JavaScript. It is possible to extend CLHSDB command set
aoqi@0 100 by implementing more commands in a JavaScript file and by loading it by <b>jsload</b> command. <b>jseval</b>
aoqi@0 101 command may be used to evaluate arbitrary JavaScript expression from a string. Any JavaScript function
aoqi@0 102 may be exposed as a CLHSDB command by registering it using JavaScript <b><code>registerCommand</code></b>
aoqi@0 103 function. This function accepts command name, usage and name of the JavaScript implementation function
aoqi@0 104 as arguments.
aoqi@0 105 </p>
aoqi@0 106
aoqi@0 107 <h3>Simple CLHSDB command implemented in JavaScript</h3>
aoqi@0 108
aoqi@0 109 <b>File: test.js</b>
aoqi@0 110 <pre>
aoqi@0 111 <code>
aoqi@0 112 function helloImpl(name) {
aoqi@0 113 println("hello, " + name);
aoqi@0 114 }
aoqi@0 115
aoqi@0 116 // register the above JavaScript function as CLHSDB command
aoqi@0 117 registerCommand("hello", "hello name", "helloImpl");
aoqi@0 118 </code>
aoqi@0 119 </pre>
aoqi@0 120 ---------<br>
aoqi@0 121
aoqi@0 122 "test.js" can be loaded in CLHSDB prompt using <b>jsload</b> command using
aoqi@0 123
aoqi@0 124 <pre>
aoqi@0 125 <code>
aoqi@0 126 hsdb&gt; jsload test.js
aoqi@0 127 </code>
aoqi@0 128 </pre>
aoqi@0 129
aoqi@0 130 <h3>Compilation Replay</h3>
aoqi@0 131 <p>
aoqi@0 132 When a java process crashes in compiled method, usually a core file is saved.
aoqi@0 133 The replay function can reproduce the compiling process in the core.
aoqi@0 134 <a href="cireplay.html">cireplay.html</a>
aoqi@0 135
aoqi@0 136 </body>
aoqi@0 137 </html>

mercurial