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;
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;
}
#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