From patchwork Mon Jan 20 15:53:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahab Vahedi X-Patchwork-Id: 37446 Received: (qmail 113365 invoked by alias); 20 Jan 2020 15:53:51 -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 113345 invoked by uid 89); 20 Jan 2020 15:53:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=continued, H*m:gmail, HContent-Transfer-Encoding:8bit X-HELO: mail-lj1-f195.google.com Received: from mail-lj1-f195.google.com (HELO mail-lj1-f195.google.com) (209.85.208.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Jan 2020 15:53:39 +0000 Received: by mail-lj1-f195.google.com with SMTP id h23so34320337ljc.8 for ; Mon, 20 Jan 2020 07:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ATgE3vkQIKPLAPMC1t38fbwHffzw5fYm5Ro8lwCFN1Y=; b=qE6V4fOU3os+2BdBQnGCz7ljPVgyH2cfNftprpjBoe92sJNRn4CF0VbtlOzLZD8Sxu a2wyD4bfCxhR/azz7ulXWs01rcGVfUwZ3Wp83I6w45lFvV7l2MQnD4q3AcqCh0Lymtm9 jCqcc5ycGi4/r1FI3eF67CzKeieaW27JnCzuOGIEEFUTdPVzgMolySLzkrGcD0U9/9EH wlpdD6kQdJS69GvbX9Bj5VovrKgd3HlHGNdH5uNmV7dlY+WyCoWEV1l31RWIoTD5Bw3f EISWRIslhkV3Yquz/5quhzTrQenhZoSSTpO7kOPMt8VSOSUGfgIaokjffIlRhCXIr2g+ NGuQ== Return-Path: Received: from archie.internal.synopsys.com ([2a03:1b20:6:f011::2d]) by smtp.gmail.com with ESMTPSA id f11sm4230600lfm.12.2020.01.20.07.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 07:53:36 -0800 (PST) From: Shahab Vahedi To: gdb-patches@sourceware.org Cc: Shahab Vahedi , Claudiu Zissulescu , Francois Bedard Subject: [PATCH] Do not print empty-group regs when printing general ones Date: Mon, 20 Jan 2020 16:53:15 +0100 Message-Id: <20200120155315.30333-1-shahab.vahedi@gmail.com> MIME-Version: 1.0 From: Shahab Vahedi When the command "info registers" (same as "info registers general"), is issued, _all_ the registers from a tdesc XML are printed. This includes the registers with empty register groups (set as "") which are supposed to be only printed by "info registers all" (or "info all-registers"). This bug got introduced after all the overhauls that the tdesc_register_in_reggroup_p() went through. You can see that the logic of tdesc_register_in_reggroup_p() did NOT remain the same after all those changes: git difftool c9c895b9666..HEAD -- gdb/target-descriptions.c With the current implementation, when the reg->group is an empty string, this function returns -1, while in the working revision (c9c895b9666), it returned 0. This patch makes sure that the 0 is returned again. The old implementation of tdesc_register_in_reggroup_p() returned -1 when "reggroup" was set to "all_reggroups" at line 4 below: 1 tdesc_register_reggroup_p (...) 2 { 3 ... 4 ret = tdesc_register_in_reggroup_p (gdbarch, regno, reggroup); 5 if (ret != -1) 6 return ret; 7 8 return default_register_reggroup_p (gdbarch, regno, reggroup); 9 } As a result, the execution continued at line 8 and the default_register_reggroup_p(..., reggroup=all_reggroups) would return 1. However, with the current implementation of tdesc_register_in_reggroup_p() that allows checking against any arbitrary group name, it returns 0 when comparing the "reg->group" against the string "all" which is the group name for "all_reggroups". I have added a special check to cover this case and "info all-registers" works as expected. gdb/ChangeLog: 2020-01-20 Shahab Vahedi * target-descriptions.c (tdesc_register_in_reggroup_p): Return 0 when reg->group is empty and reggroup is not. --- gdb/target-descriptions.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 04711ba2fa5..937210cf25e 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -977,13 +977,15 @@ tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno, { struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno); - if (reg != NULL && !reg->group.empty () - && (reg->group == reggroup_name (reggroup))) + if (reg != NULL) + { + if (reggroup == all_reggroup) return 1; - - if (reg != NULL - && (reggroup == save_reggroup || reggroup == restore_reggroup)) - return reg->save_restore; + else if (reggroup == save_reggroup || reggroup == restore_reggroup) + return reg->save_restore; + else + return (int) (reg->group == reggroup_name (reggroup)); + } return -1; }