Hello devs,
I'm writing to report a bug in the new debugger plugin. Consider the following test case
#include <iostream>
#include <string>
#include <wx/wx.h>
int main(int argc, char **argv)
{
if ( ! ::wxInitialize() ) return -1;
wxString testString;
wxString testString2;
wxString testString3;
wxString testString4;
wxString testString5;
std::string testSTL;
testString = wxT("AAA AAA");
testString2 = wxT("AAA ");
testString3 = wxT("AAAA ");
testString4 = wxT(" AAAA");
testString5 = wxT("AAAAAAAAAAAA");
testSTL = "AAA ";
std::cout << testString.mb_str(wxConvUTF8) << std::endl;
std::cout << testString2.mb_str(wxConvUTF8) << std::endl;
std::cout << testString3.mb_str(wxConvUTF8) << std::endl;
std::cout << testString4.mb_str(wxConvUTF8) << std::endl;
std::cout << testString5.mb_str(wxConvUTF8) << std::endl;
std::cout << testSTL.c_str() << std::endl;
return 0;
}
Compile it (Windows XP SP3,MINGW using GCC 4.5.0, latest packages and GDB 7.2) and start a debug session after setting a breakpoint in line 23. Watch all the strings. You can observe some of the wxStrings are shown truncating the repeated character. That's happening if there are more than 9 identical characters repeated.
The debug log said
>>>>>>cb_gdb:
> whatis &testString5
type = wxString *
>>>>>>cb_gdb:
> output /c testString5.m_pchData[0]@((wxStringData*)testString5.m_pchData - 1)->nDataLength
{65 'A' <repeats 12 times>}>>>>>>cb_gdb:
for an incorrect reporting and
> whatis &testString
type = wxString *
>>>>>>cb_gdb:
> output /c testString.m_pchData[0]@((wxStringData*)testString.m_pchData - 1)->nDataLength
{65 'A', 65 'A', 65 'A', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 65 'A', 65 'A', 65 'A'}>>>>>>cb_gdb:
for a correct one. May be the <repeats 12 times> is the root cause.
The STL string is showing two lines the first with the "AAA" and the second with the ' ' <repeated 12 times>.
I think the expected behavior shuold be just one line with the full string.
Hope this helps
Max