-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libunwind][nfc] Avoid type warning of debug printf #67390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Avoid type warning of debug printf since VE uses 64 bits SjLj.
@llvm/pr-subscribers-libunwind ChangesAvoid type warning of debug printf since VE uses 64 bits SjLj. Full diff: https://github.com/llvm/llvm-project/pull/67390.diff 1 Files Affected:
diff --git a/libunwind/src/Unwind-sjlj.c b/libunwind/src/Unwind-sjlj.c
index 4d9a02699cddd78..f24088a0e98ae99 100644
--- a/libunwind/src/Unwind-sjlj.c
+++ b/libunwind/src/Unwind-sjlj.c
@@ -42,12 +42,18 @@ struct _Unwind_FunctionContext {
// set by personality handler to be parameters passed to landing pad function
uint64_t resumeParameters[4];
+
+ // specify format for debug dump of resumeLocation and resumeParameters[]
+#define SJLJ_PRI_PTR PRIxPTR
#else
// set by calling function before registering to be the landing pad
uint32_t resumeLocation;
// set by personality handler to be parameters passed to landing pad function
uint32_t resumeParameters[4];
+
+ // specify format for debug dump of resumeLocation and resumeParameters[]
+#define SJLJ_PRI_PTR PRIuPTR
#endif
// set by calling function before registering
@@ -427,9 +433,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,
/// Called by personality handler during phase 2 to alter register values.
_LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
uintptr_t new_value) {
- _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%" PRIuPTR
- ")",
- (void *)context, index, new_value);
+ _LIBUNWIND_TRACE_API(
+ "_Unwind_SetGR(context=%p, reg=%d, value=0x%" SJLJ_PRI_PTR ")",
+ (void *)context, index, new_value);
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
ufc->resumeParameters[index] = new_value;
}
@@ -438,7 +444,7 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
/// Called by personality handler during phase 2 to get instruction pointer.
_LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
- _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIu32,
+ _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" SJLJ_PRI_PTR,
(void *)context, ufc->resumeLocation + 1);
return ufc->resumeLocation + 1;
}
@@ -451,7 +457,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
int *ipBefore) {
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
*ipBefore = 0;
- _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%" PRIu32,
+ _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%" SJLJ_PRI_PTR,
(void *)context, (void *)ipBefore,
ufc->resumeLocation + 1);
return ufc->resumeLocation + 1;
@@ -461,7 +467,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
/// Called by personality handler during phase 2 to alter instruction pointer.
_LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
uintptr_t new_value) {
- _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%" PRIuPTR ")",
+ _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%" SJLJ_PRI_PTR ")",
(void *)context, new_value);
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
ufc->resumeLocation = new_value - 1;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use %p instead of 0x% Pri*
and cast the uintptr_t
to void *
? That would avoid the need for the new macros.
Or alternatively use PRIxPTR unconditionally, using PRIuPTR with 0x-prefixed outputs is super confusing |
@arichardson Thank for your kind comment. I confused them already. I update my patch following your 2nd suggestion. |
Update the top comment to describe what I modify. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change LGTM assuming CI is also happy.
Change PRIu32 to PRIxPTR to avoid type warning of debug printf since VE uses 64 bits SjLj. I don't use PRIuPTR since the print message has 0x-prefix from the beginning. I also change related PRIuPTR to PRIxPTR since those uses 0x-prefix too.
Change PRIu32 to PRIxPTR to avoid type warning of debug printf since VE uses 64 bits SjLj. I don't use PRIuPTR since the print message has 0x-prefix from the beginning. I also change related PRIuPTR to PRIxPTR since those uses 0x-prefix too.