gdb/source.c: Fix matching path substitute rule listing
authorBrad Mouring <bmouring@ni.com>
Mon, 2 Jun 2014 20:55:10 +0000 (15:55 -0500)
committerJoel Brobecker <brobecker@adacore.com>
Tue, 3 Jun 2014 14:17:06 +0000 (07:17 -0700)
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.

gdb/ChangeLog:

        * source.c (show_substitute_path_command): Fix display of matching
        substitution rules.

gdb/testsuite/ChangeLog:

        * gdb.ada/subst.exp: Add tests to verify partial path matching
        output.

This was tested on x86_64 Linux.

gdb/ChangeLog
gdb/source.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/subst.exp

index bda46b5e34c80f8bfe91666533b0c783c92a99b7..698c15c37c41528460b4a02b60e8c0aba5c9053f 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-03  Brad Mouring  <bmouring@ni.com>  (tiny patch)
+
+       Pushed by Joel Brobecker  <brobecker@adacore.com>
+       * source.c (show_substitute_path_command): Fix display of matching
+       substitution rules.
+
 2014-06-03  Gary Benson  <gbenson@redhat.com>
 
        * gnu-v2-abi.c (gnuv2_value_rtti_type): Use gdb_demangle.
index c985a1b1fea6f87a76a71bb055fc73b194dc626f..14b1f71c855344781153c7d3fda64d294df670c5 100644 (file)
@@ -1890,7 +1890,7 @@ show_substitute_path_command (char *args, int from_tty)
 
   while (rule != NULL)
     {
-      if (from == NULL || FILENAME_CMP (rule->from, from) == 0)
+      if (from == NULL || substitute_path_rule_matches (rule, from) != 0)
         printf_filtered ("  `%s' -> `%s'.\n", rule->from, rule->to);
       rule = rule->next;
     }
index 821740349f100fd5f994ada3fb76b9b33e8169de..40518b6730738be962cff43796bcf8b789a00dab 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-03  Brad Mouring  <bmouring@ni.com>  (tiny patch)
+
+       * gdb.base/subst.exp: Add tests to verify partial path matching
+       output.
+
 2014-06-03  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/sss-bp-on-user-bp-2.exp: Skip if testing with a remote
index e132809f748a83e41421c0190a06e563d5f77bbd..e99735be0811645c0d53692ab10f8f2086726af5 100644 (file)
@@ -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"
This page took 0.032176 seconds and 4 git commands to generate.