LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2006, 06:38 PM   #1
Nightfox
Member
 
Registered: Jun 2004
Location: Hillsboro, Oregon, USA
Distribution: Mint
Posts: 41

Rep: Reputation: 15
Problem with gdb, or is there a better debugger for C++?


I've been a little frusterated with gdb when debugging some software.. For one, it doesn't seem smart enough to realize that if you want to print the value of an STL string in C++, you usually just want to print the characters contained in the string; instead, it prints the object information with its members, etc.. I've gotten into the habit of typing something like "print myString.c_str()" in gdb so that it only prints the characters in the string.

Additionally, I've encountered a lot of situations where gdb doesn't even seem to print the correct value of an STL string. I'll print the value of a string in gdb and get garbage, but the program will behave as if that's not the value of the string.

It's as if gdb isn't quite smart enough or up to par for C++. I've downloaded and installed other debuggers (i.e., DDD & kdbg), only to find out that they're simply wrappers around gdb, which doesn't really help; gdb still exhibits the same problems. Are there any debuggers for Linux for debugging C++ that are a little more intuitive and smarter?
 
Old 01-25-2006, 08:16 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Quote:
I've been a little frustrated with users when I give them my code. For one, they doesn't seem smart enough to realise that when they test the code they should at least fix it. Instead they tell me in excruciating datal what they did...
Seriously though GDB does show you the contents of the string, in excruciating detail, and the value you're interested in is typically the last part. The bit in quotes, that is the content. If you use a wrapper like kdbg then it breaks the output down to show you the actual content.

I think it really depends on what people are looking for in a debugger. gdb is very powerful and in my experience using the c_str() or data() doesn't work, I think it is to do with how the data is dynamically allocated within the string.

But if your only problem is that the display of string data isn't pretty then I doubt that is a real problem. Learn to use it. Play with the breakpoints, watchpoint, and run little scripts at a breakpoint.

graeme.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GDB (GNU DeBugger) plutonas Linux - Software 8 03-19-2013 12:09 PM
normal gdb and spec gdb for kgdb Igor007 Linux - Newbie 1 09-23-2005 01:41 PM
Compiling xmame for debugging: gdb and mame debugger CooManChu Linux - Games 0 05-29-2005 10:22 AM
gdb .. looking for 32 bit gdb.. for ia64 suse.. nkshirsagar SUSE / openSUSE 0 12-09-2004 03:02 AM
problem i using emacs with gdb debugger? varala_kanth Linux - Software 2 04-05-2004 01:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration