From patchwork Wed May 28 22:41: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: 1189 Received: (qmail 9741 invoked by alias); 28 May 2014 22:42:15 -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 9673 invoked by uid 89); 28 May 2014 22:42:14 -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 skprod2.natinst.com (HELO ni.com) (130.164.80.23) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 28 May 2014 22:42:14 +0000 Received: from us-aus-mgwout2.amer.corp.natinst.com (nb-snip2-1338.natinst.com [130.164.19.135]) by us-aus-skprod2.natinst.com (8.14.5/8.14.5) with ESMTP id s4SMgB17012003; Wed, 28 May 2014 17:42:11 -0500 Received: from linuxgetsreal.amer.corp.natinst.com ([130.164.14.198]) by us-aus-mgwout2.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP5) with SMTP id 2014052817421031-444267 ; Wed, 28 May 2014 17:42:10 -0500 Received: by linuxgetsreal.amer.corp.natinst.com (sSMTP sendmail emulation); Wed, 28 May 2014 17:42:10 -0500 From: "Brad Mouring" To: gdb-patches@sourceware.org Cc: Joel Brobecker , Brad Mouring Subject: [PATCH 2/2] gdb/source.c: Fix matching path substitute rule listing Date: Wed, 28 May 2014 17:41:42 -0500 Message-Id: <1401316902-12320-3-git-send-email-brad.mouring@ni.com> In-Reply-To: <1401316902-12320-1-git-send-email-brad.mouring@ni.com> References: <20140528161531.GA4289@adacore.com> <1401316902-12320-1-git-send-email-brad.mouring@ni.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.96, 1.0.14, 0.0.0000 definitions=2014-05-28_07:2014-05-28, 2014-05-28, 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. 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) Signed-off-by: Brad Mouring --- gdb/source.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/source.c b/gdb/source.c index c77a4f4..a32872f 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1875,6 +1875,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); @@ -1897,7 +1898,11 @@ 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 || + ((filename_ncmp (rule->from, from, rule_from_len) == 0) && + (IS_DIR_SEPARATOR (from[rule_from_len]) || + from[rule_from_len] == 0))) printf_filtered (" `%s' -> `%s'.\n", rule->from, rule->to); rule = rule->next; }