[Crash-utility] Faster iteration on list of struct.field

Dave Anderson anderson at redhat.com
Wed Feb 5 19:12:57 UTC 2020



----- Original Message -----
> Hi,
> 
> I often find myself dumping a bunch of addresses to files to iterate
> with 'struct_name.field < file_with_addresses', but that is horribly
> slow for large number of iterations.
> 
> `help list` comment for -S vs. -s made me try to use `rd` instead,
> e.g. get offset manually from `struct -o` then use rd instead like
> `rd -o xx < addr_list | awk '{ print $2 }' > value_list` -- and that is
> infinitely better.
> 
> 
> Would it make sense to add a similar option to 'struct' instead so one
> could do e.g. `struct -S struct_name.field addr` instead of the dance I was doing?
> (That would require to cache field offset in crash and not query it
> again everytime, from a quick look at the code, but we could only cache
> one and still gain a lot for such iterations...)
> 
> 
> Am I missing another more practical way of doing this?
> (I guess it's not so bad now I came up with using 'rd', but that was
> non-obvious to me. My use case here involved following a couple of
> pointers from a list so I dumped the first pointer to follow from list
> with -S struct1.field1, but then the following iteration just wouldn't
> end naively)

Dominique,

What might make sense is to use the "struct -r" option, which does a raw
memory dump of a data structure.  But for a reason I do not recall, it
prevents that option from being used with a "struct_name.field" argument.
(see line 6628 of symbols.c).  But I don't see why that couldn't be made 
to work, though, since the end result is simply a call to raw_data_dump().  

Dave




More information about the Crash-utility mailing list