emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 9ae5c0a: Fix emacs-module-tests on MS-Windows


From: Eli Zaretskii
Subject: [Emacs-diffs] master 9ae5c0a: Fix emacs-module-tests on MS-Windows
Date: Mon, 5 Jun 2017 12:18:00 -0400 (EDT)

branch: master
commit 9ae5c0a2e12c25f37736d9b106c55227b55521e6
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix emacs-module-tests on MS-Windows
    
    * src/print.c (print_vectorlike): Make sure module function's
    address prints with a leading "0x".  This fixes emacs-module-tests
    on MS-Windows.  Fix whitespace.
    * src/dynlib.c (dynlib_addr): Remove unused variable.  Update
    commentary.
---
 src/dynlib.c |  6 +++---
 src/print.c  | 55 ++++++++++++++++++++++++++++++-------------------------
 2 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/src/dynlib.c b/src/dynlib.c
index 79e98b0..47ba5e3 100644
--- a/src/dynlib.c
+++ b/src/dynlib.c
@@ -126,7 +126,6 @@ void
 dynlib_addr (void *addr, const char **fname, const char **symname)
 {
   static char dll_filename[MAX_UTF8_PATH];
-  static char addr_str[22];
   static GetModuleHandleExA_Proc s_pfn_Get_Module_HandleExA = NULL;
   char *dll_fn = NULL;
   HMODULE hm_kernel32 = NULL;
@@ -216,8 +215,9 @@ dynlib_addr (void *addr, const char **fname, const char 
**symname)
      of the module functions will be unexported, and probably even
      static, which means the symbols can be obtained only if we link
      against libbfd (and the DLL can be stripped anyway).  So we just
-     show the address and the file name; they can use that with
-     addr2line or GDB to recover the symbolic name.  */
+     show the address and the file name (see print_vectorlike in
+     print.c); they can use that with addr2line or GDB to recover the
+     symbolic name.  */
   *symname = NULL;
 }
 
diff --git a/src/print.c b/src/print.c
index 76ae10f..aaec5b0 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1701,31 +1701,36 @@ print_vectorlike (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag,
 #ifdef HAVE_MODULES
     case PVEC_MODULE_FUNCTION:
       {
-        print_c_string ("#<module function ", printcharfun);
-        void *ptr = XMODULE_FUNCTION (obj)->subr;
-        const char *file = NULL;
-        const char *symbol = NULL;
-        dynlib_addr (ptr, &file, &symbol);
-
-        if (symbol == NULL)
-          {
-            print_c_string ("at ", printcharfun);
-            enum { pointer_bufsize = sizeof ptr * 16 / CHAR_BIT + 2 + 1 };
-            char buffer[pointer_bufsize];
-            int needed = snprintf (buffer, sizeof buffer, "%p", ptr);
-            eassert (needed <= sizeof buffer);
-            print_c_string (buffer, printcharfun);
-          }
-        else
-          print_c_string (symbol, printcharfun);
-
-        if (file != NULL)
-          {
-            print_c_string (" from ", printcharfun);
-            print_c_string (file, printcharfun);
-          }
-
-        printchar ('>', printcharfun);
+       print_c_string ("#<module function ", printcharfun);
+       void *ptr = XMODULE_FUNCTION (obj)->subr;
+       const char *file = NULL;
+       const char *symbol = NULL;
+       dynlib_addr (ptr, &file, &symbol);
+
+       if (symbol == NULL)
+         {
+           print_c_string ("at ", printcharfun);
+           enum { pointer_bufsize = sizeof ptr * 16 / CHAR_BIT + 2 + 1 };
+           char buffer[pointer_bufsize];
+           int needed = snprintf (buffer, sizeof buffer, "%p", ptr);
+           const char p0x[] = "0x";
+           eassert (needed <= sizeof buffer);
+           /* ANSI C doesn't guarantee that %p produces a string that
+              begins with a "0x".  */
+           if (c_strncasecmp (buffer, p0x, sizeof (p0x) - 1) != 0)
+             print_c_string (p0x, printcharfun);
+           print_c_string (buffer, printcharfun);
+         }
+       else
+         print_c_string (symbol, printcharfun);
+
+       if (file != NULL)
+         {
+           print_c_string (" from ", printcharfun);
+           print_c_string (file, printcharfun);
+         }
+
+       printchar ('>', printcharfun);
       }
       break;
 #endif



reply via email to

[Prev in Thread] Current Thread [Next in Thread]