From 3e3e792a2931b973d5c9bc4fa79168dec8ab7730 Mon Sep 17 00:00:00 2001 From: Indu Bhagat Date: Thu, 2 Feb 2023 00:48:59 -0800 Subject: [PATCH] gas: use "stack trace" instead of "unwind" for SFrame SFrame format is meant for generating stack traces only. gas/ * as.c: Replace the use of "unwind" with "stack trace". * config/tc-aarch64.c: Likewise. * config/tc-aarch64.h: Likewise. * config/tc-i386.c: Likewise. * config/tc-i386.h: Likewise. * gen-sframe.c: Likewise. * gen-sframe.h: Likewise. * testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s: Likewise. * testsuite/gas/cfi-sframe/cfi-sframe-common-8.s: Likewise. * testsuite/gas/cfi-sframe/common-empty-2.s: Likewise. * testsuite/gas/cfi-sframe/common-empty-3.s: Likewise. --- gas/as.c | 2 +- gas/config/tc-aarch64.c | 4 +-- gas/config/tc-aarch64.h | 8 +++--- gas/config/tc-i386.c | 4 +-- gas/config/tc-i386.h | 6 ++-- gas/gen-sframe.c | 28 ++++++++++--------- gas/gen-sframe.h | 2 +- .../gas/cfi-sframe/cfi-sframe-aarch64-2.s | 6 ++-- .../gas/cfi-sframe/cfi-sframe-common-8.s | 4 +-- gas/testsuite/gas/cfi-sframe/common-empty-2.s | 2 +- gas/testsuite/gas/cfi-sframe/common-empty-3.s | 2 +- 11 files changed, 35 insertions(+), 33 deletions(-) diff --git a/gas/as.c b/gas/as.c index 602ed3b5f79..f548294c3dc 100644 --- a/gas/as.c +++ b/gas/as.c @@ -317,7 +317,7 @@ Options:\n\ fprintf (stream, _("\ generate GNU Build notes if none are present in the input\n")); fprintf (stream, _("\ - --gsframe generate SFrame unwind info\n")); + --gsframe generate SFrame stack trace information\n")); #endif /* OBJ_ELF */ fprintf (stream, _("\ diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 2aeab6f958a..980710e8992 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -76,7 +76,7 @@ enum aarch64_abi_type }; unsigned int aarch64_sframe_cfa_sp_reg; -/* The other CFA base register for SFrame unwind info. */ +/* The other CFA base register for SFrame stack trace info. */ unsigned int aarch64_sframe_cfa_fp_reg; unsigned int aarch64_sframe_cfa_ra_reg; @@ -8474,7 +8474,7 @@ aarch64_init_frag (fragS * fragP, int max_chars) } } -/* Whether SFrame unwind info is supported. */ +/* Whether SFrame stack trace info is supported. */ bool aarch64_support_sframe_p (void) diff --git a/gas/config/tc-aarch64.h b/gas/config/tc-aarch64.h index 134c1f87b4f..f11d04826c3 100644 --- a/gas/config/tc-aarch64.h +++ b/gas/config/tc-aarch64.h @@ -263,19 +263,19 @@ extern void aarch64_after_parse_args (void); #ifdef OBJ_ELF -/* Whether SFrame unwind info is supported. */ +/* Whether SFrame stack trace info is supported. */ extern bool aarch64_support_sframe_p (void); #define support_sframe_p aarch64_support_sframe_p -/* The stack-pointer register number for SFrame unwind info. */ +/* The stack-pointer register number for SFrame stack trace info. */ extern unsigned int aarch64_sframe_cfa_sp_reg; #define SFRAME_CFA_SP_REG aarch64_sframe_cfa_sp_reg -/* The base-pointer register number for CFA unwind info. */ +/* The base-pointer register number for CFA stack trace info. */ extern unsigned int aarch64_sframe_cfa_fp_reg; #define SFRAME_CFA_FP_REG aarch64_sframe_cfa_fp_reg -/* The return address register number for CFA unwind info. */ +/* The return address register number for CFA stack trace info. */ extern unsigned int aarch64_sframe_cfa_ra_reg; #define SFRAME_CFA_RA_REG aarch64_sframe_cfa_ra_reg diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index e1f8f65f90b..438180cf4e8 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -607,7 +607,7 @@ static int use_big_obj = 0; static int shared = 0; unsigned int x86_sframe_cfa_sp_reg; -/* The other CFA base register for SFrame unwind info. */ +/* The other CFA base register for SFrame stack trace info. */ unsigned int x86_sframe_cfa_fp_reg; unsigned int x86_sframe_cfa_ra_reg; @@ -9285,7 +9285,7 @@ x86_cleanup (void) bool x86_support_sframe_p (void) { - /* At this time, SFrame unwind is supported for AMD64 ABI only. */ + /* At this time, SFrame stack trace is supported for AMD64 ABI only. */ return (x86_elf_abi == X86_64_ABI); } diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 49d2d25a7a6..9247cdeab8b 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -363,15 +363,15 @@ extern bfd_vma x86_64_section_letter (int, const char **); extern void x86_cleanup (void); #define md_cleanup() x86_cleanup () -/* Whether SFrame unwind info is supported. */ +/* Whether SFrame stack trace info is supported. */ extern bool x86_support_sframe_p (void); #define support_sframe_p x86_support_sframe_p -/* The stack-pointer register number for SFrame unwind info. */ +/* The stack-pointer register number for SFrame stack trace info. */ extern unsigned int x86_sframe_cfa_sp_reg; #define SFRAME_CFA_SP_REG x86_sframe_cfa_sp_reg -/* The frame-pointer register number for CFA unwind info. */ +/* The frame-pointer register number for SFrame stack trace info. */ extern unsigned int x86_sframe_cfa_fp_reg; #define SFRAME_CFA_FP_REG x86_sframe_cfa_fp_reg diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index d6961f893a6..c5470596d14 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -33,7 +33,7 @@ /* Whether frame row entries track RA. - A target may not need return address tracking for stack unwinding. If it + A target may not need return address tracking for stack tracing. If it does need the same, SFRAME_CFA_RA_REG must be defined with the return address register number. */ @@ -892,7 +892,7 @@ sframe_xlate_ctx_add_fre (struct sframe_xlate_ctx *xlate_ctx, xlate_ctx->num_xlate_fres++; } -/* A SFrame Frame Row Entry is self-sufficient in terms of unwind information +/* A SFrame Frame Row Entry is self-sufficient in terms of stack tracing info for a given PC. It contains information assimilated from multiple CFI instructions, and hence, a new SFrame FRE is initialized with the data from the previous known FRE, if any. @@ -1024,7 +1024,7 @@ sframe_xlate_do_def_cfa_offset (struct sframe_xlate_ctx *xlate_ctx, gas_assert (cur_fre); /* Define the current CFA rule to use the provided offset (but to keep the old register). However, if the old register is not FP/SP, - skip creating SFrame unwind info for the function. */ + skip creating SFrame stack trace info for the function. */ if ((cur_fre->cfa_base_reg == SFRAME_CFA_FP_REG) || (cur_fre->cfa_base_reg == SFRAME_CFA_SP_REG)) { @@ -1081,7 +1081,7 @@ sframe_xlate_do_val_offset (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, /* 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 asynchonicity of - unwind information. */ + stack trace information. */ if (cfi_insn->u.r == SFRAME_CFA_FP_REG) return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ #ifdef SFRAME_FRE_RA_TRACKING @@ -1103,8 +1103,8 @@ sframe_xlate_do_remember_state (struct sframe_xlate_ctx *xlate_ctx) struct sframe_row_entry *last_fre = xlate_ctx->last_fre; /* If there is no FRE state to remember, nothing to do here. Return - early with non-zero error code, this will cause no SFrame unwind info - for the function involved. */ + early with non-zero error code, this will cause no SFrame stack trace + info for the function involved. */ if (!last_fre) return SFRAME_XLATE_ERR_INVAL; @@ -1248,7 +1248,7 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx, default: { /* Other CFI opcodes are not processed at this time. - These do not impact the coverage of the basic stack unwinding + These do not impact the coverage of the basic stack tracing information as conveyed in the SFrame format. - DW_CFA_register, - ... @@ -1285,7 +1285,7 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, err = sframe_do_cfi_insn (xlate_ctx, cfi_insn); if (err != SFRAME_XLATE_OK) { - /* Skip generating SFrame unwind info for the function if any + /* Skip generating SFrame stack trace info for the function if any offending CFI is encountered by sframe_do_cfi_insn (). */ return err; /* Return the error code. */ } @@ -1309,10 +1309,11 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, return SFRAME_XLATE_OK; } -/* Create SFrame unwind info for all functions. +/* Create SFrame stack trace info for all functions. - This function consumes the already generated FDEs (by dw2gencfi) and - generates unwind data in SFrame format. */ + This function consumes the already generated DWARF FDEs (by dw2gencfi) and + generates data which is later emitted as stack trace information encoded in + the SFrame format. */ static void create_sframe_all (void) @@ -1330,7 +1331,8 @@ create_sframe_all (void) /* Process and link SFrame FDEs if no error. Also skip adding an SFrame FDE if it does not contain any SFrame FREs. There is little use of an - SFrame FDE if there is no unwind information about the function. */ + SFrame FDE if there is no stack tracing information for the + function. */ int err = sframe_do_fde (xlate_ctx, dw_fde); if (err || xlate_ctx->num_xlate_fres == 0) { @@ -1355,7 +1357,7 @@ output_sframe (segT sframe_seg) /* Setup the version specific access functions. */ sframe_set_version (SFRAME_VERSION_1); - /* Process all fdes and create SFrame unwind information. */ + /* Process all fdes and create SFrame stack trace information. */ create_sframe_all (); output_sframe_internal (); diff --git a/gas/gen-sframe.h b/gas/gen-sframe.h index 77630255e8b..0a0b3658302 100644 --- a/gas/gen-sframe.h +++ b/gas/gen-sframe.h @@ -149,7 +149,7 @@ struct sframe_version_ops unsigned char (*set_func_info) (unsigned int, unsigned int, unsigned int); }; -/* Generate SFrame unwind info and prepare contents for the output. +/* Generate SFrame stack trace info and prepare contents for the output. outout_sframe () is called at the end of file. */ extern void output_sframe (segT sframe_seg); diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s index 8106c937b39..03ae313d620 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s @@ -2,9 +2,9 @@ ## main idea behind this is to use the unused bits in the pointer values. ## Each pointer is patched with a PAC before writing to memory, and is verified ## before using it. -## When the pointers are mangled, the unwinder needs to know so it can mask off -## the PAC from the pointer value to recover the return address, and -## conversely, skip doing so if the pointers are not mangled. +## When the pointers are mangled, the stack trace generator needs to know so it +## can mask off the PAC from the pointer value to recover the return address, +## and conversely, skip doing so if the pointers are not mangled. ## ## .cfi_negate_ra_state CFI directive is used to convey this information. ## diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.s index f2083e6a106..50c57c9611e 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.s +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.s @@ -1,8 +1,8 @@ ## cfi_val_offset when used with "not interesting" registers (from the ## perspective of SFrame section, non FP/RA registers are not ## interesting) does not affect the asynchronicity of the SFrame -## unwind information. Such CFI directives can be skipped for SFrame -## unwind info generation. +## stack trace information. Such CFI directives can be skipped for SFrame +## stack trace info generation. .cfi_startproc .long 0 .cfi_def_cfa_offset 16 diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-2.s b/gas/testsuite/gas/cfi-sframe/common-empty-2.s index 146c53de785..53bb8c0ce9b 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-2.s +++ b/gas/testsuite/gas/cfi-sframe/common-empty-2.s @@ -1,5 +1,5 @@ ## CFA register is not defined to be SP/FP. -## No SFrame unwind info for this function will be generated. +## No SFrame stack trace info for this function will be generated. .cfi_startproc simple .long 0 .long 0 diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-3.s b/gas/testsuite/gas/cfi-sframe/common-empty-3.s index 982fe0c851d..cd58499619d 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-3.s +++ b/gas/testsuite/gas/cfi-sframe/common-empty-3.s @@ -1,5 +1,5 @@ ## The return column is not the default value. -## No SFrame unwind info for this function will be generated. +## No SFrame stack trace info for this function will be generated. .cfi_startproc .cfi_return_column 0 .long 0 -- 2.30.2