From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 1BF943954C5A for ; Tue, 19 May 2020 17:35:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1BF943954C5A Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 04JHZDnI009415 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 May 2020 13:35:18 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 04JHZDnI009415 Received: from [10.0.0.193] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 5D82C1E79B; Tue, 19 May 2020 13:35:13 -0400 (EDT) Subject: Re: -Werror,-Wtautological-overlap-compare error in h8300-tdep.c To: Yoshinori Sato Cc: "gdb-patches@sourceware.org" References: <8704f67d-6950-7e26-ad91-69359bd328ee@polymtl.ca> <877dxaoeed.wl-ysato@users.sourceforge.jp> <3caeb8ce-74d2-6409-3b9d-9bd2221d1cee@polymtl.ca> <875zcto181.wl-ysato@users.sourceforge.jp> From: Simon Marchi Message-ID: Date: Tue, 19 May 2020 13:35:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <875zcto181.wl-ysato@users.sourceforge.jp> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 19 May 2020 17:35:13 +0000 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Tue, 19 May 2020 17:35:21 -0000 On 2020-05-18 8:51 a.m., Yoshinori Sato wrote: > Yes. > register number 6 (er6) is frame pointer in h8300 ABI. > Since we are analyzing the code that accesses the stack frame, > we will only look at the frame pointer. Ah ok, thanks for the explanation. Here's what I pushed. Note that I also changed the read_memory_integer to read_memory_unsigned_integer. >From 1d6ce4d31257e1ea49b3a1b257055bf8f7ff16af Mon Sep 17 00:00:00 2001 From: Yoshinori Sato Date: Tue, 19 May 2020 13:33:08 -0400 Subject: [PATCH] gdb: fix -Wtautological-overlap-compare error in h8300-tdep.c Compiling with clang 11 gives us: CXX h8300-tdep.o /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:225:21: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare] if (disp < 0 && disp > 0xffffff) ~~~~~~~~~^~~~~~~~~~~~~~~~~~ /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:203:17: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare] if (disp < 0 && disp > 0xffffff) ~~~~~~~~~^~~~~~~~~~~~~~~~~~ /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:184:17: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare] if (disp < 0 && disp > 0xffffff) ~~~~~~~~~^~~~~~~~~~~~~~~~~~ Indeed, disp (of type LONGEST) can't be less than 0 and greater than 0xffffff. Fix it by changing the way we check if disp is negative. Check the sign bit of disp, which is a 24-bit number. gdb/ChangeLog: * h8300-tdep.c (h8300_is_argument_spill): Change how we check whether disp is negative. --- gdb/ChangeLog | 5 +++++ gdb/h8300-tdep.c | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f086b5cf908c..c4393182dd95 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-05-19 Yoshinori Sato + + * h8300-tdep.c (h8300_is_argument_spill): Change how we check + whether disp is negative. + 2020-05-19 Simon Marchi * symfile.h (struct symfile_segment_data) diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index 3c2f502a124d..b569a23f2631 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -178,10 +178,10 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc) if (IS_MOVB_Rn24_SP (read_memory_unsigned_integer (pc + 2, 2, byte_order))) { - LONGEST disp = read_memory_integer (pc + 4, 4, byte_order); + ULONGEST disp = read_memory_unsigned_integer (pc + 4, 4, byte_order); /* ... and d:24 is negative. */ - if (disp < 0 && disp > 0xffffff) + if ((disp & 0x00800000) != 0) return 8; } } @@ -197,10 +197,10 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc) if (IS_MOVW_Rn24_SP (read_memory_unsigned_integer (pc + 2, 2, byte_order))) { - LONGEST disp = read_memory_integer (pc + 4, 4, byte_order); + ULONGEST disp = read_memory_unsigned_integer (pc + 4, 4, byte_order); /* ... and d:24 is negative. */ - if (disp < 0 && disp > 0xffffff) + if ((disp & 0x00800000) != 0) return 8; } } @@ -219,10 +219,11 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc) { if (IS_MOVL_Rn24_SP (read_memory_integer (pc + 4, 2, byte_order))) { - LONGEST disp = read_memory_integer (pc + 6, 4, byte_order); + ULONGEST disp = read_memory_unsigned_integer (pc + 6, 4, + byte_order); /* ... and d:24 is negative. */ - if (disp < 0 && disp > 0xffffff) + if ((disp & 0x00800000) != 0) return 10; } } -- 2.26.2