Skip to content

Conversation

@ALTracer
Copy link
Contributor

@ALTracer ALTracer commented Feb 1, 2026

Detailed description

  • This is not a new feature, but still a potentially dangerous change. A sort of continuation of PR2014.
  • The existing problem is gdb_main FSM performing VLA for m/M-packets.
  • This PR solves it by reusing half of gdb packet buffer for (un)hexify operations.

Tested on BMDA (env CC=clang, -Db_sanitize=address) and on blackpill-f411ce against GD32VF103. Dump and compare-sections seem to match, GDB receives 512 byte (1024 hex-encoded) packets.
g/G-packets still depend on VLA because BMP supports multiple architectures with different amounts of general-purpose registers. {armv7-m 20*4, armv8-m.main 24*4} + fpv4-sp-d16 33*4, armv7-a/r 17*4 + VFPv3 33*4, armv8-a 31*8, rv32i 33*4, rv32e 17*4, rv64i 33*8. IMHO a static regcache of 512 bytes could be enough (with build-time static assert that no arch needs more), but it's not visibly broken now, so not touching.

Your checklist for this pull request

Closing issues

Closes #2042. @perigoso

Copy link
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

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

LGTM, please rebase on main and we'll get this merged. Thank you for the contribtion! We quite like this way of working round the VLA problem - it's really a nice solution.

@dragonmux dragonmux added this to the v2.1 release milestone Feb 2, 2026
@dragonmux dragonmux added the Enhancement General project improvement label Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement General project improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of alloca in gdb m-packet handling can be optimized out

2 participants