Author Topic: Debugging std::wstrings / wchar_t* strings  (Read 4688 times)

Offline Carl Colijn

  • Multiple posting newcomer
  • *
  • Posts: 11
    • TwoLogs - a natural choice!
Debugging std::wstrings / wchar_t* strings
« on: October 06, 2010, 04:54:27 pm »
Hi all,

Since I switched my apps to Unicode I was without debugging support for strings (std::wstring and wchar_t*).  Googling for a solution didn't help too much, and mostly gave solutions that required a combination of helper functions in my app to be called by gdb and/or gdb init script and/or Code::Blocks gdb_types.script code.  Since I only want to manage this in one place (because next time I upgrade anything to my build system I will have forgotten all about how I did it the previous time), I've developed a pure Code::Blocks gdb_types.script solution.  For eveyone that wants to use it, see the attached .txt document.

The only problem I still have with this solution is that the correct formatting is only used in the debug tooltips, and not in the watches window.  I'm probably overlooking something basic here, but can anyone point me in the right direction?

Kind regards,
Carl Colijn

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Debugging std::wstrings / wchar_t* strings
« Reply #1 on: October 06, 2010, 05:07:35 pm »
Have you considered using gdb 7+ with python scripting enabled?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Carl Colijn

  • Multiple posting newcomer
  • *
  • Posts: 11
    • TwoLogs - a natural choice!
Re: Debugging std::wstrings / wchar_t* strings
« Reply #2 on: October 06, 2010, 08:54:01 pm »
Well, since I'm still running gdb version 6.8 (and an ancient Code::Blocks version as well) I didn't realize Python was an option.  But thanks for the suggestion; it would have made the script somewhat easier I think (though my Squirrel is as good as my Python :) ).

Still leaves the question of why the watches window doesn't seem to pick up on my custom debug output scripts?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Debugging std::wstrings / wchar_t* strings
« Reply #3 on: October 06, 2010, 09:00:57 pm »
STL support is already implemented in gcc 4.5+.
It works (not bug free thought) in gcc 4.4
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Carl Colijn

  • Multiple posting newcomer
  • *
  • Posts: 11
    • TwoLogs - a natural choice!
Re: Debugging std::wstrings / wchar_t* strings
« Reply #4 on: October 07, 2010, 09:33:56 am »
I had a check to see what specific version I'm running, but it's gcc 3.4.5 (and a derivative of Code::Blocks 8.02).  Since I'm a bit hesitant about upgrading only parts of the build toolchain and since upgrading Code::Blocks itself is not that easy for me (I've made some code mods to override the colors used in the log window so it is useable in the high-contrast display setting I use) I'll opt for sticking with the current config (hey, it works good enough for me ;) ).

Thanks for the info though!