Dne Čt 7. června 2012 03:58:16 qiaonuohan napsal(a):
> At 2012-6-6 21:44, Petr Tesarik wrote:
> > crash> list task_struct.tasks -s task_struct.tasks -h 0xeede04f0+432
> > eede04f0
> >
> > tasks = {
> >
> > next = 0xd79d6f20,
> > prev = 0xd55e6220
> >
> > }
> >
> > d79d6d70
> >
> > tasks = {
> >
> > next = 0xc32c5320,
> > prev = 0xeede06a0
> >
> > }
> >
> > ...
> >
> > Note that the first element in the list (the one which contains the
> > starting list_head) is included.
> >
> > Based on the above, I'm afraid don't quite get the intended goal of your
> > patch.
>
> Hello Petr and Dave,
>
> I misunderstood the usage.
>
> What I really think is changing the start address from the address of
> list_head to the address of the structure where list_head is embedded.
>
> In many cases I use list command, I found I can get the address of the
> structure where the list_head embedded directly. And I can get the
> offset of list_head by -o option. So the offset, say "+432" in your
> example, can be omitted. What do you think of such change?
That was also my suggestion. It would even turn "list -h" into something
useful. ;-)
Here's my attempt at a patch.
Petr
From: Petr Tesarik <[email protected]>
Subject: Improve the usability of "list -h"
The "list -h" option is undocumented and hardly useful to anybody. There is
a comment in tools.c that explains what it does:
* If the structures are linked using list_head structures, the -h or -H
* options must be used. In that case, the "start" address is:
* a pointer to the embedded list_head structure (-h), or a pointer to a
* LIST_HEAD() structure (-H).
This matches exactly what crash actually does, but it's not as useful as if
it accepted the address of the containing structure instead.
Signed-off-by: Petr Tesarik <[email protected]>
---
tools.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--- a/tools.c
+++ b/tools.c
@@ -3083,8 +3083,8 @@ print_number(struct number_option *np, i
*
* If the structures are linked using list_head structures, the -h or -H
* options must be used. In that case, the "start" address is:
- * a pointer to the embedded list_head structure (-h), or a pointer to a
- * LIST_HEAD() structure (-H).
+ * a pointer to the structure that contains the list_head structure (-h),
+ * or a pointer to a LIST_HEAD() structure (-H).
*
* Given that the contents of the structures containing the next pointers
* often contain useful data, the "-s structname" also prints each structure
@@ -3322,7 +3322,8 @@ next_arg:
fprintf(fp, "(empty)\n");
return;
}
- }
+ } else
+ ld->start += ld->list_head_offset;
}
ld->flags &= ~(LIST_OFFSET_ENTERED|LIST_START_ENTERED);
--
Crash-utility mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/crash-utility