jdb: socket problem, what is wrong?
dear all, i am new to jdb, thanks for help.
i am using windows OS.
when i use shared-memory in jdb, every thing is OK, but i can not use socket, follwing is what i did:
run first bat file with command successfully:
java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y -classpath G:\Victor\Vc5060\Develop\_Test\java\debug\class; Frm0
java says:
Listening for transport dt_socket at address: 1369
then run jdb in second bat file with command:
"e:\install\java\jdk1.3.1_05\bin\jdb" -attach 1369
jdb says:
Error accessing shared memory, rc = -1
java.io.IOException: shmemBase_attach failed, error code = -1
at com.sun.tools.jdi.SharedMemoryTransport.attach0(Native Method)
at com.sun.tools.jdi.SharedMemoryTransport.attach(SharedMemoryTransport.
java:41)
at com.sun.tools.jdi.SharedMemoryAttachingConnector.attach(SharedMemoryA
ttachingConnector.java:41)
at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnectio
n.java:284)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:1
31)
at com.sun.tools.example.debug.tty.Env.init(Env.java:63)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:918)
Fatal error:
Unable to attach to target VM.
//====================================================
my Q is:
1. what is wrong in jdb command?
2. i use socket, why i got shared-memory error?
3. can i use socket for jdb on windows OS?
many thanks
[1599 byte] By [
soso999a] at [2007-9-29 15:05:58]

Hello
You wrote:
> i am using windows OS.
> when i use shared-memory in jdb, every thing is OK,
> but i can not use socket
The default transport on win32 platforms is shared memory.
Socket transport is available on win32, but you have to make
sure both debugee and debugger are started properly to
override the default.See below for an example.
[as a side note, the default transport on U*ix platforms (Solaris,
Linux, etc...) is socket.]
>, follwing is what i did:
>
> run first bat file with command successfully:
> java -Xdebug -Xnoagent -Djava.compiler=NONE
> -Xrunjdwp:transport=dt_socket,server=y,suspend=y
> -classpath
> G:\Victor\Vc5060\Develop\_Test\java\debug\class; Frm0
>
> java says:
> Listening for transport dt_socket at address: 1369
That's fine. You started the debugee with the correct
parameters to use the socket transport. Since you did
not specify a port number, the transport selected one
and printed it out: 1369
> then run jdb in second bat file with command:
>
> "e:\install\java\jdk1.3.1_05\bin\jdb" -attach 1369
>
> jdb says:
>
> Error accessing shared memory, rc = -1
Here is the problem. The debugger is trying to use
the default transport (shared memory) and cannot connect
to the debugee. You need to start jdb like this so that
it will use the correct transport and connect to the debugee:
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=1369
Note the port number (1369) matches the value selected by the
debugee during startup.
For more information, refer to "JPDA Connection and Invocation Details":
http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html