Skip to content

Commit 4aff284

Browse files
debug output
1 parent 5dce4c7 commit 4aff284

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

examples/examples_util.h

+20
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,23 @@ static void secure_erase(void *ptr, size_t len) {
106106
volatile_memset(ptr, 0, len);
107107
#endif
108108
}
109+
110+
/* Debug helper for printing arrays of unsigned char. */
111+
#define PRINT_BUF(buf, len) do { \
112+
printf("%s[%lu] = ", #buf, (unsigned long)len); \
113+
print_buf_plain(buf, len); \
114+
} while(0)
115+
116+
static void print_buf_plain(const unsigned char *buf, size_t len) {
117+
size_t i;
118+
printf("{");
119+
for (i = 0; i < len; i++) {
120+
if (i % 8 == 0) {
121+
printf("\n ");
122+
} else {
123+
printf(" ");
124+
}
125+
printf("0x%02X,", buf[i]);
126+
}
127+
printf("\n}\n");
128+
}

examples/silentpayments.c

+6
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ const unsigned char* label_lookup(
101101
const struct labels_cache* cache = (const struct labels_cache*)cache_ptr;
102102
size_t i;
103103
for (i = 0; i < cache->entries_used; i++) {
104+
printf("i = %ld\n", i);
105+
printf("cache->entries[i].label = \n");
106+
PRINT_BUF(cache->entries[i].label, 33);
107+
printf("label = 33\n");
108+
PRINT_BUF(label33, 33);
109+
printf("\n\n");
104110
if (memcmp(cache->entries[i].label, label33, 33) == 0) {
105111
return cache->entries[i].label_tweak;
106112
}

0 commit comments

Comments
 (0)