From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by sourceware.org (Postfix) with ESMTPS id 7FDC13858D1E for ; Mon, 19 Dec 2022 16:22:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7FDC13858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=seketeli.org Received: (Authenticated sender: dodji@seketeli.org) by mail.gandi.net (Postfix) with ESMTPSA id E472324000B for ; Mon, 19 Dec 2022 16:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seketeli.org; s=gm1; t=1671466956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=mvQBHoeQndfbfstt8aWGqXNzIJew5ulUb8DLqfFgd/E=; b=InyOcHnssVI/ljtLNvy1Blm4ondtN9JSncz1dCfdYWJSMcqNKNpS88jfUZZawzSSjPB6QG RvwEt7ky/xuR+Ltlet9LXU1EdnrCTmO+TY+JqczUP1N1HU+5lu26ka4yljzlXozTleqTo1 sr9vk4gbDlVEPl+zIBjN3plOnuj3rfOx7Qa0Qp21ONGJtDCg+ikdHjEmPtcH+Er/idhDwS /k96AaDrnLS4t87+3Nzzrdin+mHLum/S3y+Z537KZz5ziq64QesC33Y4IeE1bLPDsQHhX+ WlTdNrge8qFf2RfJfBSqVdZB6z0HR/Js2KShLIrZIQ/KW1i5jDoF+XTq4aWw4w== Received: by localhost (Postfix, from userid 1000) id DF149B5649; Mon, 19 Dec 2022 17:22:34 +0100 (CET) From: Dodji Seketeli To: libabigail@sourceware.org Subject: [PATCH, applied] ir: Add a debug_comp_stack debugging function Organization: Me, myself and I X-Operating-System: CentOS Stream release 9 X-URL: http://www.seketeli.net/~dodji Date: Mon, 19 Dec 2022 17:22:34 +0100 Message-ID: <871qovfjn9.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, When debugging type comparison, it can useful to see what the comparison stack is. This patch adds the a debug_comp_stack to dump the comparison stack as a string. * include/abg-fwd.h (debug_comp_stack): Declare function. * src/abg-ir.cc (debug_comp_vec, print_comp_stack): Define static functions. (debug_comp_stack): Define new function. Signed-off-by: Dodji Seketeli --- include/abg-fwd.h | 3 +++ src/abg-ir.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/abg-fwd.h b/include/abg-fwd.h index d5fcce7b..8a4383c2 100644 --- a/include/abg-fwd.h +++ b/include/abg-fwd.h @@ -1056,6 +1056,9 @@ debug(const decl_base* artifact); bool debug_equals(const type_or_decl_base *l, const type_or_decl_base *r); +void +debug_comp_stack(const environment& env); + bool odr_is_relevant(const type_or_decl_base&); diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 85b5cbb3..2719954e 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -9533,6 +9533,52 @@ debug_equals(const type_or_decl_base *l, const type_or_decl_base *r) return (*l == *r); } +/// Emit a trace of a comparison operand stack. +/// +/// @param vect the operand stack to emit the trace for. +/// +/// @param o the output stream to emit the trace to. +static void +debug_comp_vec(const vector& vect, std::ostringstream& o) +{ + for (auto t : vect) + { + o << "|" << t->get_pretty_representation() + << "@" << std::hex << t << std::dec; + } + if (!vect.empty()) + o << "|"; +} + +/// Construct a trace of the two comparison operand stacks. +/// +/// @param the environment in which the comparison operand stacks are. +/// +/// @return a string representing the trace. +static string +print_comp_stack(const environment& env) +{ + std::ostringstream o; + o << "left-operands: "; + debug_comp_vec(env.priv_->left_type_comp_operands_, o); + o << "\n" << "right-operands: "; + debug_comp_vec(env.priv_->right_type_comp_operands_, o); + o << "\n"; + return o.str(); +} + +/// Emit a trace of the two comparison operands stack on the standard +/// error stream. +/// +/// @param env the environment the comparison operands stack belong +/// to. +void +debug_comp_stack(const environment& env) +{ + std::cerr << print_comp_stack(env); + std::cerr << std::endl; +} + /// By looking at the language of the TU a given ABI artifact belongs /// to, test if the ONE Definition Rule should apply. /// -- 2.31.1 -- Dodji