life ideas

September 13, 2006

display wchar_t in GDB

Filed under: C/C++, Uncategorized — manoftoday @ 11:35 pm

Do you even need to show  wchar_t * string in GDB?  

 I once googled and had no answer.  someone suggested me that I can use call:

gdb) call wprintf(wide_string)
or

(gdb) call fputws(ptr, stdout)

 

However, It doesn’t work. because wprintf require the format string starts with L,i.e. wprintf(L”%s”,s2), and GDB DOESN”T recognize L symbol.

 

the solution is :

(gdb) call printf(“%ls \n”,s2)  <=== printf can print wchar_t * ????  YES! wprintf can also print char*
suppose wchar_t * s2=L”xyzw”; we will get xyzw. if s2 is std::wstring(L”xyzw”), you can : call printf(“%ls \n”,s2.c_str())

 suppose wchar_t * s2=L”xyzw”;
GDB itself also has a command :printf, you can use it like :
(gdb)printf,”%d %s\n”, 100, “abcd”(

but if you usel GDB’s printf command with wchat_t*  GDB will crash!!! a bug.

 

 

hope the technology is helpful for you, especially for those localization developer.

Advertisements

5 Comments »

  1. Oh maaaaaan, that’s a life saver 🙂 Good find!

    Comment by franiu — July 28, 2008 @ 8:21 pm

  2. Excellent!

    Comment by iska — March 3, 2009 @ 9:03 am

  3. […] Sites Trusted Steroid Sites Trusted Steroid Sites Trusted Steroid Sites Trusted Steroid Sites Trusted Steroid Sites Trusted Steroid Sites Trusted Steroid Sites Trusted Steroid Sites Trusted Steroid Sites Trusted […]

    Pingback by ordering steroids online — June 11, 2017 @ 8:27 am

  4. My brother suggested I may like this blog. He used to be totally right.

    This publish truly made my day. You cann’t imagine simply
    how much time I had spent for this info! Thanks!

    Comment by hd love images with quotes — January 3, 2018 @ 5:34 pm

  5. Thanks for finally writing about >display wchar_t in GDB | life
    ideas <Loved it!

    Comment by Millie — August 18, 2018 @ 1:02 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: