简体   繁体   English

如何在gdb中打印Java数组?

[英]How do I print a Java array in gdb?

I compiled a very simple java program with gcj-4.4 and -o option. 我用gcj-4.4和-o选项编译了一个非常简单的java程序。 I loaded it in gdb-7.2 and tried to do some debugging. 我在gdb-7.2中加载它并尝试进行一些调试。 I noticed at I could print the variables in int type but I could not print an array of int. 我注意到我可以在int类型中打印变量,但我无法打印int数组。 I received this error message: 我收到此错误消息:

(gdb) p orderFinish[0]
cannot find java.lang.Object
(gdb) p (int)orderFinish
$8 = -136261440
(gdb) p orderFinish[3]
cannot find java.lang.Object
(gdb) p in
$9 = 1
(gdb) whatis orderFinish 
type = int[]

So my question is how can I print a Java array in gdb? 所以我的问题是如何在gdb中打印Java数组? My OS is openSUSE-11.1 x64-86bit. 我的操作系统是openSUSE-11.1 x64-86bit。 Thanks! 谢谢!

Its been a while since I used GDB but p *array-variable@length should work. 自从我使用GDB以来已经有一段时间了,但是p * array-variable @ length应该可行。

Source: http://www.yolinux.com/TUTORIALS/GDB-Commands.html 资料来源: http//www.yolinux.com/TUTORIALS/GDB-Commands.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM