General debugging hints

Jalimo maintains a page where they collect information on cross-debugging Cacao. Albeit it is using OpenEmbedded the information can be adapted to other build systems as well.

Useful macros

Steps one instruction and disassembles the current instruction:

define sdi
        stepi
        disass $pc $pc+1
end

Prints the procedure vector for a program counter:

Usage: pv <pc>

define pv
        call codegen_get_pv_from_pc($arg0)
end

For a given program counter, prints the name of the containing java method:

Usage: methodinfo <pc>

define methodinfo
        printf "Method at 0x%08X is %s/%s\n", \
        $arg0, \
        (*(codeinfo **)(codegen_get_pv_from_pc($arg0) - 4))->m->class->name->text, \
        (*(codeinfo **)(codegen_get_pv_from_pc($arg0) - 4))->m->name->text
end

For a given program counter, prints the stackframe size of the containing java method.

Usage: framesize <pc>

define framesize
        printf "Framesize is %d\n", *(int *)(codegen_get_pv_from_pc($arg0) - 8)
end

For a given stack pointer and frame size, prints the return address.

Usage: ra <sp> <framesize>

define ra
        printf "RA for SP 0x%08X and framesize %d is 0x%08X.\n", \
                $arg0, \
                $arg1, \
                *(void **)($arg0 + $arg1 - 8)
end

Prints the runtime type of a java object.

Usage: class <address>

define class
    printf "Class of object 0x%08X is %s.\n", \
        $arg0, \
        ((java_object_t *)($arg0))->vftbl->class->name->text
end

cacaowiki: GdbMacros (last edited 2008-05-26 11:13:30 by RobertSchuster)