Subject: 28.0.50; gdb-mi mangles strings with octal escapes
From: Mattias Engdegård <[email-masked]>
To: [email-masked]
Date: Fri, 23 Oct 2020 13:50:24 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

When GDB sends a string containing octally-escaped characters, it will be something like

 "abc\377def"

which is first massaged into JSON and then parsed as such, but since JSON doesn't recognise octal escapes, the result is

 "abc377def"

which is wrong. This assumes gdb-mi-decode-strings is nil, which it is by default; otherwise the octal escapes are decoded by a fragile preprocessing stage (gdb-mi-decode) which itself has known problems as noted in a comment.

Frankly, this business with going via JSON after several ad-hoc text-based transforms isn't very principled.

While the bug could be 'solved' by adding yet another regexp hack to gdb-mi-decode or gdb-mi-jsonify-buffer, I suggest we write a GDB/MI parser in Lisp directly, ditching the gdb-mi-decode preprocessing and JSON form entirely, solving this and related bugs once and for all. Many transforms can then be done on the S-expression result after parsing, which should be more efficient and less error-prone.