diff options
author | Indu Bhagat <indu.bhagat@oracle.com> | 2023-06-29 11:03:32 -0700 |
---|---|---|
committer | Indu Bhagat <indu.bhagat@oracle.com> | 2023-06-29 11:03:32 -0700 |
commit | 3169b734cf07ec8800436b2c5298897aa993d2be (patch) | |
tree | 8bbea74563363a576b3f2fbb34e512c096880f46 /include | |
parent | b7b6f36275d5ff6a9e2bf679a5e3d354e531648a (diff) | |
download | gdb-3169b734cf07ec8800436b2c5298897aa993d2be.zip gdb-3169b734cf07ec8800436b2c5298897aa993d2be.tar.gz gdb-3169b734cf07ec8800436b2c5298897aa993d2be.tar.bz2 |
libsframe: fix sframe_find_fre for pltN entries
For a toy application on x86_64, for example, following is the SFrame
stack trace information for the 3 pltN entries of 16 bytes each:
func idx [1]: pc = 0x401030, size = 48 bytes
STARTPC[m] CFA FP RA
0000000000000000 sp+8 u u
000000000000000b sp+16 u u
The data in first column is the start_ip_offset. Also note that the FDE
is of type SFRAME_FDE_TYPE_PCMASK (denoted by the [m] on LHS).
Where each pltN (note: excluding plt0 entry) entry looks like:
401030: jmp *0x2fca(%rip)
401036: push $0x0
40103b: jmp 401020<_init+0x20>
401040: jmp *0x2fc2(%rip)
401046: push $0x1
40104b: jmp 401020<_init+0x20>
401050: jmp *0x2fba(%rip)
401056: push $0x2
40105b: jmp 401020<_init+0x20>
Now, to find SFrame stack trace information from an FDE of type
SFRAME_FDE_TYPE_PCMASK, sframe_find_fre () was doing an operation
like,
(start_ip_offset & 0xf) >= (pc & 0xf)
This works for pltN entry of size, say, less than 16 bytes. But if the
pltN entries or similar code stubs (for which SFrame FDE of type
SFRAME_FDE_TYPE_PCMASK may be used), evolve to be of size > 16 bytes,
this will cease to work.
To match the range covered by the SFrame FRE, one should instead perform
a modulo operation. The constant for the modulo operation must be the
size of the pltN entry. Further, this constant should ideally be
encoded in the format, as it may be different for each ABI.
In SFrame Version 2 of the format, we will move towards encoding it
explicitly in the SFrame FDE. For now, fix up the logic to at least
move towards modulo operation.
libsframe/
* sframe.c (sframe_fre_check_range_p): New definition.
(sframe_find_fre): Refactor a bit and use the new definition
above.
include/
* sframe.h (SFRAME_FDE_TYPE_PCMASK): Update comment.
libsframe/doc/
* sframe-spec.texi: Fix the text for SFRAME_FDE_TYPE_PCMASK FDE
type.
Diffstat (limited to 'include')
-rw-r--r-- | include/sframe.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/sframe.h b/include/sframe.h index c3dbb3a..cdf275f 100644 --- a/include/sframe.h +++ b/include/sframe.h @@ -117,8 +117,8 @@ extern "C" /* Unwinders perform a (PC >= FRE_START_ADDR) to look up a matching FRE. */ #define SFRAME_FDE_TYPE_PCINC 0 -/* Unwinders perform a (PC & FRE_START_ADDR_AS_MASK >= FRE_START_ADDR_AS_MASK) - to look up a matching FRE. */ +/* Unwinders perform a (PC % REP_BLOCK_SIZE >= FRE_START_ADDR) to look up a + matching FRE. */ #define SFRAME_FDE_TYPE_PCMASK 1 typedef struct sframe_preamble |