Skip to contentSkip to conversation

scripts/gdb: fix 'lx-current' for x86

PATCH Applied Jeff Xie 2 participants 3 messages Feb 4, 2023 – Feb 7, 2023 GDB kernel debugging helper scripts

lore
Share & tools
lore

Jeff Xie

author
#0 lore raw

PATCH 1/1 scripts/gdb: fix 'lx-current' for x86

When printing the name of the current process, it will report an error:
(gdb) p $lx_current().comm
Python Exception <class 'gdb.error'> No symbol "current_task" in current context.:
Error occurred in Python: No symbol "current_task" in current context.

Because the commit <e57ef2ed97c1> ("x86: Put hot per CPU variables into a struct") changed it.

---
 scripts/gdb/linux/cpus.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/cpus.py +1 -1
index 15fc4626d236..9ee99f9fae8d 100644
@@ -163,7 +163,7 @@ def get_current_task(cpu):
     task_ptr_type = task_type.get_type().pointer()
 
     if utils.is_target_arch("x86"):
-         var_ptr = gdb.parse_and_eval("&current_task")
+         var_ptr = gdb.parse_and_eval("&pcpu_hot.current_task")
          return per_cpu(var_ptr, cpu).dereference()
     elif utils.is_target_arch("aarch64"):
          current_task_addr = gdb.parse_and_eval("$SP_EL0")
Signature · 1 line
2.25.1
author
#1 lore raw

Andrew was added.

Hi Andrew,

I found the patches for the ./scripts/gdb/* were merged by you before, but the "./scripts/get_maintainer.pl ./scripts/gdb/linux/cpus.py" can't find your name, so added you.

Can you review this patch ;-)

Quoted 30 lines · Jeff Xie

When printing the name of the current process, it will report an error:
(gdb) p $lx_current().comm
Python Exception <class 'gdb.error'> No symbol "current_task" in current context.:
Error occurred in Python: No symbol "current_task" in current context.

Because the commit <e57ef2ed97c1> ("x86: Put hot per CPU variables into a struct") changed it.

---
 scripts/gdb/linux/cpus.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/cpus.py +1 -2
index 15fc4626d236..9ee99f9fae8d 100644
@@ -163,7 +163,7 @@ def get_current_task(cpu):
     task_ptr_type = task_type.get_type().pointer()
 
     if utils.is_target_arch("x86"):
-         var_ptr = gdb.parse_and_eval("&current_task")
+         var_ptr = gdb.parse_and_eval("&pcpu_hot.current_task")
          return per_cpu(var_ptr, cpu).dereference()
     elif utils.is_target_arch("aarch64"):
          current_task_addr = gdb.parse_and_eval("$SP_EL0")
--

2.25.1

Signature · 2 lines
Thanks,
JeffXie
maintainer Reviewed-by
#2 lore raw
Quoted 8 lines · Jeff Xie

Andrew was added.

Hi Andrew,

I found the patches for the ./scripts/gdb/* were merged by you before, but the "./scripts/get_maintainer.pl ./scripts/gdb/linux/cpus.py" can't find your name, so added you.

Yes, Andrew is merging scripts/gdb stuff.

Quoted 24 lines

Can you review this patch ;-)

Quoted 21 lines · Jeff Xie

When printing the name of the current process, it will report an error:
(gdb) p $lx_current().comm
Python Exception <class 'gdb.error'> No symbol "current_task" in current context.:
Error occurred in Python: No symbol "current_task" in current context.

Because the commit <e57ef2ed97c1> ("x86: Put hot per CPU variables into a struct") changed it.

---
 scripts/gdb/linux/cpus.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/cpus.py +0 -0
index 15fc4626d236..9ee99f9fae8d 100644
@@ -163,7 +163,7 @@ def get_current_task(cpu):
     task_ptr_type = task_type.get_type().pointer()
 
Quoted 10 lines
Quoted 9 lines
scripts/gdb/linux/cpus.py +1 -2
     if utils.is_target_arch("x86"):
-         var_ptr = gdb.parse_and_eval("&current_task")
+         var_ptr = gdb.parse_and_eval("&pcpu_hot.current_task")
          return per_cpu(var_ptr, cpu).dereference()
     elif utils.is_target_arch("aarch64"):
          current_task_addr = gdb.parse_and_eval("$SP_EL0")
--

2.25.1

FWIW:

Should go into 6.2 if possible.

Thanks
Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux