News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How can I debug into the C++ source code?

Started by leeguevara, February 06, 2010, 07:12:39 AM

Previous topic - Next topic

leeguevara

Hi, all. I am a begineer of C++. I use the code::blocks, and I want to debug into the c++ source code.
For example,I write a simple code.

int main()
{
     int i=10;
     cout<<i<<endl;
}

I toggle a break point before the "cout", and I want to step into the "cout".
In the "call stack" window, I can see such message "#0 0042E583   std::ostream::operator<<(std::ostream& (*)(std::ostream&) (C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/iostream:77)"   

How can I see source code of "std::ostream::operator<<(std::ostream& (*)(std::ostream&)"?
Thanks a lot.

rcoll

Quote from: leeguevara on February 06, 2010, 07:12:39 AM
Hi, all. I am a begineer of C++. I use the code::blocks, and I want to debug into the c++ source code.
For example,I write a simple code.

int main()
{
     int i=10;
     cout<<i<<endl;
}

I toggle a break point before the "cout", and I want to step into the "cout".
In the "call stack" window, I can see such message "#0 0042E583   std::ostream::operator<<(std::ostream& (*)(std::ostream&) (C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/iostream:77)"   

How can I see source code of "std::ostream::operator<<(std::ostream& (*)(std::ostream&)"?
Thanks a lot.

You need to actually have a copy of the source code somewhere on your hard-disk; all the debugger will ever do is read that source code file and show you which line you are currently on.  If the debugger can not find the source code, it will not be able to show it to you.

Also, you really need to be asking these sorts of questions on a forum dedicated to C++ programming.  This forum is for discussing Code::Blocks (which in an IDE, not a compiler).

Ringo

ollydbg

Quote from: leeguevara on February 06, 2010, 07:12:39 AM
Hi, all. I am a begineer of C++. I use the code::blocks, and I want to debug into the c++ source code.
For example,I write a simple code.

int main()
{
     int i=10;
     cout<<i<<endl;
}

I toggle a break point before the "cout", and I want to step into the "cout".
In the "call stack" window, I can see such message "#0 0042E583   std::ostream::operator<<(std::ostream& (*)(std::ostream&) (C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/iostream:77)"   

How can I see source code of "std::ostream::operator<<(std::ostream& (*)(std::ostream&)"?
Thanks a lot.
No, you can't debug into the source of "cout". only if you're using a debug version of c++ library.
So, did you build the c++ library yourself?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

leeguevara

I didn't build the C++ library myself. I just down load the MinGW from the internet.