hard to do it, please help me
i have a research task, which has made me dead, if i can't get light from the forum, i really can't continue.
the task is: use an user interface to debug java program.
what i did is:
step 1:
create an user interface, then run java from the interface with following command:
java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,address=jdbconn0,server=y,suspend=y -classpath G:\Victor\Vc5060\Develop\_Test\java\debug\class; Frm0
the step is OK, because java is running successfully.
step 2:
(the user interface is in C++, windows)
send commands such as: "stop at Frm0:30" or "run" through shared-memory, but java doesn't give me any feedback.
key problem is: according to c++ tech, i need to send Events to java to tell it i am writing to shared-memory, but i don't know what Events i should use (normally an event has a string as its name, i need the name).
(if this is not key problem, please let me know what it is and how to use)
if you can help me solve problem above, please give me light on this also:
are the command sent to shared-memory to java just in format of sun-help docs, such as:
"stop at Frm0:30", "run", "cont", and so on?
your answers are very important.
many thanks from heart.
[1324 byte] By [
soso999a] at [2007-9-29 15:06:28]

Hello
You wrote:
> the task is: use an user interface to debug java
> program.
I suggest you spend some time reading the JPDA documentation:
http://java.sun.com/j2se/1.4.2/docs/guide/jpda/jpda.html
http://java.sun.com/j2se/1.4.2/docs/guide/jpda/architecture.html
Once you have an idea how the layers work together, then take
a look at the demo/example debugging code. Compile the samples
and run them.
The example code is available in $JAVA_HOME/demo/jpda/examples.jar:
cd $JAVA_HOME/demo/jpda
jar -xvf examples.jar
The jdb sources are in:
com/sun/tools/example/debug/tty
The javadt (GUI debugger) sources are in:
com/sun/tools/example/debug/gui
and
com/sun/tools/example/debug/bdi
and
com/sun/tools/example/debug/event
The code in:
com/sun/tools/example/debug/expr
is shared by both jdb and javadt.
These files describe the contents of examples.jar:
com/sun/tools/example/doc/index.html
com/sun/tools/example/doc/javadt.html
com/sun/tools/example/doc/jdb.html
com/sun/tools/example/doc/trace.html
> what i did is:
>
> step 1:
> create an user interface, then run java from the
> interface with following command:
> java -Xdebug -Xnoagent -Djava.compiler=NONE
> -Xrunjdwp:transport=dt_shmem,address=jdbconn0,server=y,
> uspend=y -classpath
> G:\Victor\Vc5060\Develop\_Test\java\debug\class; Frm0
>
> the step is OK, because java is running successfully.
>
> step 2:
> (the user interface is in C++, windows)
>
> send commands such as: "stop at Frm0:30" or "run"
> through shared-memory, but java doesn't give me any
> feedback.
If you are trying to communicate directly with the shared
memory region, your program needs to use the correct protocol
(JDWP). For more information, take a look at the diagram on
this page:
http://java.sun.com/j2se/1.4.2/docs/guide/jpda/architecture.html
> key problem is: according to c++ tech, i need to send
> Events to java to tell it i am writing to
> shared-memory, but i don't know what Events i should
> use (normally an event has a string as its name, i
> need the name).
>
> (if this is not key problem, please let me know what
> it is and how to use)
> if you can help me solve problem above, please give me
> light on this also:
>
> are the command sent to shared-memory to java just in
> format of sun-help docs, such as:
> "stop at Frm0:30", "run", "cont", and so on?
No. You cannot send jdb style commands directly to the
debugee. jdb interfaces with the debugee program at a
much higher level. Please refer to the JPDA documentation
identified at the top of this posting.
Hope this helps, and good luck with your project.
thx sir for ur authoritative answer,
i will read docs u recommended line by line as soon as possible, in the moment, i hope u come again and answer following questions (sorry, because answers may be inside ur docs, but ur simple sentences is way for me to go).
1. is it possible to create a c++ user interface (on windows OS) which uses java.exe directly to debug?
if yes, which method is easier (socket or shared-memory)? if one of them is easier, could u type few lines to let me know why?
(if not, i will give up at once).
2. is source code of jdb.exe available? if yes, where is it (web-site)? if not, is jdb.exe developed in c++ (on windows)? (it should be, i guess).
3. windows dos-window (command-window) is a c++ application, all of i need is to develop (similar to) the dos-window, could u give me some hints so i can do it. i mean:
a) if using socket, when i type command (i.e.) "run" in the dos-window then press enter-key, does dos-window send the command directly to same socket-port as described in start command (java -X...)? does the dos-window listen to the same port also?
b) when the dos-window sends "run" command, what is real command sent to jdb (sorry for same reason, it will be my start-point and i enjoy to heard from u directly - it is comfirmed).
many thanks
> 1. is it possible to create a c++ user interface (on
> windows OS) which uses java.exe directly to debug?
> if yes, which method is easier (socket or
> shared-memory)? if one of them is easier, could u
> type few lines to let me know why?
> (if not, i will give up at once).
JVMDI is a C or C++ language interface... but be careful.
You will be creating a shared library that executes in the
same address space as the debugee JVM. Any mistake could
crash the whole process. Also, the debugger may have
performance effects on the JVM and the debugee (since they
are in the same address space) that will make debugging harder.
For more information, refer to "Why do debugger applications
run in a separate VM from the debuggee?" on this web page:
http://java.sun.com/products/jpda/faq.html
On the same page, take a look at "Which interface layer
should I use?"
> 2. is source code of jdb.exe available? if yes, where
> is it (web-site)?
This is available as part of the Sun Community Source Licensing (SCSL)
download of the full J2SE sources:
http://servlet.java.sun.com/help/legal_and_licensing/#195
>if not, is jdb.exe developed in c++
> (on windows)? (it should be, i guess).
No, jdb.exe is just a C language program that starts up
a Java Virtual Machine, executes the class
com.sun.tools.example.debug.tty.TTY,
and passes the other parameters on the command line to the VM.
The Java language code that is executed is exactly the same as what
you will find in the $JAVA_HOME/demo/jpda/examples.jar file.
This command line:
jdb HelloWorld
is the same as:
java -classpath "$JAVA_HOME/lib/tools.jar:." com.sun.tools.example.debug.tty.TTY HelloWorld
