]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[SFrame-V3] gas: sframe: use three states for location tracking
authorIndu Bhagat <indu.bhagat@oracle.com>
Fri, 16 Jan 2026 00:42:29 +0000 (16:42 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Fri, 16 Jan 2026 01:02:25 +0000 (17:02 -0800)
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 <jremus@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
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.

gas/gen-sframe.c
gas/gen-sframe.h

index ee002584ef95b332a7b393ca11d28a7f9f26d12a..58028ef7a38107e70d751c67488193e5611c2967 100644 (file)
@@ -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;
     }
index eff089f6a243db12df7fd3515eb06898379b332f..fe7f3961fc9231be47b6aaa7b64aff38f2f809ee 100644 (file)
       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)