Repository navigation
Conversation
|
Are the errors actual locations where you're using 64-bit variables improperly in traces? |
@paulstelian97 yes, you should be able to see that in CI logs |
|
I assume you can add the fixes for those cases (in most cases I think a cast to (uint32_t) will suffice? ) in this same PR, or would it be a better idea to separate it? |
@paulstelian97 exactly, let's see how many were not included in my test configuration |
|
Build failed for ARM (i.MX8*) in src/drivers/imx/interrupt.c::irq_handler() at @dbaluta as far as I understand ARM doesn't have a magic bullet to make 64-bit tracing work, does it? So this has to be fixed too? |
Yes. @paulstelian97 care to help when you have some time. I'm currently in vacation and getting back on September, 14. |
|
Oh yeah, forgot about that one. I'll see it tomorrow, but basically I'd just fetch that into a 64-bit variable and print two hex parameters which are the 32-bit halves. It was broken (always showing zeros) before anyway. |
@dbaluta @paulstelian97 I've added a fix for that to the patch too |
paulstelian97
left a comment
There was a problem hiding this comment.
What helps you to not get build errors when passing pointers to traces? I can't seem to identify the spot that fixes it...
SOF tracing can only handle up to 32-bit long values, attempts to trace 64-bit values produce unpredictable results. Fix such cases by making sure values are within range and casting them to 32 bits. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
paulstelian97
left a comment
There was a problem hiding this comment.
From my point of view this looks good. Do handle Liam's comments as I agree.
|
SOFCI TEST |
Currently SOF tracing only supports up to 32 bit arguments, using it with 64-bit arguments produces unpredictable results. Add compile- time checks to make sure all arguments are of correct size. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The PP_NARG() macro can only handle integer type arguments, use META_COUNT_VARAGS_BEFORE_COMPILE() instead to avoid having to cast pointer types to integers. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
| #define trace_check_size_uint32_0() do { } while (0) | ||
|
|
||
| #define trace_check_size_uint32_1(a) do { \ | ||
| STATIC_ASSERT(sizeof(a) <= sizeof(uint32_t), \ | ||
| trace_parameter_too_large); \ | ||
| } while (0) | ||
|
|
||
| #define trace_check_size_uint32_2(a, b) do { \ | ||
| trace_check_size_uint32_1(a); \ | ||
| trace_check_size_uint32_1(b); \ | ||
| } while (0) | ||
|
|
||
| #define trace_check_size_uint32_3(a, b, c) do { \ | ||
| trace_check_size_uint32_1(a); \ | ||
| trace_check_size_uint32_1(b); \ | ||
| trace_check_size_uint32_1(c); \ | ||
| } while (0) | ||
|
|
||
| #define trace_check_size_uint32_4(a, b, c, d) do { \ | ||
| trace_check_size_uint32_1(a); \ | ||
| trace_check_size_uint32_1(b); \ | ||
| trace_check_size_uint32_1(c); \ | ||
| trace_check_size_uint32_1(d); \ | ||
| } while (0) | ||
|
|
||
| #define trace_check_args(...) META_CONCAT(trace_check_size_uint32_, \ | ||
| META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__))(__VA_ARGS__) | ||
|
|
There was a problem hiding this comment.
@lyakh maybe we would like to use META_MAP(), then trace_check_size_uint32_2, trace_check_size_uint32_3, trace_check_size_uint32_4 could be removed and solution will be more flexible when possible number of max number of trace arguments change.
There was a problem hiding this comment.
@ktrzcinx you mean like
#define trace_check_size_uint32_2(a, b) META_MAP(1, trace_check_size_uint32_1, a, b)
#define trace_check_size_uint32_3(a, b, c) META_MAP(1, trace_check_size_uint32_1, a, b, c)
#define trace_check_size_uint32_4(a, b, c, d) META_MAP(2, trace_check_size_uint32_2, a, b, c, d)
yeah, sure, why not make it a bit more confusing yet :-D Or just make the above a bit more compact by
#define trace_check_size_uint32_3(a, b, c) do { \
trace_check_size_uint32_2(a, b); \
trace_check_size_uint32_1(c); \
} while (0)
#define trace_check_size_uint32_4(a, b, c, d) do { \
trace_check_size_uint32_2(a, b); \
trace_check_size_uint32_2(c, d); \
} while (0)
There was a problem hiding this comment.
I think rather about something like:
#define trace_check_size_uint32_1(a)
STATIC_ASSERT(sizeof(a) <= sizeof(uint32_t), trace_parameter_too_large);
#define STATIC_CHECK_ARGS(...) do { META_RECURSE( \
META_MAP(1, META_DEFER(trace_check_size_uint32_1), __VA_ARGS__)); \
} while (0)
#define _log_message(atomic, lvl, comp_class, ctx, id_1, id_2, \
format, ...) \
do { \
_DECLARE_LOG_ENTRY(lvl, format, comp_class, \
PP_NARG(__VA_ARGS__)); \
STATIC_CHECK_ARGS(__VA_ARGS__); \
STATIC_ASSERT(
...
*not tested
There was a problem hiding this comment.
@ktrzcinx I tried that and it didn't compile. Maybe I'm using it wrongly, and I don't see any other uses of META_MAP() in the code, so, unless you volunteer to investigate, maybe it's better to stay with the current solution for now.
There was a problem hiding this comment.
Given that we are close to v1.6 lets merge this today unless @ktrzcinx can update the macro as it's better than what we have today. We can always revisit after v1.6. I would also like us to revisit META_MAP() if there are no users.
There was a problem hiding this comment.
It wasn't one line change, so I created separate PR covering this topic: #3393.
There was a problem hiding this comment.
@lgirdwood sure, would @ktrzcinx also pull the third patch from this series into his PR?
|
PR content moved to #3393 |
It's useful for my debugging, and it's compile-time only, so we might merge it, but we don't have to, it's completely optional.
Currently SOF tracing only supports up to 32 bit arguments, using it with 64-bit arguments produces unpredictable results. Add compile-time checks to make sure all arguments are of correct size.
Oh, and yes, it currently breaks building, which is what it's supposed to do. So if we want to merge this we first have to fix those breakages (expect a patch soon).