Commit 854f2764 authored by Kuan-Ying Lee's avatar Kuan-Ying Lee Committed by Andrew Morton
Browse files

scripts/gdb/tasks: fix lx-ps command error

Since commit 8e1f3851 ("kill task_struct->thread_group") remove
the thread_group, we will encounter below issue.

(gdb) lx-ps
      TASK          PID    COMM
0xffff800086503340   0   swapper/0
Python Exception <class 'gdb.error'>: There is no member named thread_group.
Error occurred in Python: There is no member named thread_group.

We use signal->thread_head to iterate all threads instead.

[Kuan-Ying.Lee@mediatek.com: v2]
  Link: https://lkml.kernel.org/r/20231129065142.13375-2-Kuan-Ying.Lee@mediatek.com
Link: https://lkml.kernel.org/r/20231127070404.4192-2-Kuan-Ying.Lee@mediatek.com


Fixes: 8e1f3851 ("kill task_struct->thread_group")
Signed-off-by: default avatarKuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
Tested-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Chinwen Chang <chinwen.chang@mediatek.com>
Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Qun-Wei Lin <qun-wei.lin@mediatek.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 97219cc3
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@

import gdb

from linux import utils
from linux import utils, lists


task_type = utils.CachedType("struct task_struct")
@@ -22,18 +22,14 @@ task_type = utils.CachedType("struct task_struct")
def task_lists():
    task_ptr_type = task_type.get_type().pointer()
    init_task = gdb.parse_and_eval("init_task").address
    t = g = init_task
    t = init_task

    while True:
        while True:
            yield t

            t = utils.container_of(t['thread_group']['next'],
                                   task_ptr_type, "thread_group")
            if t == g:
                break
        thread_head = t['signal']['thread_head']
        for thread in lists.list_for_each_entry(thread_head, task_ptr_type, 'thread_node'):
            yield thread

        t = g = utils.container_of(g['tasks']['next'],
        t = utils.container_of(t['tasks']['next'],
                               task_ptr_type, "tasks")
        if t == init_task:
            return