简体   繁体   English

如果先前的命令失败,GDB命令将停止执行

[英]GDB commands stop execution if previous command fails

In GDB want to print values of all pointers in an array on hitting a breakpoint. 在GDB中,要在击中断点时打印数组中所有指针的值。 There may be array elements with value as 0x0. 可能存在值为0x0的数组元素。

Ex: 例如:

arr[] = {0x0, 0x5cb04, 0x5510, 0x0, 0x5c84}

(gdb) info b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x1234 in fun1 at file1.c:200
        p arr
        p *arr[0]
        p *arr[1]
        p *arr[2]
        p *arr[3]
        c

But GDB fails to print values of *arr[1], *arr[2], *arr[3], coz 但是GDB无法打印* arr [1],* arr [2],* arr [3],coz的值

*arr[0] hits the error * arr [0]遇到错误

"Cannot access memory at address 0x0" . “无法访问地址0x0的内存”。

Is there any solution or workaround to this problem? 是否有解决此问题的方法或解决方法?

gdb print命令可以使用任何有效的表达式 ,因此您可以执行以下操作:

p (arr[0]) ? *arr[0] : "null"

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

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