aboutsummaryrefslogtreecommitdiff
path: root/gdb/frame.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/frame.c')
-rw-r--r--gdb/frame.c222
1 files changed, 113 insertions, 109 deletions
diff --git a/gdb/frame.c b/gdb/frame.c
index 9c3a1ae..f65d43f 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)
{