Menu

elf4j / Blog: Recent posts

Enhanced Low Level Debugger Interface

Enhanced Low Level debugger Interface

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

Posted by Da Feng 2012-02-20

How to use the low level debugger interface

Usage of low level debugger interface

1.choose target method

A sample use of the debugger:

  • use bootclasspath to load elf4j.jar during boot
  • set "gdb.elf.provider" to provider implementation
  • set "provider.tmp.dir" to tmp dir
  • set "methods.to.register" to target methods, use "package.class.method.signature" format to describe target methods. Better to use fuzzy matching, add "." to distinguish between methods with similar prefix or suffix. Don't register too much methods at a time, ulimit does not allow too many open files. If intermediate method in the call chain is not registered, the stack unwinding doesn't work properly.... read more
Posted by Da Feng 2011-10-29 Labels: how to

1.0 source code uploaded

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:

  1. ELF generation

    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

Posted by Da Feng 2011-10-29 Labels: internals

Project begins, source code is ready.

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

Posted by Da Feng 2011-10-14 Labels: introduction