java jdb 调试
[hadoop@hadoop-01 ~]$ javac -help
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files and annotation processors
-cp <path> Specify where to find user class files and annotation processors
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-proc:{none,only} Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
-processorpath <path> Specify where to find annotation processors
-parameters Generate metadata for reflection on method parameters
-d <directory> Specify where to place generated class files
-s <directory> Specify where to place generated source files
-h <directory> Specify where to place generated native header files
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-profile <profile> Check that API used is available in the specified profile
-version Version information
-help Print a synopsis of standard options
-Akey[=value] Options to pass to annotation processors
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
-Werror Terminate compilation if warnings occur
@<filename> Read options and filenames from file [hadoop@hadoop-01 ~]$ vi HelloJDB.java
public class HelloJDB {
public static void main(String...args) {
int i = 5;
int j = 6;
int sum = add(i, j);
sum = 0;
for (i = 0; i < 100; i++) {
sum += i;
}
System.out.println(sum);
}
public static int add(int augend, int addend) {
int sum = augend + addend;
return sum;
}
} [hadoop@hadoop-01 ~]$ javac -g HelloJDB.java
[hadoop@hadoop-01 ~]$ jdb -classpath .:HelloJDB
Initializing jdb ...
> help
** command list **
connectors -- list available connectors and transports in this VM run [class [args]] -- start execution of application's main class threads [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 id> <expr> -- kill a thread with the given exception object
interrupt <thread id> -- interrupt a thread 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 classes -- 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 fields threadgroups -- list threadgroups
threadgroup <name> -- set current threadgroup stop 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] <class id>|<class pattern>
-- break when specified exception occurs
ignore [uncaught|caught|all] <class id>|<class pattern>
-- 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 [go] methods [thread]
-- trace method entries and exits.
-- All threads are suspended unless 'go' is specified
trace [go] method exit | exits [thread]
-- trace the current method's exit, or all methods' exits
-- All threads are suspended unless 'go' is specified
untrace [methods] -- stop tracing method entrys and/or exits
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 list [line number|method] -- print source code
use (or sourcepath) [source file path]
-- display or change the source path
exclude [<class pattern>, ... | "none"]
-- do not report step or method events for specified classes
classpath -- print classpath info from target VM monitor <command> -- execute command each time the program stops
monitor -- list monitors
unmonitor <monitor#> -- delete a monitor
read <filename> -- read and execute a command file lock <expr> -- print lock info for an object
threadlocks [thread id] -- print lock info for a thread pop -- 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 class disablegc <expr> -- prevent garbage collection of an object
enablegc <expr> -- permit garbage collection of an object !! -- repeat last command
<n> <command> -- repeat command n times
# <command> -- discard (no-op)
help (or ?) -- list commands
version -- print version information
exit (or quit) -- exit debugger <class id>: a full class name with package qualifiers
<class pattern>: a class name with a leading or trailing wildcard ('*')
<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
> stop in HelloJDB.main
Deferring breakpoint HelloJDB.main.
It will be set after the class is loaded.
> run
Main class and arguments must be specified
> run HelloJDB
run HelloJDB
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Set deferred breakpoint HelloJDB.main Breakpoint hit: "thread=main", HelloJDB.main(), line=3 bci=0
3 int i = 5; main[1] locals
Method arguments:
args = instance of java.lang.String[0] (id=403)
Local variables:
main[1] step
>
Step completed: "thread=main", HelloJDB.main(), line=4 bci=2
4 int j = 6; main[1] locals
Method arguments:
args = instance of java.lang.String[0] (id=403)
Local variables:
i = 5
main[1] step
>
Step completed: "thread=main", HelloJDB.main(), line=5 bci=5
5 int sum = add(i, j); main[1] locals
Method arguments:
args = instance of java.lang.String[0] (id=403)
Local variables:
i = 5
j = 6
main[1] print i
i = 5
main[1] print j
j = 6
main[1] list
1 public class HelloJDB {
2 public static void main(String...args) {
3 int i = 5;
4 int j = 6;
5 => int sum = add(i, j);
6 sum = 0;
7 for (i = 0; i < 100; i++) {
8 sum += i;
9 }
10 System.out.println(sum);
main[1] step
>
Step completed: "thread=main", HelloJDB.add(), line=13 bci=0
13 int sum = augend + addend; main[1] list
9 }
10 System.out.println(sum);
11 }
12 public static int add(int augend, int addend) {
13 => int sum = augend + addend;
14 return sum;
15 }
16 }
main[1] step up
>
Step completed: "thread=main", HelloJDB.main(), line=5 bci=10
5 int sum = add(i, j); main[1] list
1 public class HelloJDB {
2 public static void main(String...args) {
3 int i = 5;
4 int j = 6;
5 => int sum = add(i, j);
6 sum = 0;
7 for (i = 0; i < 100; i++) {
8 sum += i;
9 }
10 System.out.println(sum);
main[1] step
>
Step completed: "thread=main", HelloJDB.main(), line=6 bci=11
6 sum = 0; main[1] print sum
sum = 11
main[1] step
>
Step completed: "thread=main", HelloJDB.main(), line=7 bci=13
7 for (i = 0; i < 100; i++) { main[1] list
3 int i = 5;
4 int j = 6;
5 int sum = add(i, j);
6 sum = 0;
7 => for (i = 0; i < 100; i++) {
8 sum += i;
9 }
10 System.out.println(sum);
11 }
12 public static int add(int augend, int addend) {
main[1] stop at HelloJDB:10
Set breakpoint HelloJDB:10
main[1] list
3 int i = 5;
4 int j = 6;
5 int sum = add(i, j);
6 sum = 0;
7 => for (i = 0; i < 100; i++) {
8 sum += i;
9 }
10 System.out.println(sum);
11 }
12 public static int add(int augend, int addend) {
main[1] cont
>
Breakpoint hit: "thread=main", HelloJDB.main(), line=10 bci=31
10 System.out.println(sum); main[1] list
6 sum = 0;
7 for (i = 0; i < 100; i++) {
8 sum += i;
9 }
10 => System.out.println(sum);
11 }
12 public static int add(int augend, int addend) {
13 int sum = augend + addend;
14 return sum;
15 }
main[1] print sum
sum = 4950
main[1] exit
4950
[hadoop@hadoop-01 ~]$
参照:https://www.cnblogs.com/rocedu/p/6371262.html
java jdb 调试的更多相关文章
- 使用JDB调试Java程序
Java程序中有逻辑错误,就需要使用JDB来进行调试了.调试程序在IDE中很方便了,比如这篇博客介绍了在Intellj IDEA中调试Java程序的方法. 我们课程内容推荐在Linux环境下学习,有同 ...
- 解决JAVA单步调试键盘输入被JDB占用的问题
解决JAVA单步调试键盘输入被JDB占用的问题 问题来源: 在完成本周任务时,编写的代码中含有Scanner类,编译及运行过程均正确,但使用JDB单步调试时,运行到输入行无法在JDB内部输入变量值. ...
- jdb调试scala代码的简单介绍
在linux调试C/C++的代码需要通过gdb,调试java代码呢?那就需要用到jdb工具了.关于jdb的用法在网上大家都可以找到相应的文章,但是对scala进行调试的就比较少了.其实调试的大致流程都 ...
- jdb 调试
C:\Users\Reverse>adb shell am start -D -n lwf.lc.pncdd/lwf.lc.pncdd.MainC 查看内存情况: cat /proc/N/map ...
- 在Ubuntu中使用JDB调试代码
在Ubuntu中使用JDB调试代码 了解JDB JDB是JDK安装的一部分,是基于文本和命令行的调试工具,JDB是可以免费获取且平台独立的,缺点是只有命令行格式. JDB基础命令 在方法中设置断点st ...
- 迭代和JDB调试
迭代和JDB调试 题目要求 1 使用C(n,m)=C(n-1,m-1)+C(n-1,m)公式进行递归编程实现求组合数C(m,n)的功能 2 m,n 要通过命令行传入 3 提交测试运行截图(至少三张:正 ...
- 014-通过JDB调试,通过HSDB来查看HotSpot VM的运行时数据
一.JDB调试 在预发环境下进行debug时,时常因为工具和环境的限制,导致debug体验非常差,那么有什么方法能够简化我们进行debug的体验吗?JDB就是一种. JDB ...
- Java远程调试 java -Xdebug各参数说明
JAVA自身支持调试功能,并提供了一个简单的调试工具--JDB,类似于功能强大的GDB,JDB也是一个字符界面的 调试环境,并支持设置断点,支持线程线级的调试 JAVA的调试方法如下: 1.首先支持J ...
- JDB调试之小试牛刀
用JDK自带工具JDB调试示例程序HelloJDB(d:\jdb\HelloJDB) HelloJDB代码如下: public class HelloJDB { public static void ...
随机推荐
- 《Linux就该这么学》第十二天课程
使用ssh服务管理远程主机 绑定两块网卡 原创地址:https://www.linuxprobe.com/chapter-09.html 第1步:在虚拟机系统中再添加一块网卡设备,请确保两块网卡都处在 ...
- 预装win8的笔记本用第三方分区软件分区后出现0x0000225错误的解决方法/同理win7
最近为采用EFI分区的联想电脑分区,是通过第三方软件进行的,完成后重启,发现系统报错0x0000225,提示插入安装介质修复. 应该是EFI分区导致的 http://zhidao.baidu.com/ ...
- 流量控制与RateLimiter
一背景 如何提高系统的稳定性,简单来说除了加机器外就是服务降级.限流.加机器就是常说的分布式,从整个架构的稳定性角度看,一般SOA每个接口的所能提供的单位时间服务能力是有上限.假如超过服务能力,一般会 ...
- SFTP文件服务器的搭建
由于公司项目的需要,需要自己搭建一个SFTP文件服务器,来实现不同IP服务器之间文件的传输: 应用的场景:由于需要缓解服务器的压力,需要对服务进分离,分别放置在不同IP服务器上: 首先提供一个SFTP ...
- sftp修改用户home目录后登录时报connection closed by remote host
在sftp用户需要修改登录根目录的情况下,我们可以修改/etc/ssh/sshd_config文件中ChrootDirectory /home/[path]的路径. 但是,在重启sshd服务后,sft ...
- Exp3 免杀原理与实践 20154320 李超
基础知识 如何检测出恶意代码 基于特征码的检测:分析指令的统计特性.代码的结构特性等.如果一个可执行文件(或其他运行的库.脚本等)拥有一般恶意代码所通有的特征(开启后门等)则被认为是恶意代码 启发式恶 ...
- cisco基本配置命令
实验命令 router> enable 从用户模式进入特权模式 router# disable or exit 从特权模式退出到用户模式 router# show sessions 查看本机上的 ...
- kvm-qcow2派生镜像的远程备份的方法!
在虚拟化环境中,关于虚拟机的远程备份是一个比较重要的环节,这个是有关于整个机房挂掉之后,仍然可以恢复的最后一招. 在kvm中这种情况可以通过直接备份虚拟机的镜像文件(qcow2)到远端存储解决. 但有 ...
- CSS中清除浮动的作用以及如何清除浮动
1.什么是浮动,浮动的作用 “浮动”从字面上来理解就是“悬浮移动.非固定”的意思.块级元素(div.table.span…)是以垂直方向排列,而在前端界面中往往要使用水平布局块级元素使界面更美观.这就 ...
- vue.js 系列教程
Vuejs——(1)入门(单向绑定.双向绑定.列表渲染.响应函数) Vuejs——(2)Vue生命周期,数据,手动挂载,指令,过滤器 Vuejs——(3)计算属性,样式和类绑定 Vuejs——(4)v ...