From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4292 invoked by alias); 18 Aug 2012 12:32:24 -0000 Received: (qmail 4278 invoked by uid 22791); 18 Aug 2012 12:32:23 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_NIX_SPAM,SPF_SOFTFAIL,TW_BJ,TW_CP X-Spam-Check-By: sourceware.org Received: from mtaout22.012.net.il (HELO mtaout22.012.net.il) (80.179.55.172) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 18 Aug 2012 12:32:08 +0000 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0M8Y00E00AORVS00@a-mtaout22.012.net.il> for gdb-patches@sourceware.org; Sat, 18 Aug 2012 15:32:07 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8Y00EPQATITM10@a-mtaout22.012.net.il> for gdb-patches@sourceware.org; Sat, 18 Aug 2012 15:32:07 +0300 (IDT) Date: Sat, 18 Aug 2012 12:32:00 -0000 From: Eli Zaretskii Subject: GDB 7.5: Problems with the auto-load safe-path feature To: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83d32ogz3g.fsf@gnu.org> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00505.txt.bz2 This new feature in GDB 7.5 looks like a nuisance in my (short) experience. First, on MS-Windows the file gdb/gdb-gdb.gdb is not loaded, because GDB wants it to be named gdb.exe-gdb.gdb. I think the .exe suffix should be ignored in this case, so I suggest the patch below. OK to commit? Next, I have trouble understanding how we are supposed to deal with this in, e.g., the Emacs distribution, which comes with a heavily customized .gdbinit file. There seems to be no way of telling GDB that this .gdbinit is safe, except (a) through command-line arguments, or (b) by adding settings to global or user-private init files. How can other projects allow seamless loading of their GDB init files, in a way that is compatible with previous GDB versions, and without requiring each user to hack their global/private GDB init files? (If there is such a way, it should be prominently described in the GDB manual.) Another problem is that the error message displayed when GDB rejects to auto-load a file, viz.: warning: File "D:\gnu\bzr\emacs\trunk\src\.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load". leaves it to the user to find out where are those safe directories. Is there an easy way of displaying $datadir and $debugdir? Trying the obvious, I get: (gdb) p $datadir $1 = void Is that a bug? For $datadir, I can do this: (gdb) show data-directory GDB's data directory is "d:\usr\share\gdb". But for $debugdir, there's no "show debug-directory"; instead I need to do this: (gdb) show debug-file-directory The directory where separate debug symbols are searched for is "d:\usr\lib\debug". and the description does not make me sure this is the right directory, since it does not mention anything about scripts. At the very least, we should fix the description to mention the scripts. Finally, "apropos director" reveals another problem: (gdb) apropos director [...] info auto-load local-gdbinit -- Print whether current directory [...] set auto-load local-gdbinit -- Enable or disable auto-loading of [...] show auto-load local-gdbinit -- Show whether auto-loading These truncated descriptions are caused by using ".gdbinit" in the first line of the doc string. To fix this, we should either use "GDB init" instead of .gdbinit, or remove the code that stops on the first period or comma altogether. Here's the patch I suggest for the first problem described above: 2012-08-18 Eli Zaretskii * auto-load.c (auto_load_objfile_script): If OBJFILE specifies a DOS/Windows-style .exe executable program, remove the .exe suffix when generating the script file name. --- gdb/auto-load.c~ 2012-07-02 13:57:33.000000000 +0300 +++ gdb/auto-load.c 2012-08-18 13:54:33.578125000 +0300 @@ -708,6 +708,20 @@ auto_load_objfile_script (struct objfile realname = gdb_realpath (objfile->name); len = strlen (realname); +#if defined (__MSDOS__) || defined(__MINGW32__) + /* For Windows/DOS .exe executables, strip the .exe suffix, so that + FOO-gdb.gdb could be used for FOO.exe. */ + { + const size_t lexe = sizeof (".exe") - 1; + + if (len > lexe + && strcasecmp (realname + len - lexe, ".exe") == 0) + { + len -= lexe; + realname[len] = '\0'; + } + } +#endif filename = xmalloc (len + strlen (language->suffix) + 1); memcpy (filename, realname, len); strcpy (filename + len, language->suffix);