This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[RFA] Record types of method arguments when debugging
- From: Kyle Galloway <kgallowa at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Fri, 23 Feb 2007 15:18:25 -0500
- Subject: [RFA] Record types of method arguments when debugging
Hi,
This patch add a change to the DEBUG interpreter to record the types of
the method arguments so their slots appear valid when accessing local
variables. Since method arguments occupy slots from the beginning of a
method call and are rarely written to, it is necessary to set their type
flags at method invocation. This fixes a problem when accessing local
variables from JVMTI where slots occupied by method arguments would
appear invalid.
Questions/Comments?
- Kyle
Index: /home/kgallowa/work/gcc-commit/libjava/interpret-run.cc
===================================================================
--- /home/kgallowa/work/gcc-commit/libjava/interpret-run.cc (revision 122263)
+++ /home/kgallowa/work/gcc-commit/libjava/interpret-run.cc (working copy)
@@ -27,11 +27,70 @@
_Jv_word locals[meth->max_locals];
-#ifdef DEBUG
+#ifdef DEBUG
+ // This is the information needed to get and set local variables with
+ // proper type checking.
frame_desc.locals = locals;
char locals_type[meth->max_locals];
+ frame_desc.locals_type = locals_type;
+
+ // Set all slots as invalid until they are written to.
memset (locals_type, 'x', meth->max_locals);
- frame_desc.locals_type = locals_type;
+
+ // We need to set the local variable types for the method arguments since
+ // they are valid at invocation.
+
+ _Jv_Method *method = meth->get_method ();
+ int type_ctr = 0;
+
+ // If the method is non-static, we need to set the type for the "this" pointer.
+ if ((method->accflags & java::lang::reflect::Modifier::STATIC) == 0)
+ {
+ frame_desc.locals_type[0] = 'o';
+ type_ctr++;
+ }
+
+ // Now parse the method signature to set the types of the other arguments.
+ int sig_len = method->signature->len ();
+ char *signature = method->signature->chars ();
+ for (int i = 0; signature[i] != ')' && i <= sig_len; i++)
+ {
+ if (signature[i] == 'Z' || signature[i] == 'B' || signature[i] == 'C'
+ || signature[i] == 'S' || signature[i] == 'I')
+ {
+ frame_desc.locals_type[type_ctr] = 'i';
+ type_ctr++;
+ continue;
+ }
+ else if (signature[i] == 'F')
+ {
+ frame_desc.locals_type[type_ctr] = 'f';
+ type_ctr++;
+ continue;
+ }
+ else if (signature[i] == 'J')
+ {
+ frame_desc.locals_type[type_ctr] = 'l';
+ frame_desc.locals_type[type_ctr+1] = 'x';
+ type_ctr += 2;
+ continue;
+ }
+ else if (signature[i] == 'D')
+ {
+ frame_desc.locals_type[type_ctr] = 'd';
+ frame_desc.locals_type[type_ctr+1] = 'x';
+ type_ctr += 2;
+ continue;
+ }
+ else if (signature[i] == 'L')
+ {
+ frame_desc.locals_type[type_ctr] = 'o';
+ type_ctr++;
+ while (signature[i] != ';')
+ i++;
+ continue;
+ }
+ }
#endif
#define INSN_LABEL(op) &&insn_##op
@@ -359,8 +418,6 @@
#ifdef DEBUG
// Get the object pointer for this method, after checking that it is
// non-static.
- _Jv_Method *method = meth->get_method ();
-
if ((method->accflags & java::lang::reflect::Modifier::STATIC) == 0)
frame_desc.obj_ptr = locals[0].o;
#endif