Node: Breakpoints, Next: , Previous: Statics, Up: gdb Tutorial



Breakpoints, ...

A breakpoint is set by supplying a C++ function name to the break or b command. J2c maps a Java method definition to a toplevel C++ function name by JNI encoding the simple name of the method's class, and the method name, choosing a unique integer, and combining all three seperated by underscores.

Suppose we wish to set a breakpoint on the executive domain Object constructor. Gdb's tab completion can come to our aid. Typing b Object__<tab><tab> results in the following:

     (gdb) b Object__0003c
     Object__0003cclinit_0003e_13477(u1_java_lang_Object_static)
     Object__0003cclinit_0003e_13477(u1_java_lang_Object_static*)
     Object__0003cinit_0003e_26(u1_java_lang_Object)
     Object__0003cinit_0003e_26(u1_java_lang_Object*)
     Object__0003cinit_0003e_7(e_java_lang_Object)
     Object__0003cinit_0003e_7(e_java_lang_Object*)
     (gdb) b Object__0003c
     
Since we don't care about static inintializers or user-domain object, i<tab>7 will complete the method name we care about.

It is often useful to break when an exception is raised. This can be done in a number of ways. J2c currently calls the helper function j2cThrow each time a java exception is thrown, so setting a breakpoint on this function will break on every exception.

j2cThrow takes an Oop argument (HEADER *o in C++), but we generally care o's runtime type rather than it's static type. The command pclass o will display the runtime type the exception being thrown.

If you issue the command list j2cThrow, you will notice that java exceptions are mapped to C++ by throwing a pointer to the exceptions runtime type. Hence, we can use gdb's C++ exception support to set Java catchpoints. For instance, we can stop on every bad array dereference in the executive domain with

     catch throw e_java_lang_ArrayIndexOutOfBoundsException *