By attaching the user initiated gdb thread to VM, JNI methods dispatching call into VM is invoked just as ordinary C methods. Though synchronization related problems exist, the tool eases debugging. The Enhanced Low Level Debugger Interface dynamically register new method of interest to gdb, and maintain a record so that re-compiled versions are monitored the same way.... read more
1.choose target method
A sample use of the debugger:
MRP with harmony lib can now pass all dacapo-2006 test cases, and all dacapo-9.12-bach test cases except batik. Harmoy awt implementation has non-implemented methods. This project provided the critical VM level debugging tools.
Implementation details:
This library uses RandomAccess file to output bytes to hard disk and passes the resulting object file to native code to register with GDB. Native code is implemented as JikesRVM SysCall. It maps the object file into memory and then manages the registering and removal of the compiled method.
To fill in length field in object file, elf4j uses placeholders. This lib updates all placeholders after content body is written out.
ELF file sections include: ".shstrtab", ".strtab", ".symtab", ".text", ".eh_frame" | ".debug_frame", ".debug_line", ".debug_str", ".debug_abbrev", ".debug_info", ".debug_aranges", ".debug_pubnames", ".debug_pubtypes".
.text section is filled with RVM binary code.
.debug_line is extracted from BaseLineCompiler byteCodeMap or OptCompiler _mcMap.
.eh_frame is extracted from recorded information in CompiledMethod. Enhanced BaseLineCompiler, OptCompiler and JNICompiler stores instrution offset of following operations for later use:push $rsp, mov $fp $rsp, pop $fp, ret. Also they will store first local offset on stack inside __local0 variable. Parameters is available for BaselineCompiled method. For OptCompiled method, first 2 parameter value stored in registers may not be available on stack. They have to be manually fetched from local stack and not parameter stack.... read more
I developed GC algorithm on Jikes rvm and ported the OPT compiler to x86_64. All of the work is currently available as patches under MRP project, a fork of RVM. Hopefully they'd be part of the code base.
During the R&&D process, I find low level debugging necessary and gdb is mandatory. When vm is not stable, only gdb can help. I need gdb to do difficult work: disassemble, signal handling, stack examine and core file reading. To further improve the interoperability between java and gdb, I use the gdb-jit interface. V8 of javascript,LLVM of CLang all have supported the interface. ... read more