aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2017-06-05 19:16:04 +0300
committerEli Zaretskii2017-06-05 19:16:04 +0300
commit9ae5c0a2e12c25f37736d9b106c55227b55521e6 (patch)
tree2ce563b68d2694c9358c497f9a887ea20704c6b1 /src
parent5d29c0f006d071008eba8d235db917d5c8b271bb (diff)
downloademacs-9ae5c0a2e12c25f37736d9b106c55227b55521e6.tar.gz
emacs-9ae5c0a2e12c25f37736d9b106c55227b55521e6.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/dynlib.c6
-rw-r--r--src/print.c55
2 files changed, 33 insertions, 28 deletions
diff --git a/src/dynlib.c b/src/dynlib.c
index 79e98b0f288..47ba5e3d91b 100644
--- a/src/dynlib.c
+++ b/src/dynlib.c
@@ -126,7 +126,6 @@ void
126dynlib_addr (void *addr, const char **fname, const char **symname) 126dynlib_addr (void *addr, const char **fname, const char **symname)
127{ 127{
128 static char dll_filename[MAX_UTF8_PATH]; 128 static char dll_filename[MAX_UTF8_PATH];
129 static char addr_str[22];
130 static GetModuleHandleExA_Proc s_pfn_Get_Module_HandleExA = NULL; 129 static GetModuleHandleExA_Proc s_pfn_Get_Module_HandleExA = NULL;
131 char *dll_fn = NULL; 130 char *dll_fn = NULL;
132 HMODULE hm_kernel32 = NULL; 131 HMODULE hm_kernel32 = NULL;
@@ -216,8 +215,9 @@ dynlib_addr (void *addr, const char **fname, const char **symname)
216 of the module functions will be unexported, and probably even 215 of the module functions will be unexported, and probably even
217 static, which means the symbols can be obtained only if we link 216 static, which means the symbols can be obtained only if we link
218 against libbfd (and the DLL can be stripped anyway). So we just 217 against libbfd (and the DLL can be stripped anyway). So we just
219 show the address and the file name; they can use that with 218 show the address and the file name (see print_vectorlike in
220 addr2line or GDB to recover the symbolic name. */ 219 print.c); they can use that with addr2line or GDB to recover the
220 symbolic name. */
221 *symname = NULL; 221 *symname = NULL;
222} 222}
223 223
diff --git a/src/print.c b/src/print.c
index 76ae10fe132..aaec5b04956 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1701,31 +1701,36 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
1701#ifdef HAVE_MODULES 1701#ifdef HAVE_MODULES
1702 case PVEC_MODULE_FUNCTION: 1702 case PVEC_MODULE_FUNCTION:
1703 { 1703 {
1704 print_c_string ("#<module function ", printcharfun); 1704 print_c_string ("#<module function ", printcharfun);
1705 void *ptr = XMODULE_FUNCTION (obj)->subr; 1705 void *ptr = XMODULE_FUNCTION (obj)->subr;
1706 const char *file = NULL; 1706 const char *file = NULL;
1707 const char *symbol = NULL; 1707 const char *symbol = NULL;
1708 dynlib_addr (ptr, &file, &symbol); 1708 dynlib_addr (ptr, &file, &symbol);
1709 1709
1710 if (symbol == NULL) 1710 if (symbol == NULL)
1711 { 1711 {
1712 print_c_string ("at ", printcharfun); 1712 print_c_string ("at ", printcharfun);
1713 enum { pointer_bufsize = sizeof ptr * 16 / CHAR_BIT + 2 + 1 }; 1713 enum { pointer_bufsize = sizeof ptr * 16 / CHAR_BIT + 2 + 1 };
1714 char buffer[pointer_bufsize]; 1714 char buffer[pointer_bufsize];
1715 int needed = snprintf (buffer, sizeof buffer, "%p", ptr); 1715 int needed = snprintf (buffer, sizeof buffer, "%p", ptr);
1716 eassert (needed <= sizeof buffer); 1716 const char p0x[] = "0x";
1717 print_c_string (buffer, printcharfun); 1717 eassert (needed <= sizeof buffer);
1718 } 1718 /* ANSI C doesn't guarantee that %p produces a string that
1719 else 1719 begins with a "0x". */
1720 print_c_string (symbol, printcharfun); 1720 if (c_strncasecmp (buffer, p0x, sizeof (p0x) - 1) != 0)
1721 1721 print_c_string (p0x, printcharfun);
1722 if (file != NULL) 1722 print_c_string (buffer, printcharfun);
1723 { 1723 }
1724 print_c_string (" from ", printcharfun); 1724 else
1725 print_c_string (file, printcharfun); 1725 print_c_string (symbol, printcharfun);
1726 } 1726
1727 1727 if (file != NULL)
1728 printchar ('>', printcharfun); 1728 {
1729 print_c_string (" from ", printcharfun);
1730 print_c_string (file, printcharfun);
1731 }
1732
1733 printchar ('>', printcharfun);
1729 } 1734 }
1730 break; 1735 break;
1731#endif 1736#endif