Skip to contentSkip to conversation

linux-user: fix GPROF build failure

PATCH Applied Alex Bennée 3 participants 9 messages May 2, 2019 – May 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: fix GPROF build failure

When linux-user/exit was introduced we failed to move the gprof include at the same time. The CI didn't notice because it only builds system emulation. Fix it for those that still find gprof useful.

---
 linux-user/exit.c    | 3 +++
 linux-user/syscall.c | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
linux-user/exit.c +3 -0
index 14e94e28fa..bdda720553 100644
@@ -18,6 +18,9 @@
  */
 #include "qemu/osdep.h"
 #include "qemu.h"
+#ifdef TARGET_GPROF
+#include <sys/gmon.h>
+#endif
 
 #ifdef CONFIG_GCOV
 extern void __gcov_dump(void);
linux-user/syscall.c +0 -3
index 96cd4bf86d..f2d9883aef 100644
@@ -59,9 +59,6 @@
 #ifdef CONFIG_TIMERFD
 #include <sys/timerfd.h>
 #endif
-#ifdef TARGET_GPROF
-#include <sys/gmon.h>
-#endif
 #ifdef CONFIG_EVENTFD
 #include <sys/eventfd.h>
 #endif
Signature · 1 line
2.20.1
Tested-by on v1 1/1
#1 lore raw

Hello,

Quoted 6 lines · Alex Bennée

When linux-user/exit was introduced we failed to move the gprof include at the same time. The CI didn't notice because it only builds system emulation. Fix it for those that still find gprof useful.

Thanks,

Laurent

Quoted 37 lines
---
 linux-user/exit.c    | 3 +++
 linux-user/syscall.c | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
linux-user/exit.c +3 -0
index 14e94e28fa..bdda720553 100644
@@ -18,6 +18,9 @@
  */
 #include "qemu/osdep.h"
 #include "qemu.h"
+#ifdef TARGET_GPROF
+#include <sys/gmon.h>
+#endif
 
 #ifdef CONFIG_GCOV
 extern void __gcov_dump(void);
linux-user/syscall.c +0 -4
index 96cd4bf86d..f2d9883aef 100644
@@ -59,9 +59,6 @@
 #ifdef CONFIG_TIMERFD
 #include <sys/timerfd.h>
 #endif
-#ifdef TARGET_GPROF
-#include <sys/gmon.h>
-#endif
 #ifdef CONFIG_EVENTFD
 #include <sys/eventfd.h>
 #endif
--

2.20.1

#2 lore raw
Quoted 11 lines · Laurent Desnogues

Hello,

Quoted 6 lines · Alex Bennée

When linux-user/exit was introduced we failed to move the gprof include at the same time. The CI didn't notice because it only builds system emulation. Fix it for those that still find gprof useful.

Sadly running programs then fails because of the SIG_PROF signal getting passed to the guest. I wonder how this ever worked?

--
Alex Bennée

#3 lore raw

PATCH 1/1 linux-user: avoid treading on gprof's SIGPROF signals

The guest tends to get confused when it receives signals it doesn't know about. Given the gprof magic has also set up it's own handler we would do well to avoid stomping on it as well.

---
 linux-user/signal.c | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/signal.c +5 -0
index e2c0b37173..44b2d3b35a 100644
@@ -508,6 +508,11 @@ void signal_init(void)
     act.sa_flags = SA_SIGINFO;
     act.sa_sigaction = host_signal_handler;
     for(i = 1; i <= TARGET_NSIG; i++) {
+#ifdef TARGET_GPROF
+        if (i == SIGPROF) {
+            continue;
+        }
+#endif
         host_sig = target_to_host_signal(i);
         sigaction(host_sig, NULL, &oact);
         if (oact.sa_sigaction == (void *)SIG_IGN) {
Signature · 1 line
2.20.1
#4 lore raw

Re: [Qemu-devel] [PATCH] linux-user: avoid treading on gprof's SIGPROF signals

Quoted 16 lines · Alex Bennée

The guest tends to get confused when it receives signals it doesn't know about. Given the gprof magic has also set up it's own handler we would do well to avoid stomping on it as well.

---
 linux-user/signal.c | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/signal.c +0 -0
index e2c0b37173..44b2d3b35a 100644
@@ -508,6 +508,11 @@ void signal_init(void)
     act.sa_flags = SA_SIGINFO;

linux-user/signal.c void signal_init(void) · line 518

Quoted 10 lines
linux-user/signal.c +5 -0
     act.sa_sigaction = host_signal_handler;
     for(i = 1; i <= TARGET_NSIG; i++) {
+#ifdef TARGET_GPROF
+        if (i == SIGPROF) {
+            continue;
+        }
+#endif
         host_sig = target_to_host_signal(i);
         sigaction(host_sig, NULL, &oact);
         if (oact.sa_sigaction == (void *)SIG_IGN) {

Perhaps merge this with the previous one and send a v2: it will ease bisecting.

Thanks,
Laurent

#5 lore raw

Re: [Qemu-devel] [PATCH] linux-user: avoid treading on gprof's SIGPROF signals

Quoted 23 lines · Laurent Vivier
Quoted 21 lines · Alex Bennée

The guest tends to get confused when it receives signals it doesn't know about. Given the gprof magic has also set up it's own handler we would do well to avoid stomping on it as well.

---
 linux-user/signal.c | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/signal.c +4 -0
index e2c0b37173..44b2d3b35a 100644
@@ -508,6 +508,11 @@ void signal_init(void)
     act.sa_flags = SA_SIGINFO;
     act.sa_sigaction = host_signal_handler;
     for(i = 1; i <= TARGET_NSIG; i++) {
+#ifdef TARGET_GPROF
+        if (i == SIGPROF) {
+            continue;
+        }
Quoted 8 lines

linux-user/signal.c void signal_init(void) · line 518

Quoted 5 lines
linux-user/signal.c +1 -0
+#endif
         host_sig = target_to_host_signal(i);
         sigaction(host_sig, NULL, &oact);
         if (oact.sa_sigaction == (void *)SIG_IGN) {

Perhaps merge this with the previous one and send a v2: it will ease bisecting.

I agree it would be better, though it should be noted that the signal issue has existed for at least 8 years (that's when I had to add a specific patch in my private repository).

Thanks,

Laurent

#6 lore raw

Re: [Qemu-devel] [PATCH] linux-user: avoid treading on gprof's SIGPROF signals

Quoted 33 lines · Laurent Desnogues
Quoted 23 lines · Laurent Vivier
Quoted 21 lines · Alex Bennée

The guest tends to get confused when it receives signals it doesn't know about. Given the gprof magic has also set up it's own handler we would do well to avoid stomping on it as well.

---
 linux-user/signal.c | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/signal.c +4 -0
index e2c0b37173..44b2d3b35a 100644
@@ -508,6 +508,11 @@ void signal_init(void)
     act.sa_flags = SA_SIGINFO;
     act.sa_sigaction = host_signal_handler;
     for(i = 1; i <= TARGET_NSIG; i++) {
+#ifdef TARGET_GPROF
+        if (i == SIGPROF) {
+            continue;
+        }
Quoted 8 lines

linux-user/signal.c void signal_init(void) · line 518

Quoted 5 lines
linux-user/signal.c +1 -0
+#endif
         host_sig = target_to_host_signal(i);
         sigaction(host_sig, NULL, &oact);
         if (oact.sa_sigaction == (void *)SIG_IGN) {

Perhaps merge this with the previous one and send a v2: it will ease bisecting.

Quoted 3 lines

I agree it would be better, though it should be noted that the signal issue has existed for at least 8 years (that's when I had to add a specific patch in my private repository).

I can also apply the second first, and the first then...

Thanks,
Laurent

#7 lore raw

Re: [Qemu-devel] [PATCH] linux-user: avoid treading on gprof's SIGPROF signals

In reply to Alex Bennée
Quoted 16 lines · Alex Bennée

The guest tends to get confused when it receives signals it doesn't know about. Given the gprof magic has also set up it's own handler we would do well to avoid stomping on it as well.

---
  linux-user/signal.c | 5 +++++
  1 file changed, 5 insertions(+)
linux-user/signal.c +0 -0
index e2c0b37173..44b2d3b35a 100644
@@ -508,6 +508,11 @@ void signal_init(void)
      act.sa_flags = SA_SIGINFO;

linux-user/signal.c void signal_init(void) · line 518

Quoted 10 lines
linux-user/signal.c +5 -0
      act.sa_sigaction = host_signal_handler;
      for(i = 1; i <= TARGET_NSIG; i++) {
+#ifdef TARGET_GPROF
+        if (i == SIGPROF) {
+            continue;
+        }
+#endif
          host_sig = target_to_host_signal(i);
          sigaction(host_sig, NULL, &oact);
          if (oact.sa_sigaction == (void *)SIG_IGN) {

Applied to my linux-user branch.

Thanks,
Laurent

#8 lore raw
In reply to Alex Bennée
Quoted 30 lines · Alex Bennée

When linux-user/exit was introduced we failed to move the gprof include at the same time. The CI didn't notice because it only builds system emulation. Fix it for those that still find gprof useful.

---
  linux-user/exit.c    | 3 +++
  linux-user/syscall.c | 3 ---
  2 files changed, 3 insertions(+), 3 deletions(-)
linux-user/exit.c +3 -0
index 14e94e28fa..bdda720553 100644
@@ -18,6 +18,9 @@
   */
  #include "qemu/osdep.h"
  #include "qemu.h"
+#ifdef TARGET_GPROF
+#include <sys/gmon.h>
+#endif
 
  #ifdef CONFIG_GCOV
  extern void __gcov_dump(void);
linux-user/syscall.c +0 -0
index 96cd4bf86d..f2d9883aef 100644

linux-user/syscall.c line 64

Quoted 9 lines
linux-user/syscall.c +0 -3
@@ -59,9 +59,6 @@
  #ifdef CONFIG_TIMERFD
  #include <sys/timerfd.h>
  #endif
-#ifdef TARGET_GPROF
-#include <sys/gmon.h>
-#endif
  #ifdef CONFIG_EVENTFD
  #include <sys/eventfd.h>
  #endif

Applied to my linux-user branch.

Thanks,
Laurent