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.
This commit is contained in:
parent
5d29c0f006
commit
9ae5c0a2e1
2 changed files with 30 additions and 25 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
49
src/print.c
49
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);
|
||||
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 (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);
|
||||
}
|
||||
if (file != NULL)
|
||||
{
|
||||
print_c_string (" from ", printcharfun);
|
||||
print_c_string (file, printcharfun);
|
||||
}
|
||||
|
||||
printchar ('>', printcharfun);
|
||||
printchar ('>', printcharfun);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue