Usage: jdb <options> <class> <arguments>where options include: -help print out this message and exit -sourcepath <directories separated by ";"> directories in which to look for source files -attach <address> attach to a running VM at the specified address using standard connector -listen <address> wait for a running VM to connect at the specified address using standard connector -listenany wait for a running VM to connect at any available address using standard connector -launch launch VM immediately instead of waiting for 'run' command -connect <connector-name>:<name1>=<value1>,... connect to target VM using named connector with listed argument values -dbgtrace [flags] print info for debugging jdb -tclient run the application in the Hotspot(tm) Performance Engine (Client) -tserver run the application in the Hotspot(tm) Performance Engine (Server)options forwarded to debuggee process: -v -verbose[:class|gc|jni] turn on verbose mode -D<name>=<value> set a system property -classpath <directories separated by ";"> list directories in which to look for classes -X<option> non-standard target VM option<class> is the name of the class to begin debugging <arguments> are the arguments passed to the main() method of <class>For command help type 'help' at jdb prompt** command list ** run [class [args]] -- start execution of application's main classthreads [threadgroup] -- list threads thread <thread id> -- set default thread suspend [thread id(s)] -- suspend threads (default: all) resume [thread id(s)] -- resume threads (default: all) where [thread id] | all -- dump a thread's stack wherei [thread id] | all -- dump a thread's stack, with pc info up [n frames] -- move up a thread's stack down [n frames] -- move down a thread's stack kill <thread> <expr> -- kill a thread with the given exception object interrupt <thread> -- interrupt a threadprint <expr> -- print value of expression dump <expr> -- print all object information eval <expr> -- evaluate expression (same as print) set <lvalue> = <expr> -- assign new value to field/variable/array element locals -- print all local variables in current stack frameclasses -- list currently known classes class <class id> -- show details of named class methods <class id> -- list a class's methods fields <class id> -- list a class's fieldsthreadgroups -- list threadgroups threadgroup <name> -- set current threadgroupstop in <class id>.<method>[(argument_type,...)] -- set a breakpoint in a method stop at <class id>:<line> -- set a breakpoint at a line clear <class id>.<method>[(argument_type,...)] -- clear a breakpoint in a method clear <class id>:<line> -- clear a breakpoint at a line clear -- list breakpoints catch [uncaught|caught|all] <exception-class id> -- break when specified exception occurs ignore [uncaught|caught|all] <exception-class id> -- cancel 'catch' for the specified exception watch [access|all] <class id>.<field name> -- watch access/modifications to a field unwatch [access|all] <class id>.<field name> -- discontinue watching access/modifications to a field trace methods [thread] -- trace method entry and exit untrace methods [thread] -- stop tracing method entry and exit step -- execute current line step up -- execute until the current method returns to its caller stepi -- execute current instruction next -- step one line (step OVER calls) cont -- continue execution from breakpointlist [line number|method] -- print source code use (or sourcepath) [source file path] -- display or change the source path exclude [class id ... | "none"] -- do not report step or method events for specified classes classpath -- print classpath info from target VMmonitor <command> -- execute command each time the program stops monitor -- list monitors unmonitor <monitor#> -- delete a monitor read <filename> -- read and execute a command filelock <expr> -- print lock info for an object threadlocks [thread id] -- print lock info for a threadpop -- pop the stack through and including the current frame reenter -- same as pop, but current frame is reentered redefine <class id> <class file name> -- redefine the code for a classdisablegc <expr> -- prevent garbage collection of an object enablegc <expr> -- permit garbage collection of an object!! -- repeat last command <n> <command> -- repeat command n times help (or ?) -- list commands version -- print version information exit (or quit) -- exit debugger<class id> or <exception-class id>: full class name with package qualifiers or a pattern with a leading or trailing wildcard ('*') NOTE: any wildcard pattern will be replaced by at most one full class name matching the pattern. <thread id>: thread number as reported in the 'threads' command <expr>: a Java(tm) Programming Language expression. Most common syntax is supported.Startup commands can be placed in either "jdb.ini" or ".jdbrc" in user.home or user.dir 设好classpath,运行: jdb **.**.Class提示符为>:stop at <class id>:<line> //类名:行号,运行到此处停止run //开始运行停止后: print <expr> -- print value of expression dump <expr> -- print all object information eval <expr> -- evaluate expression (same as print) set <lvalue> = <expr> -- assign new value to field/variable/array element locals -- print all local variables in current stack frame 看变量值,改变量值.step -- execute current line单步执行 step up -- execute until the current method returns to its caller执行完当前函数 stepi -- execute current instruction next -- step one line (step OVER calls)下一句 cont -- continue execution from breakpoint到下一断点exit
我想不好在dos下调试!
想做到楼主所说的
1、单步运行
2、跟踪进入
3、跳出
4、运行到指定行我想必须在程序里加入必要的调试代码!这样才能随心所欲的控制调试过程吧!我是菜鸟,意见恐怕很幼稚吧!
-help print out this message and exit
-sourcepath <directories separated by ";">
directories in which to look for source files
-attach <address>
attach to a running VM at the specified address using standard connector
-listen <address>
wait for a running VM to connect at the specified address using standard connector
-listenany
wait for a running VM to connect at any available address using standard connector
-launch
launch VM immediately instead of waiting for 'run' command
-connect <connector-name>:<name1>=<value1>,...
connect to target VM using named connector with listed argument values
-dbgtrace [flags] print info for debugging jdb
-tclient run the application in the Hotspot(tm) Performance Engine (Client)
-tserver run the application in the Hotspot(tm) Performance Engine (Server)options forwarded to debuggee process:
-v -verbose[:class|gc|jni]
turn on verbose mode
-D<name>=<value> set a system property
-classpath <directories separated by ";">
list directories in which to look for classes
-X<option> non-standard target VM option<class> is the name of the class to begin debugging
<arguments> are the arguments passed to the main() method of <class>For command help type 'help' at jdb prompt** command list **
run [class [args]] -- start execution of application's main classthreads [threadgroup] -- list threads
thread <thread id> -- set default thread
suspend [thread id(s)] -- suspend threads (default: all)
resume [thread id(s)] -- resume threads (default: all)
where [thread id] | all -- dump a thread's stack
wherei [thread id] | all -- dump a thread's stack, with pc info
up [n frames] -- move up a thread's stack
down [n frames] -- move down a thread's stack
kill <thread> <expr> -- kill a thread with the given exception object
interrupt <thread> -- interrupt a threadprint <expr> -- print value of expression
dump <expr> -- print all object information
eval <expr> -- evaluate expression (same as print)
set <lvalue> = <expr> -- assign new value to field/variable/array element
locals -- print all local variables in current stack frameclasses -- list currently known classes
class <class id> -- show details of named class
methods <class id> -- list a class's methods
fields <class id> -- list a class's fieldsthreadgroups -- list threadgroups
threadgroup <name> -- set current threadgroupstop in <class id>.<method>[(argument_type,...)]
-- set a breakpoint in a method
stop at <class id>:<line> -- set a breakpoint at a line
clear <class id>.<method>[(argument_type,...)]
-- clear a breakpoint in a method
clear <class id>:<line> -- clear a breakpoint at a line
clear -- list breakpoints
catch [uncaught|caught|all] <exception-class id>
-- break when specified exception occurs
ignore [uncaught|caught|all] <exception-class id>
-- cancel 'catch' for the specified exception
watch [access|all] <class id>.<field name>
-- watch access/modifications to a field
unwatch [access|all] <class id>.<field name>
-- discontinue watching access/modifications to a field
trace methods [thread] -- trace method entry and exit
untrace methods [thread] -- stop tracing method entry and exit
step -- execute current line
step up -- execute until the current method returns to its caller
stepi -- execute current instruction
next -- step one line (step OVER calls)
cont -- continue execution from breakpointlist [line number|method] -- print source code
use (or sourcepath) [source file path]
-- display or change the source path
exclude [class id ... | "none"]
-- do not report step or method events for specified classes
classpath -- print classpath info from target VMmonitor <command> -- execute command each time the program stops
monitor -- list monitors
unmonitor <monitor#> -- delete a monitor
read <filename> -- read and execute a command filelock <expr> -- print lock info for an object
threadlocks [thread id] -- print lock info for a threadpop -- pop the stack through and including the current frame
reenter -- same as pop, but current frame is reentered
redefine <class id> <class file name>
-- redefine the code for a classdisablegc <expr> -- prevent garbage collection of an object
enablegc <expr> -- permit garbage collection of an object!! -- repeat last command
<n> <command> -- repeat command n times
help (or ?) -- list commands
version -- print version information
exit (or quit) -- exit debugger<class id> or <exception-class id>: full class name with package
qualifiers or a pattern with a leading or trailing wildcard ('*')
NOTE: any wildcard pattern will be replaced by at most one full class
name matching the pattern.
<thread id>: thread number as reported in the 'threads' command
<expr>: a Java(tm) Programming Language expression.
Most common syntax is supported.Startup commands can be placed in either "jdb.ini" or ".jdbrc"
in user.home or user.dir
设好classpath,运行:
jdb **.**.Class提示符为>:stop at <class id>:<line> //类名:行号,运行到此处停止run //开始运行停止后:
print <expr> -- print value of expression
dump <expr> -- print all object information
eval <expr> -- evaluate expression (same as print)
set <lvalue> = <expr> -- assign new value to field/variable/array element
locals -- print all local variables in current stack frame
看变量值,改变量值.step -- execute current line单步执行
step up -- execute until the current method returns to its caller执行完当前函数
stepi -- execute current instruction
next -- step one line (step OVER calls)下一句
cont -- continue execution from breakpoint到下一断点exit
请加入我的JAVA群
初学者的好地方
一起学习JAVA,
一起进步!!!6276733