如何用java -cp myjar.jar class.myclass做gdb

时间:2012-03-20 00:02:14

标签: java linux gdb openjdk

如何告诉gdb以这种方式运行:gdb java -cp /var/tmp/Test.jar myjava.class

$ gdb /var/tmp/Test.jar 14940
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
"/var/tmp/Test.jar": not in executable format: File format not recognized
Attaching to process 14940
Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
/var/tmp/14940: No such file or directory.
(gdb) run
Starting program:  
No executable file specified.
Use the "file" or "exec-file" command.
(gdb) 

$ gdb -p 14940
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Attaching to process 14940
Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
(gdb) run
Starting program:  
No executable file specified.
Use the "file" or "exec-file" command.
(gdb) 

1 个答案:

答案 0 :(得分:0)

从GDB的角度来看,这里的程序是java。它接受许多参数(-cp,classname等)

您可以使用set args

设置参数

http://www.delorie.com/gnu/docs/gdb/gdb_19.html