/* Cached copy of the previous frame's architecture. */
struct
{
- int p;
+ bool p;
struct gdbarch *arch;
} prev_arch;
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. */
/* 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
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
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, "-> ");
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
/* 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);
}
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;
}
id.stack_status = FID_STACK_UNAVAILABLE;
id.code_addr = code_addr;
- id.code_addr_p = 1;
+ id.code_addr_p = true;
return id;
}
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;
}
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;
}
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)
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)
{
fprint_frame_id (gdb_stdlog, r);
fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", eq);
}
+
return eq;
}
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
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
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=");
fprint_frame_id (gdb_stdlog, r);
fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", inner);
}
+
return inner;
}
{
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
try
{
pc = gdbarch_unwind_pc (prev_gdbarch, this_frame);
- pc_p = 1;
+ pc_p = true;
}
catch (const gdb_exception_error &ex)
{
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;
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;
}
}
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);
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
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;
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)
{
frame_register (frame, regnum, optimizedp, unavailablep,
&lval, &addr, &realnum, myaddr);
if (*optimizedp || *unavailablep)
- return 0;
+ return false;
}
else
{
if (*optimizedp || *unavailablep)
{
release_value (value);
- return 0;
+ return false;
}
+
memcpy (myaddr, value_contents_all (value) + offset, curr_len);
release_value (value);
}
*optimizedp = 0;
*unavailablep = 0;
- return 1;
+
+ return true;
}
void
(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)
{
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
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)
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
/* 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;
}
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);
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. */
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)
{
catch (const gdb_exception_error &ex)
{
if (ex.error == NOT_AVAILABLE_ERROR)
- return 0;
+ return false;
throw;
}
- return 1;
+ return true;
}
symtab_and_line
/* 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;
}
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. */
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",
get_frame_language (struct frame_info *frame)
{
CORE_ADDR pc = 0;
- int pc_p = 0;
+ bool pc_p = false;
gdb_assert (frame!= NULL);
try
{
pc = get_frame_address_in_block (frame);
- pc_p = 1;
+ pc_p = true;
}
catch (const gdb_exception_error &ex)
{
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:
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. */
/* 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).
/* 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
/* 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.
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. */
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
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
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. */
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);
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. */
/* 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. */