From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from qproxy3-pub.mail.unifiedlayer.com (qproxy3-pub.mail.unifiedlayer.com [67.222.38.20]) by sourceware.org (Postfix) with ESMTPS id AD76C3858C62 for ; Thu, 19 Jan 2023 17:39:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD76C3858C62 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by qproxy3.mail.unifiedlayer.com (Postfix) with ESMTP id 14F16802E022 for ; Thu, 19 Jan 2023 17:39:07 +0000 (UTC) Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 09C7410049CB9 for ; Thu, 19 Jan 2023 17:38:47 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IYsApMlLONX2aIYsApANnf; Thu, 19 Jan 2023 17:38:47 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63c98027 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=soIR4bj_ZffgZpQRjyUA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DVcEKjGJOOo2IvroN2uNiV6s/ZGzGj8M/Ju6wJSgiOM=; b=evD7q/EDLH8IgYji0UVqIDErYf X5VpcVC2ofTEtv3WS8jP2E9VmcnnpwvNlNd4UrWsKC+wp2fXdzmq9xi74WBxdYRLhufBLLC3MqRra u6SLlVHYhtHhPoOsZ56FNpN1p; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:52474 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIYsA-003N8L-KU; Thu, 19 Jan 2023 10:38:46 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Use bool in pc_in_* functions Date: Thu, 19 Jan 2023 10:38:36 -0700 Message-Id: <20230119173836.653968-1-tom@tromey.com> X-Mailer: git-send-email 2.39.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIYsA-003N8L-KU X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:52474 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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: I noticed that pc_in_unmapped_range had a weird return type -- it was returning a CORE_ADDR but intending to return a bool. This patch changes all the pc_in_* functions to return bool instead. --- gdb/gdbthread.h | 2 +- gdb/objfiles.c | 15 +++++---------- gdb/objfiles.h | 4 ++-- gdb/symfile.c | 12 ++++++------ gdb/symfile.h | 4 ++-- gdb/thread.c | 2 +- 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 11d69fceab0..c0f27a8a66e 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -892,7 +892,7 @@ extern void delete_exited_threads (void); /* Return true if PC is in the stepping range of THREAD. */ -int pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread); +bool pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread); /* Enable storing stack temporaries for thread THR and disable and clear the stack temporaries on destruction. Holds a strong diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 411bf121ede..e085356c571 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -1209,18 +1209,13 @@ find_pc_section (CORE_ADDR pc) /* Return non-zero if PC is in a section called NAME. */ -int +bool pc_in_section (CORE_ADDR pc, const char *name) { - struct obj_section *s; - int retval = 0; - - s = find_pc_section (pc); - - retval = (s != NULL - && s->the_bfd_section->name != NULL - && strcmp (s->the_bfd_section->name, name) == 0); - return (retval); + struct obj_section *s = find_pc_section (pc); + return (s != nullptr + && s->the_bfd_section->name != nullptr + && strcmp (s->the_bfd_section->name, name) == 0); } diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 3b0f94197ff..342aa09ac6a 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -891,8 +891,8 @@ extern int have_minimal_symbols (void); extern struct obj_section *find_pc_section (CORE_ADDR pc); -/* Return non-zero if PC is in a section called NAME. */ -extern int pc_in_section (CORE_ADDR, const char *); +/* Return true if PC is in a section called NAME. */ +extern bool pc_in_section (CORE_ADDR, const char *); /* Return non-zero if PC is in a SVR4-style procedure linkage table section. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index e0942dfb22d..f1ec4c12524 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3023,7 +3023,7 @@ section_is_mapped (struct obj_section *osect) /* Function: pc_in_unmapped_range If PC falls into the lma range of SECTION, return true, else false. */ -CORE_ADDR +bool pc_in_unmapped_range (CORE_ADDR pc, struct obj_section *section) { if (section_is_overlay (section)) @@ -3036,26 +3036,26 @@ pc_in_unmapped_range (CORE_ADDR pc, struct obj_section *section) if (bfd_section_lma (bfd_section) + offset <= pc && pc < bfd_section_lma (bfd_section) + offset + size) - return 1; + return true; } - return 0; + return false; } /* Function: pc_in_mapped_range If PC falls into the vma range of SECTION, return true, else false. */ -CORE_ADDR +bool pc_in_mapped_range (CORE_ADDR pc, struct obj_section *section) { if (section_is_overlay (section)) { if (section->addr () <= pc && pc < section->endaddr ()) - return 1; + return true; } - return 0; + return false; } /* Return true if the mapped ranges of sections A and B overlap, false diff --git a/gdb/symfile.h b/gdb/symfile.h index fb5fda795e3..81cf80d8719 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -296,10 +296,10 @@ extern int section_is_overlay (struct obj_section *); extern int section_is_mapped (struct obj_section *); /* Return true if pc belongs to section's VMA. */ -extern CORE_ADDR pc_in_mapped_range (CORE_ADDR, struct obj_section *); +extern bool pc_in_mapped_range (CORE_ADDR, struct obj_section *); /* Return true if pc belongs to section's LMA. */ -extern CORE_ADDR pc_in_unmapped_range (CORE_ADDR, struct obj_section *); +extern bool pc_in_unmapped_range (CORE_ADDR, struct obj_section *); /* Map an address from a section's LMA to its VMA. */ extern CORE_ADDR overlay_mapped_address (CORE_ADDR, struct obj_section *); diff --git a/gdb/thread.c b/gdb/thread.c index 3ce7048035d..efcbe649643 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -968,7 +968,7 @@ can_access_registers_thread (thread_info *thread) return true; } -int +bool pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread) { return (pc >= thread->control.step_range_start -- 2.39.0