From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 72C9C38493C6; Fri, 20 Jan 2023 18:11:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72C9C38493C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674238289; bh=iBfg26QETLexZ9Hb5C/OoJbJJ1XlMEUtmbF9H9PN0Ss=; h=From:To:Subject:Date:From; b=M2PTuWlgxVcWrYiy61wu0hEXQl3RaA9LGpJuLNfPAWKZ0JgxHc7DIocmFuucXJTS7 X++q/njOySLb8EibzTMIHc28D09mWPAgwCZxkJP65SO6hvDF7wW+uWj5MchBnXCPZJ KGZZGiPS2FwgAB9tLr/bPXV53a+8eLdxMBTDvxjk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use bool in pc_in_* functions X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 42938c1a5b84207e9b6526e56d8e57e1ad3bab5f X-Git-Newrev: 6ec27270ff995940ffa532ee15414300782c30e8 Message-Id: <20230120181129.72C9C38493C6@sourceware.org> Date: Fri, 20 Jan 2023 18:11:29 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6ec27270ff99= 5940ffa532ee15414300782c30e8 commit 6ec27270ff995940ffa532ee15414300782c30e8 Author: Tom Tromey Date: Wed Jan 18 16:36:52 2023 -0700 Use bool in pc_in_* functions =20 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. Diff: --- 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); =20 /* Return true if PC is in the stepping range of THREAD. */ =20 -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); =20 /* 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 8e920c726f5..e4fe3562c12 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -1208,18 +1208,13 @@ find_pc_section (CORE_ADDR pc) =20 /* Return non-zero if PC is in a section called NAME. */ =20 -int +bool pc_in_section (CORE_ADDR pc, const char *name) { - struct obj_section *s; - int retval =3D 0; - - s =3D find_pc_section (pc); - - retval =3D (s !=3D NULL - && s->the_bfd_section->name !=3D NULL - && strcmp (s->the_bfd_section->name, name) =3D=3D 0); - return (retval); + struct obj_section *s =3D find_pc_section (pc); + return (s !=3D nullptr + && s->the_bfd_section->name !=3D nullptr + && strcmp (s->the_bfd_section->name, name) =3D=3D 0); } =0C =20 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); =20 extern struct obj_section *find_pc_section (CORE_ADDR pc); =20 -/* 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 *); =20 /* 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 3e1aa405319..181f859052a 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3022,7 +3022,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. */ =20 -CORE_ADDR +bool pc_in_unmapped_range (CORE_ADDR pc, struct obj_section *section) { if (section_is_overlay (section)) @@ -3035,26 +3035,26 @@ pc_in_unmapped_range (CORE_ADDR pc, struct obj_sect= ion *section) =20 if (bfd_section_lma (bfd_section) + offset <=3D pc && pc < bfd_section_lma (bfd_section) + offset + size) - return 1; + return true; } =20 - return 0; + return false; } =20 /* Function: pc_in_mapped_range If PC falls into the vma range of SECTION, return true, else false. */ =20 -CORE_ADDR +bool pc_in_mapped_range (CORE_ADDR pc, struct obj_section *section) { if (section_is_overlay (section)) { if (section->addr () <=3D pc && pc < section->endaddr ()) - return 1; + return true; } =20 - return 0; + return false; } =20 /* 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 *); =20 /* 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 *); =20 /* 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 *); =20 /* 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; } =20 -int +bool pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread) { return (pc >=3D thread->control.step_range_start