From unknown Fri Jun 20 20:09:37 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43404: 28.0.50; .gdbinit 'pp' command cannot print stack-based Lisp values. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Sep 2020 17:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43404 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 43404@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16001055769535 (code B ref -1); Mon, 14 Sep 2020 17:47:01 +0000 Received: (at submit) by debbugs.gnu.org; 14 Sep 2020 17:46:16 +0000 Received: from localhost ([127.0.0.1]:56113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHsYS-0002Tj-6I for submit@debbugs.gnu.org; Mon, 14 Sep 2020 13:46:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:42954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHsYP-0002Ta-BM for submit@debbugs.gnu.org; Mon, 14 Sep 2020 13:46:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHsYN-00081V-TU for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 13:46:12 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56999) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHsYM-0001No-Jx for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 13:46:11 -0400 Received: from [176.228.60.248] (port=4636 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kHsYM-0007yR-1e for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 13:46:10 -0400 Date: Mon, 14 Sep 2020 20:46:14 +0300 Message-Id: <83ft7k9rq1.fsf@gnu.org> From: Eli Zaretskii X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This problem seems to be very old: I see it as far back as Emacs 25. But it's an annoying problem that makes debugging Emacs harder than it could be, so I hope we can fix it. The problem is that stack-based Lisp variables created by the likes of AUTO_STRING cannot have their values displayed by the 'pp' command defined in src/.gdbinit. To reproduce: $ cd /path/to/emacs/src $ gdb ./emacs (gdb) break fileio.c:4004 (gdb) r -Q Then in Emacs: C-x C-f README RET C-x i ../etc/HELLO RET At this point the breakpoint breaks and GDB gets control. Then: Thread 1 hit Breakpoint 2, Finsert_file_contents ( filename=XIL(0x8000000006d00380), visit=XIL(0), beg=XIL(0), end=XIL(0), replace=XIL(0)) at fileio.c:4004 4004 record_unwind_current_buffer (); (gdb) pp name # But 'name' is a perfectly valid Lisp string: (gdb) p name $1 = XIL(0x8000000000829580) (gdb) xtype Lisp_String (gdb) xstring $2 = (struct Lisp_String *) 0x829580 " *code-converting-work*" The reason for this misfeature is the following safety net: void safe_debug_print (Lisp_Object arg) { int valid = valid_lisp_object_p (arg); if (valid > 0) debug_print (arg); else { EMACS_UINT n = XLI (arg); fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n", !valid ? "INVALID" : "SOME", n); } } And valid_lisp_object_p returns zero for stack-based Lisp objects, because (AFAIU) it wasn't meant to be used with such objects. I can reproduce this both on MS-Windows and on GNU/Linux. In GNU Emacs 28.0.50 (build 563, i686-pc-mingw32) of 2020-09-14 built on HOME-C4E4A596F7 Repository revision: 15d2f6af000625640b3c47d2aeec3114ac1ac544 Repository branch: master Windowing system distributor 'Microsoft Corp.', version 5.1.2600 System Description: Microsoft Windows XP Service Pack 3 (v5.1.0.2600) Configured using: 'configure -C --prefix=/d/usr --with-wide-int --with-modules --enable-checking=yes,glyphs 'CFLAGS=-O0 -gdwarf-4 -g3'' Configured features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY W32NOTIFY ACL GNUTLS LIBXML2 HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS JSON PDUMPER LCMS2 Important settings: value of $LANG: ENU locale-coding-system: cp1255 Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml easymenu mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map text-property-search time-date subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 57744 8582) (symbols 48 7871 1) (strings 16 21145 2417) (string-bytes 1 614043) (vectors 16 12401) (vector-slots 8 167226 11660) (floats 8 23 239) (intervals 40 249 73) (buffers 888 10))