From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30311 invoked by alias); 10 Oct 2014 17:18:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 30295 invoked by uid 89); 10 Oct 2014 17:18:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 10 Oct 2014 17:18:00 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s9AHHw2T028820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 10 Oct 2014 17:17:58 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s9AHHvOc010746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 10 Oct 2014 17:17:58 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s9AHHvJB026404 for ; Fri, 10 Oct 2014 17:17:57 GMT Received: from termi.uk.oracle.com (/10.175.211.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 10 Oct 2014 10:17:56 -0700 From: "Jose E. Marchesi" To: gdb-patches@sourceware.org Subject: [PATCH V2 1/9] Adapt `info probes' to support printing probes of different types. Date: Fri, 10 Oct 2014 17:18:00 -0000 Message-Id: <1412961772-16249-2-git-send-email-jose.marchesi@oracle.com> In-Reply-To: <1412961772-16249-1-git-send-email-jose.marchesi@oracle.com> References: <1412961772-16249-1-git-send-email-jose.marchesi@oracle.com> X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00259.txt.bz2 A "probe type" (backend for the probe abstraction implemented in probe.[ch]) can extend the information printed by `info probes' by defining additional columns. This means that when `info probes' is used to print all the probes regardless of their types, some of the columns will be "not applicable" to some of the probes (like, say, the Semaphore column only makes sense for SystemTap probes). This patch makes `info probes' fill these slots with "n/a" marks (currently it breaks the table) and not include headers for which no actual probe has been found in the list of defined probes. gdb/ChangeLog: 2014-10-10 Jose E. Marchesi * probe.c (print_ui_out_not_applicables): New function. (exists_probe_with_pops): Likewise. (info_probes_for_ops): Do not include column headers for probe types for which no probe has been actually found on any object. Also invoke `print_ui_out_not_applicables' in order to match the column rows with the header when probes of several types are listed. --- gdb/ChangeLog | 10 +++++++++ gdb/probe.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/gdb/probe.c b/gdb/probe.c index 3b8882e..47f5dc2 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -410,6 +410,31 @@ gen_ui_out_table_header_info (VEC (bound_probe_s) *probes, do_cleanups (c); } +/* Helper function to print not-applicable strings for all the extra + columns defined in a probe_ops. */ + +static void +print_ui_out_not_applicables (const struct probe_ops *pops) +{ + struct cleanup *c; + VEC (info_probe_column_s) *headings = NULL; + info_probe_column_s *column; + int ix; + + if (pops->gen_info_probes_table_header == NULL) + return; + + c = make_cleanup (VEC_cleanup (info_probe_column_s), &headings); + pops->gen_info_probes_table_header (&headings); + + for (ix = 0; + VEC_iterate (info_probe_column_s, headings, ix, column); + ++ix) + ui_out_field_string (current_uiout, column->field_name, _("n/a")); + + do_cleanups (c); +} + /* Helper function to print extra information about a probe and an objfile represented by PROBE. */ @@ -482,6 +507,23 @@ get_number_extra_fields (const struct probe_ops *pops) return n; } +/* Helper function that returns 1 if there is a probe in PROBES + featuring the given POPS. It returns 0 otherwise. */ + +static int +exists_probe_with_pops (VEC (bound_probe_s) *probes, + const struct probe_ops *pops) +{ + struct bound_probe *probe; + int ix; + + for (ix = 0; VEC_iterate (bound_probe_s, probes, ix, probe); ++ix) + if (probe->probe->pops == pops) + return 1; + + return 0; +} + /* See comment in probe.h. */ void @@ -517,6 +559,9 @@ info_probes_for_ops (const char *arg, int from_tty, } } + probes = collect_probes (objname, provider, probe_name, pops); + make_cleanup (VEC_cleanup (probe_p), &probes); + if (pops == NULL) { const struct probe_ops *po; @@ -529,16 +574,16 @@ info_probes_for_ops (const char *arg, int from_tty, To do that, we iterate over all probe_ops, querying each one about its extra fields, and incrementing `ui_out_extra_fields' to reflect - that number. */ + that number. But note that we ignore the probe_ops for which no probes + are defined with the given search criteria. */ for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix) - ui_out_extra_fields += get_number_extra_fields (po); + if (exists_probe_with_pops (probes, po)) + ui_out_extra_fields += get_number_extra_fields (po); } else ui_out_extra_fields = get_number_extra_fields (pops); - probes = collect_probes (objname, provider, probe_name, pops); - make_cleanup (VEC_cleanup (probe_p), &probes); make_cleanup_ui_out_table_begin_end (current_uiout, 4 + ui_out_extra_fields, VEC_length (bound_probe_s, probes), @@ -571,10 +616,12 @@ info_probes_for_ops (const char *arg, int from_tty, const struct probe_ops *po; int ix; - /* We have to generate the table header for each new probe type that we - will print. */ + /* We have to generate the table header for each new probe type + that we will print. Note that this excludes probe types not + having any defined probe with the search criteria. */ for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix) - gen_ui_out_table_header_info (probes, po); + if (exists_probe_with_pops (probes, po)) + gen_ui_out_table_header_info (probes, po); } else gen_ui_out_table_header_info (probes, pops); @@ -604,6 +651,8 @@ info_probes_for_ops (const char *arg, int from_tty, ++ix) if (probe->probe->pops == po) print_ui_out_info (probe->probe); + else if (exists_probe_with_pops (probes, po)) + print_ui_out_not_applicables (po); } else print_ui_out_info (probe->probe); -- 1.7.10.4