[PATCH] skip -gfile: call fnmatch without FNM_FILE_NAME

Fangrui Song via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
fnmatch is called with the FNM_FILE_NAME flag so that `skip -gfi /usr/*`
doesn't match /usr/include/*.  This makes the file matching feature not
useful for STL headers that reside in multiple directories.  Drop the
FNM_FILE_NAME flag.
---
 gdb/doc/gdb.texinfo | 2 +-
 gdb/skip.c          | 4 ++--
 gdb/symtab.c        | 4 ++--
 gdb/utils.c         | 2 --
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index b985399cf34..7ae486e3b7a 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6737,7 +6737,7 @@ Functions in @var{file} will be skipped over when stepping.
 @itemx -gfi @var{file-glob-pattern}
 @cindex skipping over files via glob-style patterns
 Functions in files matching @var{file-glob-pattern} will be skipped
-over when stepping.
+over when stepping.  The metacharacter @code{*} matches slashes.
 
 @smallexample
 (@value{GDBP}) skip -gfi utils/*.c
diff --git a/gdb/skip.c b/gdb/skip.c
index 3791c29b1e0..082fd2edbc8 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -531,7 +531,7 @@ skiplist_entry::do_skip_gfile_p (const symtab_and_line &function_sal) const
   /* Check first sole SYMTAB->FILENAME.  It may not be a substring of
      symtab_to_fullname as it may contain "./" etc.  */
   if (gdb_filename_fnmatch (m_file.c_str (), function_sal.symtab->filename,
-			    FNM_FILE_NAME | FNM_NOESCAPE) == 0)
+			    FNM_NOESCAPE) == 0)
     result = true;
 
   /* Before we invoke symtab_to_fullname, which is expensive, do a quick
@@ -542,7 +542,7 @@ skiplist_entry::do_skip_gfile_p (const symtab_and_line &function_sal) const
   else if (!basenames_may_differ
       && gdb_filename_fnmatch (lbasename (m_file.c_str ()),
 			       lbasename (function_sal.symtab->filename),
-			       FNM_FILE_NAME | FNM_NOESCAPE) != 0)
+			       FNM_NOESCAPE) != 0)
     result = false;
   else
     {
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 106e540ca48..00c470b4d3e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -609,7 +609,7 @@ compare_glob_filenames_for_search (const char *filename,
     {
       return (search_path_elements == file_path_elements
 	      && gdb_filename_fnmatch (search_name, filename,
-				       FNM_FILE_NAME | FNM_NOESCAPE) == 0);
+				       FNM_NOESCAPE) == 0);
     }
 
   {
@@ -618,7 +618,7 @@ compare_glob_filenames_for_search (const char *filename,
 				     file_path_elements - search_path_elements);
 
     return gdb_filename_fnmatch (search_name, file_to_compare,
-				 FNM_FILE_NAME | FNM_NOESCAPE) == 0;
+				 FNM_NOESCAPE) == 0;
   }
 }
 
diff --git a/gdb/utils.c b/gdb/utils.c
index 6f2055e299d..d39cbacba71 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3500,8 +3500,6 @@ wait_to_die_with_timeout (pid_t pid, int *status, int timeout)
 int
 gdb_filename_fnmatch (const char *pattern, const char *string, int flags)
 {
-  gdb_assert ((flags & FNM_FILE_NAME) != 0);
-
   /* It is unclear how '\' escaping vs. directory separator should coexist.  */
   gdb_assert ((flags & FNM_NOESCAPE) != 0);
 
-- 
2.47.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.