[COMMITTED] libsframe: fix sframe_find_fre for pltN entries

Message ID 20230609192822.2471957-1-indu.bhagat@oracle.com
State Accepted
Headers
Series [COMMITTED] libsframe: fix sframe_find_fre for pltN entries |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Indu Bhagat June 9, 2023, 7:28 p.m. UTC
  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 & 0xff) >= (pc & 0xff), etc.

This is buggy and needs correction.  The mask 0xff should be 0xf (to
work for a pltN entry of size say, 16 bytes).

At this time, the size of the pltN entry is implicitly assumed to be 16
bytes by libsframe.  In next version of the SFrame format, we can encode
this information explicitly in the SFrame FDE.

For now, we should fix the code to at least behave correctly for the
generated code and the generated SFrame stack trace information for the
pltN entries on x86_64.

libsframe/
	* sframe.c (sframe_find_fre): Correct the bitmask used for
	SFrame FDEs of type SFRAME_FDE_TYPE_PCMASK.
---
 libsframe/sframe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index a5f4a7f6519..7308a45ce88 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -1066,7 +1066,7 @@  sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc,
   /* FIXME - the bitmask should be picked per ABI or encoded in the format
      somehow. For AMD64, the pltN entry stub is 16 bytes. */
   if (fde_type == SFRAME_FDE_TYPE_PCMASK)
-    bitmask = 0xff;
+    bitmask = 0xf;
 
   fres = ctx->sfd_fres + fdep->sfde_func_start_fre_off;
   func_start_addr = fdep->sfde_func_start_address;