[PATCH 1/2] sframe: Add SFrame v3 decode support for regular FDEs
Jens Remus
jremus@linux.ibm.com
Fri Apr 17 15:59:10 GMT 2026
Hello Claudiu!
On 4/14/2026 2:23 PM, claudiu.zissulescu-ianculescu@oracle.com wrote:
> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>
> Add SFrame v3 format definitions and modify the backtrace routines to
> handle both v2 and v3 function descriptor layouts.
>
> The sframe stack trace backtracer now detects the outer most frame
> returning without error. Also, the decoder reads v3 index/attribute
> records, performs explicit bounds checks for FRE access, and uses
> int64_t PC/start-address handling for version-agnostic lookup.
Nice work!
> @@ -279,7 +400,11 @@ sframe_fre_check_range_p (sframe_decoder_ctx *dctx, uint32_t func_idx,
> /* For SFrame FDEs encoding information for repetitive pattern of insns,
> masking with the rep_block_size is necessary to find the matching FRE. */
> if (mask_p)
> + {
> + if (rep_block_size == 0)
> + return false;
> pc_offset = pc_offset % rep_block_size;
Nit: Indentation appears to be wrong.
> + }
>
> return (start_ip_offset <= pc_offset) && (end_ip_offset >= pc_offset);
> }
> diff --git a/sysdeps/generic/sframe.c b/sysdeps/generic/sframe.c
> @@ -117,6 +117,10 @@ __stacktrace_sframe (void **ra_lst, int count, frame *frame)
> return 0;
> }
>
> + /* A FRE with undefined RA indicates the outermost frame. */
> + if (SFRAME_V2_FRE_RA_UNDEFINED_P (frep->fre_info))
> + return i;
> +
Thanks for taking care of the RA undefined indication for outermost
frames!
> /* Get the CFA offset from the FRE. If offset is unavailable,
> sets err. */
> cfa_offset = __sframe_fre_get_cfa_offset (dctx, frep, &err);
> diff --git a/sysdeps/generic/sframe.h b/sysdeps/generic/sframe.h
> @@ -102,6 +107,7 @@ extern "C"
> #define SFRAME_ABI_AARCH64_ENDIAN_BIG 1 /* AARCH64 big endian. */
> #define SFRAME_ABI_AARCH64_ENDIAN_LITTLE 2 /* AARCH64 little endian. */
> #define SFRAME_ABI_AMD64_ENDIAN_LITTLE 3 /* AMD64 little endian. */
> +#define SFRAME_ABI_S390X_ENDIAN_BIG 4 /* s390x big endian. */
Would it make sene to leave that out for my s390 64-bit support patch to
add it?
> @@ -307,6 +418,25 @@ typedef struct sframe_fre_info
> fi
> Note that in AAPCS64, a frame record, if created, will save both FP and
> LR on stack.
> +
> + s390x:
> + offset1 (interpreted as CFA = BASE_REG + offset1)
> + if RA is being tracked
> + offset2 (interpreted as RA = CFA + offset2; an offset value of
> + SFRAME_FRE_RA_OFFSET_INVALID indicates a dummy padding RA offset
> + to represent FP without RA saved on stack)
> + if FP is being tracked
> + offset3 (intrepreted as FP = CFA + offset3)
> + fi
> + else
> + if FP is being tracked
> + offset2 (intrepreted as FP = CFA + offset2)
> + fi
> + fi
> + Note that in s390x, if a FP/RA is to be restored from a register, flex FDEs
> + are used in SFrame V3. In SFrame V2, default FDEs were used: the
> + least-significant bit of the offset was set to indicate that the encoded
> + value is a DWARF register number shifted to the left by 1.
Likewise?
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@linux.ibm.com
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the Libc-alpha
mailing list