From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EA5sB6KY71/aTQAAWB0awg (envelope-from ) for ; Fri, 01 Jan 2021 16:48:18 -0500 Received: by simark.ca (Postfix, from userid 112) id 0F5B21F0B8; Fri, 1 Jan 2021 16:48:17 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,MAILING_LIST_MULTI, RDNS_NONE,T_DKIM_INVALID,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 402E41F0B7 for ; Fri, 1 Jan 2021 16:48:15 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 10F29389247F; Fri, 1 Jan 2021 21:48:05 +0000 (GMT) Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.130]) by sourceware.org (Postfix) with ESMTPS id 0CBB7388E82E for ; Fri, 1 Jan 2021 21:48:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0CBB7388E82E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway33.websitewelcome.com (Postfix) with ESMTP id A33A0BEC5C3 for ; Fri, 1 Jan 2021 15:48:00 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id vSHAka1P3nPrxvSHAkldqZ; Fri, 01 Jan 2021 15:48:00 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9hRDUWkT+vhwJ8jMOSoX0l0WOMSJxo0GuwBZh3pIzUQ=; b=Br7EtQxItBOnIPrYnU/z81iWN6 fzBlF4s6R+QiJ1g/lrwuP8IbPoNysOeg+0TSYK4sYo2thMJgLqAYDhdJAwO/b8Jbx/efwSdtPaRfY RiVdfs8AqZcKQfzgNZEnz6CYo; Received: from 97-122-81-39.hlrn.qwest.net ([97.122.81.39]:60390 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kvSHA-0029Mc-F7 for gdb-patches@sourceware.org; Fri, 01 Jan 2021 14:48:00 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 074/203] Implement dumping Date: Fri, 1 Jan 2021 14:45:14 -0700 Message-Id: <20210101214723.1784144-75-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210101214723.1784144-1-tom@tromey.com> References: <20210101214723.1784144-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.81.39 X-Source-L: No X-Exim-ID: 1kvSHA-0029Mc-F7 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-39.hlrn.qwest.net (localhost.localdomain) [97.122.81.39]:60390 X-Source-Auth: tom+tromey.com X-Email-Count: 75 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This patch implements the dumping methods for tuple_holding_operation. A number of overloads are used. Note that no default case is given. This approach makes it simple to detect when a new overload is needed -- compilation will fail. (There is an example of this in a later patch in the series.) gdb/ChangeLog 2021-01-01 Tom Tromey * expprint.c (expr::dump_for_expression): New functions. * expop.h (dump_for_expression): New overloads. (tuple_holding_operation::dump, tuple_holding_operation::do_dump): Update. --- gdb/ChangeLog | 7 +++ gdb/expop.h | 55 +++++++++++++++++++++- gdb/expprint.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+), 1 deletion(-) diff --git a/gdb/expop.h b/gdb/expop.h index 1ce57a10d9a..9fea1152cc9 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -133,6 +133,57 @@ check_objfile (const std::pair &item, struct objfile *objfile) || check_objfile (item.second, objfile)); } +static inline void +dump_for_expression (struct ui_file *stream, int depth, + const operation_up &op) +{ + op->dump (stream, depth); +} + +extern void dump_for_expression (struct ui_file *stream, int depth, + enum exp_opcode op); +extern void dump_for_expression (struct ui_file *stream, int depth, + const std::string &str); +extern void dump_for_expression (struct ui_file *stream, int depth, + struct type *type); +extern void dump_for_expression (struct ui_file *stream, int depth, + CORE_ADDR addr); +extern void dump_for_expression (struct ui_file *stream, int depth, + internalvar *ivar); +extern void dump_for_expression (struct ui_file *stream, int depth, + symbol *sym); +extern void dump_for_expression (struct ui_file *stream, int depth, + minimal_symbol *msym); +extern void dump_for_expression (struct ui_file *stream, int depth, + const block *bl); +extern void dump_for_expression (struct ui_file *stream, int depth, + type_instance_flags flags); +extern void dump_for_expression (struct ui_file *stream, int depth, + enum c_string_type_values flags); +extern void dump_for_expression (struct ui_file *stream, int depth, + enum range_flag flags); +extern void dump_for_expression (struct ui_file *stream, int depth, + objfile *objf); + +template +void +dump_for_expression (struct ui_file *stream, int depth, + const std::vector &vals) +{ + fprintf_filtered (stream, _("%*sVector:\n"), depth, ""); + for (auto &item : vals) + dump_for_expression (stream, depth + 1, item); +} + +template +void +dump_for_expression (struct ui_file *stream, int depth, + const std::pair &vals) +{ + dump_for_expression (stream, depth, vals.first); + dump_for_expression (stream, depth, vals.second); +} + /* Base class for most concrete operations. This class holds data, specified via template parameters, and supplies generic implementations of the 'dump' and 'uses_objfile' methods. */ @@ -155,7 +206,8 @@ class tuple_holding_operation : public operation void dump (struct ui_file *stream, int depth) const override { - do_dump<0, Arg...> (stream, depth, m_storage); + dump_for_expression (stream, depth, opcode ()); + do_dump<0, Arg...> (stream, depth + 1, m_storage); } protected: @@ -178,6 +230,7 @@ class tuple_holding_operation : public operation do_dump (struct ui_file *stream, int depth, const std::tuple &value) const { + dump_for_expression (stream, depth, std::get (value)); do_dump (stream, depth, value); } diff --git a/gdb/expprint.c b/gdb/expprint.c index f75874b77df..3c84a65bfda 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -30,6 +30,8 @@ #include "objfiles.h" #include "valprint.h" #include "cli/cli-style.h" +#include "c-lang.h" +#include "expop.h" #include @@ -1153,3 +1155,125 @@ dump_prefix_expression (struct expression *exp, struct ui_file *stream) elt = dump_subexp (exp, stream, elt); fputs_filtered ("\n", stream); } + +namespace expr +{ + +void +dump_for_expression (struct ui_file *stream, int depth, enum exp_opcode op) +{ + fprintf_filtered (stream, _("%*sOperation: %s\n"), depth, "", op_name (op)); +} + +void +dump_for_expression (struct ui_file *stream, int depth, const std::string &str) +{ + fprintf_filtered (stream, _("%*sString: %s\n"), depth, "", str.c_str ()); +} + +void +dump_for_expression (struct ui_file *stream, int depth, struct type *type) +{ + fprintf_filtered (stream, _("%*sType: "), depth, ""); + type_print (type, nullptr, stream, 0); + fprintf_filtered (stream, "\n"); +} + +void +dump_for_expression (struct ui_file *stream, int depth, CORE_ADDR addr) +{ + fprintf_filtered (stream, _("%*sAddress: %s\n"), depth, "", + core_addr_to_string (addr)); +} + +void +dump_for_expression (struct ui_file *stream, int depth, internalvar *ivar) +{ + fprintf_filtered (stream, _("%*sInternalvar: $%s\n"), depth, "", + internalvar_name (ivar)); +} + +void +dump_for_expression (struct ui_file *stream, int depth, symbol *sym) +{ + fprintf_filtered (stream, _("%*sSymbol: %s\n"), depth, "", + sym->print_name ()); +} + +void +dump_for_expression (struct ui_file *stream, int depth, minimal_symbol *msym) +{ + fprintf_filtered (stream, _("%*sMinsym: %s\n"), depth, "", + msym->print_name ()); +} + +void +dump_for_expression (struct ui_file *stream, int depth, const block *bl) +{ + fprintf_filtered (stream, _("%*sBlock: %p\n"), depth, "", bl); +} + +void +dump_for_expression (struct ui_file *stream, int depth, + type_instance_flags flags) +{ + fprintf_filtered (stream, _("%*sType flags: "), depth, ""); + if (flags & TYPE_INSTANCE_FLAG_CONST) + fputs_unfiltered ("const ", stream); + if (flags & TYPE_INSTANCE_FLAG_VOLATILE) + fputs_unfiltered ("volatile", stream); + fprintf_filtered (stream, "\n"); +} + +void +dump_for_expression (struct ui_file *stream, int depth, + enum c_string_type_values flags) +{ + fprintf_filtered (stream, _("%*sC string flags: "), depth, ""); + switch (flags & ~C_CHAR) + { + case C_WIDE_STRING: + fputs_unfiltered (_("wide "), stream); + break; + case C_STRING_16: + fputs_unfiltered (_("u16 "), stream); + break; + case C_STRING_32: + fputs_unfiltered (_("u32 "), stream); + break; + default: + fputs_unfiltered (_("ordinary "), stream); + break; + } + + if ((flags & C_CHAR) != 0) + fputs_unfiltered (_("char"), stream); + else + fputs_unfiltered (_("string"), stream); + fputs_unfiltered ("\n", stream); +} + +void +dump_for_expression (struct ui_file *stream, int depth, objfile *objf) +{ + fprintf_filtered (stream, _("%*sObjfile: %s\n"), depth, "", + objfile_name (objf)); +} + +void +dump_for_expression (struct ui_file *stream, int depth, + enum range_flag flags) +{ + fprintf_filtered (stream, _("%*sRange:"), depth, ""); + if ((flags & RANGE_LOW_BOUND_DEFAULT) != 0) + fputs_unfiltered (_("low-default "), stream); + if ((flags & RANGE_HIGH_BOUND_DEFAULT) != 0) + fputs_unfiltered (_("high-default "), stream); + if ((flags & RANGE_HIGH_BOUND_EXCLUSIVE) != 0) + fputs_unfiltered (_("high-exclusive "), stream); + if ((flags & RANGE_HAS_STRIDE) != 0) + fputs_unfiltered (_("has-stride"), stream); + fprintf_filtered (stream, "\n"); +} + +} /* namespace expr */ -- 2.26.2