crash打印数组小技巧

2020-05-31 21:34:07 浏览数 (1)

以16进制输出结果:

crash> struct -x pipe_inode_info 0xffff883491df8c40 | grep buffers

buffers = 0x10,

以10进制输出结果:

crash> struct -d pipe_inode_info 0xffff883491df8c40 | grep buffers

buffers = 16,

crash>

crash> struct -x pipe_inode_info 0xffff883491df8c40 | grep -w bufs

bufs = 0xffff883acd0d5800,

crash> struct pipe_inode_info.bufs 0xffff883491df8c40

bufs = 0xffff883acd0d5800

crash>

struct pipe_inode_info {

....

....

struct pipe_buffer *bufs;

....

};

void free_pipe_info(struct pipe_inode_info *pipe)

{

...

...

for (i = 0; i < pipe->buffers; i ) {

struct pipe_buffer *buf = pipe->bufs i;

if (buf->ops)

buf->ops->release(pipe, buf);

}

...

...

}

打印第九(数组索引8)个数组成员内容,类型为struct pipe_buffer,0xffff883acd0d5800为数组起始地址:

crash> px ((struct pipe_buffer *)0xffff883acd0d5800)[8]

$1 = {

page = 0x0,

offset = 0x0,

len = 0x0,

ops = 0xffffffc7,

flags = 0x0,

private = 0x0

}

crash>

0 人点赞