From: Indu Bhagat <ibhagat@sourceware.org>
To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org
Subject: [binutils-gdb] libsframe: use uint8_t data type for FRE info related stubs
Date: Fri, 26 May 2023 06:57:44 +0000 (GMT) [thread overview]
Message-ID: <20230526065744.02C673858422@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e80578bea749c35ac9222bf86c112f408ce8a55b
commit e80578bea749c35ac9222bf86c112f408ce8a55b
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date: Thu May 25 23:43:45 2023 -0700
libsframe: use uint8_t data type for FRE info related stubs
libsframe/
* sframe.c: Use uint8_t for FRE offset count and FRE offset
size. Use uint8_t for FRE info word as well.
Diff:
---
libsframe/sframe.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index d65662484cb..a79d4de96da 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -112,20 +112,20 @@ sframe_get_hdr_size (sframe_header *sfh)
/* Access functions for frame row entry data. */
-static unsigned int
-sframe_fre_get_offset_count (unsigned char fre_info)
+static uint8_t
+sframe_fre_get_offset_count (uint8_t fre_info)
{
return SFRAME_V1_FRE_OFFSET_COUNT (fre_info);
}
-static unsigned int
-sframe_fre_get_offset_size (unsigned char fre_info)
+static uint8_t
+sframe_fre_get_offset_size (uint8_t fre_info)
{
return SFRAME_V1_FRE_OFFSET_SIZE (fre_info);
}
static bool
-sframe_get_fre_ra_mangled_p (unsigned char fre_info)
+sframe_get_fre_ra_mangled_p (uint8_t fre_info)
{
return SFRAME_V1_FRE_MANGLED_RA_P (fre_info);
}
@@ -237,8 +237,7 @@ flip_fre_start_address (char *fp, unsigned int fre_type)
}
static void
-flip_fre_stack_offsets (char *fp, unsigned char offset_size,
- unsigned char offset_cnt)
+flip_fre_stack_offsets (char *fp, uint8_t offset_size, uint8_t offset_cnt)
{
int j;
void *offsets = (void *)fp;
@@ -287,8 +286,8 @@ sframe_fre_start_addr_size (unsigned int fre_type)
static bool
sframe_fre_sanity_check_p (sframe_frame_row_entry *frep)
{
- unsigned int offset_size, offset_cnt;
- unsigned int fre_info;
+ uint8_t offset_size, offset_cnt;
+ uint8_t fre_info;
if (frep == NULL)
return false;
@@ -311,9 +310,9 @@ sframe_fre_sanity_check_p (sframe_frame_row_entry *frep)
/* Get FRE_INFO's offset size in bytes. */
static size_t
-sframe_fre_offset_bytes_size (unsigned char fre_info)
+sframe_fre_offset_bytes_size (uint8_t fre_info)
{
- unsigned int offset_size, offset_cnt;
+ uint8_t offset_size, offset_cnt;
offset_size = sframe_fre_get_offset_size (fre_info);
@@ -337,7 +336,7 @@ sframe_fre_entry_size (sframe_frame_row_entry *frep, unsigned int fre_type)
if (frep == NULL)
return 0;
- unsigned char fre_info = frep->fre_info;
+ uint8_t fre_info = frep->fre_info;
size_t addr_size = sframe_fre_start_addr_size (fre_type);
return (addr_size + sizeof (frep->fre_info)
@@ -347,8 +346,8 @@ sframe_fre_entry_size (sframe_frame_row_entry *frep, unsigned int fre_type)
static int
flip_fre (char *fp, unsigned int fre_type, size_t *fre_size)
{
- unsigned char fre_info;
- unsigned int offset_size, offset_cnt;
+ uint8_t fre_info;
+ uint8_t offset_size, offset_cnt;
size_t addr_size, fre_info_size = 0;
int err = 0;
@@ -361,13 +360,13 @@ flip_fre (char *fp, unsigned int fre_type, size_t *fre_size)
addr_size = sframe_fre_start_addr_size (fre_type);
fp += addr_size;
- /* FRE info is unsigned char. No need to flip. */
- fre_info = *(unsigned char*)fp;
+ /* FRE info is uint8_t. No need to flip. */
+ fre_info = *(uint8_t*)fp;
offset_size = sframe_fre_get_offset_size (fre_info);
offset_cnt = sframe_fre_get_offset_count (fre_info);
/* Advance the buffer pointer to where the stack offsets are. */
- fre_info_size = sizeof (unsigned char);
+ fre_info_size = sizeof (uint8_t);
fp += fre_info_size;
flip_fre_stack_offsets (fp, offset_size, offset_cnt);
@@ -500,7 +499,7 @@ fde_func (const void *p1, const void *p2)
static int32_t
sframe_get_fre_offset (sframe_frame_row_entry *fre, int idx, int *errp)
{
- int offset_cnt, offset_size;
+ uint8_t offset_cnt, offset_size;
if (fre == NULL || !sframe_fre_sanity_check_p (fre))
return sframe_set_errno (errp, SFRAME_ERR_FRE_INVAL);
@@ -606,7 +605,7 @@ sframe_fre_get_base_reg_id (sframe_frame_row_entry *fre, int *errp)
if (fre == NULL)
return sframe_set_errno (errp, SFRAME_ERR_FRE_INVAL);
- unsigned int fre_info = fre->fre_info;
+ uint8_t fre_info = fre->fre_info;
return SFRAME_V1_FRE_CFA_BASE_REG_ID (fre_info);
}
@@ -750,9 +749,9 @@ sframe_decode_fre (const char *fre_buf, sframe_frame_row_entry *fre,
sframe_decode_fre_start_address (fre_buf, &fre->fre_start_addr, fre_type);
addr_size = sframe_fre_start_addr_size (fre_type);
- fre->fre_info = *(unsigned char *)(fre_buf + addr_size);
+ fre->fre_info = *(uint8_t *)(fre_buf + addr_size);
/* Sanity check as the API works closely with the binary format. */
- sframe_assert (sizeof (fre->fre_info) == sizeof (unsigned char));
+ sframe_assert (sizeof (fre->fre_info) == sizeof (uint8_t));
/* Cleanup the space for fre_offsets first, then copy over the valid
bytes. */
reply other threads:[~2023-05-26 6:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230526065744.02C673858422@sourceware.org \
--to=ibhagat@sourceware.org \
--cc=bfd-cvs@sourceware.org \
--cc=gdb-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).