String arguments in kaffe

Godmar Back kaffe@rufus.w3.org
Tue, 25 Aug 1998 12:35:35 -0600 (MDT)


> 
> Harish Sankaran writes:
> > Before a method is actually executed ,I want to trap the string
> > arguments(if any) in the method in the JVM.
> > 
> > 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
> 

Strings are stored as Hjava_lang_String objects.  Use makeCString
to convert them to a printable C string (you must gc_free_fixed it
after you're done.)

In gdb, you might find the following macro useful:

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

	- Godmar