From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24412 invoked by alias); 17 Jan 2012 14:46:15 -0000 Received: (qmail 24401 invoked by uid 22791); 17 Jan 2012 14:46:12 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Jan 2012 14:45:55 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0HEjU8f024288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 17 Jan 2012 09:45:30 -0500 Received: from host2.jankratochvil.net (ovpn-116-21.ams2.redhat.com [10.36.116.21]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0HEjO9q021722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 17 Jan 2012 09:45:27 -0500 Date: Tue, 17 Jan 2012 14:49:00 -0000 From: Jan Kratochvil To: Joel Brobecker Cc: Eli Zaretskii , gdb-patches@sourceware.org Subject: [patch 7.4] Deprecate local .gdbinit [Re: [patch] New set auto-load-local-gdbinit + disable it by default] Message-ID: <20120117144524.GA31953@host2.jankratochvil.net> References: <20120117095552.GA6141@host2.jankratochvil.net> <20120117133913.GX31383@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120117133913.GX31383@adacore.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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-01/txt/msg00594.txt.bz2 On Tue, 17 Jan 2012 14:39:13 +0100, Joel Brobecker wrote: > If we do move forward on that change, I think we should do it more > gradually: > 1. We start by emitting a warning when seeing a local .gdbinit file, > but otherwise read it. > 2. We stop reading them once a release with the warning is out. Like still into the 7.4 branch? No regressions for gdb_7_4-branch on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu. OTOH TBH I do not think from #gdb etc. users in general use very every GDB release with the current rapid release cycles. Thanks, Jan gdb/ 2012-01-17 Jan Kratochvil Deprecate reading of file .gdbinit in current directory. * NEWS: New entry. * main.c: Include readline/tilde.h. (get_init_files): New parameter local_gdbinit_stat. Describe it in the function comment. Change local variable cwdbuf to localinit_stat. (captured_main): New variable local_gdbinit_stat, initialize it by get_init_files. Check local_gdbinit duplicity against CMDARG. New warning before calling catch_command_errors for local_gdbinit. (print_gdb_help): Update the get_init_files caller. New message for "local init file". --- a/gdb/NEWS +++ b/gdb/NEWS @@ -22,6 +22,10 @@ watchpoints are slower than real hardware watchpoints but are significantly faster than gdb software watchpoints. +* Automatic reading of file .gdbinit in current directory has been deprecated + and it will be removed in gdb-7.5. + Use explicit 'gdb -x .gdbinit ...' command instead. + * Python scripting ** The register_pretty_printer function in module gdb.printing now takes --- a/gdb/main.c +++ b/gdb/main.c @@ -41,6 +41,7 @@ #include "cli/cli-cmds.h" #include "python/python.h" #include "objfiles.h" +#include "readline/tilde.h" /* The selected interpreter. This will be used as a set command variable, so it should always be malloc'ed - since @@ -152,23 +153,26 @@ relocate_gdb_directory (const char *initial, int flag) } /* Compute the locations of init files that GDB should source and - return them in SYSTEM_GDBINIT, HOME_GDBINIT, LOCAL_GDBINIT. If - there is no system gdbinit (resp. home gdbinit and local gdbinit) - to be loaded, then SYSTEM_GDBINIT (resp. HOME_GDBINIT and - LOCAL_GDBINIT) is set to NULL. */ + return them in SYSTEM_GDBINIT, HOME_GDBINIT, LOCAL_GDBINIT and + LOCAL_GDBINIT_STAT. If there is no system gdbinit (resp. home + gdbinit and local gdbinit) to be loaded, then SYSTEM_GDBINIT (resp. + HOME_GDBINIT and LOCAL_GDBINIT) is set to NULL, LOCAL_GDBINIT_STAT is + zeroed. */ + static void get_init_files (char **system_gdbinit, char **home_gdbinit, - char **local_gdbinit) + char **local_gdbinit, struct stat *local_gdbinit_stat) { static char *sysgdbinit = NULL; static char *homeinit = NULL; static char *localinit = NULL; + static struct stat localinit_stat; static int initialized = 0; if (!initialized) { - struct stat homebuf, cwdbuf, s; + struct stat homebuf, s; char *homedir, *relocated_sysgdbinit; if (SYSTEM_GDBINIT[0]) @@ -186,12 +190,12 @@ get_init_files (char **system_gdbinit, /* If the .gdbinit file in the current directory is the same as the $HOME/.gdbinit file, it should not be sourced. homebuf - and cwdbuf are used in that purpose. Make sure that the stats - are zero in case one of them fails (this guarantees that they - won't match if either exists). */ + and localinit_stat are used in that purpose. Make sure + that the stats are zero in case one of them fails (this + guarantees that they won't match if either exists). */ memset (&homebuf, 0, sizeof (struct stat)); - memset (&cwdbuf, 0, sizeof (struct stat)); + memset (&localinit_stat, 0, sizeof (struct stat)); if (homedir) { @@ -203,11 +207,10 @@ get_init_files (char **system_gdbinit, } } - if (stat (gdbinit, &cwdbuf) == 0) + if (stat (gdbinit, &localinit_stat) == 0) { if (!homeinit - || memcmp ((char *) &homebuf, (char *) &cwdbuf, - sizeof (struct stat))) + || memcmp (&homebuf, &localinit_stat, sizeof (struct stat))) localinit = gdbinit; } @@ -217,6 +220,8 @@ get_init_files (char **system_gdbinit, *system_gdbinit = sysgdbinit; *home_gdbinit = homeinit; *local_gdbinit = localinit; + if (local_gdbinit_stat) + *local_gdbinit_stat = localinit_stat; } /* Call command_loop. If it happens to return, pass that through as a @@ -293,6 +298,7 @@ captured_main (void *data) char *system_gdbinit; char *home_gdbinit; char *local_gdbinit; + struct stat local_gdbinit_stat; int i; int save_auto_load; @@ -727,7 +733,8 @@ captured_main (void *data) /* Lookup gdbinit files. Note that the gdbinit file name may be overriden during file initialization, so get_init_files should be called after gdb_init. */ - get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit); + get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit, + &local_gdbinit_stat); /* Do these (and anything which might call wrap_here or *_filtered) after initialize_all_files() but before the interpreter has been @@ -899,7 +906,45 @@ captured_main (void *data) /* Read the .gdbinit file in the current directory, *if* it isn't the same as the $HOME/.gdbinit file (it should exist, also). */ if (local_gdbinit && !inhibit_gdbinit) - catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL); + { + for (i = 0; i < ncmd; i++) + if (cmdarg[i].type == CMDARG_FILE) + { + struct cleanup *old_cleanups; + char *file; + int fd; + + file = tilde_expand (cmdarg[i].string); + old_cleanups = make_cleanup (xfree, file); + + fd = openp (source_path, OPF_TRY_CWD_FIRST, file, O_RDONLY, NULL); + + do_cleanups (old_cleanups); + + if (fd != -1) + { + struct stat statbuf; + + if (fstat (fd, &statbuf) == 0 + && memcmp (&statbuf, &local_gdbinit_stat, + sizeof (statbuf)) == 0) + local_gdbinit = NULL; + + close (fd); + if (local_gdbinit == NULL) + break; + } + } + + if (local_gdbinit) + { + warning (_("Automatic reading of file .gdbinit in current directory " + "has been deprecated and it will be removed in gdb-7.5. " + "Use explicit 'gdb -x .gdbinit ...' command instead.")); + catch_command_errors (source_script, local_gdbinit, 0, + RETURN_MASK_ALL); + } + } /* Now that all .gdbinit's have been read and all -d options have been processed, we can read any scripts mentioned in SYMARG. @@ -966,7 +1011,7 @@ print_gdb_help (struct ui_file *stream) char *home_gdbinit; char *local_gdbinit; - get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit); + get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit, NULL); fputs_unfiltered (_("\ This is the GNU debugger. Usage:\n\n\ @@ -1042,7 +1087,7 @@ At startup, GDB reads the following init files and executes their commands:\n\ "), home_gdbinit); if (local_gdbinit) fprintf_unfiltered (stream, _("\ - * local init file: ./%s\n\ + * local init file (it will no longer be read by default since gdb-7.5): ./%s\n\ "), local_gdbinit); fputs_unfiltered (_("\n\ For more information, type \"help\" from within GDB, or consult the\n\