Add debug output about skipping files and functions
authorSimon Marchi <simon.marchi@ericsson.com>
Wed, 12 Sep 2018 16:24:41 +0000 (12:24 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Wed, 12 Sep 2018 16:25:26 +0000 (12:25 -0400)
While trying to create skips for libstdc++, I found myself debugging GDB
quite a bit, mostly to find out what the exact function name to match
is.  I thought it would make sense to have this information as debug
output.

This patch adds "set debug skip on|off".

gdb/ChangeLog:

* skip.c (debug_skip): New variable.
(skiplist_entry::do_skip_file_p): Add debug output.
(skiplist_entry::do_skip_gfile_p): Likewise.
(skiplist_entry::skip_function_p): Likewise.
(_initialize_step_skip): Create debug command.
* NEWS: Mention set/show debug skip.

gdb/doc/ChangeLog:

* gdb.texinfo (Skipping Over Functions and Files): Document
set/show debug skip.

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/skip.c

index 5f8480548e92675879b8fae0dd9afc955d297005..d751253b9a4d1fe28ade7ee45017b45713996a0e 100644 (file)
@@ -1,3 +1,12 @@
+2018-09-12  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * skip.c (debug_skip): New variable.
+       (skiplist_entry::do_skip_file_p): Add debug output.
+       (skiplist_entry::do_skip_gfile_p): Likewise.
+       (skiplist_entry::skip_function_p): Likewise.
+       (_initialize_step_skip): Create debug command.
+       * NEWS: Mention set/show debug skip.
+
 2018-09-11  Xavier Roirand  <roirand@adacore.com>
 
        * darwin-nat.c (should_disable_startup_with_shell):
index 75436b0fc32f11043d23f27ba733e80e489665a0..4e4f12d8d13671b5fc7cf8c1bd302023d7e402f3 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -29,6 +29,11 @@ show debug compile-cplus-types
   C++ compile feature.  Commands have no effect while compiliong
   for other languages.
 
+set debug skip
+show debug skip
+  Control whether debug output about files/functions skipping is
+  displayed.
+
 frame apply [all | COUNT | -COUNT | level LEVEL...] [FLAG]... COMMAND
   Apply a command to some frames.
   FLAG arguments allow to control what output to produce and how to handle
index 04e8250894be8703049b271283ee6aa2ffd9af9c..f04dca4283543c7ab33eb13567045122ca05e9d9 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-12  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * gdb.texinfo (Skipping Over Functions and Files): Document
+       set/show debug skip.
+
 2018-09-10  Tom Tromey  <tom@tromey.com>
 
        * python.texi (Frames In Python, Blocks In Python)
index 1d96c68d830cc32a95b6dece35955124166c9715..efbec3debffdc01f40dabec23a2294fc99d3a6a7 100644 (file)
@@ -5895,6 +5895,14 @@ skips.
 Disable the specified skip(s).  If @var{range} is not specified, disable all
 skips.
 
+@kindex set debug skip
+@item set debug skip @r{[}on|off@r{]}
+Set whether to print the debug output about skipping files and functions.
+
+@kindex show debug skip
+@item show debug skip
+Show whether the debug output about skipping files and functions is printed.
+
 @end table
 
 @node Signals
index 7a6f2e712b9d82efb75992442f9d52ba5840c1ee..13db0f6b43c617d8495fe6edc45bf902dea323d5 100644 (file)
 #include "common/gdb_optional.h"
 #include <list>
 
+/* True if we want to print debug printouts related to file/function
+   skipping. */
+static int debug_skip = 0;
+
 class skiplist_entry
 {
 public:
@@ -482,59 +486,77 @@ skip_delete_command (const char *arg, int from_tty)
 bool
 skiplist_entry::do_skip_file_p (const symtab_and_line &function_sal) const
 {
+  if (debug_skip)
+    fprintf_unfiltered (gdb_stdlog,
+                       "skip: checking if file %s matches non-glob %s...",
+                       function_sal.symtab->filename, m_file.c_str ());
+
+  bool result;
+
   /* Check first sole SYMTAB->FILENAME.  It may not be a substring of
      symtab_to_fullname as it may contain "./" etc.  */
   if (compare_filenames_for_search (function_sal.symtab->filename,
                                    m_file.c_str ()))
-    return true;
+    result = true;
 
   /* Before we invoke realpath, which can get expensive when many
      files are involved, do a quick comparison of the basenames.  */
-  if (!basenames_may_differ
-      && filename_cmp (lbasename (function_sal.symtab->filename),
-                      lbasename (m_file.c_str ())) != 0)
-    return false;
+  else if (!basenames_may_differ
+          && filename_cmp (lbasename (function_sal.symtab->filename),
+                           lbasename (m_file.c_str ())) != 0)
+    result = false;
+  else
+    {
+      /* Note: symtab_to_fullname caches its result, thus we don't have to.  */
+      const char *fullname = symtab_to_fullname (function_sal.symtab);
 
-  /* Note: symtab_to_fullname caches its result, thus we don't have to.  */
-  {
-    const char *fullname = symtab_to_fullname (function_sal.symtab);
+      result = compare_filenames_for_search (fullname, m_file.c_str ());
+    }
 
-    if (compare_filenames_for_search (fullname, m_file.c_str ()))
-      return true;
-  }
+  if (debug_skip)
+    fprintf_unfiltered (gdb_stdlog, result ? "yes.\n" : "no.\n");
 
-  return false;
+  return result;
 }
 
 bool
 skiplist_entry::do_skip_gfile_p (const symtab_and_line &function_sal) const
 {
+  if (debug_skip)
+    fprintf_unfiltered (gdb_stdlog,
+                       "skip: checking if file %s matches glob %s...",
+                       function_sal.symtab->filename, m_file.c_str ());
+
+  bool result;
+
   /* 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)
-    return true;
+    result = true;
 
   /* Before we invoke symtab_to_fullname, which is expensive, do a quick
      comparison of the basenames.
      Note that we assume that lbasename works with glob-style patterns.
      If the basename of the glob pattern is something like "*.c" then this
      isn't much of a win.  Oh well.  */
-  if (!basenames_may_differ
+  else if (!basenames_may_differ
       && gdb_filename_fnmatch (lbasename (m_file.c_str ()),
                               lbasename (function_sal.symtab->filename),
                               FNM_FILE_NAME | FNM_NOESCAPE) != 0)
-    return false;
+    result = false;
+  else
+    {
+      /* Note: symtab_to_fullname caches its result, thus we don't have to.  */
+      const char *fullname = symtab_to_fullname (function_sal.symtab);
 
-  /* Note: symtab_to_fullname caches its result, thus we don't have to.  */
-  {
-    const char *fullname = symtab_to_fullname (function_sal.symtab);
+      result = compare_glob_filenames_for_search (fullname, m_file.c_str ());
+    }
 
-    if (compare_glob_filenames_for_search (fullname, m_file.c_str ()))
-      return true;
-  }
+  if (debug_skip)
+    fprintf_unfiltered (gdb_stdlog, result ? "yes.\n" : "no.\n");
 
-  return false;
+  return result;
 }
 
 bool
@@ -558,14 +580,33 @@ skiplist_entry::skip_function_p (const char *function_name) const
   if (m_function.empty ())
     return false;
 
+  bool result;
+
   if (m_function_is_regexp)
     {
+      if (debug_skip)
+        fprintf_unfiltered (gdb_stdlog,
+                           "skip: checking if function %s matches regex %s...",
+                           function_name, m_function.c_str ());
+
       gdb_assert (m_compiled_function_regexp);
-      return (m_compiled_function_regexp->exec (function_name, 0, NULL, 0)
-             == 0);
+      result
+       = (m_compiled_function_regexp->exec (function_name, 0, NULL, 0) == 0);
     }
   else
-    return strcmp_iw (function_name, m_function.c_str ()) == 0;
+    {
+      if (debug_skip)
+        fprintf_unfiltered (gdb_stdlog,
+                           ("skip: checking if function %s matches non-regex "
+                            "%s..."),
+                           function_name, m_function.c_str ());
+      result = (strcmp_iw (function_name, m_function.c_str ()) == 0);
+    }
+
+  if (debug_skip)
+    fprintf_unfiltered (gdb_stdlog, result ? "yes.\n" : "no.\n");
+
+  return result;
 }
 
 /* See skip.h.  */
@@ -664,4 +705,14 @@ Usage: skip info [NUMBER | RANGES]...\n\
 The \"Type\" column indicates one of:\n\
 \tfile        - ignored file\n\
 \tfunction    - ignored function"));
+
+  add_setshow_boolean_cmd ("skip", class_maintenance,
+                          &debug_skip, _("\
+Set whether to print the debug output about skipping files and functions."),
+                          _("\
+Show whether the debug output about skipping files and functions is printed"),
+                          _("\
+When non-zero, debug output about skipping files and functions is displayed."),
+                          NULL, NULL,
+                          &setdebuglist, &showdebuglist);
 }
This page took 0.065492 seconds and 4 git commands to generate.