From 4b15f82f7d9879d629b87ca8905c2ae45cd50a55 Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Wed, 22 Jul 2026 08:04:40 +0200 Subject: [PATCH] Provide trace_dump() --- src/avr.c | 15 +++++++++++++++ src/libavrdude.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/avr.c b/src/avr.c index ae2d6ca9..0aa7ccd8 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1866,3 +1866,18 @@ void trace_buffer(const char *funstr, const unsigned char *buf, size_t buflen) { } msg_trace("\n"); } + +// Output comms buffer like memory dump +void trace_dump(const char *funstr, const unsigned char *buf, size_t buflen) { + pmsg_trace("%s: ", funstr); + while(buflen) { + char out[69]; + size_t len = buflen > 16? 16: buflen; + + str_hexdump16(out, buf, len); + msg_trace("%s\n", out); + buf += len; + if(buflen -= len) + pmsg_trace("%*s", (int) strlen(funstr)+2, ""); + } +} diff --git a/src/libavrdude.h b/src/libavrdude.h index b3772f5d..d8d3e96f 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1233,6 +1233,7 @@ extern "C" { int avr_unlock(const PROGRAMMER *pgm, const AVRPART *p); void report_progress(int completed, int total, const char *hdr); void trace_buffer(const char *funstr, const unsigned char *buf, size_t buflen); + void trace_dump(const char *funstr, const unsigned char *buf, size_t buflen); int avr_has_paged_access(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m); int avr_has_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m); int avr_has_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m);