In downloaded file stdcxx_and_wx_pythonscript.7z, when I decompress, in wx folder I can see libwx\v28\: is this files are really working with wxWidgets 2.9 ?
I have never used wx 2.9, so I can't say much, as I said before, you need the wx python script from the wx trunk:
http://svn.wxwidgets.org/viewvc/wx/wxWidgets/trunk/misc/gdb/print.py
I suggest you can just put the contents of the print.py to PathToYourMinGw\bin\libwx\v28\printers.py
the last change is just use pcx's new 4.6.1 packages. and put the code:
source $(TARGET_COMPILER_DIR)bin\stl.gdb
source $(TARGET_COMPILER_DIR)bin\wx.gdb
in your c::b's debugger's initial command edit control.
When I load gdb-python27.exe in place of gdb.exe (in toolchain executable) it seems to change some things.
One example : on breakpoint in "bool wxXmlResource::Load(const wxString& filemask_)"
bool wxXmlResource::Load(const wxString& filemask_)
{
wxString filemask = ConvertFileNameToURL(filemask_);
bool allOK = true;
#if wxUSE_FILESYSTEM
wxFileSystem fsys;
# define wxXmlFindFirst fsys.FindFirst(filemask, wxFILE)
# define wxXmlFindNext fsys.FindNext()
#else
# define wxXmlFindFirst wxFindFirstFile(filemask, wxFILE)
# define wxXmlFindNext wxFindNextFile()
#endif
wxString fnd = wxXmlFindFirst;
if ( fnd.empty() )
{
wxLogError(_("Cannot load resources from '%s'."), filemask);
return false;
}
With tooltip on filemask_ indicate "m_impl = L<error reading variable>"
Tooltip on filemask indicate "No symbol "wxStringData" in current context"
Two wxString that not indicate the same thing, strange.
In debugger (add watch) filemask_ indicate : Attemps to take contents of a non-pointer value.
In debugger (add watch) filemask indicate : "" and it is not true.
If I run GDB in place of gdb-python27.exe, the tooltip of filemask_ indicate the expand of all the class.
For the moment, it don't work ! :(
I'm sure some other developpers have already test and make debug with wxWidgets 2.9.x under gdb/CodeBlocks, or I am alone in the earth ?
print.py is automatically loaded ? Strange, I don't understand how it is loaded.
I have just take several hours to build a wx 2.9.2 under pcx's mingw 4.6.1 then try to see whether it works on wxWidgets.
it seems that you need to change the file:
MinGW_gcc4.6.1release_static_win32\bin\libwx\v28\printers.py
Then use the content below for the wxString class:
# shamelessly stolen from std::string example
@register_pretty_printer
class wxStringPrinter:
regex = re.compile('^wxString$$');
@static
def supports(typename):
return wxStringPrinter.regex.search(typename)
@static
def is_undefine(val):
try:
val['m_impl']['_M_dataplus']['_M_p'].string()
return True
except:
return False
def __init__(self, val):
self.val = val
def to_string(self):
return self.val['m_impl']['_M_dataplus']['_M_p'].string()
def display_hint(self):
return 'string'
then, everything works fine.
here is my test debug log:
> p msg
$1 = "wxWidgets 2.9.2-Windows-Unicode build"
>>>>>>cb_gdb:
my test code was just use wx wizard to generate a simple wx smith project.
BTW: I use you command to build the wx library. such as:
echo Add MinGW path
set PATH=D:\code\MinGW_gcc4.6.1release_static_win32\bin;%PATH%
cd wxWidgets-2.9.2\build\msw
mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release USE_XRC=1 DEBUG_FLAG=0
But I found that I need to manuall change the setup.h, and un-comment the line: (line 70)
otherwise, I will have a build error, something like:
undefined reference to `wxTheAssertHandler'
more details can be found:
http://trac.wxwidgets.org/ticket/12626
So, I guess the option :DEBUG_FLAG=0 should not be used. :D
Hi,
for all those, who dont want to use python:
I have modified the small script from CodeBlocks (10.5) for displaying wxStrings.
The old code located in <path to C::B>/share/CodeBlocks/scripts/gdb_types.script
function Evaluate_wxString(type, a_str, start, count)
{
local oper = _T(".");
if (type.Find(_T("*"), false) > 0)
oper = _T("->");
local result = _T("output /c ") + a_str + oper + _T("m_pchData[") + start + _T("]@");
if (count != 0)
result = result + count;
else
result = result + _T("((wxStringData*)") + a_str + oper + _T("m_pchData - 1)->nDataLength");
return result;
}
doesnt work on wxWidgets 2.9.2 anymore
this code
function Evaluate_wxString(type, a_str, start, count)
{
local oper = _T(".");
if (type.Find(_T("*"), false) > 0)
oper = _T("->");
local result = _T("output /c *((wxChar *)(") + a_str + oper + _T("fn_str()))@") + a_str + oper + _T("Length()");
return result;
}
displays the String again.
Hope this helps a little bit.
P.S. dont overwrite the whole file, but only the function Evaluate_wxString. :wink:
Hi
Starting with wx 2.9, the wxString internal representation depends on the OS. See
http://docs.wxwidgets.org/trunk/overview_string.html (http://docs.wxwidgets.org/trunk/overview_string.html)
To get your own OS suitable type, use wxString::wx_str(), which returns a pointer of the needed type.
To get the length (in characters, not chars, no bytes, no etc.) there are three functions: Len(), Length() and length().
If you use Len(), then the compiler knows about it and can use it too. If your code does not, GDB neither.
In Squirrel language, I can't find a way for telling the size of an "external" array. So let's GDB manage it.
Because wxString is moving to use std::string, it seems length() (lower case letter) is available.
With all of this, the Evaluate_wxString function at gdb_types.script would look like:
function Evaluate_wxString(type, a_str, start, count)
{
local oper = _T(".");
if (type.Find(_T("*"), false) > 0)
oper = _T("->");
local result = _T("output /c ") + a_str + oper + _T("wx_str()") + _T("[") + start + _T("]@");
if (count != 0)
result = result + count;
else
result = result + a_str + oper + _T("length()");
return result;
}
Now, the C:B Watches window shows the contents of the wxString type var.
Note the GDB command 'output /c' will treat each character as an integer and display it in 7 bit ASCII or escaped sequences if value>127
So, if your wxString has some characters not representable in 7 bit ASCII, you'll see escaped sequences for them.
N.B.
Looking at wx2.8.12 wxWidgets string.h, I find both functions (wx_str & length) are defined. So this script should work also for [all?] wx 2.8 series.
Regards
Manolo