Node: Locals, Next: , Previous: Navigation, Up: gdb Tutorial



Examining local variables

In general, j2c is able to preserve java local variable names. These names are mangled in the same manner as fields, so that this becomes ovm_this. If we are in a call to S3Domain.makeThrowable for the user domain, we can examine the receiver like so

     print *(e_s3_core_domain_S3JavaUserDomain *) ovm_this
     

Note, when precise GC is enabled, reference variables are not stored in C++ local variables, but in a stack-allocated structure called frame, so the above example becomes

     print *(e_s3_core_domain_S3JavaUserDomain *) frame.ovm_this
     

Sometimes, j2c is unable to map bytecode-level local variable numbers to source level variable names. In these situations, it is useful to look at all C++ variables in the method, and try to guess where a Java variable is hiding.

There are differences between Apple gdb v5.3 and FSF gdb v5.3. The most notable Apple extension is show locals. This command prints the names and values of all local variables in the current function. You can get similar results under Linux with the command, show scope current-line-number.