Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Fix: log string deduplication - #2097

Merged
dragonmux merged 5 commits into
blackmagic-debug:mainfrom
ALTracer:fix/dedupe-strings
Jul 21, 2025
Merged

Fix: log string deduplication#2097
dragonmux merged 5 commits into
blackmagic-debug:mainfrom
ALTracer:fix/dedupe-strings

Conversation

@ALTracer

Copy link
Copy Markdown
Contributor

Detailed description

  • No significant new features.
  • The existing problem is suboptimal/repeating message strings for DEBUG_ERROR/WARN/TARGET().
  • This PR solves it by factoring out unique substrings and enabling linker relaxation across newly-identical strings.

Discovered by staring at strings -n16 build-f411ce/blackmagic_blackpill_f411ce_firmware.bin | less output.

  1. First commit saves up to 256 bytes when all targets are enabled and DEBUG_TARGET() is enabled.
  2. In stm32h7.c, I drop the logline I added previously for H7B3 compat FLASH_CR patcher helper, because the driver is tested to work and that logline spams output during flashing. -116 bytes.
  3. Renesas RA driver has three really long warnings with identical prefix/suffix and missing comma. -136 bytes.
  4. LPC17xx & LPC40xx have similar mass-erase functions in which strings differ and hence don't get merged. -104 bytes.
  5. LPC55xx reports IAP errors for five unique commands, and I decided to extract these instead. -52 bytes.

I would need some autobuilder script to measure size savings from each commit, but they're on the order of 50-100 bytes, for a total of about -292 bytes up to DEBUG_WARN, and -372 bytes more up to DEBUG_TARGET (-664).
Can't test on most of targets modified in PR scope. Idea similar to #1527 and #1863. Should have no effect on release firmware with disabled logging. When -Ddebug_output=true, default native and swlink/stlink/bluepill and f072 builds still overflow by 17-23 KiB. The other probe platforms are not 128 KiB but 256 KiB or even larger.

Your checklist for this pull request

Closing issues

@dragonmux dragonmux added the Enhancement General project improvement label Mar 21, 2025
dragonmux
dragonmux previously approved these changes Mar 21, 2025

@dragonmux dragonmux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we'll get this merged when the v2.1 merge window opens. Thank you for the contribution!

@dragonmux dragonmux added this to the v2.1 release milestone Mar 21, 2025
@ALTracer
ALTracer force-pushed the fix/dedupe-strings branch from c3ed8fc to 946a52e Compare July 21, 2025 10:16
@ALTracer
ALTracer force-pushed the fix/dedupe-strings branch from 0b01dc3 to d3fee6f Compare July 21, 2025 20:32
@ALTracer

Copy link
Copy Markdown
Contributor Author

Rebased. Added static and macro guards to lpc55xx.c string reflection array, to keep release binary size-diff in check at +0 rom bytes. Log-enabled diff locally is -312, or -668 with DEBUG_TARGET unguarded (multiple loglevels in PR scope).

@dragonmux dragonmux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing that small oops that was identified in Discord, and rebasing this! Merging.

@dragonmux
dragonmux merged commit d3fee6f into blackmagic-debug:main Jul 21, 2025
36 checks passed
@ALTracer
ALTracer deleted the fix/dedupe-strings branch February 21, 2026 21:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Enhancement General project improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants