From patchwork Tue Sep 11 11:03:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 29301 Received: (qmail 19783 invoked by alias); 11 Sep 2018 11:04:27 -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 19644 invoked by uid 89); 11 Sep 2018 11:04:25 -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, SPF_PASS autolearn=ham version=3.3.2 spammy=*c 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; Tue, 11 Sep 2018 11:04:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1536663860; 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=h6hW0L1lIVSRKkGB7dXWGTeBjDePABxsgzHsrT81vIU=; b=Uep0jP3OvpXlyKBQSHg24k0zh0pT61AYlZ5Ijg0Z2srRW5Kft47sCA0GX2h9qNXB p160mO8Y9Tvdbe7Qij4+HowH4k19N6Xv7kEmy/ooTGfoKfexlSzJu7sWhIakhN+1 Mfy2skLrb/52NsMYJPTIxL4OQ5HOmXLtx/AtuUYqtnQ=; Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 67.BE.31332.431A79B5; Tue, 11 Sep 2018 13:04:20 +0200 (CEST) Received: from ESESBMB502.ericsson.se (153.88.183.169) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 11 Sep 2018 13:04:20 +0200 Received: from NAM04-BN3-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; Tue, 11 Sep 2018 13:04:19 +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=3J2MRo4GDvZBwKa7WEAJoxYgqOz42KXEzpyDLk6StpY=; b=Tpc5dm1sAHCIYU53bambvSq5d82gv+GYjGr0Yc7kmsvSKDdcqEQP2poIWGmTeCFo51Vb4iYXdMSa3OOd8mhunQRHXAnLQ3X85fUPVOBfUj6X2hs9I8doqv94YrWo4osY+SF+6A+FPNU3DG9acgLsF6Vzd8fzLa3cKenCUCMtol0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.localdomain (62.252.144.58) by BYAPR15MB2390.namprd15.prod.outlook.com (2603:10b6:a02:8c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Tue, 11 Sep 2018 11:04:17 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH] Add debug output for the skip feature Date: Tue, 11 Sep 2018 12:03:51 +0100 Message-Id: <1536663831-15507-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes 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. --- gdb/skip.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 25 deletions(-) diff --git a/gdb/skip.c b/gdb/skip.c index 7a6f2e7..0efa8de 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,12 @@ 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 skip files/functions debugging."), _("\ +Show skip files/functions debugging."), _("\ +When non-zero, debugging output for skipping files/functions is displayed."), + NULL, NULL, + &setdebuglist, &showdebuglist); }