aboutsummaryrefslogtreecommitdiff
path: root/libsframe
diff options
context:
space:
mode:
authorIndu Bhagat <indu.bhagat@oracle.com>2023-05-25 23:44:02 -0700
committerIndu Bhagat <indu.bhagat@oracle.com>2023-05-25 23:44:02 -0700
commit812d868850126d8e791795c7e248ffbf580925f6 (patch)
treea7ce82476f432ae6f29a5dabf3767a997bd1c1b6 /libsframe
parente80578bea749c35ac9222bf86c112f408ce8a55b (diff)
downloadgdb-812d868850126d8e791795c7e248ffbf580925f6.zip
gdb-812d868850126d8e791795c7e248ffbf580925f6.tar.gz
gdb-812d868850126d8e791795c7e248ffbf580925f6.tar.bz2
libsframe: use const char * consistently for immutable FRE buffers
libsframe/ * sframe.c (sframe_decode_fre): Use const char * datatype when handling buffer containing the FREs. (sframe_fre_get_end_ip_offset): Likewise. (sframe_find_fre): Likewise. (sframe_decoder_get_fre): Likewise.
Diffstat (limited to 'libsframe')
-rw-r--r--libsframe/sframe.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index a79d4de..72b2213 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -733,11 +733,10 @@ sframe_decode_fre_start_address (const char *fre_buf,
static int
sframe_decode_fre (const char *fre_buf, sframe_frame_row_entry *fre,
- unsigned int fre_type,
- size_t *esz)
+ unsigned int fre_type, size_t *esz)
{
int err = 0;
- void *stack_offsets = NULL;
+ const char *stack_offsets = NULL;
size_t stack_offsets_sz;
size_t addr_size;
size_t fre_size;
@@ -758,7 +757,7 @@ sframe_decode_fre (const char *fre_buf, sframe_frame_row_entry *fre,
memset (fre->fre_offsets, 0, MAX_OFFSET_BYTES);
/* Get offsets size. */
stack_offsets_sz = sframe_fre_offset_bytes_size (fre->fre_info);
- stack_offsets = (unsigned char *)fre_buf + addr_size + sizeof (fre->fre_info);
+ stack_offsets = fre_buf + addr_size + sizeof (fre->fre_info);
memcpy (fre->fre_offsets, stack_offsets, stack_offsets_sz);
/* The FRE has been decoded. Use it to perform one last sanity check. */
@@ -991,7 +990,7 @@ sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc,
sframe_func_desc_entry *fdep;
uint32_t start_address, i;
sframe_frame_row_entry cur_fre, next_fre;
- unsigned char *sp;
+ const char *fres;
unsigned int fre_type, fde_type;
size_t esz;
int err = 0;
@@ -1022,10 +1021,10 @@ sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc,
if (fde_type == SFRAME_FDE_TYPE_PCMASK)
bitmask = 0xff;
- sp = (unsigned char *) ctx->sfd_fres + fdep->sfde_func_start_fre_off;
+ fres = ctx->sfd_fres + fdep->sfde_func_start_fre_off;
for (i = 0; i < fdep->sfde_func_num_fres; i++)
{
- err = sframe_decode_fre ((const char *)sp, &next_fre, fre_type, &esz);
+ err = sframe_decode_fre (fres, &next_fre, fre_type, &esz);
start_address = next_fre.fre_start_addr;
if (((fdep->sfde_func_start_address
@@ -1037,8 +1036,7 @@ sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc,
if (i < fdep->sfde_func_num_fres - 1)
{
sp += esz;
- err = sframe_decode_fre ((const char*)sp, &next_fre,
- fre_type, &esz);
+ err = sframe_decode_fre (fres, &next_fre, fre_type, &esz);
/* Sanity check the next FRE. */
if (!sframe_fre_sanity_check_p (&next_fre))
@@ -1141,7 +1139,7 @@ sframe_decoder_get_fre (sframe_decoder_ctx *ctx,
{
sframe_func_desc_entry *fdep;
sframe_frame_row_entry ifre;
- unsigned char *sp;
+ const char *fres;
uint32_t i;
unsigned int fre_type;
size_t esz = 0;
@@ -1158,11 +1156,11 @@ sframe_decoder_get_fre (sframe_decoder_ctx *ctx,
fre_type = sframe_get_fre_type (fdep);
/* Now scan the FRE entries. */
- sp = (unsigned char *) ctx->sfd_fres + fdep->sfde_func_start_fre_off;
+ fres = ctx->sfd_fres + fdep->sfde_func_start_fre_off;
for (i = 0; i < fdep->sfde_func_num_fres; i++)
{
/* Decode the FRE at the current position. Return it if valid. */
- err = sframe_decode_fre ((const char *)sp, &ifre, fre_type, &esz);
+ err = sframe_decode_fre (fres, &ifre, fre_type, &esz);
if (i == fre_idx)
{
if (!sframe_fre_sanity_check_p (&ifre))
@@ -1179,7 +1177,7 @@ sframe_decoder_get_fre (sframe_decoder_ctx *ctx,
return 0;
}
/* Next FRE. */
- sp += esz;
+ fres += esz;
}
return sframe_set_errno (&err, SFRAME_ERR_FDE_NOTFOUND);