gdb: change frame_info::prev_func::p type to cached_copy_status

One might think that variable `frame_info::prev_func::p` is a simple
true/false value, but that's not the case, it can also have the value -1
to mean "unavaiable".  Change it to use the `cached_copy_status` enum,
which seems designed exactly for this purpose.

Rename to `status` to be consistent with `prev_pc::status` (and be cause
`p` means `predicate`, which implies boolean, which this is not).

gdb/ChangeLog:

	* frame.c (frame_info) <prev_func> <p>: Rename to status, change
	type to cached_copy_status.
	(fprintf_frame): Adjust.
	(get_frame_func_if_available): Adjust.
	(frame_cleanup_after_sniffer): Adjust.

Change-Id: I50c6ebef6c0acb076e25c741f7f417bfd101d953
This commit is contained in:
Simon Marchi 2020-08-04 14:52:44 -04:00 committed by Simon Marchi
parent 6cfa9b59e2
commit fedfee8850
2 changed files with 18 additions and 8 deletions

View file

@ -1,3 +1,11 @@
2020-08-04 Simon Marchi <simon.marchi@efficios.com>
* frame.c (frame_info) <prev_func> <p>: Rename to status, change
type to cached_copy_status.
(fprintf_frame): Adjust.
(get_frame_func_if_available): Adjust.
(frame_cleanup_after_sniffer): Adjust.
2020-08-04 Mark Wielaard <mark@klomp.org> 2020-08-04 Mark Wielaard <mark@klomp.org>
* MAINTAINERS (Write After Approval): Update email address. * MAINTAINERS (Write After Approval): Update email address.

View file

@ -133,7 +133,7 @@ struct frame_info
/* Cached copy of the previous frame's resume address. */ /* Cached copy of the previous frame's resume address. */
struct { struct {
enum cached_copy_status status; cached_copy_status status;
/* Did VALUE require unmasking when being read. */ /* Did VALUE require unmasking when being read. */
bool masked; bool masked;
CORE_ADDR value; CORE_ADDR value;
@ -143,7 +143,7 @@ struct frame_info
struct struct
{ {
CORE_ADDR addr; CORE_ADDR addr;
int p; cached_copy_status status;
} prev_func; } prev_func;
/* This frame's ID. */ /* This frame's ID. */
@ -478,7 +478,7 @@ fprint_frame (struct ui_file *file, struct frame_info *fi)
fprintf_unfiltered (file, "<unknown>"); fprintf_unfiltered (file, "<unknown>");
fprintf_unfiltered (file, ","); fprintf_unfiltered (file, ",");
fprintf_unfiltered (file, "func="); fprintf_unfiltered (file, "func=");
if (fi->next != NULL && fi->next->prev_func.p) if (fi->next != NULL && fi->next->prev_func.status == CC_VALUE)
fprintf_unfiltered (file, "%s", hex_string (fi->next->prev_func.addr)); fprintf_unfiltered (file, "%s", hex_string (fi->next->prev_func.addr));
else else
fprintf_unfiltered (file, "<unknown>"); fprintf_unfiltered (file, "<unknown>");
@ -1008,7 +1008,7 @@ get_frame_func_if_available (struct frame_info *this_frame, CORE_ADDR *pc)
{ {
struct frame_info *next_frame = this_frame->next; struct frame_info *next_frame = this_frame->next;
if (!next_frame->prev_func.p) if (next_frame->prev_func.status == CC_UNKNOWN)
{ {
CORE_ADDR addr_in_block; CORE_ADDR addr_in_block;
@ -1016,7 +1016,7 @@ get_frame_func_if_available (struct frame_info *this_frame, CORE_ADDR *pc)
found. */ found. */
if (!get_frame_address_in_block_if_available (this_frame, &addr_in_block)) if (!get_frame_address_in_block_if_available (this_frame, &addr_in_block))
{ {
next_frame->prev_func.p = -1; next_frame->prev_func.status = CC_UNAVAILABLE;
if (frame_debug) if (frame_debug)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"{ get_frame_func (this_frame=%d)" "{ get_frame_func (this_frame=%d)"
@ -1025,7 +1025,7 @@ get_frame_func_if_available (struct frame_info *this_frame, CORE_ADDR *pc)
} }
else else
{ {
next_frame->prev_func.p = 1; next_frame->prev_func.status = CC_VALUE;
next_frame->prev_func.addr = get_pc_function_start (addr_in_block); next_frame->prev_func.addr = get_pc_function_start (addr_in_block);
if (frame_debug) if (frame_debug)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
@ -1035,13 +1035,15 @@ get_frame_func_if_available (struct frame_info *this_frame, CORE_ADDR *pc)
} }
} }
if (next_frame->prev_func.p < 0) if (next_frame->prev_func.status == CC_UNAVAILABLE)
{ {
*pc = -1; *pc = -1;
return 0; return 0;
} }
else else
{ {
gdb_assert (next_frame->prev_func.status == CC_VALUE);
*pc = next_frame->prev_func.addr; *pc = next_frame->prev_func.addr;
return 1; return 1;
} }
@ -2908,7 +2910,7 @@ frame_cleanup_after_sniffer (struct frame_info *frame)
The previous PC is independent of the unwinder, but the previous The previous PC is independent of the unwinder, but the previous
function is not (see get_frame_address_in_block). */ function is not (see get_frame_address_in_block). */
frame->prev_func.p = 0; frame->prev_func.status = CC_UNKNOWN;
frame->prev_func.addr = 0; frame->prev_func.addr = 0;
/* Discard the unwinder last, so that we can easily find it if an assertion /* Discard the unwinder last, so that we can easily find it if an assertion