473,653 Members | 3,000 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debugging C++ program in GDB on linux

I am trying to debug a C++ program in GDB on linux.
I want to dump out the content of the "this" object,
Here is what I get:
(gdb) print *this
$2 = {path = <incomplete type>}

My question is why I don't see the content of 'path'? It said
'<incomplete type>'.

In the code, path is:
ostringstream path;

When I try to do this: at GDB prompt 'print this->path.str()' , I get
this error:

(gdb) print this->path.str()
Couldn't find method ostringstream:: str

Jan 21 '06 #1
4 7059
yi*****@gmail.c om wrote:
I am trying to debug a C++ program in GDB on linux.
I want to dump out the content of the "this" object,
Here is what I get:
(gdb) print *this
$2 = {path = <incomplete type>}

My question is why I don't see the content of 'path'? It said
'<incomplete type>'.
[..]


This is OT here. Please consider asking in 'gnu.gdb' or in
'gnu.utils.help ' or as a last resort in the newsgroup for your
operating system (comp.os.linux. develpment.* hierarchy).

V
Jan 21 '06 #2
yi*****@gmail.c om wrote:
I am trying to debug a C++ program in GDB on linux.
I want to dump out the content of the "this" object,
Here is what I get:
(gdb) print *this
I think its not the right way. There are multiple *this in a given
program. Its like using a compiler. If you randomly say:

int main()
{
*this->print();
}

then it doesn't mean anything. C++ compilers do name mangling (ok I
don't know what I am talking about) which gives everything a unique
name, and same goes for debuggers. You have to give the name of the
object you are trying to call a method of.
$2 = {path = <incomplete type>}

My question is why I don't see the content of 'path'? It said
'<incomplete type>'.
Of course it is incomplete. *this doesn't exist on its own.

In the code, path is:
ostringstream path;

When I try to do this: at GDB prompt 'print this->path.str()' , I get
this error:

(gdb) print this->path.str()
Couldn't find method ostringstream:: str


Same...and once you have the names ready just follow Victor's advice
and look in the newsgroups he suggests.

Jan 21 '06 #3
Hello,

yi*****@gmail.c om wrote:
I am trying to debug a C++ program in GDB on linux.
I want to dump out the content of the "this" object,
Here is what I get:
(gdb) print *this
$2 = {path = <incomplete type>}

My question is why I don't see the content of 'path'? It said
'<incomplete type>'.

In the code, path is:
ostringstream path;

When I try to do this: at GDB prompt 'print this->path.str()' , I get
this error:

(gdb) print this->path.str()
Couldn't find method ostringstream:: str


While others found this off-topic, I think there are at least three
problems here connected to debugging which can be faced on all usual
C++ implementations . The subject line was clearly off-topic.

Could it be that your standard library is missing debugging information?
Then showing information about its internals will surely fail with all
C++ implementations . The incomplete type is a clear indication that
debugging information is missing.

I'm not sure, whether non-open-source implementors of a standard C++
library have the freedom to make their internals visible enough to make
some debugging sensible at all, i.e. handing out information the full
source code could be derived from easily. I would not expect
source-level debugging to be possible with all C++ implementations .
Even g++ has not enabled this by default. The runtime libraries might
have to be recompiled to make this possible.

Calling methods from a debugger might not be possible when methods are
inlined due to optimization. Maybe you can force the compiler to emit a
non-inlined version of the functions by taking their addresses. The
small missing method which is used in the code is a clear indication of
inlining.

Bernd Strieder

Jan 23 '06 #4
Bernd Strieder wrote:
Calling methods from a debugger might not be possible when
methods are inlined due to optimization. Maybe you can force the
compiler to emit a non-inlined version of the functions by
taking their addresses.


With GCC, using -fkeep-inline-functions might be preferable to
putting contrived lines in the code to do that.
Martin

--
Quidquid latine scriptum sit, altum viditur.
Jan 24 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2052
by: Joseph S. | last post by:
hi all, debugging PHP applications interactively is possible, easy and free. I am talking about PHPEclipse and using it for debugging over several scripts or debugging through a session. Since I have wasted a lot of time writing echo statements all over the code in order to confirm program flow and watch variables, I feel I must share this with others who will be facing similar problems. PHPEclispe users can go to Step 5 directly....
20
4193
by: krypto.wizard | last post by:
Is there any editor or IDE in Python (either Windows or Linux) which has very good debugging facilites like MS VisualStudio has or something like that. I like SPE but couldn't easily use winPDP. I need tips to debug my code easily. Every help is greatly appreciated. Thanks
4
2366
by: George Sakkis | last post by:
I have a pure python program (no C extensions) that occasionally core dumps in a non-reproducible way. The program is started by a (non- python) cgi script when a form is submitted. It involves running a bunch of other programs through subprocess in multiple threads and writing its output in several files. So the only suspicious parts I can think of is subprocess and/or multithreading. For the multithreading part I'm using a modified...
1
3712
by: seba | last post by:
Hi everybody, I'm trying to debud a c++ program using gdb, but I have this problem. $ gdb GNU gdb Red Hat Linux (6.5-15.fc6rh) (gdb) file ./newcall Reading symbols from /home/seba/workspace2/rel15/newcall...(no debugging symbols found)...done. Using host libthread_db library "/lib/libthread_db.so.1".
2
3694
by: Zach | last post by:
I compiled a game client and it crashed (segmentation fault) resulting in a core file being generated. I'm trying to find out exactly what caused it to crash. Any ideas how I can do this with gdb? In the Makefile can I just add a "-g" flag to have the binary produced with debugging symbols? The source is written in ANSI C. This is what I have now: "CC = gcc" The client binary is 433680 and the core file produced when it crashed
2
2646
by: Bruno Gonzalez (STenyaK) | last post by:
(first of all, sorry if this is not the correct place to ask, but i couldn't find a better one...) I'm new to debugging using core dumps. I've managed to get core dumps + symbols using g++ and gdb under linux. I compile using g++ -g -dH, and i debug using gdb executableFile -c coredumpFile. This is a test program backtrace in the original computer (a gentoo
1
1446
by: r_ahimsa_m | last post by:
Hello, I am learning PHP5 in Fedora Linux. I use Quanta+ 3.5. I have written a program that I would like to debug but I don't see Debug menu. Is it possible to debug program somehow? I know that Eclipse PDT has debugging but I prefer Quanta+ because it's fast. Is there any external debugger I could use? If not, how can I find bugs? I have read about var_dump(). What functions could I use? /RAM/
2
20835
jwwicks
by: jwwicks | last post by:
C/C++ Programs and Debugging in Linux This tutorial will give you a basic idea how to debug a program in Linux using GDB. As you are aware Visual Studio doesn’t run on Linux so you have to use some of the tools provided on the command-line. If you hate the command line tools, get over it since you’re bound to be using them at some point in your career. All commands in Linux ARE case sensitive so capital letters are different from lowercase...
33
2873
by: fmassei | last post by:
Hello! I made a short piece of code that I find very useful for debugging, and I wanted to ask you if it is correct, somehow acceptable or if I simply reinvented the wheel. To deal with some bad bugs caused by memory leaks I ended up with this simple solution: I made one header file that, when included, replaces the malloc/calloc/realloc/free functions with some other functions that do the actual job and insert (or remove) the pointers to...
0
8370
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5620
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.