blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.3k stars 775 forks source link

crc32: Buffer up log output to avoid prefix-chunking, fix `func` #1998

Open ALTracer opened 2 weeks ago

ALTracer commented 2 weeks ago

Detailed description

  1. Because of #1713 and requirements to support Windows and MacOS (cross-platform portable software), the __func__ portion of log became identical as collateral damage. This change restores the behaviour intended in #1708, so that we can tell apart speed reports from BMF+ENABLE_DEBUG and BMDA.
  2. On out-of-tree platforms like Farpatch which use BMD as a git submodule directly, custom logger implementations format every DEBUG_INFO() call etc. by prepending loglevel and timestamp, so the 2-3 piece logmessage gets broken and mixed. This change buffers the optional output pieces into a zeroed stack buffer via snprintf() to avoid that.
  3. Xtensa Farpatch crashes on every divide-by-zero, which can happen here when <1 milliseconds are reported elapsed by corresponding platform timing code. BMF on Cortex-M3 does not trap integer divide-by-zero into UsageFault, so it was never affected. BMDA usually gets more than 1ms due to USB FS delays and all the layer overheads. This change skips the speed report by checking for both length and time to be big enough.

Your checklist for this pull request

Closing issues

Fixes some issues in Farpatch.

xobs commented 2 weeks ago

I like this change! It improves readability when doing checksum benchmarking.