tags 323094 patch
thanks

Hi,

I've tried to fix that bug (323094) and ended up with the patch (attached) which appears to do the right thing. It introduces the proper #define's to access the pc register in the sigcontext structure on sparc and explicitly links against libatomic-ops, since the resulting binary depends on the AO_store_full_emulation symbol defined there. Note that it patches Makefile.am, so autoreconf'ing is required after applying it.

I've tested the resulting qprof binary on the dumb_test.c file in the tests directory and it appears to produce sane results:

[EMAIL PROTECTED]:~/qprof-0.5.1/tests$ gcc -g dumb_test.c
[EMAIL PROTECTED]:~/qprof-0.5.1/tests$ qprof ./a.out
qprof: /home/jurij/qprof-0.5.1/tests/a.out: 116 samples, 116 counts
main:dumb_test.c:34                                              46     ( 40%)
main:dumb_test.c:35                                              47     ( 41%)
main:dumb_test.c:36                                              23     ( 20%)
[EMAIL PROTECTED]:~/qprof-0.5.1/tests$

Best regards,

Jurij Smakov                                        [EMAIL PROTECTED]
Key: http://www.wooyd.org/pgpkey/                   KeyID: C99E03CC
diff -aur a/src/prof_utils_libpfm2.c b/src/prof_utils_libpfm2.c
--- a/src/prof_utils_libpfm2.c  2005-12-29 18:30:20.000000000 -0800
+++ b/src/prof_utils_libpfm2.c  2005-12-29 18:29:18.000000000 -0800
@@ -633,6 +633,10 @@
     /* which appears to work on 32 bit kernels.  As I recall, we should */
     /* be using ucontext_t * as the type of the last argument.  But it */
     /* appears hard to extract iaoq[0] fromt that.                     */
+#elif defined(__sparc__)
+# define SET_PC \
+    struct sigcontext *sc = (struct sigcontext *) scv; \
+    unsigned long pc = (AO_T)(sc->si_regs.pc)
 #else
 # define SET_PC \
     struct sigcontext *sc = (struct sigcontext *) scv; \
diff -aur a/src/prof_utils_libpfm3.c b/src/prof_utils_libpfm3.c
--- a/src/prof_utils_libpfm3.c  2005-12-29 18:30:20.000000000 -0800
+++ b/src/prof_utils_libpfm3.c  2005-12-29 18:30:07.000000000 -0800
@@ -712,6 +712,10 @@
     /* which appears to work on 32 bit kernels.  As I recall, we should */
     /* be using ucontext_t * as the type of the last argument.  But it */
     /* appears hard to extract iaoq[0] fromt that.                     */
+#elif defined(__sparc__)
+# define SET_PC \
+    struct sigcontext *sc = (struct sigcontext *) scv; \
+    unsigned long pc = (AO_T)(sc->si_regs.pc)
 #else
 # define SET_PC \
     struct sigcontext *sc = (struct sigcontext *) scv; \
--- a/src/Makefile.am   2005-12-29 22:30:47.000000000 -0800
+++ b/src/Makefile.am   2005-12-29 22:20:02.000000000 -0800
@@ -9,11 +9,11 @@
 
 libqprof_libpfm2_la_SOURCES=prof_main.c prof_utils_libpfm2.c
 libqprof_libpfm2_la_LIBADD=libqprof_utils.la
-libqprof_libpfm2_la_LDFLAGS=-ldl -pthread
+libqprof_libpfm2_la_LDFLAGS=-ldl -pthread -latomic_ops
 
 libqprof_libpfm3_la_SOURCES=prof_main.c prof_utils_libpfm3.c
 libqprof_libpfm3_la_LIBADD=libqprof_utils.la
-libqprof_libpfm3_la_LDFLAGS=-ldl -pthread
+libqprof_libpfm3_la_LDFLAGS=-ldl -pthread -latomic_ops
 
 libmalloc_trace_la_SOURCES=malloc_trace.c wrap.h 
 libmalloc_trace_la_LDFLAGS=-ldl

Reply via email to