alp@vilnius: ~ up since 2019 · Vilnius Download cv.pdf

← ALP-OS

alp ~ $ work trace-decoder

Writing my own trace decoder

Debugging our main cellular platform depended on the chip vendor’s closed trace tool. I wrote my own in C++20 and checked it against the vendor’s output at every step. On 108,755 traces, it produces the same bytes.

108,755traces decoded, byte-identical

Debugging our main cellular platform depended on the chip vendor’s trace tool. It was closed, so when it had problems, nobody outside the vendor could fix them.

A replacement is only worth using if people trust it as much as the original. So the real job wasn’t just building it. It was proving that it reads traces exactly the way the vendor’s tool does.

What it does

I wrote it in C++20, with a Dear ImGui GUI and a command-line version. It handles capture, decoding, merging, pcap export, GSMTAP export for Wireshark, symbols and a Ctrl+K command palette. It idles at 1.9% CPU with a 2-million-row log open.

Checked against the vendor’s tool

Every stage is tested against the vendor tool’s own output, with golden tests covering 3.7 million records. Decoding is compared byte for byte. I also rewrote one of the vendor’s message decoders and checked it the same way: 37,340 of 37,340 messages match. Capture has nothing to compare against, so it got a soak test instead.

Where my trace tool is checked against the vendor's own output Two paths through my tool, each drawn with my stages on top and the vendor reference they are compared to underneath. Trace path: the device’s trace capture feeds my capture stage, then trace decode, then a message decoder I reimplemented, then merge and export to pcap and GSMTAP for Wireshark. Capture has no vendor reference. It had 0 PC-side loss in a 30-minute soak. Trace decode is compared with the vendor trace tool's decode output: 108,755 traces are byte-identical, and 8.7 MB decodes in 0.8 s. The message decoder is checked against the vendor tool’s output: 37,340 of 37,340 random messages match. Crash path: a memory dump taken after a crash goes to a stage that walks the RTOS task blocks and queues, then a stage that unwinds stacks with DWARF CFI, giving symbolized call stacks. These are compared with the vendor's crash report: 57 of 57 call stacks match. Golden tests cover 3.7 million records. TRACE PATH · my stages on top, the vendor reference below device trace capture capture PC side decode traces message decoder reimplemented merge, export pcap · GSMTAP 0 lost 30-min soak 108,755 traces byte-identical 8.7 MB in 0.8 s vendor tool decode output 37,340 / 37,340 messages match random inputs vendor tool output CRASH PATH · the same check, against the vendor's crash report memory dump after a crash walk task blocks and queues unwind stacks DWARF CFI call stacks symbolized 57 / 57 call stacks match vendor crash report Golden tests cover 3.7 million records.
Where my trace tool is checked against the vendor's own output

Crash analysis

The crash analyzer walks the RTOS task blocks and queues, and unwinds the stacks using DWARF CFI. Its call stacks are compared with the vendor’s crash report.

Conclusion

Decoding is byte-identical on 108,755 traces, and 8.7 MB decodes in 0.8 s. 57 of 57 crash call stacks match the vendor’s report. A 30-minute capture soak lost nothing on the PC side.

Matching the vendor’s tool proves that mine agrees with it, not that both are right. For a replacement, agreement is the point.

Tags tooling reverse-engineering testing