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

2020-02-05 Thread Dominique Martinet
Dave Anderson wrote on Wed, Feb 05, 2020:
> > 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().

I'll give this a try tomorrow, probably just needs to add
dm->member_offset to addr and dump dm->member_size long value, that
looks straightforward enough.

> ...and then if you get "struct -r" to work with a "struct_name.field" 
> argument, the next challenge would be the caching aspect of your request.
> 
> Currently there's no manner in which command-specific information is
> cached beyond the execution of a single command.  With "< file", the
> command gets executed from scratch each time. 

That does look more challenging... Or rather more a matter of taste? a
kludge probably wouldn't be so bad to put in, but it's probably better
to have something more generic than making 'datatype_member' static in
cmd_datatype_common (well, it needs a bit more than that as the argument
strings won't be useable from one call to the next...)


I assume the slow part in this will be the member_to_datatype call in
do_datatype_addr? I'll first confirm that's the only slow bit, if there
is only one spot to optimize away it might not be so bad.

But yeah, without caching I don't think it's realistic; and making the
'< file' construct iterate within the function looks more work than
trying to make struct cache some info.

Thanks!
-- 
Dominique


--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility



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

2020-02-05 Thread Dave Anderson



- Original Message -
> 
> 
> - 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

...and then if you get "struct -r" to work with a "struct_name.field" 
argument, the next challenge would be the caching aspect of your request.

Currently there's no manner in which command-specific information is
cached beyond the execution of a single command.  With "< file", the
command gets executed from scratch each time. 

Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility



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

2020-02-05 Thread Dave Anderson



- 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

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility



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

2020-02-05 Thread Dominique Martinet
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)



Thanks,
-- 
Dominique


--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility