[Crash-utility] Traversing hlist_node linked structures

Dave Anderson anderson at redhat.com
Tue Nov 10 14:58:36 UTC 2015



----- Original Message -----
> Hello,
> 
> I'd like to ask whether it's possible to traverse the chains of a
> hashtable which is defined via the hashtable.h infrastructure? If
> there is no support for this currently I guess crash has to be taught
> to understand how to do the maths to extract the container structures
> from embedded hlist_nodes, similar to how it does it for list_head
> type of structs? And unless this is done doing the arithmetic manually
> is the only way?
> 
> Regards,
> Nikolay

You can easily traverse the chain of hlist_node structures linked from 
an hlist_head using the "list" command, but if you want to display the data
structure that contains each hlist_node, it's typically a two-step process
where you:
 
 (1) capture the list of hlist_node addresses in an output file, and then
 (2) feed that list back to "struct -l offset", where the offset to the
     hlist_node is supplied.

If you're lucky and the hlist_node happens to be the first member of the 
containing structure, you could use the "list -s" option directly.

An interesting option to "list [-s struct[.member[,member]] ..." might
be the addition of a "-l offset", which would only be accepted/utilized
if "list -s ..." is being used, i.e.:

  list [-s struct[.member[,member] [-l offset]]

Dave




More information about the Crash-utility mailing list