[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 366e25a 05/14: Simplify interface of dynlib_attr.
From: |
Philipp Stephani |
Subject: |
[Emacs-diffs] master 366e25a 05/14: Simplify interface of dynlib_attr. |
Date: |
Sun, 4 Jun 2017 13:54:06 -0400 (EDT) |
branch: master
commit 366e25a6d1caa30d8d336ce556f90f9ee46ca531
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
Simplify interface of dynlib_attr.
Instead of returning bool, set the argument pointers to NULL if the
information is not available.
* src/dynlib.c (dynlib_addr): Don't return bool.
---
src/dynlib.c | 34 +++++++++++++++-------------------
src/dynlib.h | 5 ++++-
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/src/dynlib.c b/src/dynlib.c
index 9561923..79e98b0 100644
--- a/src/dynlib.c
+++ b/src/dynlib.c
@@ -28,6 +28,8 @@ along with GNU Emacs. If not, see
<http://www.gnu.org/licenses/>. */
#include "dynlib.h"
+#include <stddef.h>
+
#ifdef WINDOWSNT
/* MS-Windows systems. */
@@ -120,7 +122,7 @@ dynlib_sym (dynlib_handle_ptr h, const char *sym)
return (void *)sym_addr;
}
-bool
+void
dynlib_addr (void *addr, const char **fname, const char **symname)
{
static char dll_filename[MAX_UTF8_PATH];
@@ -128,7 +130,6 @@ dynlib_addr (void *addr, const char **fname, const char
**symname)
static GetModuleHandleExA_Proc s_pfn_Get_Module_HandleExA = NULL;
char *dll_fn = NULL;
HMODULE hm_kernel32 = NULL;
- bool result = false;
HMODULE hm_dll = NULL;
wchar_t mfn_w[MAX_PATH];
char mfn_a[MAX_PATH];
@@ -206,23 +207,18 @@ dynlib_addr (void *addr, const char **fname, const char
**symname)
dynlib_last_err = GetLastError ();
}
if (dll_fn)
- {
- dostounix_filename (dll_fn);
- /* We cannot easily produce the function name, since
- typically all 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. */
- sprintf (addr_str, "at 0x%x", (DWORD_PTR)addr);
- *symname = addr_str;
- result = true;
- }
+ dostounix_filename (dll_fn);
}
*fname = dll_fn;
- return result;
+
+ /* We cannot easily produce the function name, since typically all
+ 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. */
+ *symname = NULL;
}
const char *
@@ -283,19 +279,19 @@ dynlib_sym (dynlib_handle_ptr h, const char *sym)
return dlsym (h, sym);
}
-bool
+void
dynlib_addr (void *ptr, const char **path, const char **sym)
{
+ *path = NULL;
+ *sym = NULL;
#ifdef HAVE_DLADDR
Dl_info info;
if (dladdr (ptr, &info) && info.dli_fname && info.dli_sname)
{
*path = info.dli_fname;
*sym = info.dli_sname;
- return true;
}
#endif
- return false;
}
const char *
diff --git a/src/dynlib.h b/src/dynlib.h
index 5ccec11..6246c6a 100644
--- a/src/dynlib.h
+++ b/src/dynlib.h
@@ -27,8 +27,11 @@ dynlib_handle_ptr dynlib_open (const char *path);
void *dynlib_sym (dynlib_handle_ptr h, const char *sym);
typedef struct dynlib_function_ptr_nonce *(*dynlib_function_ptr) (void);
dynlib_function_ptr dynlib_func (dynlib_handle_ptr h, const char *sym);
-bool dynlib_addr (void *ptr, const char **path, const char **sym);
const char *dynlib_error (void);
int dynlib_close (dynlib_handle_ptr h);
+/* Sets *FILE to the file name from which PTR was loaded, and *SYM to
+ its symbol name. If the file or symbol name could not be
+ determined, set the corresponding argument to NULL. */
+void dynlib_addr (void *ptr, const char **file, const char **sym);
#endif /* DYNLIB_H */
- [Emacs-diffs] master updated (bd3c6ee -> 2aa8b15), Philipp Stephani, 2017/06/04
- [Emacs-diffs] master db74384 01/14: Remove two FIXMEs that can't be fixed, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 1839699 02/14: Define helper macro to reduce code duplication, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 034275e 07/14: ; Small comment fix, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 3b0080d 03/14: Rework printing of module functions, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 366e25a 05/14: Simplify interface of dynlib_attr.,
Philipp Stephani <=
- [Emacs-diffs] master a8a93b1 10/14: Guard against signed integer overflows, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master fb3a9fd 08/14: ; Grammar fix, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 9be8b2b 06/14: Use ATTRIBUTE_MAY_ALIAS where alias violations are likely, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 5497062 09/14: Add a couple more assertions to the module code, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 27445a8 11/14: Remove an unneeded assertion, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 2aa8b15 14/14: Remove an unused error symbol, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master d372017 12/14: Use more specific errors for module load failure, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 045d21c 04/14: Rationalize environment lifetime management functions, Philipp Stephani, 2017/06/04
- [Emacs-diffs] master 66da3f4 13/14: Support quitting in modules, Philipp Stephani, 2017/06/04