Re: Fix bug of list -h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 2012-6-7 21:39, Dave Anderson wrote:
I think the -h description should state that the address is a pointer to
a "data structure containing a list_head".  The "next" sentence probably
doesn't belong there, because it's pretty much repeating the list_head
related discussion above in help page's number "2" section.  And
there should probably be a caveat re: the fact that there may be
a bogus structure address shown in the case of an external LIST_HEAD()
or a starting list_head that's in a different data structure entirely.

And most importantly, a simple but clear example should be shown.

Hello Dave,

I made some modification to help__list. Is it suitable to describe the
function of "-h" option?

--
--
Regards
Qiao Nuohan


diff --git a/help.c b/help.c
index af165e8..3db8fe3 100755
--- a/help.c
+++ b/help.c
@@ -4372,37 +4372,49 @@ NULL
 char *help__list[] = {
 "list",
 "linked list",
-"[[-o] offset] [-e end] [-s struct[.member[,member]] -[xd]] [-H] start",
+"[[-o] offset] [-e end] [-s struct[.member[,member]] -[xd]] [-h|-H] start",
 "  This command dumps the contents of a linked list.  The entries in a linked",
 "  list are typically data structures that are tied together in one of two",
 "  formats:",
 " ",
 "  1. A starting address points to a data structure; that structure contains",
-"     a member that is a pointer to the next structure, and so on.  The list",
-"     typically ends when a \"next\" pointer value contains one of the",
-"     following:\n",
+"     a member that is a pointer to the next structure, and so on. If \"list\"",
+"     command is used to dump such type of linked list, \"-h\" or \"-H\" should",
+"     not be pre-pended before \"start\" argument. The list typically ends when",
+"     a \"next\" pointer value contains one of the following:\n",
 "       a. a NULL pointer.",
 "       b. a pointer to the start address.",
 "       c. a pointer to the first item pointed to by the start address.",
 "       d. a pointer to its containing structure.",
 "  ",
 "  2. Most Linux lists are linked via embedded list_head structures contained ",
-"     within the data structures in the list.  The linked list is headed by an",
-"     external LIST_HEAD, which is simply a list_head structure initialized to",
-"     point to itself, signifying that the list is empty:",
+"     within the data structures in the list.",
 " ",
 "       struct list_head {",
 "           struct list_head *next, *prev;",
 "       };",
 " ",
-"       #define LIST_HEAD_INIT(name) { &(name), &(name) }"
-" ",
-"       #define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)",
-" ",
 "     In the case of list_head-type lists, the \"next\" pointer is the address",
 "     of the embedded list_head structure in the next structure, and not the",
-"     address of the structure itself.  The list typically ends when the",
-"     list_head's next pointer points back to the LIST_HEAD address.",
+"     address of the structure itself. \"-h\" or \"-H\" be used to indicate",
+"     such type of list:\n",
+"       a. \"-h\" is used to indicate the \"start\" argument is the address of",
+"          the structure which contains the structure list_head. The list",
+"          typically ends when the list_head's next pointer points back to the",
+"          embedded list_head contained in the structure whose address is",
+"          offered by \"start\" argument",
+"       b. \"-H\" is used to indicate the \"start\" argument is the address of",
+"          LIST_HEAD. The linked list can be headed by an external LIST_HEAD,",
+"          which is simply a list_head structure initialized to point to itself,",
+"          signifying that the list is empty:",
+" ",
+"            #define LIST_HEAD_INIT(name) { &(name), &(name) }"
+" ",
+"            #define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)",
+" ",
+"          If \"start\" argument is the address of such list_head structure,",
+"          \"-H\" is needed. The list typically ends when the list_head's next",
+"          pointer points back to the LIST_HEAD address.",
 " ",
 "  This command can handle both types of linked list; in both cases the list",
 "  of addresses that are dumped are the addresses of the data structures",
@@ -4427,10 +4439,11 @@ char *help__list[] = {
 "           -d  override default output format with decimal format.",
 " ",
 "  The meaning of the \"start\" argument, which can be expressed either",
-"  symbolically or in hexadecimal format, depends upon whether the -H option",
+"  symbolically or in hexadecimal format, depends upon whether the -h/-H option",
 "  is pre-pended or not:",
 " ",
 "      start  The address of the first structure in the list.",
+"   -h start  The address of the structure which contains the embeded list_head",
 "   -H start  The address of the list_head structure, typically expressed",
 "             symbolically, but also can be an expression evaluating to the",
 "             address of the starting list_head structure.",
@@ -4555,7 +4568,7 @@ char *help__list[] = {
 "    f7254000",
 "    f7004000",
 " ",
-"  Lastly, in some kernel versions, the vfsmount structures of the mounted",
+"  In some kernel versions, the vfsmount structures of the mounted",
 "  filesystems are linked by the LIST_HEAD \"vfsmntlist\", which uses the",
 "  mnt_list list_head of each vfsmount structure in the list.  To dump each",
 "  vfsmount structure in the list, append the -s option:\n",
@@ -4596,6 +4609,35 @@ char *help__list[] = {
 "    f7445f60",
 "    struct vfsmount {",
 "    ...",
+"  Structure task_struct is linked by a embedded \"tasks\". To dump all linked",
+"  task_struct, using \"-h\" option:\n"
+"    %s> list task_struct.tasks -s task_struct.tasks -h ffff88004b56ca80",
+"    ffff88004b56ca80",
+"      tasks = {",
+"        next = 0xffffffff81a8d468, ",
+"        prev = 0xffff88004b56d908",
+"      }",
+"    ffffffff81a8d020",
+"      tasks = {",
+"        next = 0xffff88004eac3908, ",
+"        prev = 0xffff88004b56cec8",
+"      }",
+"    ffff88004eac34c0",
+"      tasks = {",
+"        next = 0xffff88004eac2ec8, ",
+"        prev = 0xffffffff81a8d468",
+"      }",
+"    ...",
+"    ffff88004b62a0c0",
+"      tasks = {",
+"        next = 0xffff88004b56d908, ",
+"        prev = 0xffff88004b62af48",
+"      }",
+"    ffff88004b56d4c0",
+"      tasks = {",
+"        next = 0xffff88004b56cec8, ",
+"        prev = 0xffff88004b62a508",
+"      }",
 NULL               
 };
 
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux