2020-08-18 04:05:53

by Ritesh Harjani

[permalink] [raw]
Subject: [PATCH 0/2] scripts:gdb: Add few structs in gdb scripts

I was using these structs info internally in my gdb scripts.
So sending it out for merge to upstream.

Ritesh Harjani (2):
proc: Add struct mount & struct super_block addr in lx-mounts command
tasks: Add task_struct addr for lx-ps cmd

scripts/gdb/linux/lists.py | 43 ++++++++++++++++++++++++++++++++++++++
scripts/gdb/linux/proc.py | 15 +++++++------
scripts/gdb/linux/tasks.py | 9 ++++----
3 files changed, 12 insertions(+), 12 deletions(-)

--
2.25.4


2020-08-18 04:07:10

by Ritesh Harjani

[permalink] [raw]
Subject: [PATCH 2/2] tasks: Add task_struct addr for lx-ps cmd

task_struct addr in lx-ps cmd seems helpful

<e.g. o/p>
TASK PID COMM
0xffffffff82c2b8c0 0 swapper/0
0xffff888a0ba20040 1 systemd
0xffff888a0ba24040 2 kthreadd
0xffff888a0ba28040 3 rcu_gp

Signed-off-by: Ritesh Harjani <[email protected]>
---
scripts/gdb/linux/tasks.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
index 0301dc1e0138..17ec19e9b5bf 100644
--- a/scripts/gdb/linux/tasks.py
+++ b/scripts/gdb/linux/tasks.py
@@ -73,11 +73,12 @@ class LxPs(gdb.Command):
super(LxPs, self).__init__("lx-ps", gdb.COMMAND_DATA)

def invoke(self, arg, from_tty):
+ gdb.write("{:>10} {:>12} {:>7}\n".format("TASK", "PID", "COMM"))
for task in task_lists():
- gdb.write("{address} {pid} {comm}\n".format(
- address=task,
- pid=task["pid"],
- comm=task["comm"].string()))
+ gdb.write("{} {:^5} {}\n".format(
+ task.format_string().split()[0],
+ task["pid"].format_string(),
+ task["comm"].string()))


LxPs()
--
2.25.4

2020-08-18 05:42:14

by Jan Kiszka

[permalink] [raw]
Subject: Re: [PATCH 2/2] tasks: Add task_struct addr for lx-ps cmd

On 18.08.20 06:04, Ritesh Harjani wrote:
> task_struct addr in lx-ps cmd seems helpful
>
> <e.g. o/p>
> TASK PID COMM
> 0xffffffff82c2b8c0 0 swapper/0
> 0xffff888a0ba20040 1 systemd
> 0xffff888a0ba24040 2 kthreadd
> 0xffff888a0ba28040 3 rcu_gp
>
> Signed-off-by: Ritesh Harjani <[email protected]>
> ---
> scripts/gdb/linux/tasks.py | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
> index 0301dc1e0138..17ec19e9b5bf 100644
> --- a/scripts/gdb/linux/tasks.py
> +++ b/scripts/gdb/linux/tasks.py
> @@ -73,11 +73,12 @@ class LxPs(gdb.Command):
> super(LxPs, self).__init__("lx-ps", gdb.COMMAND_DATA)
>
> def invoke(self, arg, from_tty):
> + gdb.write("{:>10} {:>12} {:>7}\n".format("TASK", "PID", "COMM"))
> for task in task_lists():
> - gdb.write("{address} {pid} {comm}\n".format(
> - address=task,
> - pid=task["pid"],
> - comm=task["comm"].string()))
> + gdb.write("{} {:^5} {}\n".format(
> + task.format_string().split()[0],
> + task["pid"].format_string(),
> + task["comm"].string()))
>
>
> LxPs()
>

This patch is confusing me. We already dump the task address. What the
patch changes is adding a header and some conversions of the values. Can
you elaborate?

Jan

--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

2020-08-18 08:57:03

by Ritesh Harjani

[permalink] [raw]
Subject: Re: [PATCH 2/2] tasks: Add task_struct addr for lx-ps cmd



On 8/18/20 11:10 AM, Jan Kiszka wrote:
> On 18.08.20 06:04, Ritesh Harjani wrote:
>> task_struct addr in lx-ps cmd seems helpful
>>
>> <e.g. o/p>
>> TASK PID COMM
>> 0xffffffff82c2b8c0 0 swapper/0
>> 0xffff888a0ba20040 1 systemd
>> 0xffff888a0ba24040 2 kthreadd
>> 0xffff888a0ba28040 3 rcu_gp
>>
>> Signed-off-by: Ritesh Harjani <[email protected]>
>> ---
>> scripts/gdb/linux/tasks.py | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
>> index 0301dc1e0138..17ec19e9b5bf 100644
>> --- a/scripts/gdb/linux/tasks.py
>> +++ b/scripts/gdb/linux/tasks.py
>> @@ -73,11 +73,12 @@ class LxPs(gdb.Command):
>> super(LxPs, self).__init__("lx-ps", gdb.COMMAND_DATA)
>>
>> def invoke(self, arg, from_tty):
>> + gdb.write("{:>10} {:>12} {:>7}\n".format("TASK", "PID", "COMM"))
>> for task in task_lists():
>> - gdb.write("{address} {pid} {comm}\n".format(
>> - address=task,
>> - pid=task["pid"],
>> - comm=task["comm"].string()))
>> + gdb.write("{} {:^5} {}\n".format(
>> + task.format_string().split()[0],
>> + task["pid"].format_string(),
>> + task["comm"].string()))
>>
>>
>> LxPs()
>>
>
> This patch is confusing me. We already dump the task address. What the
> patch changes is adding a header and some conversions of the values. Can
> you elaborate?

You are right. Sorry for the confusion. I will update the commit msg (in
v2) to reflect that this patch adds the header and formats the spacing.
Without the patch we get it like this:-

0xffffffff82c2b8c0 <init_task> 0 swapper/0
0xffff888a0ba20040 1 systemd
0xffff888a0ba24040 2 kthreadd
0xffff888a0ba28040 3 rcu_gp

-ritesh