[2/2] gdb: use bool in frame code

Message ID 20200803191510.16781-2-simon.marchi@efficios.com
State New
Headers show
Series
  • [1/2] gdb: change frame_info::prev_func::p type to cached_copy_status
Related show

Commit Message

Eli Zaretskii via Gdb-patches Aug. 3, 2020, 7:15 p.m.
Change instances of int variables and return values used as boolean
values to use the bool type.

Shorten the comments of a few functions, because I think they go a bit
too much in implementation details, which appear out of date anyway.

Make other misc changes to the functions that are already being changed,
such as using nullptr instead of NULL, dropping `struct` keywords and
declaring variables when first used.

gdb/ChangeLog:

	* frame.h (frame_id_p): Return bool.
	(frame_id_artificial_p): Return bool.
	(frame_id_eq): Return bool.
	(has_stack_frames): Return bool.
	(get_selected_frame): Fix typo in comment.
	(get_frame_pc_if_available): Return bool.
	(get_frame_address_in_block_if_available): Return bool.
	(get_frame_func_if_available): Return bool.
	(read_frame_register_unsigned): Return bool.
	(get_frame_register_bytes): Return bool.
	(safe_frame_unwind_memory): Return bool.
	(deprecated_frame_register_read): Return bool.
	(frame_unwinder_is): Return bool.
	* frame.c (struct frame_info) <prev_arch::p>: Change type to
	bool.
	<this_id::p>: Likewise.
	<prev_p>: Likewise.
	(frame_stash_add): Return bool.
	(get_frame_id): Use bool.
	(frame_id_build_special) Use bool.
	(frame_id_build_unavailable_stack): Use bool.
	(frame_id_build): Use bool.
	(frame_id_p): Return bool, use true/false instead of 1/0.
	(frame_id_artificial_p): Likewise.
	(frame_id_eq): Likewise.
	(frame_id_inner): Likewise.
	(get_frame_func_if_available): Likewise.
	(read_frame_register_unsigned): Likewise.
	(deprecated_frame_register_read): Likewise.
	(get_frame_register_bytes): Likewise.
	(has_stack_frames): Likewise.
	(inside_main_func): Likewise.
	(inside_entry_func): Likewise.
	(get_frame_pc_if_available): Likewise.
	(get_frame_address_in_block_if_available): Likewise.
	(frame_unwinder_is): Likewise.
	(safe_frame_unwind_memory): Likewise.
	(frame_unwind_arch): Likewise.

Change-Id: I6121fa56739b688be79d73d087d76b268ba5a46a
---
 gdb/dwarf2/frame-tailcall.c |   2 +-
 gdb/frame.c                 | 222 ++++++++++++++++++------------------
 gdb/frame.h                 |  60 +++++-----
 3 files changed, 141 insertions(+), 143 deletions(-)

-- 
2.28.0

Patch

diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c
index 7ea6daca25b..a90056808df 100644
--- a/gdb/dwarf2/frame-tailcall.c
+++ b/gdb/dwarf2/frame-tailcall.c
@@ -219,7 +219,7 @@  tailcall_frame_this_id (struct frame_info *this_frame, void **this_cache,
 
   *this_id = get_frame_id (next_frame);
   (*this_id).code_addr = get_frame_pc (this_frame);
-  (*this_id).code_addr_p = 1;
+  (*this_id).code_addr_p = true;
   (*this_id).artificial_depth = (cache->chain_levels
 				 - existing_next_levels (this_frame, cache));
   gdb_assert ((*this_id).artificial_depth > 0);
diff --git a/gdb/frame.c b/gdb/frame.c
index 9c3a1ae1d5c..f65d43f9fcc 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -127,7 +127,7 @@  struct frame_info
   /* Cached copy of the previous frame's architecture.  */
   struct
   {
-    int p;
+    bool p;
     struct gdbarch *arch;
   } prev_arch;
 
@@ -138,21 +138,21 @@  struct frame_info
     bool masked;
     CORE_ADDR value;
   } prev_pc;
-  
+
   /* Cached copy of the previous frame's function address.  */
   struct
   {
     CORE_ADDR addr;
     cached_copy_status status;
   } prev_func;
-  
+
   /* This frame's ID.  */
   struct
   {
-    int p;
+    bool p;
     struct frame_id value;
   } this_id;
-  
+
   /* The frame's high-level base methods, and corresponding cache.
      The high level base methods are selected based on the frame's
      debug info.  */
@@ -162,7 +162,7 @@  struct frame_info
   /* Pointers to the next (down, inner, younger) and previous (up,
      outer, older) frame_info's in the frame cache.  */
   struct frame_info *next; /* down, inner, younger */
-  int prev_p;
+  bool prev_p;
   struct frame_info *prev; /* up, outer, older */
 
   /* The reason why we could not set PREV, or UNWIND_NO_REASON if we
@@ -257,27 +257,24 @@  frame_stash_create (void)
    Returns false if a frame with the same ID was already stashed, true
    otherwise.  */
 
-static int
-frame_stash_add (struct frame_info *frame)
+static bool
+frame_stash_add (frame_info *frame)
 {
-  struct frame_info **slot;
-
   /* Do not try to stash the sentinel frame.  */
   gdb_assert (frame->level >= 0);
 
-  slot = (struct frame_info **) htab_find_slot (frame_stash,
-						frame,
-						INSERT);
+  frame_info **slot = (struct frame_info **) htab_find_slot (frame_stash,
+							     frame, INSERT);
 
   /* If we already have a frame in the stack with the same id, we
      either have a stack cycle (corrupted stack?), or some bug
      elsewhere in GDB.  In any case, ignore the duplicate and return
      an indication to the caller.  */
-  if (*slot != NULL)
-    return 0;
+  if (*slot != nullptr)
+    return false;
 
   *slot = frame;
-  return 1;
+  return true;
 }
 
 /* Internal function to search the frame stash for an entry with the
@@ -560,7 +557,7 @@  compute_frame_id (struct frame_info *fi)
   fi->this_id.value = outer_frame_id;
   fi->unwind->this_id (fi, &fi->prologue_cache, &fi->this_id.value);
   gdb_assert (frame_id_p (fi->this_id.value));
-  fi->this_id.p = 1;
+  fi->this_id.p = true;
   if (frame_debug)
     {
       fprintf_unfiltered (gdb_stdlog, "-> ");
@@ -580,8 +577,6 @@  get_frame_id (struct frame_info *fi)
 
   if (!fi->this_id.p)
     {
-      int stashed;
-
       /* If we haven't computed the frame id yet, then it must be that
 	 this is the current frame.  Compute it now, and stash the
 	 result.  The IDs of other frames are computed as soon as
@@ -594,7 +589,7 @@  get_frame_id (struct frame_info *fi)
 
       /* Since this is the first frame in the chain, this should
 	 always succeed.  */
-      stashed = frame_stash_add (fi);
+      bool stashed = frame_stash_add (fi);
       gdb_assert (stashed);
     }
 
@@ -641,9 +636,9 @@  frame_id_build_special (CORE_ADDR stack_addr, CORE_ADDR code_addr,
   id.stack_addr = stack_addr;
   id.stack_status = FID_STACK_VALID;
   id.code_addr = code_addr;
-  id.code_addr_p = 1;
+  id.code_addr_p = true;
   id.special_addr = special_addr;
-  id.special_addr_p = 1;
+  id.special_addr_p = true;
   return id;
 }
 
@@ -656,7 +651,7 @@  frame_id_build_unavailable_stack (CORE_ADDR code_addr)
 
   id.stack_status = FID_STACK_UNAVAILABLE;
   id.code_addr = code_addr;
-  id.code_addr_p = 1;
+  id.code_addr_p = true;
   return id;
 }
 
@@ -670,9 +665,9 @@  frame_id_build_unavailable_stack_special (CORE_ADDR code_addr,
 
   id.stack_status = FID_STACK_UNAVAILABLE;
   id.code_addr = code_addr;
-  id.code_addr_p = 1;
+  id.code_addr_p = true;
   id.special_addr = special_addr;
-  id.special_addr_p = 1;
+  id.special_addr_p = true;
   return id;
 }
 
@@ -684,7 +679,7 @@  frame_id_build (CORE_ADDR stack_addr, CORE_ADDR code_addr)
   id.stack_addr = stack_addr;
   id.stack_status = FID_STACK_VALID;
   id.code_addr = code_addr;
-  id.code_addr_p = 1;
+  id.code_addr_p = true;
   return id;
 }
 
@@ -698,38 +693,39 @@  frame_id_build_wild (CORE_ADDR stack_addr)
   return id;
 }
 
-int
-frame_id_p (struct frame_id l)
+bool
+frame_id_p (frame_id l)
 {
-  int p;
-
   /* The frame is valid iff it has a valid stack address.  */
-  p = l.stack_status != FID_STACK_INVALID;
+  bool p = l.stack_status != FID_STACK_INVALID;
+
   /* outer_frame_id is also valid.  */
   if (!p && memcmp (&l, &outer_frame_id, sizeof (l)) == 0)
-    p = 1;
+    p = true;
+
   if (frame_debug)
     {
       fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l=");
       fprint_frame_id (gdb_stdlog, l);
       fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", p);
     }
+
   return p;
 }
 
-int
-frame_id_artificial_p (struct frame_id l)
+bool
+frame_id_artificial_p (frame_id l)
 {
   if (!frame_id_p (l))
-    return 0;
+    return false;
 
-  return (l.artificial_depth != 0);
+  return l.artificial_depth != 0;
 }
 
-int
-frame_id_eq (struct frame_id l, struct frame_id r)
+bool
+frame_id_eq (frame_id l, frame_id r)
 {
-  int eq;
+  bool eq;
 
   if (l.stack_status == FID_STACK_INVALID && l.special_addr_p
       && r.stack_status == FID_STACK_INVALID && r.special_addr_p)
@@ -738,30 +734,30 @@  frame_id_eq (struct frame_id l, struct frame_id r)
        we might step into another function - from which we can't
        unwind either.  More thought required to get rid of
        outer_frame_id.  */
-    eq = 1;
+    eq = true;
   else if (l.stack_status == FID_STACK_INVALID
 	   || r.stack_status == FID_STACK_INVALID)
     /* Like a NaN, if either ID is invalid, the result is false.
        Note that a frame ID is invalid iff it is the null frame ID.  */
-    eq = 0;
+    eq = false;
   else if (l.stack_status != r.stack_status || l.stack_addr != r.stack_addr)
     /* If .stack addresses are different, the frames are different.  */
-    eq = 0;
+    eq = false;
   else if (l.code_addr_p && r.code_addr_p && l.code_addr != r.code_addr)
     /* An invalid code addr is a wild card.  If .code addresses are
        different, the frames are different.  */
-    eq = 0;
+    eq = false;
   else if (l.special_addr_p && r.special_addr_p
 	   && l.special_addr != r.special_addr)
     /* An invalid special addr is a wild card (or unused).  Otherwise
        if special addresses are different, the frames are different.  */
-    eq = 0;
+    eq = false;
   else if (l.artificial_depth != r.artificial_depth)
     /* If artificial depths are different, the frames must be different.  */
-    eq = 0;
+    eq = false;
   else
     /* Frames are equal.  */
-    eq = 1;
+    eq = true;
 
   if (frame_debug)
     {
@@ -771,6 +767,7 @@  frame_id_eq (struct frame_id l, struct frame_id r)
       fprint_frame_id (gdb_stdlog, r);
       fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", eq);
     }
+
   return eq;
 }
 
@@ -806,15 +803,15 @@  frame_id_eq (struct frame_id l, struct frame_id r)
    a stack overflow strategy that cause the handler to be run on a
    different stack.  */
 
-static int
+static bool
 frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
 {
-  int inner;
+  bool inner;
 
   if (l.stack_status != FID_STACK_VALID || r.stack_status != FID_STACK_VALID)
     /* Like NaN, any operation involving an invalid ID always fails.
        Likewise if either ID has an unavailable stack address.  */
-    inner = 0;
+    inner = false;
   else if (l.artificial_depth > r.artificial_depth
 	   && l.stack_addr == r.stack_addr
 	   && l.code_addr_p == r.code_addr_p
@@ -831,7 +828,7 @@  frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
 
       if (lb == NULL || rb == NULL)
 	/* Something's gone wrong.  */
-	inner = 0;
+	inner = false;
       else
 	/* This will return true if LB and RB are the same block, or
 	   if the block with the smaller depth lexically encloses the
@@ -844,6 +841,7 @@  frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
        functions are not strictly inner than (same .stack but
        different .code and/or .special address).  */
     inner = gdbarch_inner_than (gdbarch, l.stack_addr, r.stack_addr);
+
   if (frame_debug)
     {
       fprintf_unfiltered (gdb_stdlog, "{ frame_id_inner (l=");
@@ -852,6 +850,7 @@  frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
       fprint_frame_id (gdb_stdlog, r);
       fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", inner);
     }
+
   return inner;
 }
 
@@ -914,7 +913,7 @@  frame_unwind_pc (struct frame_info *this_frame)
     {
       struct gdbarch *prev_gdbarch;
       CORE_ADDR pc = 0;
-      int pc_p = 0;
+      bool pc_p = false;
 
       /* The right way.  The `pure' way.  The one true way.  This
 	 method depends solely on the register-unwind code to
@@ -937,7 +936,7 @@  frame_unwind_pc (struct frame_info *this_frame)
       try
 	{
 	  pc = gdbarch_unwind_pc (prev_gdbarch, this_frame);
-	  pc_p = 1;
+	  pc_p = true;
 	}
       catch (const gdb_exception_error &ex)
 	{
@@ -1003,8 +1002,8 @@  frame_unwind_caller_pc (struct frame_info *this_frame)
   return frame_unwind_pc (this_frame);
 }
 
-int
-get_frame_func_if_available (struct frame_info *this_frame, CORE_ADDR *pc)
+bool
+get_frame_func_if_available (frame_info *this_frame, CORE_ADDR *pc)
 {
   struct frame_info *next_frame = this_frame->next;
 
@@ -1038,14 +1037,14 @@  get_frame_func_if_available (struct frame_info *this_frame, CORE_ADDR *pc)
   if (next_frame->prev_func.status == CC_UNAVAILABLE)
     {
       *pc = -1;
-      return 0;
+      return false;
     }
   else
     {
       gdb_assert (next_frame->prev_func.status == CC_VALUE);
 
       *pc = next_frame->prev_func.addr;
-      return 1;
+      return true;
     }
 }
 
@@ -1358,8 +1357,8 @@  get_frame_register_unsigned (struct frame_info *frame, int regnum)
   return frame_unwind_register_unsigned (frame->next, regnum);
 }
 
-int
-read_frame_register_unsigned (struct frame_info *frame, int regnum,
+bool
+read_frame_register_unsigned (frame_info *frame, int regnum,
 			      ULONGEST *val)
 {
   struct value *regval = get_frame_register_value (frame, regnum);
@@ -1372,10 +1371,10 @@  read_frame_register_unsigned (struct frame_info *frame, int regnum,
       int size = register_size (gdbarch, VALUE_REGNUM (regval));
 
       *val = extract_unsigned_integer (value_contents (regval), size, byte_order);
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
 void
@@ -1416,9 +1415,9 @@  put_frame_register (struct frame_info *frame, int regnum,
 
    Returns 0 if the register value could not be found.  */
 
-int
-deprecated_frame_register_read (struct frame_info *frame, int regnum,
-		     gdb_byte *myaddr)
+bool
+deprecated_frame_register_read (frame_info *frame, int regnum,
+				gdb_byte *myaddr)
 {
   int optimized;
   int unavailable;
@@ -1432,8 +1431,8 @@  deprecated_frame_register_read (struct frame_info *frame, int regnum,
   return !optimized && !unavailable;
 }
 
-int
-get_frame_register_bytes (struct frame_info *frame, int regnum,
+bool
+get_frame_register_bytes (frame_info *frame, int regnum,
 			  CORE_ADDR offset, int len, gdb_byte *myaddr,
 			  int *optimizedp, int *unavailablep)
 {
@@ -1482,7 +1481,7 @@  get_frame_register_bytes (struct frame_info *frame, int regnum,
 	  frame_register (frame, regnum, optimizedp, unavailablep,
 			  &lval, &addr, &realnum, myaddr);
 	  if (*optimizedp || *unavailablep)
-	    return 0;
+	    return false;
 	}
       else
 	{
@@ -1495,8 +1494,9 @@  get_frame_register_bytes (struct frame_info *frame, int regnum,
 	  if (*optimizedp || *unavailablep)
 	    {
 	      release_value (value);
-	      return 0;
+	      return false;
 	    }
+
 	  memcpy (myaddr, value_contents_all (value) + offset, curr_len);
 	  release_value (value);
 	}
@@ -1509,7 +1509,8 @@  get_frame_register_bytes (struct frame_info *frame, int regnum,
 
   *optimizedp = 0;
   *unavailablep = 0;
-  return 1;
+
+  return true;
 }
 
 void
@@ -1576,7 +1577,7 @@  create_sentinel_frame (struct program_space *pspace, struct regcache *regcache)
      (the unwound PC is the same as the pc), so make it so.  */
   frame->next = frame;
   /* The sentinel frame has a special ID.  */
-  frame->this_id.p = 1;
+  frame->this_id.p = true;
   frame->this_id.value = sentinel_frame_id;
   if (frame_debug)
     {
@@ -1650,30 +1651,30 @@  get_current_frame (void)
 
 static struct frame_info *selected_frame;
 
-int
-has_stack_frames (void)
+bool
+has_stack_frames ()
 {
   if (!target_has_registers || !target_has_stack || !target_has_memory)
-    return 0;
+    return false;
 
   /* Traceframes are effectively a substitute for the live inferior.  */
   if (get_traceframe_number () < 0)
     {
       /* No current inferior, no frame.  */
       if (inferior_ptid == null_ptid)
-	return 0;
+	return false;
 
       thread_info *tp = inferior_thread ();
       /* Don't try to read from a dead thread.  */
       if (tp->state == THREAD_EXITED)
-	return 0;
+	return false;
 
       /* ... or from a spinning thread.  */
       if (tp->executing)
-	return 0;
+	return false;
     }
 
-  return 1;
+  return true;
 }
 
 /* Return the selected frame.  Always non-NULL (unless there isn't an
@@ -1796,7 +1797,7 @@  create_new_frame (CORE_ADDR addr, CORE_ADDR pc)
      based on the PC.  */
   frame_unwind_find_by_frame (fi, &fi->prologue_cache);
 
-  fi->this_id.p = 1;
+  fi->this_id.p = true;
   fi->this_id.value = frame_id_build (addr, pc);
 
   if (frame_debug)
@@ -2014,7 +2015,7 @@  get_prev_frame_always_1 (struct frame_info *this_frame)
   if (this_frame->unwind == NULL)
     frame_unwind_find_by_frame (this_frame, &this_frame->prologue_cache);
 
-  this_frame->prev_p = 1;
+  this_frame->prev_p = true;
   this_frame->stop_reason = UNWIND_NO_REASON;
 
   /* If we are unwinding from an inline frame, all of the below tests
@@ -2249,34 +2250,36 @@  frame_debug_got_null_frame (struct frame_info *this_frame,
 
 /* Is this (non-sentinel) frame in the "main"() function?  */
 
-static int
-inside_main_func (struct frame_info *this_frame)
+static bool
+inside_main_func (frame_info *this_frame)
 {
-  struct bound_minimal_symbol msymbol;
-  CORE_ADDR maddr;
+  if (symfile_objfile == nullptr)
+    return false;
+
+  bound_minimal_symbol msymbol
+    = lookup_minimal_symbol (main_name (), NULL, symfile_objfile);
+  if (msymbol.minsym == nullptr)
+    return false;
 
-  if (symfile_objfile == 0)
-    return 0;
-  msymbol = lookup_minimal_symbol (main_name (), NULL, symfile_objfile);
-  if (msymbol.minsym == NULL)
-    return 0;
   /* Make certain that the code, and not descriptor, address is
      returned.  */
-  maddr = gdbarch_convert_from_func_ptr_addr (get_frame_arch (this_frame),
-					      BMSYMBOL_VALUE_ADDRESS (msymbol),
-					      current_top_target ());
+  CORE_ADDR maddr
+    = gdbarch_convert_from_func_ptr_addr (get_frame_arch (this_frame),
+					  BMSYMBOL_VALUE_ADDRESS (msymbol),
+					  current_top_target ());
+
   return maddr == get_frame_func (this_frame);
 }
 
 /* Test whether THIS_FRAME is inside the process entry point function.  */
 
-static int
-inside_entry_func (struct frame_info *this_frame)
+static bool
+inside_entry_func (frame_info *this_frame)
 {
   CORE_ADDR entry_point;
 
   if (!entry_point_address_query (&entry_point))
-    return 0;
+    return false;
 
   return get_frame_func (this_frame) == entry_point;
 }
@@ -2419,8 +2422,8 @@  get_frame_pc (struct frame_info *frame)
   return frame_unwind_pc (frame->next);
 }
 
-int
-get_frame_pc_if_available (struct frame_info *frame, CORE_ADDR *pc)
+bool
+get_frame_pc_if_available (frame_info *frame, CORE_ADDR *pc)
 {
 
   gdb_assert (frame->next != NULL);
@@ -2432,12 +2435,12 @@  get_frame_pc_if_available (struct frame_info *frame, CORE_ADDR *pc)
   catch (const gdb_exception_error &ex)
     {
       if (ex.error == NOT_AVAILABLE_ERROR)
-	return 0;
+	return false;
       else
 	throw;
     }
 
-  return 1;
+  return true;
 }
 
 /* Return an address that falls within THIS_FRAME's code block.  */
@@ -2502,8 +2505,8 @@  get_frame_address_in_block (struct frame_info *this_frame)
   return pc;
 }
 
-int
-get_frame_address_in_block_if_available (struct frame_info *this_frame,
+bool
+get_frame_address_in_block_if_available (frame_info *this_frame,
 					 CORE_ADDR *pc)
 {
 
@@ -2514,11 +2517,11 @@  get_frame_address_in_block_if_available (struct frame_info *this_frame,
   catch (const gdb_exception_error &ex)
     {
       if (ex.error == NOT_AVAILABLE_ERROR)
-	return 0;
+	return false;
       throw;
     }
 
-  return 1;
+  return true;
 }
 
 symtab_and_line
@@ -2634,11 +2637,12 @@  get_frame_args_address (struct frame_info *fi)
 /* Return true if the frame unwinder for frame FI is UNWINDER; false
    otherwise.  */
 
-int
-frame_unwinder_is (struct frame_info *fi, const struct frame_unwind *unwinder)
+bool
+frame_unwinder_is (frame_info *fi, const frame_unwind *unwinder)
 {
-  if (fi->unwind == NULL)
+  if (fi->unwind == nullptr)
     frame_unwind_find_by_frame (fi, &fi->prologue_cache);
+
   return fi->unwind == unwinder;
 }
 
@@ -2716,12 +2720,12 @@  get_frame_memory_unsigned (struct frame_info *this_frame, CORE_ADDR addr,
   return read_memory_unsigned_integer (addr, len, byte_order);
 }
 
-int
+bool
 safe_frame_unwind_memory (struct frame_info *this_frame,
 			  CORE_ADDR addr, gdb_byte *buf, int len)
 {
   /* NOTE: target_read_memory returns zero on success!  */
-  return !target_read_memory (addr, buf, len);
+  return target_read_memory (addr, buf, len) == 0;
 }
 
 /* Architecture methods.  */
@@ -2749,7 +2753,7 @@  frame_unwind_arch (struct frame_info *next_frame)
 	arch = get_frame_arch (next_frame);
 
       next_frame->prev_arch.arch = arch;
-      next_frame->prev_arch.p = 1;
+      next_frame->prev_arch.p = true;
       if (frame_debug)
 	fprintf_unfiltered (gdb_stdlog,
 			    "{ frame_unwind_arch (next_frame=%d) -> %s }\n",
@@ -2779,7 +2783,7 @@  enum language
 get_frame_language (struct frame_info *frame)
 {
   CORE_ADDR pc = 0;
-  int pc_p = 0;
+  bool pc_p = false;
 
   gdb_assert (frame!= NULL);
 
@@ -2795,7 +2799,7 @@  get_frame_language (struct frame_info *frame)
   try
     {
       pc = get_frame_address_in_block (frame);
-      pc_p = 1;
+      pc_p = true;
     }
   catch (const gdb_exception_error &ex)
     {
diff --git a/gdb/frame.h b/gdb/frame.h
index 8d029cc065d..1c6afad1ae9 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -45,8 +45,8 @@ 
    strongly hinting at its unsafeness)
 
    safe_....(): Safer version of various functions, doesn't throw an
-   error (leave this for later?).  Returns non-zero / non-NULL if the
-   request succeeds, zero / NULL otherwize.
+   error (leave this for later?).  Returns true / non-NULL if the request
+   succeeds, false / NULL otherwise.
 
    Suffixes:
 
@@ -236,19 +236,16 @@  extern struct frame_id
    as the special identifier address are set to indicate wild cards.  */
 extern struct frame_id frame_id_build_wild (CORE_ADDR stack_addr);
 
-/* Returns non-zero when L is a valid frame (a valid frame has a
-   non-zero .base).  The outermost frame is valid even without an
-   ID.  */
-extern int frame_id_p (struct frame_id l);
+/* Returns true when L is a valid frame.  */
+extern bool frame_id_p (frame_id l);
 
-/* Returns non-zero when L is a valid frame representing a frame made up by GDB
+/* Returns true when L is a valid frame representing a frame made up by GDB
    without stack data representation in inferior, such as INLINE_FRAME or
    TAILCALL_FRAME.  */
-extern int frame_id_artificial_p (struct frame_id l);
+extern bool frame_id_artificial_p (frame_id l);
 
-/* Returns non-zero when L and R identify the same frame, or, if
-   either L or R have a zero .func, then the same frame base.  */
-extern int frame_id_eq (struct frame_id l, struct frame_id r);
+/* Returns true when L and R identify the same frame.  */
+extern bool frame_id_eq (frame_id l, frame_id r);
 
 /* Write the internal representation of a frame ID on the specified
    stream.  */
@@ -303,7 +300,7 @@  extern struct frame_info *get_current_frame (void);
 /* Does the current target interface have enough state to be able to
    query the current inferior for frame info, and is the inferior in a
    state where that is possible?  */
-extern int has_stack_frames (void);
+extern bool has_stack_frames ();
 
 /* Invalidates the frame cache (this function should have been called
    invalidate_cached_frames).
@@ -317,7 +314,7 @@  extern void reinit_frame_cache (void);
 /* On demand, create the selected frame and then return it.  If the
    selected frame can not be created, this function prints then throws
    an error.  When MESSAGE is non-NULL, use it for the error message,
-   otherwize use a generic error message.  */
+   otherwise use a generic error message.  */
 /* FIXME: cagney/2002-11-28: At present, when there is no selected
    frame, this function always returns the current (inner most) frame.
    It should instead, when a thread has previously had its frame
@@ -367,8 +364,7 @@  extern CORE_ADDR get_frame_pc (struct frame_info *);
 /* Same as get_frame_pc, but return a boolean indication of whether
    the PC is actually available, instead of throwing an error.  */
 
-extern int get_frame_pc_if_available (struct frame_info *frame,
-				      CORE_ADDR *pc);
+extern bool get_frame_pc_if_available (frame_info *frame, CORE_ADDR *pc);
 
 /* An address (not necessarily aligned to an instruction boundary)
    that falls within THIS frame's code block.
@@ -390,9 +386,8 @@  extern CORE_ADDR get_frame_address_in_block (struct frame_info *this_frame);
    PC is unavailable, it will not be), instead of possibly throwing an
    error trying to read an unavailable PC.  */
 
-extern int
-  get_frame_address_in_block_if_available (struct frame_info *this_frame,
-					   CORE_ADDR *pc);
+extern bool get_frame_address_in_block_if_available (frame_info *this_frame,
+						     CORE_ADDR *pc);
 
 /* The frame's inner-most bound.  AKA the stack-pointer.  Confusingly
    known as top-of-stack.  */
@@ -409,7 +404,7 @@  extern CORE_ADDR get_frame_func (struct frame_info *fi);
    will not be), instead of possibly throwing an error trying to read
    an unavailable PC.  */
 
-extern int get_frame_func_if_available (struct frame_info *fi, CORE_ADDR *);
+extern bool get_frame_func_if_available (frame_info *fi, CORE_ADDR *);
 
 /* Closely related to the resume address, various symbol table
    attributes that are determined by the PC.  Note that for a normal
@@ -597,8 +592,8 @@  extern ULONGEST get_frame_register_unsigned (struct frame_info *frame,
    get_frame_register_value, that do not throw if the result is
    optimized out or unavailable.  */
 
-extern int read_frame_register_unsigned (struct frame_info *frame,
-					 int regnum, ULONGEST *val);
+extern bool read_frame_register_unsigned (frame_info *frame,
+					  int regnum, ULONGEST *val);
 
 /* Get the value of the register that belongs to this FRAME.  This
    function is a wrapper to the call sequence ``frame_register_unwind
@@ -621,10 +616,10 @@  extern void put_frame_register (struct frame_info *frame, int regnum,
    in frame FRAME, starting at OFFSET, into BUF.  If the register
    contents are optimized out or unavailable, set *OPTIMIZEDP,
    *UNAVAILABLEP accordingly.  */
-extern int get_frame_register_bytes (struct frame_info *frame, int regnum,
-				     CORE_ADDR offset, int len,
-				     gdb_byte *myaddr,
-				     int *optimizedp, int *unavailablep);
+extern bool get_frame_register_bytes (frame_info *frame, int regnum,
+				      CORE_ADDR offset, int len,
+				      gdb_byte *myaddr,
+				      int *optimizedp, int *unavailablep);
 
 /* Write LEN bytes to one or multiple registers starting with REGNUM
    in frame FRAME, starting at OFFSET, into BUF.  */
@@ -662,10 +657,10 @@  extern LONGEST get_frame_memory_signed (struct frame_info *this_frame,
 extern ULONGEST get_frame_memory_unsigned (struct frame_info *this_frame,
 					   CORE_ADDR memaddr, int len);
 
-/* Same as above, but return non-zero when the entire memory read
-   succeeds, zero otherwize.  */
-extern int safe_frame_unwind_memory (struct frame_info *this_frame,
-				     CORE_ADDR addr, gdb_byte *buf, int len);
+/* Same as above, but return true zero when the entire memory read
+   succeeds, false otherwise.  */
+extern bool safe_frame_unwind_memory (frame_info *this_frame, CORE_ADDR addr,
+				      gdb_byte *buf, int len);
 
 /* Return this frame's architecture.  */
 extern struct gdbarch *get_frame_arch (struct frame_info *this_frame);
@@ -772,8 +767,8 @@  extern void print_frame_info (const frame_print_options &fp_opts,
 
 extern struct frame_info *block_innermost_frame (const struct block *);
 
-extern int deprecated_frame_register_read (struct frame_info *frame, int regnum,
-				gdb_byte *buf);
+extern bool deprecated_frame_register_read (frame_info *frame, int regnum,
+					    gdb_byte *buf);
 
 /* From stack.c.  */
 
@@ -907,8 +902,7 @@  extern struct frame_info *create_new_frame (CORE_ADDR base, CORE_ADDR pc);
 /* Return true if the frame unwinder for frame FI is UNWINDER; false
    otherwise.  */
 
-extern int frame_unwinder_is (struct frame_info *fi,
-			      const struct frame_unwind *unwinder);
+extern bool frame_unwinder_is (frame_info *fi, const frame_unwind *unwinder);
 
 /* Return the language of FRAME.  */