hotspot/agent/src/os/win32/README.txt
author never
Mon, 04 May 2009 22:06:47 -0700
changeset 2744 57f0579fbe09
parent 1 489c9b5090e2
permissions -rw-r--r--
6837224: libsaproc.so on linux needs version of 6799141 Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
This is a "Simple Windows Debug Server" written for the purpose of
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
enabling the Serviceability Agent on Win32. It has backends both for
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
Windows NT 4.0 (using internal Windows APIs for a few routines) as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
well as for 95/98/ME/2000 via the Tool Help APIs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
The reason this debug server is necessary is that the Win32 debug APIs
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
by design tear down the target process when the debugger exits (see
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
knowledge base article Q164205 on msdn.microsoft.com). On Solaris, one
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
can attach to and detach from a process with no effect; this is key to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
allowing dbx and gcore to work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
The Simple Windows Debug Server effectively implements attach/detach
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
functionality for arbitrary debug clients. This allows the SA to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
attach non-destructively to a process, and will enable gcore for Win32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
to be written shortly. While the debugger (the "client" in all of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
source code) is attached, the target process is suspended. (Note that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
the debug server could be extended to support resumption of the target
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
process and transmission of debug events over to the debugger, but
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
this has been left for the future.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
The makefile (type "nmake") builds two executables: SwDbgSrv.exe,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
which is the server process, and SwDbgSub.exe, which is forked by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
server and should not be directly invoked by the user.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
The intent is that these two executables can be installed into
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
C:\WINNT\SYSTEM32 and SwDbgSrv installed to run as a service (on NT),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
for example using ServiceInstaller (http://www.kcmultimedia.com/smaster/). 
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
However, SwDbgSrv can also be run from the command line. It generates
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
no text output unless the source code is changed to enable debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
printouts. As long as any processes which have been attached to by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
SA are alive, the SwDbgSrv and any forked SwDbgSub processes must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
left running. Terminating them will cause termination of the target
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
processes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
The debug server opens port 27000 and accepts incoming connections
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
from localhost only. The security model assumes that if one can run a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
process on the given machine then one basically has access to most or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
all of the machine's facilities; this seems to be in line with the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
standard Windows security model. The protocol used is text-based, so
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
one can debug the debug server using telnet. See README-commands.txt
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
for documentation on the supported commands.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
Testing indicates that the performance impact of attaching to a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
process (and therefore permanently attaching a debugger) is minimal.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
Some serious performance problems had been seen which ultimately
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
appeared to be a lack of physical memory on the machine running the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
system.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
Bugs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
This debug server is fundamentally incompatible with the Visual C++
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
debugger. Once the debug server is used to attach to a process, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
Visual C++ IDE will not be able to attach to the same process (even if
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
the debug server is "detached" from that process). Note that this
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
system is designed to work with the same primitives that C and C++
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
debuggers use (like "symbol lookup" and "read from process memory")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
and exposes these primitives to Java, so in the long term we could
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
solve this problem by implementing platform-specific debug symbol
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
parsing and a platform-independent C++ debugger in Java.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
Note:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
The files IOBuf.cpp and IOBuf.hpp are also used in 
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
building src/os/solaris/agent.