From: Indu Bhagat Date: Fri, 16 Jan 2026 00:42:29 +0000 (-0800) Subject: [SFrame-V3] gas: sframe: use three states for location tracking X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fd2ec7200ca7388d3c29ae5c542b91b55bbb30f;p=thirdparty%2Fbinutils-gdb.git [SFrame-V3] gas: sframe: use three states for location tracking Up until now, for SFrame stack trace data generation (for default FDE type), keeping two states sufficed to distinguish between the following cases: - the tracked entity is saved on a location on stack (identified by SFRAME_FRE_ELEM_LOC_STACK) - the tracked entity is in its designated register (identified by SFRAME_FRE_ELEM_LOC_REG). Soon though, we will start to generate a new FDE type SFRAME_FDE_TYPE_FLEX, where in addition to above: - the tracked entity may be saved in a temporary register - the tracked entity may be saved at a "non-standard" location, e.g., not a simple CFA+offset based location - and other cases To effectively distinguish between the various states (necessary to track for flex FDEs), define three states to track the location of each tracked entity: - SFRAME_FRE_ELEM_LOC_NONE: the entity is in its desginated location (e.g., in case of AMD64 where the RA is at fixed offset from CFA) - SFRAME_FRE_ELEM_LOC_REG: the entity is in a location based off a register - SFRAME_FRE_ELEM_LOC_STACK: the entity is in a location based off the CFA While at it, rather than asserting in sframe_xlate_do_offset (), reset the fp_reg state to SFRAME_FRE_REG_INVALID. This is in preparation for upcoming flex FDE generation patches. Co-Authored-by: Jens Remus Reviewed-by: Jens Remus gas/ * gen-sframe.c (sframe_xlate_do_offset): Reset other state. (sframe_xlate_do_same_value): Reset to SFRAME_FRE_ELEM_LOC_NONE. * gen-sframe.h (SFRAME_FRE_ELEM_LOC_REG): New definition. (SFRAME_FRE_ELEM_LOC_STACK): Likewise. (SFRAME_FRE_ELEM_LOC_NONE): Likewise. --- diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index ee002584ef9..58028ef7a38 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1243,8 +1243,8 @@ sframe_xlate_do_offset (struct sframe_xlate_ctx *xlate_ctx, /* Ignore SP reg, as it can be recovered from the CFA tracking info. */ if (cfi_insn->u.ri.reg == SFRAME_CFA_FP_REG) { - gas_assert (cur_fre->fp_reg == SFRAME_FRE_REG_INVALID); sframe_fre_set_fp_track (cur_fre, cfi_insn->u.ri.offset); + cur_fre->fp_reg = SFRAME_FRE_REG_INVALID; cur_fre->merge_candidate = false; } else if (sframe_ra_tracking_p () @@ -1864,14 +1864,14 @@ sframe_xlate_do_same_value (const struct sframe_xlate_ctx *xlate_ctx, if (sframe_ra_tracking_p () && cfi_insn->u.r == SFRAME_CFA_RA_REG) { - cur_fre->ra_loc = SFRAME_FRE_ELEM_LOC_REG; + cur_fre->ra_loc = SFRAME_FRE_ELEM_LOC_NONE; cur_fre->ra_offset = 0; cur_fre->ra_undefined_p = false; cur_fre->merge_candidate = false; } else if (cfi_insn->u.r == SFRAME_CFA_FP_REG) { - cur_fre->fp_loc = SFRAME_FRE_ELEM_LOC_REG; + cur_fre->fp_loc = SFRAME_FRE_ELEM_LOC_NONE; cur_fre->fp_offset = 0; cur_fre->merge_candidate = false; } diff --git a/gas/gen-sframe.h b/gas/gen-sframe.h index eff089f6a24..fe7f3961fc9 100644 --- a/gas/gen-sframe.h +++ b/gas/gen-sframe.h @@ -31,8 +31,14 @@ as_bad (format, __VA_ARGS__); \ } while (0) -#define SFRAME_FRE_ELEM_LOC_REG 0 -#define SFRAME_FRE_ELEM_LOC_STACK 1 +/* The entity is not tracked. */ +#define SFRAME_FRE_ELEM_LOC_NONE 0 +/* The location of the tracked entity is based on a register. May or may not + involve dereferencing. */ +#define SFRAME_FRE_ELEM_LOC_REG 1 +/* The location of the tracked entity is based on the CFA. In theory, may or + may not involve dereferencing. */ +#define SFRAME_FRE_ELEM_LOC_STACK 2 /* An invalid register number. */ #define SFRAME_FRE_REG_INVALID ((unsigned int)-1)