trace list: show a negative Start / End instead of wrapping it

The Start and End columns were unsigned differences to the first frame,
so a frame stamped before it or after the timer restarted showed as
about 4294967296, eg -281 in traces/lf_hitag_crypto_dump.trace and
-29708 in traces/hf_14b_cryptorf_select.trace. Same as the frame delay
time in d11643c8f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5.5 committed 2026-11-09 15:37:09 +07:00
1 parent 634fc7d457
commit e51bf90b63
1 file changed
+9 -8
+9 -8
View File
@@ -1180,8 +1180,9 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
if (j == 0) {
uint32_t time1 = hdr->timestamp - first_hdr->timestamp;
uint32_t time2 = end_of_transmission_timestamp - first_hdr->timestamp;
// signed, a frame can predate the first one or the timer restarted
int64_t time1 = (int64_t)hdr->timestamp - first_hdr->timestamp;
int64_t time2 = (int64_t)end_of_transmission_timestamp - first_hdr->timestamp;
// ansi codes addes extra chars that needs to be taken in consideration.
if (last_line && (memcmp(crc, "\x20\x20\x20\x20", 4) != 0) && g_session.supports_colors && markCRCBytes) {
@@ -1201,7 +1202,7 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
(last_line) ? explanation : ""
);
} else {
PrintAndLogEx(NORMAL, " %10u | %10u | Tag |%-*s | %s| %s",
PrintAndLogEx(NORMAL, " %10" PRId64 " | %10" PRId64 " | Tag |%-*s | %s| %s",
time1,
time2,
str_padder,
@@ -1224,7 +1225,7 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
);
} else {
PrintAndLogEx(NORMAL,
_YELLOW_(" %10u") " | " _YELLOW_("%10u") " | " _YELLOW_("Rdr") " |" _YELLOW_("%-*s")" | " _YELLOW_("%s") "| " _YELLOW_("%s"),
_YELLOW_(" %10" PRId64) " | " _YELLOW_("%10" PRId64) " | " _YELLOW_("Rdr") " |" _YELLOW_("%-*s")" | " _YELLOW_("%s") "| " _YELLOW_("%s"),
time1,
time2,
str_padder,
@@ -1367,11 +1368,11 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
const tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
uint32_t time1 = end_of_transmission_timestamp - first_hdr->timestamp;
uint32_t time2 = next_hdr->timestamp - first_hdr->timestamp;
int64_t time1 = (int64_t)end_of_transmission_timestamp - first_hdr->timestamp;
int64_t time2 = (int64_t)next_hdr->timestamp - first_hdr->timestamp;
if (prev_eot) {
time1 = 0;
time2 = next_hdr->timestamp - end_of_transmission_timestamp;
time2 = (int64_t)next_hdr->timestamp - end_of_transmission_timestamp;
}
// Same column rules as a data row, so the table is not broken. The pad
@@ -1395,7 +1396,7 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
(float)time1 / 13.56, (float)time2 / 13.56, " ",
fdt_pad, fdt_txt, " ", "");
} else {
PrintAndLogEx(NORMAL, " %10u | %10u | %s |%-*s | %s| %s",
PrintAndLogEx(NORMAL, " %10" PRId64 " | %10" PRId64 " | %s |%-*s | %s| %s",
time1, time2, " ", fdt_pad, fdt_txt, " ", "");
}
}