summaryrefslogtreecommitdiff
path: root/rts/Libdw.h
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2015-10-17 16:44:01 +0200
committerBen Gamari <ben@smart-cactus.org>2015-10-17 16:51:32 +0200
commita6a3dabc9e6b1cfc2f4047d2d09efe634affb120 (patch)
tree89d75773c681bc0e5ade094e6ffc887fa05f36ee /rts/Libdw.h
parentfff02548d237655dea39f108364d7ebe6d0e122d (diff)
downloadhaskell-a6a3dabc9e6b1cfc2f4047d2d09efe634affb120.tar.gz
Libdw: Add libdw-based stack unwinding
This adds basic support to the RTS for DWARF-assisted unwinding of the Haskell and C stack via libdw. This only adds the infrastructure; consumers of this functionality will be introduced in future diffs. Currently we are carrying the initial register collection code in Libdw.c but this will eventually make its way upstream to libdw. Test Plan: See future patches Reviewers: Tarrasch, scpmw, austin, simonmar Reviewed By: austin, simonmar Subscribers: simonmar, thomie, erikd Differential Revision: https://phabricator.haskell.org/D1196 GHC Trac Issues: #10656
Diffstat (limited to 'rts/Libdw.h')
-rw-r--r--rts/Libdw.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/rts/Libdw.h b/rts/Libdw.h
new file mode 100644
index 0000000000..8c5f1cadb8
--- /dev/null
+++ b/rts/Libdw.h
@@ -0,0 +1,58 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 2014-2015
+ *
+ * Producing stacktraces with DWARF unwinding using libdw..
+ *
+ * Do not #include this file directly: #include "Rts.h" instead.
+ *
+ * To understand the structure of the RTS headers, see the wiki:
+ * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
+ *
+ * -------------------------------------------------------------------------- */
+
+#ifndef LIBDW_H
+#define LIBDW_H
+
+#include "BeginPrivate.h"
+
+#ifdef USE_LIBDW
+
+struct LibDwSession_;
+typedef struct LibDwSession_ LibDwSession;
+
+/* Begin a libdw session. A session is tied to a particular capability */
+LibDwSession *libdw_init(void);
+
+/* Free a session */
+void libdw_free(LibDwSession *session);
+
+/* Request a backtrace of the current stack state */
+Backtrace *libdw_get_backtrace(LibDwSession *session);
+
+/* Lookup Location information for the given address.
+ * Returns 0 if successful, 1 if address could not be found. */
+int libdw_lookup_location(LibDwSession *session, Location *loc, StgPtr pc);
+
+/* Pretty-print a backtrace to std*/
+void libdw_print_backtrace(LibDwSession *session, FILE *file, Backtrace *bt);
+
+// Traverse backtrace in order of outer-most to inner-most frame
+#define FOREACH_FRAME_INWARDS(pc, bt) \
+ BacktraceChunk *_chunk; \
+ unsigned int _frame_idx; \
+ for (_chunk = &bt->frames; _chunk != NULL; _chunk = _chunk->next) \
+ for (_frame_idx=0; \
+ pc = _chunk->frames[_frame_idx], _frame_idx < _chunk->n_frames; \
+ _frame_idx++)
+
+// Traverse a backtrace in order of inner-most to outer-most frame
+int foreach_frame_outwards(Backtrace *bt,
+ int (*cb)(StgPtr, void*),
+ void *user_data);
+
+#endif /* USE_LIBDW */
+
+#include "EndPrivate.h"
+
+#endif /* LIBDW_H */