Skip to contentSkip to conversation

User qemu profiling

PATCH Applied Laurent Desnogues 2 participants 2 messages Oct 29, 2008 – Nov 6, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 User qemu profiling

Hello,

this patch:

- Makefile.target: re-enable profiling for user qemu. It seems profiling was (accidently?) removed by commit 3937

- syscall.c:
* add an include to get _mcleanup prototype
* add a call to _mcleanup for exit_group in a way similar to what is done for exit

BTW, I wonder why -p is preferred over -pg for profiling.

Thanks,

Laurent

Makefile.target +6 -0
Index: Makefile.target
===================================================================
@@ -394,6 +394,12 @@
 endif
 endif
 
+# profiling code
+ifdef TARGET_GPROF
+LDFLAGS+=-p
+CFLAGS+=-p
+endif
+
 OBJS= main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \
       elfload.o linuxload.o uaccess.o
 LIBS+= $(AIOLIBS)
syscall.c +6 -0
Index: linux-user/syscall.c
===================================================================
@@ -54,6 +54,9 @@
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <qemu-common.h>
+#ifdef HAVE_GPROF
+#include <sys/gmon.h>
+#endif
 
 #define termios host_termios
 #define winsize host_winsize
@@ -4864,6 +4867,9 @@
 #ifdef __NR_exit_group
         /* new thread calls */
     case TARGET_NR_exit_group:
+#ifdef HAVE_GPROF
+        _mcleanup();
+#endif
         gdb_exit(cpu_env, arg1);
         ret = get_errno(exit_group(arg1));
         break;
#1 lore raw
Quoted 12 lines · Laurent Desnogues

Hello,

this patch:

- Makefile.target: re-enable profiling for user qemu. It seems profiling was (accidently?) removed by commit 3937

- syscall.c:
* add an include to get _mcleanup prototype
* add a call to _mcleanup for exit_group in a way similar to what is done for exit

Quoted 5 lines

BTW, I wonder why -p is preferred over -pg for profiling.

Thanks,

Laurent

Applied, thanks

Quoted 41 lines

Index: Makefile.target
===================================================================

Makefile.target +6 -0
@@ -394,6 +394,12 @@
 endif
 endif
 
+# profiling code
+ifdef TARGET_GPROF
+LDFLAGS+=-p
+CFLAGS+=-p
+endif
+
 OBJS= main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \
       elfload.o linuxload.o uaccess.o
 LIBS+= $(AIOLIBS)

Index: linux-user/syscall.c
===================================================================

syscall.c +6 -0
@@ -54,6 +54,9 @@
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <qemu-common.h>
+#ifdef HAVE_GPROF
+#include <sys/gmon.h>
+#endif
 
 #define termios host_termios
 #define winsize host_winsize
@@ -4864,6 +4867,9 @@
 #ifdef __NR_exit_group
         /* new thread calls */
     case TARGET_NR_exit_group:
+#ifdef HAVE_GPROF
+        _mcleanup();
+#endif
         gdb_exit(cpu_env, arg1);
         ret = get_errno(exit_group(arg1));
         break;
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net