From patchwork Wed Sep 12 16:27:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 29335 Received: (qmail 92786 invoked by alias); 12 Sep 2018 16:27:58 -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 92769 invoked by uid 89); 12 Sep 2018 16:27:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.2 spammy=H*r:10.0.0 X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Sep 2018 16:27:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1536769671; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=emZCpLhWKDz7gy8agecemIuyIBl3m0r76AuU+oWsdN0=; b=JP2Q/hasMXDNvZu2xgP3QJX+xZEsZvzjg21S6okpWpjZ140eP4YFoAwPBkxyWRk5 MT6EPEUU7BoGdsAvSceXq9x7rLtImREbshpyYTYpYBb46Xv/UCOI1+GPpw7erpRF 2GtkLcVixZdjrfxy92zoFkznDFsM9X0w5iQTWnZyjAE=; Received: from ESESBMB502.ericsson.se (Unknown_Domain [153.88.183.115]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id FD.5F.12695.78E399B5; Wed, 12 Sep 2018 18:27:51 +0200 (CEST) Received: from ESESBMR505.ericsson.se (153.88.183.201) by ESESBMB502.ericsson.se (153.88.183.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 12 Sep 2018 18:27:51 +0200 Received: from ESESBMB502.ericsson.se (153.88.183.169) by ESESBMR505.ericsson.se (153.88.183.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 12 Sep 2018 18:27:51 +0200 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB502.ericsson.se (153.88.183.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Wed, 12 Sep 2018 18:27:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fuGeKA04VFLpgCrgNPHvs0JG1FcR6rkXwFK6JOhnAAA=; b=GH40B+edsJVKT1PLbLJyq+2Ly7n2d9lJA1BiKLLmH+7RCuPSnf9QPwWRRRrYfW+i/m8IEydWZcwGf3PqFXjhpI5RAPx7gIBXp/uC1+bc7wrOgmKSHoXdkvGSyF/rjCPoqR8W8YLhDRFART6HGfzJ93WAevbGguUEjURvWNKxdq8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [10.0.0.110] (192.222.164.54) by BYAPR15MB2392.namprd15.prod.outlook.com (2603:10b6:a02:8d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.15; Wed, 12 Sep 2018 16:27:47 +0000 Subject: Re: [PATCH v2 (doc)] Add debug output for the skip feature To: Eli Zaretskii CC: References: <20180912131110.24245-1-simon.marchi@ericsson.com> <8336uen674.fsf@gnu.org> From: Simon Marchi Message-ID: <3301a11a-0c5c-24f3-ba69-092b5e250530@ericsson.com> Date: Wed, 12 Sep 2018 12:27:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <8336uen674.fsf@gnu.org> Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes On 2018-09-12 10:25 AM, Eli Zaretskii wrote: >> From: Simon Marchi >> CC: Simon Marchi >> Date: Wed, 12 Sep 2018 09:11:10 -0400 >> >> diff --git a/gdb/NEWS b/gdb/NEWS >> index 75436b0fc32..4e4f12d8d13 100644 >> --- 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. >> + > > This is OK. > >> +@kindex set debug skip >> +@item set debug skip @r{[}on|off@r{]} >> +Set whether to print the debug output about the skip feature. >> + >> +@kindex show debug skip >> +@item show debug skip >> +Show whether the debug output about the skip feature is shown. > > Here' I'd suggest to say "about skipping files and functions" instead > of "skip feature". > > Otherwise, OK. > Thanks. I've done that and pushed the patch below. Simon From 3e68067fb2d59ea93ea95d713a6c27b635332912 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 12 Sep 2018 12:24:41 -0400 Subject: [PATCH] Add debug output about skipping files and functions 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 | 9 ++++ gdb/NEWS | 5 +++ gdb/doc/ChangeLog | 5 +++ gdb/doc/gdb.texinfo | 8 ++++ gdb/skip.c | 101 +++++++++++++++++++++++++++++++++----------- 5 files changed, 103 insertions(+), 25 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5f8480548e9..d751253b9a4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2018-09-12 Simon Marchi + + * 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 * darwin-nat.c (should_disable_startup_with_shell): diff --git a/gdb/NEWS b/gdb/NEWS index 75436b0fc32..4e4f12d8d13 100644 --- 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 diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 04e8250894b..f04dca42835 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2018-09-12 Simon Marchi + + * gdb.texinfo (Skipping Over Functions and Files): Document + set/show debug skip. + 2018-09-10 Tom Tromey * python.texi (Frames In Python, Blocks In Python) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 1d96c68d830..efbec3debff 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -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 diff --git a/gdb/skip.c b/gdb/skip.c index 7a6f2e712b9..13db0f6b43c 100644 --- a/gdb/skip.c +++ b/gdb/skip.c @@ -37,6 +37,10 @@ #include "common/gdb_optional.h" #include +/* 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); }