From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12735 invoked by alias); 4 Nov 2010 01:07:52 -0000 Received: (qmail 12724 invoked by uid 22791); 4 Nov 2010 01:07:50 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Nov 2010 01:07:44 +0000 Received: from hpaq11.eem.corp.google.com (hpaq11.eem.corp.google.com [172.25.149.11]) by smtp-out.google.com with ESMTP id oA417g89022776 for ; Wed, 3 Nov 2010 18:07:42 -0700 Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.18.118.116]) by hpaq11.eem.corp.google.com with ESMTP id oA417eAC025743 for ; Wed, 3 Nov 2010 18:07:41 -0700 Received: by ruffy.mtv.corp.google.com (Postfix, from userid 67641) id 1942E2460AB; Wed, 3 Nov 2010 18:07:39 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [patch, doc RFA] gdb.parameter("directories"), new "set dir" command Message-Id: <20101104010740.1942E2460AB@ruffy.mtv.corp.google.com> Date: Thu, 04 Nov 2010 01:07:00 -0000 From: dje@google.com (Doug Evans) X-System-Of-Record: true 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: 2010-11/txt/msg00079.txt.bz2 Hi. This patch does two things. - make python gdb.parameter("directories") work - new command "set directories" Making gdb.parameter("directories") work is the high-order bit of this patch. But having added it, I've found "set dir" useful. [It can be done with two dir commands, one to empty/reset the path, and another to apply the new path list, but it's simpler to have just one command, and the consistency is nice.] Aside from a doc RFA, I will check it in in two days if there are no objections. 2010-11-03 Doug Evans Make gdb.parameter("directories") work. New command "set directories". * NEWS: Document them. * source.c (set_directories_command): New function. (show_directories_1): Renamed from show_directories. All callers updated. (show_directories_command): New function. (_initialize_source): Install "directories" as a set/show variable instead of just a show command. doc/ * gdb.texinfo (Source Path): Document "set directories". testsuite/ * gdb.base/help.exp: Update expected output. Index: NEWS =================================================================== RCS file: /cvs/src/src/gdb/NEWS,v retrieving revision 1.409 diff -u -p -r1.409 NEWS --- NEWS 2 Nov 2010 22:44:11 -0000 1.409 +++ NEWS 4 Nov 2010 00:57:36 -0000 @@ -3,6 +3,10 @@ *** Changes since GDB 7.2 +* GDB has a new command: "set directories". + It is like the "dir" command except that it replaces the + source path list instead of augmenting it. + * Python scripting ** GDB values in Python are now callable if the value represents a @@ -25,6 +29,8 @@ ** New commands "info pretty-printers", "enable pretty-printer" and "disable pretty-printer" have been added. + ** gdb.parameter("directories") is now available. + * C++ Improvements: ** GDB now puts template parameters in scope when debugging in an Index: source.c =================================================================== RCS file: /cvs/src/src/gdb/source.c,v retrieving revision 1.114 diff -u -p -r1.114 source.c --- source.c 9 Jul 2010 02:39:58 -0000 1.114 +++ source.c 4 Nov 2010 00:52:29 -0000 @@ -68,8 +68,6 @@ static void line_info (char *, int); static void source_info (char *, int); -static void show_directories (char *, int); - /* Path of directories to search for source files. Same format as the PATH environment variable's value. */ @@ -293,14 +291,49 @@ select_source_symtab (struct symtab *s) error (_("Can't find a default source file")); } +/* Handler for "set directories path-list" command. + "set dir mumble" doesn't prepend paths, it resets the entire + path list. The theory is that set(show(dir)) should be a no-op. */ + +static void +set_directories_command (char *args, int from_tty, struct cmd_list_element *c) +{ + /* This is the value that was set. + It needs to be processed to maintain $cdir:$cwd and remove dups. */ + char *set_path = source_path; + + /* We preserve the invariant that $cdir:$cwd begins life at the end of + the list by calling init_source_path. If they appear earlier in + SET_PATH then mod_path will move them appropriately. + mod_path will also remove duplicates. */ + init_source_path (); + if (*set_path != '\0') + mod_path (set_path, &source_path); + + xfree (set_path); +} + +/* Print the list of source directories. + This is used by the "ld" command, so it has the signature of a command + function. */ + static void -show_directories (char *ignore, int from_tty) +show_directories_1 (char *ignore, int from_tty) { puts_filtered ("Source directories searched: "); puts_filtered (source_path); puts_filtered ("\n"); } +/* Handler for "show directories" command. */ + +static void +show_directories_command (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + show_directories_1 (NULL, from_tty); +} + /* Forget what we learned about line positions in source files, and which directories contain them; must check again now since files may be found in a different directory now. */ @@ -367,7 +400,7 @@ directory_command (char *dirname, int fr forget_cached_source_info (); } if (from_tty) - show_directories ((char *) 0, from_tty); + show_directories_1 ((char *) 0, from_tty); } /* Add a path given with the -d command line switch. @@ -1938,16 +1971,27 @@ With no argument, reset the search path set_cmd_completer (c, filename_completer); - add_cmd ("directories", no_class, show_directories, _("\ -Current search path for finding source files.\n\ + add_setshow_optional_filename_cmd ("directories", + class_files, + &source_path, + _("\ +Set the search path for finding source files."), + _("\ +Show the search path for finding source files."), + _("\ $cwd in the path means the current working directory.\n\ -$cdir in the path means the compilation directory of the source file."), - &showlist); +$cdir in the path means the compilation directory of the source file.\n\ +GDB ensures the search path always ends with $cdir:$cwd by\n\ +appending these paths if necessary.\n\ +Setting the value to an empty string sets it to $cdir:$cwd, the default."), + set_directories_command, + show_directories_command, + &setlist, &showlist); if (xdb_commands) { add_com_alias ("D", "directory", class_files, 0); - add_cmd ("ld", no_class, show_directories, _("\ + add_cmd ("ld", no_class, show_directories_1, _("\ Current search path for finding source files.\n\ $cwd in the path means the current working directory.\n\ $cdir in the path means the compilation directory of the source file."), Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.771 diff -u -p -r1.771 gdb.texinfo --- doc/gdb.texinfo 2 Nov 2010 22:44:12 -0000 1.771 +++ doc/gdb.texinfo 4 Nov 2010 01:00:50 -0000 @@ -6620,6 +6620,11 @@ Reset the source path to its default val @c RET-repeat for @code{directory} is explicitly disabled, but since @c repeating it would be a no-op we do not say that. (thanks to RMS) +@item set directories @var{path-list} +@kindex set directories +Set the source path to @var{path-list}. +@samp{$cdir:$cwd} are added if missing. + @item show directories @kindex show directories Print the source path: show which directories it contains. Index: testsuite/gdb.base/help.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/help.exp,v retrieving revision 1.46 diff -u -p -r1.46 help.exp --- testsuite/gdb.base/help.exp 16 Aug 2010 19:19:22 -0000 1.46 +++ testsuite/gdb.base/help.exp 4 Nov 2010 00:59:18 -0000 @@ -507,7 +507,7 @@ gdb_test "help show confirm" "Show wheth # test help show convenience gdb_test "help show convenience" "Debugger convenience \\(\"\\\$foo\"\\) variables\.\[\r\n\]+These variables are created when you assign them values;\[\r\n\]+thus, \"print \\\$foo=1\" gives \"\\\$foo\" the value 1\. Values may be any type\.\[\r\n\]+A few convenience variables are given values automatically:\[\r\n\]+\"\\\$_\"holds the last address examined with \"x\" or \"info lines\",\[\r\n\]+\"\\\$__\" holds the contents of the last address examined with \"x\"\." "help show convenience" # test help show directories -gdb_test "help show directories" "Current search path for finding source files\.\[\r\n\]+\\\$cwd in the path means the current working directory\.\[\r\n\]+\\\$cdir in the path means the compilation directory of the source file\." "help show directories" +gdb_test "help show directories" "Show the search path for finding source files\.\[\r\n\]+\\\$cwd in the path means the current working directory\.\[\r\n\]+\\\$cdir in the path means the compilation directory of the source file\..*" "help show directories" # test help show editing gdb_test "help show editing" "Show editing of command lines as they are typed\.\[\r\n\]+Use \"on\" to enable the editing, and \"off\" to disable it\.\[\r\n\]+Without an argument, command line editing is enabled\. To edit, use\[\r\n\]+EMACS-like or VI-like commands like control-P or ESC\." "help show editing" # test help show environment cvs diff: Diffing testsuite/gdb.base/comp-dir cvs diff: Diffing testsuite/gdb.base/comp-dir/subdir