#4189·pwndbg

gdb command argument lexing is broken, implement our own lexer

Author: k4lizenCreated Sep 29, 2026Updated Sep 29, 2026

See detailed explanation: https://sourceware.org/bugzilla/show_bug.cgi?id=34690 .

Here is how print and similar commands work:

Image

Here is how it is for us:

Image

This is due to how gdb.string_to_argv() works, and I personally can't think of any easy workarounds to fix it. The first example I will fix since it's really pathological. But I don't think we have another way forward than to just hand roll our own lexer.

It should be able to properly handle these:

  1. cool 1 2
  2. cool 1+1 2+2
  3. cool 'weird symbol' func()
  4. cool 'weird symbol'+3 ((int*)func())+4
  5. cool -cool-flag cool-subcommand 'weird symbol'+3 I will not invoke gdb.parse_and_eval() on "-cool-flag" and "cool-subcommand" as I will just directly pass them through to argparse, I just need the lexing to work in a way that doesn't mess up the 'weird symbol'+3 expression.