duke@435: duke@435: duke@435: duke@435: Command line HSDB duke@435: duke@435: duke@435: duke@435: duke@435:

Command line HSDB

duke@435:

duke@435: When debugging remote core dumps it is easier to work with command line tools instead of duke@435: GUI tools. Command line HSDB (CLHSDB) tool is alternative to SA GUI tool HSDB. duke@435:

duke@435: duke@435:

duke@435: There is also JavaScript based SA command line interface called jsdb. duke@435: But, CLHSDB supports Unix shell-like (or dbx/gdb-like) command line interface with duke@435: support for output redirection/appending (familiar >, >>), command history and so on. duke@435: Each CLHSDB command can have zero or more arguments and optionally end with output redirection duke@435: (or append) to a file. Commands may be stored in a file and run using source command. duke@435: help command prints usage message for all supported commands (or a specific command) duke@435:

duke@435: duke@435:

Shell/batch scripts to run command line HSDB

duke@435: duke@435: duke@435: duke@435:

Annotated output of CLHSDB help command

duke@435: duke@435:
duke@435: 
duke@435: Available commands:
duke@435:   assert true | false turn on/off asserts in SA code
duke@435:   attach pid | exec core  attach SA to a process or core
duke@435:   class name find a Java class from debuggee and print oop
duke@435:   classes print all loaded Java classes with klassOop
duke@435:   detach detach SA from current target
duke@435:   dis address [ length ]  disassemble (sparc/x86) specified number of instructions from given address
duke@435:   dumpclass { address | name } [ directory ] dump .class file for given klassOop or class name
duke@435:   dumpheap [ file ] dump heap in hprof binary format
duke@435:   echo [ true | false ] turn on/off command echo mode
duke@435:   examine [ address/count ] | [ address,address] show contents of memory from given address
duke@435:   field [ type [ name fieldtype isStatic offset address ] ] print info about a field of HotSpot type
duke@435:   findpc address print info. about pointer location
duke@435:   flags [ flag ] show all -XX flag name value pairs. or just show given flag
duke@435:   help [ command ] print help message for all commands or just given command
duke@435:   history show command history. usual !command-number syntax works.
duke@435:   inspect expression inspect a given oop
duke@435:   jdis address show bytecode disassembly of a given methodOop
duke@435:   jhisto show Java heap histogram
duke@435:   jseval script evaluate a given string as JavaScript code
duke@435:   jsload file load and evaluate a JavaScript file
duke@435:   jstack [-v] show Java stack trace of all Java threads. -v is verbose mode
duke@435:   livenmethods show all live nmethods
duke@435:   mem address [ length ] show contents of memory -- also shows closest ELF/COFF symbol if found
duke@435:   pmap show Solaris pmap-like output
duke@435:   print expression print given klassOop, methodOop or arbitrary address
duke@435:   printas type expression print given address as given HotSpot type. eg. print JavaThread <address>
duke@435:   printstatics [ type ] print static fields of given HotSpot type (or all types if none specified)
duke@435:   pstack [-v] show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode
duke@435:   quit quit CLHSDB tool
duke@435:   reattach detach and re-attach SA to current target
duke@435:   scanoops start end [ type ] scan a Oop from given start to end address
duke@435:   search [ heap | codecache | threads ] value search a value in heap or codecache or threads
duke@435:   source filename load and execute CLHSDB commands from given file
duke@435:   symbol name show address of a given ELF/COFF symbol
duke@435:   sysprops show all Java System properties
duke@435:   threads show all Java threads
duke@435:   tokenize ...
duke@435:   type [ type [ name super isOop isInteger isUnsigned size ] ] show info. on HotSpot type
duke@435:   universe print gc universe
duke@435:   verbose true | false turn on/off verbose mode
duke@435:   versioncheck [ true | false ] turn on/off debuggee VM version check
duke@435:   whatis address print info about any arbitrary address
duke@435:   where { -a | id } print Java stack trace of given Java thread or all Java threads (-a)
duke@435: 
duke@435: 
duke@435: duke@435:

JavaScript integration

duke@435: duke@435:

Few CLHSDB commands are already implemented in JavaScript. It is possible to extend CLHSDB command set duke@435: by implementing more commands in a JavaScript file and by loading it by jsload command. jseval duke@435: command may be used to evaluate arbitrary JavaScript expression from a string. Any JavaScript function duke@435: may be exposed as a CLHSDB command by registering it using JavaScript registerCommand duke@435: function. This function accepts command name, usage and name of the JavaScript implementation function duke@435: as arguments. duke@435:

duke@435: duke@435:

Simple CLHSDB command implemented in JavaScript

duke@435: duke@435: File: test.js duke@435:
duke@435: 
duke@435: function helloImpl(name) {
duke@435:     println("hello, " + name);
duke@435: }
duke@435: 
duke@435: // register the above JavaScript function as CLHSDB command
duke@435: registerCommand("hello", "hello name", "helloImpl");
duke@435: 
duke@435: 
duke@435: ---------
duke@435: duke@435: "test.js" can be loaded in CLHSDB prompt using jsload command using duke@435: duke@435:
duke@435: 
duke@435: hsdb> jsload test.js
duke@435: 
duke@435: 
duke@435: duke@435: duke@435: