rts: Expose more libdw symbols
authorBen Gamari <ben@smart-cactus.org>
Fri, 23 Oct 2015 07:15:20 +0000 (09:15 +0200)
committerBen Gamari <ben@smart-cactus.org>
Mon, 23 Nov 2015 14:40:37 +0000 (15:40 +0100)
includes/rts/Libdw.h
rts/Libdw.c
rts/Libdw.h
rts/RtsSymbols.c

index e4fac7a..3c71ac7 100644 (file)
@@ -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 */
index 61fefbd..1ef51b2 100644 (file)
@@ -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 */
index 76abebc..e5fa054 100644 (file)
 
 #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);
 
index bac2fc9..bfcc3cd 100644 (file)
                                 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) \
       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)                                     \