Print cpu mask in hex in dump_rtprio
Before, we'd just print "???" if a thread's cpu mask wasn't all cpus.
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
Change-Id: Iaca88614b277804369abe61a91bbc1b7458cf623
diff --git a/aos/dump_rtprio.cc b/aos/dump_rtprio.cc
index 30d1b65..4ed9415 100644
--- a/aos/dump_rtprio.cc
+++ b/aos/dump_rtprio.cc
@@ -12,6 +12,7 @@
#include <sys/time.h>
#include <unistd.h>
+#include <bitset>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
@@ -284,13 +285,24 @@
if (not_there) continue;
- const char *cpu_mask_string =
- CPU_EQUAL(&cpu_mask, &all_cpus) ? "all" : "???";
+ std::string_view cpu_mask_string;
+ if (CPU_EQUAL(&cpu_mask, &all_cpus)) {
+ cpu_mask_string = "all";
+ } else {
+ // Convert the CPU mask to a bitset
+ std::bitset<CPU_SETSIZE> bitset;
+ for (size_t i = 0; i < CPU_SETSIZE; i++) {
+ bitset[i] = CPU_ISSET(i, &cpu_mask);
+ }
+ std::stringstream ss;
+ ss << std::hex << bitset.to_ulong();
+ cpu_mask_string = ss.str();
+ }
threads.emplace(Thread{.policy = static_cast<uint32_t>(scheduler),
.exe = exe,
.name = name,
- .cpu_mask = cpu_mask_string,
+ .cpu_mask = cpu_mask_string.data(),
.nice_value = nice_value,
.sched_priority = param.sched_priority,
.tid = tid,