How to debug hotspot integrated with java codes

Xiaobin Lu Xiaobin.Lu at Sun.COM
Mon Dec 15 14:52:47 PST 2008


I am attaching the realpath program and as its name suggests, it resolve 
the file path and gives it the real full path.

-Xiaobin
On 12/15/08 14:23, Colin(Du Li) wrote:
> Hi, Xiaobin,
>
> The "gamma" application works well without dbx attached to it.
>
> I tried the script. It give error message "Can't find realpath. 
> Exiting...".
> I guess I need modified the "realpath" in the script.  Right?
> However, what does "realpath" mean?
> Thanks a lot.
>
>
> xiaobin.lu wrote:
>   
>> Hi Colin,
>>
>> It looks like the process hang when it tried to load some classes. Did 
>> the application work without dbx attached to it?
>>
>> Along the link I sent to you, there is a link 
>> (http://developers.sun.com/solaris/articles/Java_debug/Java_debug_content.html) 
>> which tells you how to debug Java process, please take a look at it. We 
>> have a script to launch dbx internally and it takes care of the 
>> LD_LIBRARY_PATH problem as well. I am attaching it in the email. You can 
>> start that script as the following:
>>
>> dbxr <path to java executable> -server (or -client which loads the 
>> server or client VM)
>>
>> -Xiaobin
>>
>> On 12/15/08 10:57, Colin(Du Li) wrote:
>>     
>>> Hi, Xiaobin,
>>>
>>> I tried dbx, but dbx will hang after echo "reading libzip.so" as below:
>>>   
>>>       
>>>> $ dbx $LD_LIBRARY_PATH/gamma 
>>>>     
>>>>         
>>> For information about new features see `help changes'
>>> To remove this message, put `dbxenv suppress_startup_message 7.6' in your
>>> .dbxrc
>>> Reading gamma
>>> Reading ld-linux.so.2
>>> Reading libjvm.so
>>> Reading libm.so.6
>>> Reading libdl.so.2
>>> Reading libpthread.so.0
>>> Reading libc.so.6
>>> (dbx) run -version
>>> Running: gamma -version 
>>> (process id 5777)
>>> Reading librt.so.1
>>> Reading libhpi.so
>>> Reading libnsl.so.1
>>> Reading libnss_files.so.2
>>> Reading libverify.so
>>> Reading libjava.so
>>> Reading libzip.so
>>> ....
>>>
>>> Then I have to kill this process to stop it.
>>> Do you know how to resolve this problem and start dbx properly?
>>> Thanks.
>>>
>>>
>>> xiaobin.lu wrote:
>>>   
>>>       
>>>> Refer to 
>>>> http://developers.sun.com/sunstudio/overview/topics/debug_index.html to 
>>>> find more details on how to use Sun Studio which is available on Linux 
>>>> to debug mixed Java and native code.
>>>>
>>>> -Xiaobin
>>>>
>>>> Colin(Du Li) wrote:
>>>>     
>>>>         
>>>>> Hi, guys.
>>>>>
>>>>> Now I'm debugging Hotspot. I'm using GDB. When I debug the source codes
>>>>> written in  c++, it's fine. But if the VM has launched, I cannot trace
>>>>> into
>>>>> the source codes written in java. e.g. When I find Hotspot cannot load
>>>>> some
>>>>> class, and I wanna step into the class java.lang.ClassLoader ,  I don't
>>>>> know
>>>>> how to trace it. Apparently, I cannot do that with GDB. 
>>>>> Can you guys give me some suggestion for debug in this situation?
>>>>> I spend several days on this problem, and really need  some help on the
>>>>> debug things.
>>>>>
>>>>> Thanks a lot in advance!!
>>>>>
>>>>>
>>>>>
>>>>>   
>>>>>       
>>>>>           
>>>>     
>>>>         
>>>   
>>>       
>> #!/bin/sh
>> clean_temp_files() {
>>     rm -f /tmp/dbxr.$$ /tmp/cmd.$$
>> }
>>
>> arch=
>> if [ -f /proc/cpuinfo ] ; then
>>   arch=`uname -m`
>>   if [ "$arch" = i686 ]; then
>>     arch=i386
>>     realpath=/net/smite.sfbay/export/linux-i586/bin/realpath
>>   fi
>> else 
>>   arch=`uname -p`
>>   if [ "$arch" = sparc ] ; then
>>     realpath=/home/xl116366/bin/realpath
>>     PATH=/shared/dp/venus/sparc-S2/bin:$PATH
>>   elif [ "$arch" = i386 ] ; then
>>     realpath=/net/smite.sfbay/export/i386/realpath
>>     PATH=/shared/dp/venus/intel-S2/bin:$PATH
>>   fi
>> fi
>> if [ -z "$arch" ]; then
>>   echo "Unknown architecture.  Exiting..."
>>   exit 1
>> fi
>>
>> if [ ! -x $realpath ]; then
>>   echo "Can't find realpath.  Exiting..."
>>   exit 1
>> fi
>>
>> exe=$1
>> if [ ! -x "$1" ]; then
>>   exe=`which $1`
>>   dir=`$realpath $exe`
>> else
>>   dir=`$realpath $exe`
>> fi
>> dir=`dirname $dir`
>> dir=`dirname $dir`
>> if [ `basename $dir` = "bin" ]; then
>>   dir=`dirname $dir`
>> fi
>> dir=`$realpath $dir`
>>
>> trap clean_temp_files 2
>>
>> usage() {
>>   echo "Usage: dbxr [ -dbx | -gdb ] [ -window ] [ -core ] [ -corefile
>> <file> ] command ..."
>>   exit
>> }
>>
>> if [ `uname` = "SunOS" ]; then
>>     debugger=dbx
>> else
>>     debugger=gdb
>> fi
>>
>> debugargs=
>> debugprecmd=
>> while [ $# -gt 0 ]; do
>>     if [ $1 = -core ] ; then
>>         debugargs=core
>>         shift
>>     elif [ $1 = -corefile ] ; then
>>         debugargs="$2"
>>         shift 2
>>     elif [ $1 = -help ] ; then
>>         usage
>>     elif [ $1 = -dbx ] ; then
>>         debugger=dbx
>>         shift
>>     elif [ $1 = -gdb ] ; then
>>         debugger=gdb
>>         shift
>>     elif [ $1 = -window ] ; then
>>         if [ -x /usr/dt/bin/dtterm ]; then
>>             debugprecmd="/usr/dt/bin/dtterm -e"
>>         else
>>             debugprecmd="xterm -e"
>>         fi
>>         shift
>>     elif [ $1 = -echo ] ; then
>>         debugprecmd="echo"
>>         shift
>>     else
>>         break;
>>     fi
>> done
>>
>> jvmcfg=$dir/lib/$arch/jvm.cfg
>> extra=:$dir/../lib/$arch
>> if [ -d $dir/jre ]; then
>>     dir=$dir/jre
>>     extra=:$dir/../lib/$arch
>>     jvmcfg=$dir/lib/$arch/jvm.cfg
>> fi
>> if [ "$2" = -client ]; then
>>    
>> LD_LIBRARY_PATH=$dir/lib/$arch/client:$dir/lib/$arch$extra:$LD_LIBRARY_PATH
>> elif [ "$2" = -server ]; then
>>    
>> LD_LIBRARY_PATH=$dir/lib/$arch/server:$dir/lib/$arch$extra:$LD_LIBRARY_PATH
>> elif [ "$2" = -d64 ]; then
>>     if [ "$extra" != "" ]; then
>>       extra=$extra"v9"
>>     fi
>>     
>>     if [ "$arch" = i386 ]; then
>>      
>> LD_LIBRARY_PATH=$dir/lib/amd64/server:$dir/lib/amd64:$dir/../lib/amd64:$LD_LIBRARY_PATH
>>       #echo $LD_LIBRARY_PATH
>>     else 
>>      
>> LD_LIBRARY_PATH=$dir/lib/sparcv9/server:$dir/lib/sparcv9$extra:$LD_LIBRARY_PATH
>>     fi
>> else
>>     default=`awk '/^-/ { print substr($1, 2); exit(0); }' $jvmcfg`
>>    
>> LD_LIBRARY_PATH=$dir/lib/$arch/$default:$dir/lib/$arch$extra:$LD_LIBRARY_PATH
>> fi
>> export LD_LIBRARY_PATH PATH
>> javacmd=$*
>>
>> shift
>> if [ $debugger = "gdb" ] ; then
>>     echo "handle SIGSEGV noprint nostop pass" >> /tmp/cmd.$$
>>     echo "handle SIGUSR2 noprint nostop pass" >> /tmp/cmd.$$
>>     echo "handle SIGILL  noprint nostop pass" >> /tmp/cmd.$$
>>     echo "handle SIGABRT print stop nopass" >> /tmp/cmd.$$
>>     echo "shell rm /tmp/cmd.$$" >> /tmp/cmd.$$
>>     echo "set args $*" >> /tmp/cmd.$$
>>     exec $debugprecmd $debugger --command=/tmp/cmd.$$ $exe
>> else
>>     rm -f /tmp/cmd.$$
>>     echo $debugargs
>>     if [ "$debugargs" != "" ]; then
>>         echo "debug $exe $debugargs" > /tmp/cmd.$$
>>     else
>>         echo "debug $exe" >> /tmp/cmd.$$
>>         echo "runargs $*" >> /tmp/cmd.$$
>>     fi
>>     echo "if [ -f ~/.dbxr.rc ]; then source ~/.dbxr.rc; fi" >> /tmp/cmd.$$
>>     echo "rm /tmp/cmd.$$" >> /tmp/cmd.$$
>>     exec $debugprecmd $debugger -c "source /tmp/cmd.$$"
>> fi
>> clean_temp_files
>>
>>
>>     
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20081215/9c9cf0ce/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: realpath
Type: application/octet-stream
Size: 6296 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20081215/9c9cf0ce/attachment.obj 


More information about the hotspot-dev mailing list