String arguments in kaffe

Patrick Tullmann tullmann at
Tue Aug 25 11:44:34 PDT 1998

Harish Sankaran wrote:
> Before a method is actually executed ,I want to trap the string
> arguments(if any) in the method in the JVM.

I'm curious why you'd want to do this dynamically (as methods are
executed), and not when String objects are created, but I'll assume
you've got good reasons...

> For eg. if there is a method in the class
> g.drawstring("Welcome",10,20) I want to trap the string "Welcome"
> before the method is actually executed.  I tried printing the
> arguments in the function "virtualMachine" in machine.c by printing
> arg[0].v.tword,arg[1].tword etc.  The co-oridnates gets printed ok
> but for some reason I was not able to print the string by giving
> arg[2].v.tstr.

arg[2].v.taddr will be the address of an Hjava_lang_String* object.
The data is stored in the ->data->value array of Java chars.  value is
an array object which has its own ->data->body elements which is where
the string data is stored (as Java chars).  Here's a GDB macro
to print out a Kaffe Java String object.  So, depending on what you
want to do in your with the string, it might get complicated.

   define pJavaString
     set $strcount = ($arg0).data.count
     set $strstart = ($arg0).data.offset
     set $chararr = ($arg0).data.value
     if $strcount < 1
       printf "(String is zero length)\n"
       set $i = 0
       while $i < $strcount
   	printf "%c", ($[$i + $strstart]
   	set $i = $i + 1
       echo \n


More information about the kaffe mailing list