* [PATCH 0/3] sframe: Cleanups an documentation improvement
@ 2025-02-03 13:57 Jens Remus
2025-02-03 13:57 ` [PATCH 1/3] gas: sframe: Use appropriate struct cfi_insn_data union members Jens Remus
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Jens Remus @ 2025-02-03 13:57 UTC (permalink / raw)
To: binutils, Indu Bhagat; +Cc: Jens Remus, Andreas Krebbel
Patch 1 cleans up the SFrame generation from CFI directives to use the
appropriate struct cfi_insn_data union members when accessing the CFI
instruction data.
Patch 2 skips SFrame FDE if .cfi_val_offset specifies the SP register
with a non-default value offset. That is a value offset which does not
match with the implicitly assumed rule to unwind the SP register from
the CFA (e.g. SP = CFA + 0 on AMD64, and AArch64).
Patch 3 clarifies the description of the SFrame FDE function start
address and SFrame FRE PC range start address fields. Especially that
the function start address in the FDE is an offset from SFrame section.
Regards,
Jens
Jens Remus (3):
gas: sframe: Use appropriate struct cfi_insn_data union members
gas: Skip SFrame FDE if .cfi_val_offset specifies non-default offset
doc: sframe: Clarify FDE/FRE function/range start address fields
gas/gen-sframe.c | 28 ++++++++++++++--------------
libsframe/doc/sframe-spec.texi | 10 ++++++----
2 files changed, 20 insertions(+), 18 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] gas: sframe: Use appropriate struct cfi_insn_data union members
2025-02-03 13:57 [PATCH 0/3] sframe: Cleanups an documentation improvement Jens Remus
@ 2025-02-03 13:57 ` Jens Remus
2025-02-03 13:57 ` [PATCH 2/3] gas: Skip SFrame FDE if .cfi_val_offset specifies non-default offset Jens Remus
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Jens Remus @ 2025-02-03 13:57 UTC (permalink / raw)
To: binutils, Indu Bhagat; +Cc: Jens Remus, Andreas Krebbel
Use the appropriate struct cfi_insn_data union members to access
fields when generating SFrame information from CFI directives.
gas/
* gen-sframe.c (sframe_xlate_do_def_cfa, sframe_xlate_do_offset,
sframe_xlate_do_val_offset): Access ri fields, as .cfi_def_cfa,
.cfi_offset, and .cfi_val_offset define a register and offset
value.
* (sframe_xlate_do_def_cfa_register): Access r field, as
.cfi_def_cfa_register defines a register.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
gas/gen-sframe.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
index 85d2f03a55c4..e7397e040c65 100644
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -1003,11 +1003,11 @@ sframe_xlate_do_def_cfa (struct sframe_xlate_ctx *xlate_ctx,
/* Define the current CFA rule to use the provided register and
offset. However, if the register is not FP/SP, skip creating
SFrame stack trace info for the function. */
- if (cfi_insn->u.r != SFRAME_CFA_SP_REG
- && cfi_insn->u.r != SFRAME_CFA_FP_REG)
+ if (cfi_insn->u.ri.reg != SFRAME_CFA_SP_REG
+ && cfi_insn->u.ri.reg != SFRAME_CFA_FP_REG)
{
as_warn (_("skipping SFrame FDE; non-SP/FP register %u in .cfi_def_cfa"),
- cfi_insn->u.r);
+ cfi_insn->u.ri.reg);
return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */
}
sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg);
@@ -1040,7 +1040,7 @@ sframe_xlate_do_def_cfa_register (struct sframe_xlate_ctx *xlate_ctx,
cfi_insn->u.r);
return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */
}
- sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg);
+ sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.r);
sframe_fre_set_cfa_offset (cur_fre, last_fre->cfa_offset);
cur_fre->merge_candidate = false;
@@ -1097,7 +1097,7 @@ sframe_xlate_do_offset (struct sframe_xlate_ctx *xlate_ctx,
/* Change the rule for the register indicated by the register number to
be the specified offset. */
/* Ignore SP reg, as it can be recovered from the CFA tracking info. */
- if (cfi_insn->u.r == SFRAME_CFA_FP_REG)
+ if (cfi_insn->u.ri.reg == SFRAME_CFA_FP_REG)
{
gas_assert (!cur_fre->base_reg);
sframe_fre_set_bp_track (cur_fre, cfi_insn->u.ri.offset);
@@ -1105,7 +1105,7 @@ sframe_xlate_do_offset (struct sframe_xlate_ctx *xlate_ctx,
}
#ifdef SFRAME_FRE_RA_TRACKING
else if (sframe_ra_tracking_p ()
- && cfi_insn->u.r == SFRAME_CFA_RA_REG)
+ && cfi_insn->u.ri.reg == SFRAME_CFA_RA_REG)
{
sframe_fre_set_ra_track (cur_fre, cfi_insn->u.ri.offset);
cur_fre->merge_candidate = false;
@@ -1127,15 +1127,15 @@ sframe_xlate_do_val_offset (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED,
register is not interesting (FP or RA reg), the current DW_CFA_val_offset
instruction can be safely skipped without sacrificing the asynchronicity of
stack trace information. */
- if (cfi_insn->u.r == SFRAME_CFA_FP_REG
+ if (cfi_insn->u.ri.reg == SFRAME_CFA_FP_REG
#ifdef SFRAME_FRE_RA_TRACKING
- || (sframe_ra_tracking_p () && cfi_insn->u.r == SFRAME_CFA_RA_REG)
+ || (sframe_ra_tracking_p () && cfi_insn->u.ri.reg == SFRAME_CFA_RA_REG)
#endif
/* Ignore SP reg, as it can be recovered from the CFA tracking info. */
)
{
as_warn (_("skipping SFrame FDE; %s register %u in .cfi_val_offset"),
- sframe_register_name (cfi_insn->u.r), cfi_insn->u.r);
+ sframe_register_name (cfi_insn->u.ri.reg), cfi_insn->u.ri.reg);
return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */
}
--
2.45.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] gas: Skip SFrame FDE if .cfi_val_offset specifies non-default offset
2025-02-03 13:57 [PATCH 0/3] sframe: Cleanups an documentation improvement Jens Remus
2025-02-03 13:57 ` [PATCH 1/3] gas: sframe: Use appropriate struct cfi_insn_data union members Jens Remus
@ 2025-02-03 13:57 ` Jens Remus
2025-02-03 13:57 ` [PATCH 3/3] doc: sframe: Clarify FDE/FRE function/range start address fields Jens Remus
2025-02-04 14:05 ` [PATCH 0/3] sframe: Cleanups an documentation improvement Indu Bhagat
3 siblings, 0 replies; 6+ messages in thread
From: Jens Remus @ 2025-02-03 13:57 UTC (permalink / raw)
To: binutils, Indu Bhagat; +Cc: Jens Remus, Andreas Krebbel
Unwinding of the stack pointer (SP) is performed using the assumed
default rule ".cfi_val_offset <SP-reg>, 0", so that SP unwinds as:
SP = CFA
Warn if the CFI directive .cfi_val_offset is encountered for the
SP register with a different offset.
gas/
* gen-sframe.c (sframe_xlate_do_val_offset): Skip SFrame FDE
if non-default SP value offset.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
gas/gen-sframe.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
index e7397e040c65..13478efab6b9 100644
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -1124,15 +1124,15 @@ sframe_xlate_do_val_offset (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED,
struct cfi_insn_data *cfi_insn)
{
/* Previous value of register is CFA + offset. However, if the specified
- register is not interesting (FP or RA reg), the current DW_CFA_val_offset
- instruction can be safely skipped without sacrificing the asynchronicity of
- stack trace information. */
+ register is not interesting (SP, FP, or RA reg), the current
+ DW_CFA_val_offset instruction can be safely skipped without sacrificing
+ the asynchronicity of stack trace information. */
if (cfi_insn->u.ri.reg == SFRAME_CFA_FP_REG
#ifdef SFRAME_FRE_RA_TRACKING
|| (sframe_ra_tracking_p () && cfi_insn->u.ri.reg == SFRAME_CFA_RA_REG)
#endif
- /* Ignore SP reg, as it can be recovered from the CFA tracking info. */
- )
+ /* Ignore SP reg, if offset matches assumed default rule. */
+ || (cfi_insn->u.ri.reg == SFRAME_CFA_SP_REG && cfi_insn->u.ri.offset != 0))
{
as_warn (_("skipping SFrame FDE; %s register %u in .cfi_val_offset"),
sframe_register_name (cfi_insn->u.ri.reg), cfi_insn->u.ri.reg);
--
2.45.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] doc: sframe: Clarify FDE/FRE function/range start address fields
2025-02-03 13:57 [PATCH 0/3] sframe: Cleanups an documentation improvement Jens Remus
2025-02-03 13:57 ` [PATCH 1/3] gas: sframe: Use appropriate struct cfi_insn_data union members Jens Remus
2025-02-03 13:57 ` [PATCH 2/3] gas: Skip SFrame FDE if .cfi_val_offset specifies non-default offset Jens Remus
@ 2025-02-03 13:57 ` Jens Remus
2025-02-04 14:05 ` [PATCH 0/3] sframe: Cleanups an documentation improvement Indu Bhagat
3 siblings, 0 replies; 6+ messages in thread
From: Jens Remus @ 2025-02-03 13:57 UTC (permalink / raw)
To: binutils, Indu Bhagat; +Cc: Jens Remus, Andreas Krebbel
The function start address in a SFrame FDE (sfde_func_start_address)
is encoded as a signed offset to the function start address from the
SFrame section.
The PC range start address in a SFrame FRE (sfre_start_address) is
encoded as an unsigned offset to the range from the function start
address.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
libsframe/doc/sframe-spec.texi | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libsframe/doc/sframe-spec.texi b/libsframe/doc/sframe-spec.texi
index eb706901d7fd..ae115705ca73 100644
--- a/libsframe/doc/sframe-spec.texi
+++ b/libsframe/doc/sframe-spec.texi
@@ -459,7 +459,9 @@ Following table describes each component of the SFrame FDE structure:
@tab @code{int32_t}
@tab @code{sfde_func_start_address}
@tab Signed 32-bit integral field denoting the virtual memory address of the
-described function.
+described function, for which the SFrame FDE applies. The value encoded in
+the @code{sfde_func_start_address} field is the offset in bytes of the
+function's start address, from the SFrame section.
@item 0x04
@tab @code{uint32_t}
@@ -684,10 +686,10 @@ serializing and deserializing entities, if unaligned accesses need to be
avoided.
@code{sfre_start_address} is an unsigned 8-bit/16-bit/32-bit integral field
-identifies the start address of the range of program counters, for which the
+denoting the start address of a range of program counters, for which the
SFrame FRE applies. The value encoded in the @code{sfre_start_address} field
-is the offset in bytes of the start address of the SFrame FRE, from the start
-address of the function.
+is the offset in bytes of the range's start address, from the start address
+of the function.
Further SFrame FRE types may be added in future.
--
2.45.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] sframe: Cleanups an documentation improvement
2025-02-03 13:57 [PATCH 0/3] sframe: Cleanups an documentation improvement Jens Remus
` (2 preceding siblings ...)
2025-02-03 13:57 ` [PATCH 3/3] doc: sframe: Clarify FDE/FRE function/range start address fields Jens Remus
@ 2025-02-04 14:05 ` Indu Bhagat
2025-02-04 14:16 ` Jens Remus
3 siblings, 1 reply; 6+ messages in thread
From: Indu Bhagat @ 2025-02-04 14:05 UTC (permalink / raw)
To: Jens Remus, binutils; +Cc: Andreas Krebbel
On 2/3/25 5:57 AM, Jens Remus wrote:
> Patch 1 cleans up the SFrame generation from CFI directives to use the
> appropriate struct cfi_insn_data union members when accessing the CFI
> instruction data.
>
> Patch 2 skips SFrame FDE if .cfi_val_offset specifies the SP register
> with a non-default value offset. That is a value offset which does not
> match with the implicitly assumed rule to unwind the SP register from
> the CFA (e.g. SP = CFA + 0 on AMD64, and AArch64).
>
> Patch 3 clarifies the description of the SFrame FDE function start
> address and SFrame FRE PC range start address fields. Especially that
> the function start address in the FDE is an offset from SFrame section.
>
> Regards,
> Jens
>
> Jens Remus (3):
> gas: sframe: Use appropriate struct cfi_insn_data union members
> gas: Skip SFrame FDE if .cfi_val_offset specifies non-default offset
> doc: sframe: Clarify FDE/FRE function/range start address fields
>
Reviewed-by: Indu Bhagat <indu.bhagat@oracle.com>
Thanks
Indu
> gas/gen-sframe.c | 28 ++++++++++++++--------------
> libsframe/doc/sframe-spec.texi | 10 ++++++----
> 2 files changed, 20 insertions(+), 18 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] sframe: Cleanups an documentation improvement
2025-02-04 14:05 ` [PATCH 0/3] sframe: Cleanups an documentation improvement Indu Bhagat
@ 2025-02-04 14:16 ` Jens Remus
0 siblings, 0 replies; 6+ messages in thread
From: Jens Remus @ 2025-02-04 14:16 UTC (permalink / raw)
To: Indu Bhagat, binutils; +Cc: Andreas Krebbel
On 04.02.2025 15:05, Indu Bhagat wrote:
> On 2/3/25 5:57 AM, Jens Remus wrote:
>> Patch 1 cleans up the SFrame generation from CFI directives to use the
>> appropriate struct cfi_insn_data union members when accessing the CFI
>> instruction data.
>>
>> Patch 2 skips SFrame FDE if .cfi_val_offset specifies the SP register
>> with a non-default value offset. That is a value offset which does not
>> match with the implicitly assumed rule to unwind the SP register from
>> the CFA (e.g. SP = CFA + 0 on AMD64, and AArch64).
>>
>> Patch 3 clarifies the description of the SFrame FDE function start
>> address and SFrame FRE PC range start address fields. Especially that
>> the function start address in the FDE is an offset from SFrame section.
...
>> Jens Remus (3):
>> gas: sframe: Use appropriate struct cfi_insn_data union members
>> gas: Skip SFrame FDE if .cfi_val_offset specifies non-default offset
>> doc: sframe: Clarify FDE/FRE function/range start address fields
>>
>
> Reviewed-by: Indu Bhagat <indu.bhagat@oracle.com>
...
>> gas/gen-sframe.c | 28 ++++++++++++++--------------
>> libsframe/doc/sframe-spec.texi | 10 ++++++----
>> 2 files changed, 20 insertions(+), 18 deletions(-)
Thanks! Committed to mainline.
Regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-04 14:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-03 13:57 [PATCH 0/3] sframe: Cleanups an documentation improvement Jens Remus
2025-02-03 13:57 ` [PATCH 1/3] gas: sframe: Use appropriate struct cfi_insn_data union members Jens Remus
2025-02-03 13:57 ` [PATCH 2/3] gas: Skip SFrame FDE if .cfi_val_offset specifies non-default offset Jens Remus
2025-02-03 13:57 ` [PATCH 3/3] doc: sframe: Clarify FDE/FRE function/range start address fields Jens Remus
2025-02-04 14:05 ` [PATCH 0/3] sframe: Cleanups an documentation improvement Indu Bhagat
2025-02-04 14:16 ` Jens Remus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).