From: Paul Eggert Date: Mon, 28 Oct 2024 00:21:23 +0000 (-0700) Subject: Work around GDB bug 32313 when debugging Emacs internals X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c07c012b37e880fc79a238c206f8247306b53dd5;p=emacs.git Work around GDB bug 32313 when debugging Emacs internals Problem reported by Eli Zaretskii in: https://lists.gnu.org/r/emacs-devel/2024-10/msg00653.html * src/eval.c (backtrace_function_body): Rename from backtrace_function, and make it static. (GDB_FUNCPTR): New macro. (backtrace_function): New function pointer, for GDB only. (cherry picked from commit ebf3fb9a2295520ef8ce1756086fd9bbd3d04e9e) --- diff --git a/src/eval.c b/src/eval.c index 874cf6d868c..3c4999d818c 100644 --- a/src/eval.c +++ b/src/eval.c @@ -51,7 +51,6 @@ Lisp_Object Vsignaling_function; /* These would ordinarily be static, but they need to be visible to GDB. */ bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE; Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE; -Lisp_Object backtrace_function (union specbinding *) EXTERNALLY_VISIBLE; union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE; union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; @@ -108,12 +107,21 @@ specpdl_arg (union specbinding *pdl) return pdl->unwind.arg; } -Lisp_Object -backtrace_function (union specbinding *pdl) +static Lisp_Object +backtrace_function_body (union specbinding *pdl) { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->bt.function; } +/* To work around GDB bug 32313 + + make backtrace_function a visible-to-GDB pointer instead of merely + being an externally visible function itself. Declare the pointer + first to pacify gcc -Wmissing-variable-declarations. */ +#define GDB_FUNCPTR(func, resulttype, params) \ + extern resulttype (*const func) params EXTERNALLY_VISIBLE; \ + resulttype (*const func) params = func##_body +GDB_FUNCPTR (backtrace_function, Lisp_Object, (union specbinding *)); static ptrdiff_t backtrace_nargs (union specbinding *pdl)