Code::Blocks/dgb Unicode debugging for wxString
Code::Blocks/dgb Unicode debugging for wxString
Hi,
currently i try to do some developement with wxWidgets. As an IDE i use CodeBlocks.
I have compiled wxWidgets in UNICODE-Mode. Can anyone tell me how i debug my application? Who am i able to see what values wxStrings have? What about wxChar? Can i convert the unicode Chars & Strings to human readable versions e.g. in the watchlist?
Ciao, Udo
currently i try to do some developement with wxWidgets. As an IDE i use CodeBlocks.
I have compiled wxWidgets in UNICODE-Mode. Can anyone tell me how i debug my application? Who am i able to see what values wxStrings have? What about wxChar? Can i convert the unicode Chars & Strings to human readable versions e.g. in the watchlist?
Ciao, Udo
Perhaps you would get more response in the codeblocks forum at
http://forums.codeblocks.org/
http://forums.codeblocks.org/
Hi!
Debugging is really a happy journey under Code::Blocks. Here is some major step:
1)Set up debug environment:
0. Open what ever a project
1. Debug->Start
2. Debug->Debugging Windows->
Call Stack,
Watches,
Breakpoints,
Memory,
CPU Register,
Disassembly
You can choose what windows you would like to see during debugging. Adapt the floating windows in the proper place(See the screenshot in the attachment).
3. Give the debugging Windows shortcuts. I use Alt-1 to Alt-6, it means when I hold Alt and press 1 to 6, all windows will come out or disappear in the arranged position.
4. Stop Debugging: Oh, all the windows are gone! Don't worry, they will appear again when you start debuging again.
2)Debugging...
1. Just place your breakpoint by clicking at the left side of the line.
2. Debug->Start (F8 for short cut)
3. Code::Blocks will stop at the breakpoint, and all the info you might need is in the windows.
4. Set a new breakpoint and Debug->Continue (Ctrl-F7 for shortcut)
5. You can observe more,try more or explorer more for what you want.
In the screenshot you can see I was watching the wxChar * buf. You can either watch it as an character array or access its memory in the Memory window.
Right click at the Watches window, ->Add Watch. You can find useful settings in it.
wxString is a little difficult, because it allocates the memory on the heap, it includes only a pointer itself. So you can only use the pointer m_pchData to access the corresponding memory. You can see what I do in the screenshot2.
As for the human readable version of the Unicode, you might have to copy the hex code to HexEdit etc. or pop out a messagebox showing the corresponding wxString...AFAIK, Code::Blocks can't do that for you.
What I say applies to Code::Blocks SVN Build 4845----the version I'm using. In the later versions, the operations are similar.
Regards,
Utensil Candel
Debugging is really a happy journey under Code::Blocks. Here is some major step:
1)Set up debug environment:
0. Open what ever a project
1. Debug->Start
2. Debug->Debugging Windows->
Call Stack,
Watches,
Breakpoints,
Memory,
CPU Register,
Disassembly
You can choose what windows you would like to see during debugging. Adapt the floating windows in the proper place(See the screenshot in the attachment).
3. Give the debugging Windows shortcuts. I use Alt-1 to Alt-6, it means when I hold Alt and press 1 to 6, all windows will come out or disappear in the arranged position.
4. Stop Debugging: Oh, all the windows are gone! Don't worry, they will appear again when you start debuging again.
2)Debugging...
1. Just place your breakpoint by clicking at the left side of the line.
2. Debug->Start (F8 for short cut)
3. Code::Blocks will stop at the breakpoint, and all the info you might need is in the windows.
4. Set a new breakpoint and Debug->Continue (Ctrl-F7 for shortcut)
5. You can observe more,try more or explorer more for what you want.
Well, for wxChar, there is something we can do:Who am i able to see what values wxStrings have? What about wxChar? Can i convert the unicode Chars & Strings to human readable versions e.g. in the watchlist?
In the screenshot you can see I was watching the wxChar * buf. You can either watch it as an character array or access its memory in the Memory window.
Right click at the Watches window, ->Add Watch. You can find useful settings in it.
wxString is a little difficult, because it allocates the memory on the heap, it includes only a pointer itself. So you can only use the pointer m_pchData to access the corresponding memory. You can see what I do in the screenshot2.
As for the human readable version of the Unicode, you might have to copy the hex code to HexEdit etc. or pop out a messagebox showing the corresponding wxString...AFAIK, Code::Blocks can't do that for you.
What I say applies to Code::Blocks SVN Build 4845----the version I'm using. In the later versions, the operations are similar.
Regards,
Utensil Candel
In fascination of creating worlds by words, and in pursuit of words behind the world.
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
Well, I performede a search in Code::Blocks forum, I got a soluton to your question from Can't see value of unicode strings while debugging http://forums.codeblocks.org/index.php/ ... 587.0.html:
Regards,
Utensil Candel
EDIT:
I tried to edit the file and found out that in the latest nightly build(SVN 4893), it has already been modified as above.
And I used "a Shared Debug version of wxWidgets library" as guided.
But I have got nothing for return.....Still trying to figure out why.........
1. Open the gdb_types.script file in "C:\Program Files\CodeBlocks\share\CodeBlocks\scripts". Your installation dir may be different so change the above path if necessary.
2. Find the function "Evaluate_wxString".
3. Now find the line containing:
local result = _T("output /c ") + a_str + oper + _T("c_str()[") + start + _T("]@");
And change it to:
local result = _T("output /c ") + a_str + oper + _T("m_pchData[") + start + _T("]@");
Note we are only changing "c_str()" to "m_pchData".
4. Now save this file, start debugging.
Hope it helps.1. Open the same gdb_types.script and find the same "Evaluate_wxString" function.
2. Locate and change the following line from this:
result = result + a_str + oper + _T("size()");
to this:
result = result + _T("((wxStringData*)") + a_str + oper + _T("m_pchData - 1)->nDataLength"
Regards,
Utensil Candel
EDIT:
I tried to edit the file and found out that in the latest nightly build(SVN 4893), it has already been modified as above.
And I used "a Shared Debug version of wxWidgets library" as guided.
But I have got nothing for return.....Still trying to figure out why.........
In fascination of creating worlds by words, and in pursuit of words behind the world.
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
The best way to view the wxString content under gdb when using unicode version of wxWidgets, is to use wxString methods, for example:
to view the content:
this will present the value as ASCII text.
Eran
Code: Select all
wxString content(wxT("content"));
Code: Select all
(gdb)p content.ToAscii().m_str
Eran
I guess what ubit needs is to view non-ASCII text.eranif wrote:this will present the value as ASCII text.Code: Select all
(gdb)p content.ToAscii().m_str
Eran
According to Chapter 8.17 in info/gdb.info-1,
It seems gdb doesn't support printing Unicode itself. But there must be a way to hack it through Squirrel...Still trying...GDB currently includes support for the following character sets:
`ASCII'
Seven-bit U.S. ASCII. GDB can use this as its host character set.
`ISO-8859-1'
The ISO Latin 1 character set. This extends ASCII with accented
characters needed for French, German, and Spanish. GDB can use
this as its host character set.
`EBCDIC-US'
`IBM1047'
Variants of the EBCDIC character set, used on some of IBM's
mainframe operating systems. (GNU/Linux on the S/390 uses U.S.
ASCII.) GDB cannot use these as its host character set.
Note that these are all single-byte character sets. More work inside
GDB is needed to support multi-byte or variable-width character
encodings, like the UTF-8 and UCS-2 encodings of Unicode.
-Utensil
EDIT:
ubit, if what you need is to view ASCII text in wxString, you only need to
1) watch it explicitly
or
2) check "Evaluate expression under cursor" in Settings->Compiler and Debugger...->Debugger Settings
and move cursor to the wxString variable in your Code and wait a second.
In fascination of creating worlds by words, and in pursuit of words behind the world.
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
The folowing link has shown the ancient history of implementing this function in C::B:
Custom Watch Script Pluggins
http://forums.codeblocks.org/index.php/ ... 097.0.html
The following link has some instructions to write the debugging script:
http://wiki.codeblocks.org/index.php?ti ... er_scripts
The following link is the manual of Squirrel:
http://squirrel.sourceforge.net/doc/squirrel2.html
Further study will figure a way out...Still working on it...
-Utensil
Custom Watch Script Pluggins
http://forums.codeblocks.org/index.php/ ... 097.0.html
The following link has some instructions to write the debugging script:
http://wiki.codeblocks.org/index.php?ti ... er_scripts
The following link is the manual of Squirrel:
http://squirrel.sourceforge.net/doc/squirrel2.html
Further study will figure a way out...Still working on it...
-Utensil
In fascination of creating worlds by words, and in pursuit of words behind the world.
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
As far as I know, in versions later than SVN 4845, it all works fine if you watch it explicitly as "Undefined".mandrav wrote:Evaluating wxString in the watch list does not yet work.
In fascination of creating worlds by words, and in pursuit of words behind the world.
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/