gdb python:遍历数组结构 [英] gdb python: Walking through array of structures

查看:209
本文介绍了gdb python:遍历数组结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们不能遍历结构数组吗?我的意思是通过检查结构的内容并相应地打印每个字段来检查每个索引?正如我们可以为像s /类型的
$ b

  s = gdb.parse_and_eval(expr)
这样的struct .keys():
v = s [k]
如果is_pointer(v):
.....
elif is_array(v):
... ..

如何获得数组中每个索引的元素的访问控制?

解决方案

您可以使用[]符号索引数组。就像,如果'v'是代表数组或指针的gdb.Value,你可以用v [5]获取第5个元素。



在价值API部分解释了所有这些。


Can't we traverse the array of structs ? I mean for each index by checking the content of structs and print each field accordingly? As we can do for a struct like

s = gdb.parse_and_eval(expr)
for k in s.type.keys():
    v = s[k]
    if is_pointer(v):
          .....
    elif is_array(v):
          .....

How to get access control on elements at each indices of an array?

解决方案

You can index an array using the [] notation. Like, if 'v' is a gdb.Value representing an array or a pointer, you can fetch the 5th element with v[5].

The manual has a long section on the Value API that explains all of this.

这篇关于gdb python:遍历数组结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆