[RFA/JVMTI] Implement GetLocalVariableTable and GetMaxLocals
Keith Seitz
keiths@redhat.com
Tue Feb 13 18:27:00 GMT 2007
Tom Tromey wrote:
> Ok. One more problem I failed to notice earlier :(
Oh boy. My bad... I don't know why I didn't notice this. Or perhaps I've
missed the point.
A long time ago (20070207), Tom wrote:
> Kyle> + int get_local_var_table (char **name, char **sig, char
**generic_sig,
> Kyle> + long *startloc, jint *length, jint
*slot,
> Kyle> + int table_slot)
> Kyle> + *name = reinterpret_cast<char *>
> Kyle> + (_Jv_AllocBytes (strlen
(local_var_table[table_slot].name) + 1));
>
> I don't see how memory allocated here can ever be freed.
The client is responsible for doing it:
jint entry_count;
jvmtiLocalVariableEntry *table;
jvmtiError err;
err = env->GetLocalVariableTable(method, entry_count, table);
if (err != JVMTI_ERROR_NONE)
// whatever
// do something with the table
for (jint i = 0; i < entry_count; ++i)
{
jvmtiLocalVaribleEntry ve = table[i];
env->Deallocate ((unsigned char *) ve->name);
env->Deallocate ((unsigned char *) ve->signature);
if (ve->generic_signature != NULL)
env->Deallocate ((unsigned char *) ve->generic_signature);
}
env->Deallocate ((unsigned char *) table);
Or at least that's what I get from the spec (reformatted by me):
"jvmtiLocalVariableEntry **table_ptr
On return, points to an array of local variable table entries.
Agent passes a pointer to a jvmtiLocalVariableEntry*. On return, the
jvmtiLocalVariableEntry* points to a newly allocated array of size
*entry_count_ptr. The array should be freed with Deallocate. The
pointers returned in the field name of jvmtiLocalVariableEntry are newly
allocated arrays. The arrays should be freed with Deallocate. The
pointers returned in the field signature of jvmtiLocalVariableEntry are
newly allocated arrays. The arrays should be freed with Deallocate. The
pointers returned in the field generic_signature of
jvmtiLocalVariableEntry are newly allocated arrays. The arrays should be
freed with Deallocate."
??
Keith
More information about the Java-patches
mailing list