Skip to main content

How to debug a midlet in phoneme

13 replies [Last post]
river2060
Offline
Joined: 2007-04-02
Points: 0

must debug with an ide, or i can debug it with command line?
then can i step into, step over ,pause, and set breakpoint when i debug midlet?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
saru530
Offline
Joined: 2010-02-15
Points: 0

hi Andrey,

Could you please elaborate how to debug the system classes?.

I am able to debug the user MIDlets, but when I step into System classes it actually executes the system method.

Below I am writing the cldc build script which I used to build VM.

. setup.sh

make -C $HOME/cldc/build/javacall_i386_vc \
JDK_DIR=c:/java \
ENABLE_PCSL=true \
PCSL_OUTPUT_DIR=$Output/pcsl \
JAVACALL_OUTPUT_DIR=$Output/javacall \
JVMWorkSpace=$HOME/cldc \
JVMBuildSpace=$Output/cldc \
TOOLS_DIR=$HOME/tools \
TOOLS_OUTPUT_DIR=$Output/tools \
USE_VS2005=true \
ENABLE_JAVA_DEBUGGER=true \
ENABLE_ROM_DEBUG_SYMBOLS=true \
ENABLE_ROM_JAVA_DEBUGGER=true \
ENABLE_SYSTEM_CLASSES_DEBUG=true \
$1

if [ $? -ne 0 ]; then
echo "cldc_status=failed" >> $Log
else
echo "cldc_status=OK" >> $Log
fi

. $Scripts/teardown.sh

Thanks in advance.

Regards,
Saravanan

river2060
Offline
Joined: 2007-04-02
Points: 0

D:\a\midp\bin\i386>java -classpath kdp.jar kdp.KVMDebugProxy -l 2810 -r hostname
2808 -p -m -cp ../../classes.zip
KVMListener: hostname
Exception during handshake: java.lang.NullPointerException exiting...

when i use -classpath option and use kdp.KVMDebugProxy after kdp.jar , it returns another error...
and what't the problem now?

danila
Offline
Joined: 2006-09-25
Points: 0

Try substitute 'hostname' in your command line with the actual name of the host on which you run phoneME.
Also append the path to your midlet classes to ../../classes.zip in the last argument, e.g.:
... -cp ../../classes.zip:your_midlet.jar

river2060
Offline
Joined: 2007-04-02
Points: 0

now my jdb can connect the KVM, but when i use step, it returns error immediately, which means i can not debug it at the first point, can anybody tell me the reason? i can run this midlet well in phonmeme using user_test, but when i debug it , it returns error.

my commands used at this time:

java -classpath kdp.jar kdp.KVMDebugProxy -l 1234 -p -r localhost 2808 -cp ../../classes.zip

runMidlet_g.exe -port 2808 -debug l 2

jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=1234

danila
Offline
Joined: 2006-09-25
Points: 0

Where are your midlet classes located?

If they are romized and linked with phoneME binaries, along with the system classes,
then you need to enable debugging of system classes in order to debug your midlet.
To enable debugging of system classes pass additional flags when building cldc:
ENABLE_ROM_JAVA_DEBUGGER=true and ENABLE_SYSTEM_CLASSES_DEBUG=true

river2060
Offline
Joined: 2007-04-02
Points: 0

i install the midlet in phoneme by command installMidlet url.

the details of the error i got when i use step follows like that:
C:\WINDOWS\system32>jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,por
t=1234
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
>
VM Started: No frames on the current call stack

Thread1[1] threads
Group KVM_System:
(java.lang.Thread)0x1 Thread1 running
Thread1[1] step
Internal exception:
java.lang.IllegalThreadStateException
at com.sun.tools.jdi.JDWPException.toJDIException(JDWPException.java:45)

at com.sun.tools.jdi.EventRequestManagerImpl$EventRequestImpl.set(EventR
equestManagerImpl.java:181)
at com.sun.tools.jdi.EventRequestManagerImpl$EventRequestImpl.setEnabled
(EventRequestManagerImpl.java:142)
at com.sun.tools.jdi.EventRequestManagerImpl$EventRequestImpl.enable(Eve
ntRequestManagerImpl.java:127)
at com.sun.tools.example.debug.tty.Commands.commandStep(Commands.java:64
7)
at com.sun.tools.example.debug.tty.TTY.executeCommand(TTY.java:275)
at com.sun.tools.example.debug.tty.TTY.(TTY.java:539)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:850)
Thread1[1]

danila
Offline
Joined: 2006-09-25
Points: 0

Just to double check, do you pass a path to midlet classes to the debug proxy?
E.g. [...] -cp ../../classes.zip:your_midlet.jar

river2060
Offline
Joined: 2007-04-02
Points: 0

E.g. [...] -cp ../../classes.zip:your_midlet.jar

I have passed -cp ../../classes.zip to the
java -classpath kdp.jar kdp.KVMDebugProxy -l 1234 -p -r localhost 2808 -cp ../../../classes.zip command, but not :your_midlet.jar, is this a colon or a semicolon,when i use colon i found a error that shows:

Couldn't open JAR file ..\..\classes.zip:hanoi.jar
Couldn't open JAR file ..\..\classes.zip:hanoi.jar
Couldn't open JAR file ..\..\classes.zip:hanoi.jar

and when i use semicolon it still returns that error i show you before,

[...] -cp ../../classes.zip:your_midlet.jar
maybe i put my :your_midlet.jar in the wrong place, so where should i place this file. i put it in the same place as classes.zip or the same place as kdp.jar, and both return errors. so where did you put your milet.jar?

danila
Offline
Joined: 2006-09-25
Points: 0

Yes, sorry, it should be semicolon for Windows. It should be appended to classes.zip.

river2060
Offline
Joined: 2007-04-02
Points: 0

you mean i should include midlet.jar in the classes.zip,right?
so i should add midlet.jar to classes.zip by hand?

danila
Offline
Joined: 2006-09-25
Points: 0

No, just append it in the command-line arg ../../classes.zip;your_midlet.jar

aap031
Offline
Joined: 2006-10-18
Points: 0

Hi!

You should be able to use virtually any JDWP compatible debugger. For example it can be jdb for command line or Netbeans as an IDE. What you should do is to:
- build phoneME as follows:
-- set "ENABLE_JAVA_DEBUGGER=true" option when building cldc
-- set "USE_JAVA_DEBUGGER=true" for midp build
- run KDWP proxy as:
-- java -jar kdp.jar -l 2810 -r hostname 2808 -p -m -cp ../../classes.zip
-- assuming you run from $MIDP_OUTPUT_DIR/bin/i386 directory
-- "-m" switch if for MVM mode. If you compiled in SVM mode please do not use it
- run VM like:
-- runMidlet -debug internal -classpathext midlet.jar midletclassname
- attach your debugger
-- jdb -connect com.sun.jdi.SocketAttach:port=2810
-- or use GUI to attach IDE's debugger using the same parameters

You should be able to utilize all debug features of your debugger, including of course those you listed.

In case you using IDE there should be a way to automate the whole process. I have build.xml sample for Netbeans for this purpose, please reply if you interested (just don't have it on hand now).

Also in cause you interested in entering system code when debugging there are several changes to the process I described. I can elaborate if needed

Regards,
Andrey

river2060
Offline
Joined: 2007-04-02
Points: 0

when i use java -jar kdp.jar -l 2810 -r hostname 2808 -p -m -cp ../../classes.zip,
it returns Invalid or corrupt jarfile kdp.jar, what's wrong?