From patchwork Mon Jun 2 20:27:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Mouring X-Patchwork-Id: 1244 Received: (qmail 10634 invoked by alias); 2 Jun 2014 20:27:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 10623 invoked by uid 89); 2 Jun 2014 20:27:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: ni.com Received: from skprod3.natinst.com (HELO ni.com) (130.164.80.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 02 Jun 2014 20:27:58 +0000 Received: from us-aus-mgwout1.amer.corp.natinst.com (nb-snip2-1338.natinst.com [130.164.19.135]) by us-aus-skprod3.natinst.com (8.14.5/8.14.5) with ESMTP id s52KRswG004047; Mon, 2 Jun 2014 15:27:54 -0500 Received: from linuxgetsreal.amer.corp.natinst.com ([130.164.14.198]) by us-aus-mgwout1.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP5) with SMTP id 2014060215275357-638086 ; Mon, 2 Jun 2014 15:27:53 -0500 Received: by linuxgetsreal.amer.corp.natinst.com (sSMTP sendmail emulation); Mon, 02 Jun 2014 15:27:53 -0500 From: "Brad Mouring" To: gdb-patches@sourceware.org Cc: brobecker@adacore.com, Brad Mouring Subject: [PATCH] gdb/source.c: Fix matching path substitute rule listing Date: Mon, 2 Jun 2014 15:27:42 -0500 Message-Id: <1401740862-25438-1-git-send-email-brad.mouring@ni.com> In-Reply-To: <1401733662-26215-1-git-send-email-brad.mouring@ni.com> References: <1401733662-26215-1-git-send-email-brad.mouring@ni.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.14, 0.0.0000 definitions=2014-06-02_02:2014-06-02, 2014-06-02, 1970-01-01 signatures=0 The check for the source (or "from") directory snippet in listing matching path substitution rules currently will not match anything other than a direct match of the "from" field in a substitution rule, resulting in the incorrect behavior below ... (gdb) set substitute-path /a/path /another/path (gdb) show substitute-path List of all source path substitution rules: `/a/path' -> `/another/path'. (gdb) show substitute-path /a/path/to/a/file.ext Source path substitution rule matching `/a/path/to/a/file.ext': (gdb) show substitute-path /a/path Source path substitution rule matching `/a/path': `/a/path' -> `/another/path'. ... This change effects the following behavior by (sanely) checking with the length of the "from" portion of a rule and ensuring that the next character of the path considered for substitution is a path delimiter (or NULL). With this change, the following behavior is garnered ... (gdb) set substitute-path /a/path /another/path (gdb) show substitute-path List of all source path substitution rules: `/a/path' -> `/another/path'. (gdb) show substitute-path /a/path/to/a/file.ext Source path substitution rule matching `/a/path/to/a/file.ext': `/a/path' -> `/another/path'. (gdb) show substitute-path /a/pathological/case/that/should/fail.err Source path substitution rule matching `/a/pathological/case/that/should/fail.err': (gdb) Also included is a couple of tests added to subst.exp to verify this behavior in the test suite. 2014-05-28 Brad Mouring * source.c (show_substitute_path_command): Fix display of matching substitution rules * subst.exp: Add tests to verify changes in source.c --- gdb/source.c | 4 +++- gdb/testsuite/gdb.base/subst.exp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/source.c b/gdb/source.c index c112765..240062c 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1857,6 +1857,7 @@ show_substitute_path_command (char *args, int from_tty) char **argv; char *from = NULL; struct cleanup *cleanup; + int rule_from_len; argv = gdb_buildargv (args); cleanup = make_cleanup_freeargv (argv); @@ -1879,7 +1880,8 @@ show_substitute_path_command (char *args, int from_tty) while (rule != NULL) { - if (from == NULL || FILENAME_CMP (rule->from, from) == 0) + rule_from_len = strlen(rule->from); + if (from == NULL || substitute_path_rule_matches (rule, from) != 0) printf_filtered (" `%s' -> `%s'.\n", rule->from, rule->to); rule = rule->next; } diff --git a/gdb/testsuite/gdb.base/subst.exp b/gdb/testsuite/gdb.base/subst.exp index e132809..e99735b 100644 --- a/gdb/testsuite/gdb.base/subst.exp +++ b/gdb/testsuite/gdb.base/subst.exp @@ -95,6 +95,14 @@ gdb_test "show substitute-path depuis" \ "Source path substitution rule matching `depuis':\r\n +`depuis' -> `vers'." \ "show substitute-path depuis, after all paths added" +gdb_test "show substitute-path from/path" \ + "Source path substitution rule matching `from/path':\r\n +`from' -> `to'." \ + "show substitute-path from/path, after all paths added" + +gdb_test "show substitute-path from_a_bad_path" \ + "Source path substitution rule matching `from_a_bad_path':" \ + "show substitute-path from_a_bad_path, after all paths added" + gdb_test "show substitute-path garbage" \ "Source path substitution rule matching `garbage':" \ "show substitute-path garbage, after all paths added"