Skip to content
Snippets Groups Projects
Commit 2098f203 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

prelude: Add function to print hexdump of OS state

Useful for debugging.
parent 6421a26c
Branches
Tags v2.8.0-rc0
No related merge requests found
...@@ -99,6 +99,26 @@ uint32_t hash_os_state() { ...@@ -99,6 +99,26 @@ uint32_t hash_os_state() {
return first_hash ^ second_hash; return first_hash ^ second_hash;
} }
void hex_os_state() {
const uint8_t *start = (const uint8_t*)&_sdata_os_canonical;
const uint8_t *end = (const uint8_t*)&_edata_os_canonical;
uint32_t len = end-start;
printf("os-hex: len:%d 0x", len);
for (const uint8_t *i = start; i < end; i++) {
printf("%02x", *i);
}
start = (const uint8_t*)&_sdata_arch_canonical;
end = (const uint8_t*)&_edata_arch_canonical;
len = end-start;
printf(" | arch-hex: len:%d 0x", len);
for (const uint8_t *i = start; i < end; i++) {
printf("%02x", *i);
}
printf("\n");
}
void _print_os_state(const char *format, const char *syscall, const char *func) { void _print_os_state(const char *format, const char *syscall, const char *func) {
printf(format, hash_os_state(), syscall, func); printf(format, hash_os_state(), syscall, func);
printf("\n"); printf("\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment