[commit: ghc] master: rts: Expose more libdw symbols (36b2139)

git at git.haskell.org git at git.haskell.org
Mon Nov 23 16:56:04 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/36b213903db2363c2153f93c78bce079083f3d68/ghc

>---------------------------------------------------------------

commit 36b213903db2363c2153f93c78bce079083f3d68
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Fri Oct 23 09:15:20 2015 +0200

    rts: Expose more libdw symbols


>---------------------------------------------------------------

36b213903db2363c2153f93c78bce079083f3d68
 includes/rts/Libdw.h | 14 +++++++++-----
 rts/Libdw.c          | 22 ++++++++++++++++++----
 rts/Libdw.h          | 10 ----------
 rts/RtsSymbols.c     | 10 ++++++++++
 4 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/includes/rts/Libdw.h b/includes/rts/Libdw.h
index e4fac7a..3c71ac7 100644
--- a/includes/rts/Libdw.h
+++ b/includes/rts/Libdw.h
@@ -77,14 +77,18 @@ typedef struct Location_ {
     StgWord32 colno;
 } __attribute__((packed)) Location;
 
-#ifdef USE_LIBDW
+struct LibdwSession_;
+typedef struct LibdwSession_ LibdwSession;
 
+/* Free a backtrace */
 void backtraceFree(Backtrace *bt);
 
-#else
+/* Request a backtrace of the current stack state.
+ * May return NULL if a backtrace can't be acquired. */
+Backtrace *libdwGetBacktrace(LibdwSession *session);
 
-INLINE_HEADER void backtraceFree(Backtrace *bt STG_UNUSED) { }
-
-#endif /* USE_LIBDW */
+/* Lookup Location information for the given address.
+ * Returns 0 if successful, 1 if address could not be found. */
+int libdwLookupLocation(LibdwSession *session, Location *loc, StgPtr pc);
 
 #endif /* RTS_LIBDW_H */
diff --git a/rts/Libdw.c b/rts/Libdw.c
index 61fefbd..1ef51b2 100644
--- a/rts/Libdw.c
+++ b/rts/Libdw.c
@@ -6,16 +6,16 @@
  *
  * --------------------------------------------------------------------------*/
 
+#include "Rts.h"
+#include "RtsUtils.h"
+#include "Libdw.h"
+
 #ifdef USE_LIBDW
 
 #include <elfutils/libdwfl.h>
 #include <dwarf.h>
 #include <unistd.h>
 
-#include "Rts.h"
-#include "Libdw.h"
-#include "RtsUtils.h"
-
 static BacktraceChunk *backtraceAllocChunk(BacktraceChunk *next) {
     BacktraceChunk *chunk = stgMallocBytes(sizeof(BacktraceChunk),
                                            "backtraceAllocChunk");
@@ -329,4 +329,18 @@ static const Dwfl_Thread_Callbacks thread_cbs = {
     .set_initial_registers = set_initial_registers,
 };
 
+#else /* !USE_LIBDW */
+
+void backtraceFree(Backtrace *bt STG_UNUSED) { }
+
+Backtrace *libdwGetBacktrace(LibdwSession *session STG_UNUSED) {
+    return NULL;
+}
+
+int libdwLookupLocation(LibdwSession *session STG_UNUSED,
+                        Location *loc STG_UNUSED,
+                        StgPtr pc STG_UNUSED) {
+    return 1;
+}
+
 #endif /* USE_LIBDW */
diff --git a/rts/Libdw.h b/rts/Libdw.h
index 76abebc..e5fa054 100644
--- a/rts/Libdw.h
+++ b/rts/Libdw.h
@@ -18,22 +18,12 @@
 
 #ifdef USE_LIBDW
 
-struct LibdwSession_;
-typedef struct LibdwSession_ LibdwSession;
-
 /* Begin a libdw session. A session is tied to a particular capability */
 LibdwSession *libdwInit(void);
 
 /* Free a session */
 void libdwFree(LibdwSession *session);
 
-/* Request a backtrace of the current stack state */
-Backtrace *libdwGetBacktrace(LibdwSession *session);
-
-/* Lookup Location information for the given address.
- * Returns 0 if successful, 1 if address could not be found. */
-int libdwLookupLocation(LibdwSession *session, Location *loc, StgPtr pc);
-
 /* Pretty-print a backtrace to std*/
 void libdwPrintBacktrace(LibdwSession *session, FILE *file, Backtrace *bt);
 
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index bac2fc9..bfcc3cd 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -35,6 +35,15 @@
                                 SymI_HasProto(stg_makeStableNamezh)           \
                                 SymI_HasProto(stg_finalizzeWeakzh)
 
+#if defined(USE_LIBDW)
+#define RTS_LIBDW_SYMBOLS                       \
+      SymE_HasProto(backtraceFree)              \
+      SymE_HasProto(libdwGetBacktrace)          \
+      SymE_HasProto(libdwLookupLocation)
+#else
+#define RTS_LIBDW_SYMBOLS
+#endif /* USE_LIBDW */
+
 #if !defined (mingw32_HOST_OS)
 #define RTS_POSIX_ONLY_SYMBOLS                  \
       SymI_HasProto(__hscore_get_saved_termios) \
@@ -667,6 +676,7 @@
       Maybe_Stable_Names                                                \
       RTS_TICKY_SYMBOLS                                                 \
       RTS_PROF_SYMBOLS                                                  \
+      RTS_LIBDW_SYMBOLS                                                 \
       SymI_HasProto(StgReturn)                                          \
       SymI_HasProto(stg_gc_noregs)                                      \
       SymI_HasProto(stg_ret_v_info)                                     \



More information about the ghc-commits mailing list