Does gdb show C++ source code?

  • Thread starter Ramon F Herrera
  • Start date
R

Ramon F Herrera

I am running gdb on a C++ executable. The code that I wrote looks like
this:

itr = doc.GetFieldIterator();

while (itr.HasNext()) {
Field field = itr.Current();
// Console.WriteLine("Field name: {0}", field.GetName());
// printf("Field name: %s\n", (char *)field.GetName());
printf("Hola %d\n", i);
itr.Next();
i++;
}


However, gdb shows some very different code:

new_allocator() throw() { }
int i = 1;
inline Iterator() : mp_impl(0) {}
new_allocator() throw() { }
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
inline PDFDoc::pDFDoc (const char* filepath) {
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
{ return strlen(__s); }


Is there any way I can have gdb display higher level code?

TIA,

-RFH
 
C

Christopher

I am running gdb on a C++ executable. The code that I wrote looks like
this:

itr = doc.GetFieldIterator();

while (itr.HasNext()) {
Field field = itr.Current();
// Console.WriteLine("Field name: {0}", field.GetName());
// printf("Field name: %s\n", (char *)field.GetName());
printf("Hola %d\n", i);
itr.Next();
i++;
}

However, gdb shows some very different code:

new_allocator() throw() { }
int i = 1;
inline Iterator() : mp_impl(0) {}
new_allocator() throw() { }
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
inline PDFDoc::pDFDoc (const char* filepath) {
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
{ return strlen(__s); }

Is there any way I can have gdb display higher level code?

TIA,

-RFH

Consult a GDB newsgroup, forum, after first consulting the manual. The
question is off topic here.
 
R

Ramon F Herrera

Consult a GDB newsgroup, forum, after first consulting the manual. The
question is off topic here.


There is no such thing as a gdb newsgroup.

Are you saying that C++ developers do not know anything about gdb and
its applicability to C++ code?

I am sure a lot of people would like to disagree.

-RFH
 
D

Default User

Ramon said:
There is no such thing as a gdb newsgroup.

There are gcc newsgroups. You'd also probably be ok in
comp.unix.programmer, although I couldn't say for certain. I'd review
their FAQ if available.
Are you saying that C++ developers do not know anything about gdb and
its applicability to C++ code?

No, he's saying it's off-topic here. Please review the FAQ for
topicality guidelines.
I am sure a lot of people would like to disagree.

Some would. That's irrelevant. The group consensus is that
platform-specific topics, including tools such as compilers and
debuggers, are off-topic here.




Brian
 
C

Christopher

There is no such thing as a gdb newsgroup.

Not my problem. Learn how to research for information.
If there is no newsgroup specifically for GDB than there are bound to
be related newsgroups where GDB is on topic. The answer to your
question doesn't require a NG anyway. Type "man gdb" and RTFM!!!! If
you can't decypher what you are looking for, then look for a NG. If
you can't find a newsgroup where it is in fact on topic, then look for
a forum. If you can't find a forum, go on IRC. Must I explain how to
look things up for you like your 5th grade librarian?

Are you saying that C++ developers do not know anything about gdb and
its applicability to C++ code?

Nope. Everything a C++ developer knows is not on topic here. What is
on topic here is the language itself. Read the FAQ. I know that if I
pick my nose too long, it might bleed, but no one here cares and it is
not on topic.
I am sure a lot of people would like to disagree.

They can disagree all they want. What is and isn't on topic is not up
to every Joe Bob that comes along. It was decided and written for good
purpose. I didn't have anything to do with it, but I sure do agree
with it. I do not want to wade through thousands of posts about every
tool, IDE, or third party library in existence. they all have their
own documentation and resources to consult. Problem is people are too
lazy to look things up for themselves.
 
R

Ramon F Herrera

Not my problem. Learn how to research for information.

And your opinions are not my problem, either.

YOU ARE the one off topic, here. You have obvious control issues. Any
psychiatrist will tell you that.

Haven't you heard of a newsgroup called comp.lang.c++.MODERATED? Apply
for a moderator position there, and stop barking.

Oh, now I realize: You have the *need* to bark. See shrink advice
above.

-RFH
 
R

red floyd

Ramon said:
And your opinions are not my problem, either.

YOU ARE the one off topic, here. You have obvious control issues. Any
psychiatrist will tell you that.

Haven't you heard of a newsgroup called comp.lang.c++.MODERATED? Apply
for a moderator position there, and stop barking.

Oh, now I realize: You have the *need* to bark. See shrink advice
above.

No, the FAQ for the group says you're off-topic. See
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Also, if there weren't a bunch of off-topic grouches, the signal to
noise ratio for this group would be awful, and it would devolve into yet
another Windows programming group.
 
R

Ramon F Herrera

There are gcc newsgroups. You'd also probably be ok in
comp.unix.programmer, although I couldn't say for certain. I'd review
their FAQ if available.


No, he's saying it's off-topic here. Please review the FAQ for
topicality guidelines.


Some would. That's irrelevant. The group consensus is that
platform-specific topics, including tools such as compilers and
debuggers, are off-topic here.

Brian
The group consensus

Group consensus!?

You said: Group Consensus!!??

You have got to be kidding, Brian.

Can you produce the charter? Send me the notarized documentation?

Once again: you guys got what you wanted, and it is called: comp.lang.c
++.MODERATED

-RFH
 
R

Ramon F Herrera

There is a lesson for you to learn, Chris:

Just because you don't know the answer to something, it doesn't mean
it is off topic.

-RFH
 
D

Default User

Ramon said:
Group consensus!?

Yes.
You said: Group Consensus!!??

Yes. English troublesome for you?
You have got to be kidding, Brian.
No.

Can you produce the charter?

The group does not have one, hence the group consensus.


As you seem determined to be an ass, it's good old:

*plonk*

See ya in the funny papers.




Brian
 
C

Christopher

There is a lesson for you to learn, Chris:

Just because you don't know the answer to something, it doesn't mean
it is off topic.

-RFH

It took me 5 seconds to Google the answer before I made my first
reply. I also happen to have a GDB cheat sheet in front of me
containing the answer as well, which was written after reading the
manual for GDB online at their website. That is something you should
be doing instead of trolling here. Again, learn how to research before
you learn how to program.
You are correct, there are lots of things I do not know that _are_ on
topic. I might even ask about some of those in this group *gasp*.
However, the use of your choice in debuggers is not one of them.
 
H

happyasaclam111

I am running gdb on a C++ executable. The code that I wrote looks like
this:

itr = doc.GetFieldIterator();

while (itr.HasNext()) {
    Field field = itr.Current();
    // Console.WriteLine("Field name: {0}", field.GetName());
    // printf("Field name: %s\n", (char *)field.GetName());
    printf("Hola %d\n", i);
    itr.Next();
    i++;
    }

However, gdb shows some very different code:

new_allocator() throw() { }
int             i = 1;
inline Iterator() : mp_impl(0) {}
new_allocator() throw() { }
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
inline PDFDoc::pDFDoc (const char* filepath) {
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
{ return strlen(__s); }

Is there any way I can have gdb display higher level code?

TIA,

-RFH

If you are using gcc, try "g++ -g file.cpp" I think that does what
you are looking for
 
G

gdonald

I am running gdb on a C++ executable. The code that I wrote looks like

Probably wasn't compiled with debugging symbols.
Is there any way I can have gdb display higher level code?

Recompile with something like:

g++ -gstabs -Wall main.cpp -o foo


Here are those two flags from `man g++`

-gstabs
Produce debugging information in stabs format (if that is
supported), without GDB extensions. This is the format
used by DBX on most BSD systems. On MIPS, Alpha and System
V Release 4 systems this option produces stabs
debugging output which is not understood by DBX or SDB. On
System V Release 4 systems this option requires the
GNU assembler.

-Wall
Turns on all optional warnings which are desirable for
normal code. At present this is -Wcomment, -Wtrigraphs,
-Wmultichar and a warning about integer promotion causing a
change of sign in "#if" expressions. Note that many
of the preprocessor's warnings are on by default and have
no options to control them.


After that gdb will actually become useful:
gdb ./foo
Reading symbols for shared libraries .... done
(gdb) b main
Breakpoint 1 at 0x24e2: file main.cpp, line 5.
(gdb) r
Starting program: /Users/donaldg/foo
Reading symbols for shared libraries +++. done

Breakpoint 1, main () at main.cpp:5
5 return 0;
(gdb) The program is running. Exit anyway? (y or n) ^D
 
J

Jerry Coffin

[ ... ]
YOU ARE the one off topic, here. You have obvious control issues. Any
psychiatrist will tell you that.

Haven't you heard of a newsgroup called comp.lang.c++.MODERATED? Apply
for a moderator position there, and stop barking.

....and Mr. Herrera's posts suffer the death of a thousand plonks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top