summaryrefslogtreecommitdiff
path: root/rts/Libdw.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2015-11-23 12:37:17 +0100
committerBen Gamari <ben@smart-cactus.org>2015-11-23 15:21:57 +0100
commitdbad0d5d8dc1fa616065a49f5175adafb4f36080 (patch)
tree7eb0bc11c23b8e6802e0a1e8d3c9f2f2ddcb7037 /rts/Libdw.c
parent7c9a04d6eda5495f150a1140e6d26fc64e319b7e (diff)
downloadhaskell-dbad0d5d8dc1fa616065a49f5175adafb4f36080.tar.gz
Libdw: Fix build on 32-bit platforms
The casting here is a bit tricky since Dwarf_Addr is always 64-bits. This means we first need to narrow to uintptr_t before casting to/from a pointer for compatibility on 32-bit architectures.
Diffstat (limited to 'rts/Libdw.c')
-rw-r--r--rts/Libdw.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/rts/Libdw.c b/rts/Libdw.c
index 53c2cde23a..1415fe6fdf 100644
--- a/rts/Libdw.c
+++ b/rts/Libdw.c
@@ -123,18 +123,19 @@ LibdwSession *libdwInit() {
int libdwLookupLocation(LibdwSession *session, Location *frame,
StgPtr pc) {
+ Dwarf_Addr addr = (Dwarf_Addr) (uintptr_t) pc;
// Find the module containing PC
- Dwfl_Module *mod = dwfl_addrmodule(session->dwfl, (Dwarf_Addr) pc);
+ Dwfl_Module *mod = dwfl_addrmodule(session->dwfl, addr);
if (mod == NULL)
return 1;
dwfl_module_info(mod, NULL, NULL, NULL, NULL, NULL,
&frame->object_file, NULL);
// Find function name
- frame->function = dwfl_module_addrname(mod, (Dwarf_Addr) pc);
+ frame->function = dwfl_module_addrname(mod, addr);
// Try looking up source location
- Dwfl_Line *line = dwfl_module_getsrc(mod, (Dwarf_Addr) pc);
+ Dwfl_Line *line = dwfl_module_getsrc(mod, addr);
if (line != NULL) {
Dwarf_Addr addr;
int lineno, colno;
@@ -227,7 +228,7 @@ static int getBacktraceFrameCb(Dwfl_Frame *frame, void *arg) {
} else {
if (is_activation)
pc -= 1; // TODO: is this right?
- backtracePush(session->cur_bt, (StgPtr) pc);
+ backtracePush(session->cur_bt, (StgPtr) (uintptr_t) pc);
}
return DWARF_CB_OK;
@@ -264,7 +265,7 @@ static pid_t next_thread(Dwfl *dwfl, void *arg, void **thread_argp) {
static bool memory_read(Dwfl *dwfl STG_UNUSED, Dwarf_Addr addr,
Dwarf_Word *result, void *arg STG_UNUSED) {
- *result = *(Dwarf_Word *) addr;
+ *result = *(Dwarf_Word *) (uintptr_t) addr;
return true;
}