# Command line HSDB

When debugging remote core dumps it is easier to work with command line tools instead of GUI tools. Command line HSDB (CLHSDB) tool is alternative to SA GUI tool HSDB. CLHSDB is launched from the command line using the "jhsdb clhsdb" command.

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

### Annotated output of CLHSDB help command

    Available commands:
      assert true | false turn on/off asserts in SA code
      attach pid | exec core | debugserver  attach SA to a process, core, or remote debug server
      buildreplayjars [all | boot | app] build jars for replay, boot.jar for bootclasses, app.jar for application classes
      class name find a Java class from debuggee and print oop
      classes print all loaded Java classes with Klass*
      detach detach SA from current target
      dis address [ length ]  disassemble (x86) specified number of instructions from given address
      dissemble address disassemble nmethod
      dumpcfg -a | id Dump the PhaseCFG for every compiler thread that has one live
      dumpclass { address | name } [ directory ] dump .class file for given Klass* or class name
      dumpcodecache dump codecache contents
      dumpheap [ file ] dump heap in hprof binary format
      dumpideal -a | id dump ideal graph like debug flag -XX:+PrintIdeal
      dumpilt -a | id dump inline tree for C2 compilation
      dumpreplaydata <address> | -a | <thread_id> [>replay.txt] dump replay data into a file
      echo [ true | false ] turn on/off command echo mode
      examine { address[/count] | address,address } show contents of memory range
      field [ type [ name fieldtype isStatic offset address ] ] print info about a field of HotSpot type
      findpc address print info about pointer location
      findsym name print address of symbol in the executable or shared library
      flags [ flag ] show all -XX flag name value pairs. or just show given flag
      help [ command ] print help message for all commands or just given command
      history show command history. usual !command-number syntax works.
      inspect expression inspect a given oop
      intConstant [ name [ value ] ] print out hotspot integer constant(s)
      jdis address show bytecode disassembly of a given Method*
      jhisto show Java heap histogram
      jstack [-v] [-l] show Java stack trace of all Java threads. -v is verbose mode. -l includes info on owned java.util.concurrent locks.
      livenmethods show all live nmethods
      longConstant [ name [ value ] ] print out hotspot long constant(s)s
      mem [ -v ] { address[/count] | address,address } show contents of memory range. -v adds "findpc" info for addresses
      pmap show Solaris pmap-like output
      print expression print given Klass*, Method* or arbitrary address
      printas type expression print given address as given HotSpot type. eg. print JavaThread <address>
      printmdo -a | expression print method data oop
      printstatics [ type ] print static fields of given HotSpot type (or all types if none specified)
      pstack [-v] [-l] show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode. -l includes info on owned java.util.concurrent locks.
      quit quit CLHSDB tool
      reattach detach and re-attach SA to current target
      revptrs  find liveness of oops
      scanoops start end [ type ] scan a Oop from given start to end address
      search [ heap | codecache | threads ] value search a value in heap or codecache or threads
      source filename load and execute CLHSDB commands from given file
      symbol name show address of a given ELF/COFF symbol
      sysprops show all Java System properties
      thread id show thread of id
      threads show all Java threads
      tokenize ...
      type [ type [ name super isOop isInteger isUnsigned size ] ] show info. on HotSpot type
      universe print gc universe
      vmstructsdump dump hotspot type library in text
      verbose true | false turn on/off verbose mode
      versioncheck [ true | false ] turn on/off debuggee VM version check
      whatis address print info about any arbitrary address. alias for findpc command
      where { -a | id } print Java stack trace of given Java thread or all Java threads (-a)

### Compilation Replay

When a java process crashes in compiled method, usually a core file is saved. The replay function can reproduce the compiling process in the core. cireplay.html