Skip to contentSkip to conversation

linux-user: Improve strace output of personality() and sysinfo()

PATCH In review Helge Deller 4 participants 10 messages Dec 23, 2022 – Jan 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Improve strace output of personality() and sysinfo()

Make the strace look nicer for those two syscalls.

---
 linux-user/strace.list | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/strace.list +2 -2
index f9254725a1..909298099e 100644
@@ -1043,7 +1043,7 @@
 { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(%p)", NULL, print_syscall_ret_addr },
 #endif
 #ifdef TARGET_NR_pipe
 { TARGET_NR_pipe, "pipe" , NULL, NULL, NULL },
@@ -1502,7 +1502,7 @@
 { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_sysinfo
-{ TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },
+{ TARGET_NR_sysinfo, "sysinfo" , "%s(%p)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_sys_kexec_load
 { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL },

--
2.38.1

#1 lore raw
Quoted 12 lines · Helge Deller

Make the strace look nicer for those two syscalls.

---
  linux-user/strace.list | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/strace.list +0 -0
index f9254725a1..909298099e 100644

linux-user/strace.list line 1046

Quoted 5 lines
linux-user/strace.list +1 -1
@@ -1043,7 +1043,7 @@
  { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(%p)", NULL, print_syscall_ret_addr },

Shouldn't this be:

{ TARGET_NR_personality, "personality" , "%s(%u)", NULL, NULL },

?

Quoted 16 lines
linux-user/strace.list +1 -2
  #endif
  #ifdef TARGET_NR_pipe
  { TARGET_NR_pipe, "pipe" , NULL, NULL, NULL },
@@ -1502,7 +1502,7 @@
  { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_sysinfo
-{ TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },
+{ TARGET_NR_sysinfo, "sysinfo" , "%s(%p)", NULL, NULL },
  #endif
  #ifdef TARGET_NR_sys_kexec_load
  { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL },
--

2.38.1

#2 lore raw
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 12 lines · Helge Deller

Make the strace look nicer for those two syscalls.

---
  linux-user/strace.list | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/strace.list +0 -0
index f9254725a1..909298099e 100644

linux-user/strace.list line 1046

Quoted 5 lines
linux-user/strace.list +1 -1
@@ -1043,7 +1043,7 @@
   { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
   #endif
   #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(%p)", NULL, print_syscall_ret_addr },

Shouldn't this be:

Quoted 1 line

   { TARGET_NR_personality, "personality" , "%s(%u)", NULL, NULL },

Basically yes, but...
it's a bitmap, so printing it as hex value (similiar to a pointer) is easier to read/analyze.

Helge

Quoted 20 lines

?

Quoted 16 lines
linux-user/strace.list +1 -2
   #endif
   #ifdef TARGET_NR_pipe
   { TARGET_NR_pipe, "pipe" , NULL, NULL, NULL },
@@ -1502,7 +1502,7 @@
   { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL },
   #endif
   #ifdef TARGET_NR_sysinfo
-{ TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },
+{ TARGET_NR_sysinfo, "sysinfo" , "%s(%p)", NULL, NULL },
   #endif
   #ifdef TARGET_NR_sys_kexec_load
   { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL },
--

2.38.1

#3 lore raw
Quoted 23 lines · Helge Deller
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 12 lines · Helge Deller

Make the strace look nicer for those two syscalls.

---
  linux-user/strace.list | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/strace.list +0 -0
index f9254725a1..909298099e 100644

linux-user/strace.list line 1047

Quoted 6 lines
linux-user/strace.list +1 -1
@@ -1043,7 +1043,7 @@
   { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
   #endif
   #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(%p)", NULL, 
 print_syscall_ret_addr },

Shouldn't this be:

Quoted 5 lines
Quoted 1 line

    { TARGET_NR_personality, "personality" , "%s(%u)", NULL, NULL },

Basically yes, but...
it's a bitmap, so printing it as hex value (similiar to a pointer) is easier to read/analyze.

Oh, good point. Then "%s(0x"TARGET_ABI_FMT_lx")" is self-explicit.

Also for clarity:

#define print_syscall_ret_persona print_syscall_ret_addr

So what do you think of:

{ TARGET_NR_personality, "personality" , "%s(0x"TARGET_ABI_FMT_lx")",
NULL, print_syscall_ret_persona },

?

#4 lore raw
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Helge Deller
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 12 lines · Helge Deller

Make the strace look nicer for those two syscalls.

---
  linux-user/strace.list | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/strace.list +0 -0
index f9254725a1..909298099e 100644

linux-user/strace.list line 1046

Quoted 5 lines
linux-user/strace.list +1 -1
@@ -1043,7 +1043,7 @@
   { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
   #endif
   #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(%p)", NULL, print_syscall_ret_addr },

Shouldn't this be:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

    { TARGET_NR_personality, "personality" , "%s(%u)", NULL, NULL },

Basically yes, but...
it's a bitmap, so printing it as hex value (similiar to a pointer) is easier to read/analyze.

Oh, good point. Then "%s(0x"TARGET_ABI_FMT_lx")" is self-explicit.

Hmm ... I don't see that as any benefit for the user and the output is the same.

Quoted 8 lines

Also for clarity:

#define print_syscall_ret_persona print_syscall_ret_addr

So what do you think of:

{ TARGET_NR_personality, "personality" , "%s(0x"TARGET_ABI_FMT_lx")",
   NULL, print_syscall_ret_persona },

This change does make sense if someone fully implements the strace of personality() including showing the flags as string. Until then it's IMHO just one more function which uses space and gains nothing.

Helge

#5 lore raw

Le 23/12/2022 à 13:27, Helge Deller a écrit :

Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 25 lines · Helge Deller
Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Helge Deller
Quoted 12 lines

Make the strace look nicer for those two syscalls.

---
  linux-user/strace.list | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/strace.list +0 -0
index f9254725a1..909298099e 100644

linux-user/strace.list line 1046

Quoted 5 lines
linux-user/strace.list +1 -1
@@ -1043,7 +1043,7 @@
   { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
   #endif
   #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(%p)", NULL, print_syscall_ret_addr },

Shouldn't this be:

    { TARGET_NR_personality, "personality" , "%s(%u)", NULL, NULL },

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Basically yes, but...
it's a bitmap, so printing it as hex value (similiar to a pointer) is easier to read/analyze.

Oh, good point. Then "%s(0x"TARGET_ABI_FMT_lx")" is self-explicit.

Hmm ... I don't see that as any benefit for the user and the output is the same.

I agree with Philippe for this part, it's not a pointer, don't use %p.

Thanks,
Laurent

#6 lore raw

PATCH v2 1/1 linux-user: Improve strace output of personality() and sysinfo()

Make the strace look nicer for those two syscalls.

--
v2: use TARGET_ABI_FMT_lx instead of %p in personality output
as suggested by Philippe Mathieu-Daudé and Laurent Vivier

linux-user/strace.list +3 -2
index f9254725a1..703c0f1608 100644
@@ -1043,7 +1043,8 @@
 { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(0x"TARGET_ABI_FMT_lx")", NULL,
+  print_syscall_ret_addr },
 #endif
 #ifdef TARGET_NR_pipe
 { TARGET_NR_pipe, "pipe" , NULL, NULL, NULL },
@@ -1502,7 +1503,7 @@
 { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_sysinfo
-{ TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },
+{ TARGET_NR_sysinfo, "sysinfo" , "%s(%p)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_sys_kexec_load
 { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL },
Reviewed-by on v2 1/1
#8 lore raw
In reply to Helge Deller

Le 27/01/2023 à 21:18, Helge Deller a écrit :

Quoted 25 lines

Make the strace look nicer for those two syscalls.

--
v2: use TARGET_ABI_FMT_lx instead of %p in personality output
as suggested by Philippe Mathieu-Daudé and Laurent Vivier

linux-user/strace.list +2 -1
index f9254725a1..703c0f1608 100644
@@ -1043,7 +1043,8 @@
  { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(0x"TARGET_ABI_FMT_lx")", NULL,
+  print_syscall_ret_addr },
  #endif
  #ifdef TARGET_NR_pipe
  { TARGET_NR_pipe, "pipe" , NULL, NULL, NULL },

linux-user/strace.list line 1509

Quoted 8 lines
linux-user/strace.list +1 -1
@@ -1502,7 +1503,7 @@
  { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_sysinfo
-{ TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },
+{ TARGET_NR_sysinfo, "sysinfo" , "%s(%p)", NULL, NULL },
  #endif
  #ifdef TARGET_NR_sys_kexec_load
  { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL },
#9 lore raw
In reply to Helge Deller

Le 27/01/2023 à 21:18, Helge Deller a écrit :

Quoted 25 lines

Make the strace look nicer for those two syscalls.

--
v2: use TARGET_ABI_FMT_lx instead of %p in personality output
as suggested by Philippe Mathieu-Daudé and Laurent Vivier

linux-user/strace.list +2 -1
index f9254725a1..703c0f1608 100644
@@ -1043,7 +1043,8 @@
  { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_personality
-{ TARGET_NR_personality, "personality" , NULL, NULL, NULL },
+{ TARGET_NR_personality, "personality" , "%s(0x"TARGET_ABI_FMT_lx")", NULL,
+  print_syscall_ret_addr },
  #endif
  #ifdef TARGET_NR_pipe
  { TARGET_NR_pipe, "pipe" , NULL, NULL, NULL },

linux-user/strace.list line 1509

Quoted 8 lines
linux-user/strace.list +1 -1
@@ -1502,7 +1503,7 @@
  { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_sysinfo
-{ TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },
+{ TARGET_NR_sysinfo, "sysinfo" , "%s(%p)", NULL, NULL },
  #endif
  #ifdef TARGET_NR_sys_kexec_load
  { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL },

Applied to my linux-user-for-8.0 branch.

Thanks,
Laurent