trace: stop trace save writing a stale client side buffer
`trace save` saved the client side trace buffer whenever it was non-empty and only downloaded from device when it was empty. After `trace load` or `trace list -1` a following sniff -> `trace save` silently wrote the old trace, byte identical to the previous save, with no way to reset it. See #3592, and #1252 / #1512 for earlier reports of the same thing. - `trace save` now downloads from device by default and takes `-1` to save the client side buffer, mirroring `trace list`. Offline it falls back to the buffer so `trace load` -> `trace save` still works. - split download_trace() into download_trace_ex(), which hands the caller its own buffer. `trace save` uses it and no longer mutates gs_trace, so `-1` means the client buffer regardless of what ran before. - download_trace() freed gs_trace before it knew the download had worked, so a timeout threw away a loaded trace. It now swaps on success only. - added `trace clear` to discard the client side buffer, and a shared ClearTraceBuffer() to replace the free/NULL/zero pattern that was open coded in ImportTraceBuffer() and CmdTraceLoad(). Help text for both new commands names the device vs client distinction. Co-Authored-By: Claude Opus 5 (1M context)
This commit is contained in:
1 parent
255576fa43
commit
344c2d6185
3 files changed
+112
-40
No files matched your search
@@ -25,5 +25,6 @@ int CmdTrace(const char *Cmd);
|
||||
int CmdTraceList(const char *Cmd);
|
||||
int CmdTraceListAlias(const char *Cmd, const char *alias, const char *protocol);
|
||||
bool ImportTraceBuffer(const uint8_t *trace_src, uint16_t trace_len);
|
||||
void ClearTraceBuffer(void);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user