https://bugs.kde.org/show_bug.cgi?id=486541
Bug ID: 486541
Summary: Embedded null character and subsequent characters in a
watched QString are not displayed while debugging
Classification: Applications
Product: kdevelop
Version: 5.14.240480
Platform: Manjaro
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: CPP Debugger
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
STEPS TO REPRODUCE
1. Debug the following (Qt 5) code:
```
QString str = "abcdef"; // (1)
str[3] = 0; // (2)
```
2. Look at the value of `str` before and after the line (2) in Variables tool
view and in the debugger tooltip for the variable `str`.
3. Run the GDB command `print str` in GDB tool view before and after the line
(2).
OBSERVED RESULT
2. The value of `str` is "abcdef" before the line (2) and "abc" after it - both
in Variables tool view and in the debugger tooltip.
3. GDB tool view displays `$1 = "abcdef"` before the line (2) and `$2 =
"abc\000ef"` after it. Incidentally, the same value is displayed while
debugging with GDB in terminal outside of KDevelop but using KDevelop's pretty
printers.
EXPECTED RESULT
The value of `str` is something like "abc\0ef" in Variables tool view, debugger
tooltip and GDB tool view.
"\000" in GDB tool view is indisputably better than truncating the string, but
I think "\0" would be a clearer representation of the null character, at least
to C++ developers.
ADDITIONAL INFORMATION
The bug is present as early as in MIDebugger::readyReadStandardOutput(), where
the values of `reply` received from GDB are:
1 (before the line (2)):
"35^done,name=\"var0\",numchild=\"0\",value=\"\\\"abcdef\\\"\",type=\"QString\",displayhint=\"string\",dynamic=\"1\",has_more=\"0\""
2 (after the line (2)):
"35^done,name=\"var3\",numchild=\"0\",value=\"\\\"abc\\\"\",type=\"QString\",displayhint=\"string\",dynamic=\"1\",has_more=\"0\""
3 (GDB tool view after the line (2)): "~\"$1 = \\\"abc\\\\000ef\\\"\\n\""
For some reason, GDB returns only 3 characters "abc" for variable display, but
the entire string "abc\000ef" as the reply to the manual GDB print command.
After the truncated string value "abc" is read in
MIDebugger::readyReadStandardOutput(), it eventually ends up in
MIParser::parseStringLiteral() and then is displayed in the UI.
The same issue affects QByteArray in almost identical fashion and with
practically the same results (except for minor differences because of divergent
pretty-printing formats of KDevelop's QStringPrinter and QByteArrayPrinter).
--
You are receiving this mail because:
You are watching all bug changes.