Commit 36b21390 authored by Ben Gamari's avatar Ben Gamari 🐢

rts: Expose more libdw symbols

parent 70ee6389
......@@ -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 */
......@@ -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 */
......@@ -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);
......
......@@ -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) \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment