public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Use bool in pc_in_* functions
Date: Thu, 19 Jan 2023 10:38:36 -0700	[thread overview]
Message-ID: <20230119173836.653968-1-tom@tromey.com> (raw)

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);
 }
 \f
 
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


             reply	other threads:[~2023-01-19 17:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19 17:38 Tom Tromey [this message]
2023-01-20 17:09 ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230119173836.653968-1-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).