[commit: ghc] master: rts/Printer.c: drop zcode mangling/demangling support in C code (7a754a9)

git at git.haskell.org git at git.haskell.org
Sun Aug 10 20:51:06 UTC 2014


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

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

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

commit 7a754a943a4bfd55c889a780cef2198ded1d2e37
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date:   Sun Aug 10 15:47:51 2014 -0500

    rts/Printer.c: drop zcode mangling/demangling support in C code
    
    Summary:
    GHC's RTS contains ancient Zdecode code which changed format a bit.
    It's easier to drop broken part and show original names.
    
    The patch changes output for './hello +RTS -Da' (apply)
    from such gibberish:
    
        stg_ap_v_ret... PAP/1(0x92922a, &i!_-&i!_:<.s_r=Z)
        stg_ap_0_ret... base:GHC.MVar.MVar(0x7fd3d1f040f8)
        stg_ap_v_ret... THUNK(&i!_-&i!_i!f.Z)
        stg_ap_v_ret... PAP/1(0x92c1f3, EO_:<.s_r=Z, EP_:<.s_r=Z)
        stg_ap_0_ret... ghc-prim:GHC.Tuple.(,)(0x7fd3d1f04209, 0x7fd3d1f041fa)
        stg_ap_0_ret... ghc-prim:GHC.Types.:(0x7fd3d1f04301, 0x7fd3d1f042ea)
        stg_ap_0_ret... THUNK(3F0_i!f.Z, 0x9152a1)
        stg_ap_0_ret... FUN/3(&s=_GHCziIOziFD_z/fB_ff=r=/IOFD14_i!f.Z)
        stg_ap_ppv_ret... FUN/3(&s=_GHCziIOziFD_z/fB_ff=r=/IOFD14_i!f.Z)
        stg_ap_0_ret... FUN/2(&s=_GHCziIOziFD_z/fIOD=vi:=FD15_i!f.Z)
        stg_ap_pv_ret... FUN/2(&s=_GHCziIOziFD_z/fIOD=vi:=FD15_i!f.Z)
        stg_ap_0_ret... base:GHC.IO.Handle.Types.FileHandle(5'A_:<.s_r=Z, 0x7fd3d1f04ef0)
        stg_ap_v_ret... THUNK(*>_&+_2__+/_i!f.Z, 0x7fd3d1f0602a, 0x7fd3d1f04f10)
        stg_ap_v_ret... PAP/1(0x7fd3d1f0602a, 0x7fd3d1f04f10)
    
    to something more readable:
    
        stg_ap_v_ret... PAP/1(0x92922a, <Main_main_closure>[0x90b710])
        stg_ap_0_ret... base:GHC.MVar.MVar(0x7f1e256040f8)
        stg_ap_v_ret... THUNK(<Main_main_info>[0x4046c8])
        stg_ap_v_ret... PAP/1(0x92c1f3, <sEO_closure>[0x90b6f0], <sEP_closure>[0x90b6d0])
        stg_ap_0_ret... ghc-prim:GHC.Tuple.(,)(0x7f1e25604209, 0x7f1e256041fa)
        stg_ap_0_ret... ghc-prim:GHC.Types.:(0x7f1e25604301, 0x7f1e256042ea)
        stg_ap_0_ret... THUNK(<s3F0_info>[0x434f70], 0x9152a1)
        stg_ap_0_ret... FUN/3(<base_GHCziIOziFD_zdfBufferedIOFD14_info>[0x5f5198])
        stg_ap_ppv_ret... FUN/3(<base_GHCziIOziFD_zdfBufferedIOFD14_info>[0x5f5198])
        stg_ap_0_ret... FUN/2(<base_GHCziIOziFD_zdfIODeviceFD15_info>[0x5f7c60])
        stg_ap_pv_ret... FUN/2(<base_GHCziIOziFD_zdfIODeviceFD15_info>[0x5f7c60])
        stg_ap_0_ret... base:GHC.IO.Handle.Types.FileHandle(<r5qA_closure>[0x91a920], 0x7f1e25604ef0)
        stg_ap_v_ret... THUNK(<stg_ap_2_upd_info>[0x6b1c60], 0x7f1e2560602a, 0x7f1e25604f10)
        stg_ap_v_ret... PAP/1(0x7f1e2560602a, 0x7f1e25604f10)
    
    First observed on '+RTS -Di' (interpreter) on unregisterised builds.
    
    Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>
    
    Test Plan: built 'hello world' with -debug in moth modes and ran under '+RTS -Da'
    
    Reviewers: simonmar, austin, ezyang
    
    Reviewed By: austin, ezyang
    
    Subscribers: phaskell, rwbarton, simonmar, relrod, ezyang, carter
    
    Differential Revision: https://phabricator.haskell.org/D116


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

7a754a943a4bfd55c889a780cef2198ded1d2e37
 rts/Printer.c | 149 +---------------------------------------------------------
 1 file changed, 2 insertions(+), 147 deletions(-)

diff --git a/rts/Printer.c b/rts/Printer.c
index 6f37831..459db42 100644
--- a/rts/Printer.c
+++ b/rts/Printer.c
@@ -33,10 +33,7 @@ static void    insert        ( StgWord value, const char *name );
 #endif
 #if 0 /* unused but might be useful sometime */
 static rtsBool lookup_name   ( char *name, StgWord *result );
-static void    enZcode       ( char *in, char *out );
 #endif
-static char    unZcode       ( char ch );
-static void    printZcoded   ( const char *raw );
 
 /* --------------------------------------------------------------------------
  * Printer
@@ -47,7 +44,8 @@ void printPtr( StgPtr p )
     const char *raw;
     raw = lookupGHCName(p);
     if (raw != NULL) {
-        printZcoded(raw);
+        debugBelch("<%s>", raw);
+        debugBelch("[%p]", p);
     } else {
         debugBelch("%p", p);
     }
@@ -646,134 +644,6 @@ static rtsBool lookup_name( char *name, StgWord *result )
 }
 #endif
 
-/* Code from somewhere inside GHC (circa 1994)
- * * Z-escapes:
- *     "std"++xs -> "Zstd"++xs
- *     char_to_c 'Z'  = "ZZ"
- *     char_to_c '&'  = "Za"
- *     char_to_c '|'  = "Zb"
- *     char_to_c ':'  = "Zc"
- *     char_to_c '/'  = "Zd"
- *     char_to_c '='  = "Ze"
- *     char_to_c '>'  = "Zg"
- *     char_to_c '#'  = "Zh"
- *     char_to_c '<'  = "Zl"
- *     char_to_c '-'  = "Zm"
- *     char_to_c '!'  = "Zn"
- *     char_to_c '.'  = "Zo"
- *     char_to_c '+'  = "Zp"
- *     char_to_c '\'' = "Zq"
- *     char_to_c '*'  = "Zt"
- *     char_to_c '_'  = "Zu"
- *     char_to_c c    = "Z" ++ show (ord c)
- */
-static char unZcode( char ch )
-{
-    switch (ch) {
-    case 'a'  : return ('&');
-    case 'b'  : return ('|');
-    case 'c'  : return (':');
-    case 'd'  : return ('/');
-    case 'e'  : return ('=');
-    case 'g'  : return ('>');
-    case 'h'  : return ('#');
-    case 'l'  : return ('<');
-    case 'm'  : return ('-');
-    case 'n'  : return ('!');
-    case 'o'  : return ('.');
-    case 'p'  : return ('+');
-    case 'q'  : return ('\'');
-    case 't'  : return ('*');
-    case 'u'  : return ('_');
-    case 'Z'  :
-    case '\0' : return ('Z');
-    default   : return (ch);
-    }
-}
-
-#if 0
-/* Precondition: out big enough to handle output (about twice length of in) */
-static void enZcode( char *in, char *out )
-{
-    int i, j;
-
-    j = 0;
-    out[ j++ ] = '_';
-    for( i = 0; in[i] != '\0'; ++i ) {
-        switch (in[i]) {
-        case 'Z'  : 
-                out[j++] = 'Z';
-                out[j++] = 'Z';
-                break;
-        case '&'  : 
-                out[j++] = 'Z';
-                out[j++] = 'a';
-                break;
-        case '|'  : 
-                out[j++] = 'Z';
-                out[j++] = 'b';
-                break;
-        case ':'  : 
-                out[j++] = 'Z';
-                out[j++] = 'c';
-                break;
-        case '/'  : 
-                out[j++] = 'Z';
-                out[j++] = 'd';
-                break;
-        case '='  : 
-                out[j++] = 'Z';
-                out[j++] = 'e';
-                break;
-        case '>'  : 
-                out[j++] = 'Z';
-                out[j++] = 'g';
-                break;
-        case '#'  : 
-                out[j++] = 'Z';
-                out[j++] = 'h';
-                break;
-        case '<'  : 
-                out[j++] = 'Z';
-                out[j++] = 'l';
-                break;
-        case '-'  : 
-                out[j++] = 'Z';
-                out[j++] = 'm';
-                break;
-        case '!'  : 
-                out[j++] = 'Z';
-                out[j++] = 'n';
-                break;
-        case '.'  : 
-                out[j++] = 'Z';
-                out[j++] = 'o';
-                break;
-        case '+'  : 
-                out[j++] = 'Z';
-                out[j++] = 'p';
-                break;
-        case '\'' : 
-                out[j++] = 'Z';
-                out[j++] = 'q';
-                break;
-        case '*'  : 
-                out[j++] = 'Z';
-                out[j++] = 't';
-                break;
-        case '_'  : 
-                out[j++] = 'Z';
-                out[j++] = 'u';
-                break;
-        default :
-                out[j++] = in[i];
-                break;
-        }
-    }
-    out[j] = '\0';
-}
-#endif
-
 const char *lookupGHCName( void *addr )
 {
     nat i;
@@ -786,21 +656,6 @@ const char *lookupGHCName( void *addr )
     }
 }
 
-static void printZcoded( const char *raw )
-{
-    nat j = 0;
-    
-    while ( raw[j] != '\0' ) {
-        if (raw[j] == 'Z') {
-            debugBelch("%c", unZcode(raw[j+1]));
-            j = j + 2;
-        } else {
-            debugBelch("%c", unZcode(raw[j+1]));
-            j = j + 1;
-        }
-    }
-}
-
 /* --------------------------------------------------------------------------
  * Symbol table loading
  * ------------------------------------------------------------------------*/



More information about the ghc-commits mailing list