[commit: ghc] master: Libdw: Fix build on 32-bit platforms (dbad0d5)

git at git.haskell.org git at git.haskell.org
Mon Nov 23 14:21:42 UTC 2015


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

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

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

commit dbad0d5d8dc1fa616065a49f5175adafb4f36080
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Mon Nov 23 12:37:17 2015 +0100

    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.


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

dbad0d5d8dc1fa616065a49f5175adafb4f36080
 rts/Libdw.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/rts/Libdw.c b/rts/Libdw.c
index 53c2cde..1415fe6 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;
 }
 



More information about the ghc-commits mailing list