Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » -g3 debug not work,when list.push_back (When I have a list class in my C + + function, use push_ When the back function is used, G3 level debugging cannot be performed (it can be compiled and run, and G1 level debugging can be performed))
-g3 debug not work,when list.push_back [message #1828412] Tue, 09 June 2020 11:14 Go to next message
Tianshi Qiu is currently offline Tianshi QiuFriend
Messages: 1
Registered: June 2020
Junior Member
index.php/fa/38289/0/When I have a list class in my C + + function, When the push_ back function is used, G3 level debugging cannot be performed (it can be compiled and run, and G1 level debugging can be performed).
When I click F8 or next, the debug will not work normally, but will be stuck directly.
I suspect it's because of the list push_ back belongs to C + + 11,
I've tried push in other containers_ The back function, such as stack, is OK.

#include <iostream>
#include <list>
#include <deque>
#include <stack>
#include <map>
using namespace std;

int main() {
list<int> lst;
map<int, int> m;
stack<int> ss;
deque<int> dq;
lst.push_back(12);
cout << dq.front() << endl;
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}index.php/fa/38289/0/index.php/fa/38290/0/
Re: -g3 debug not work,when list.push_back [message #1828441 is a reply to message #1828412] Tue, 09 June 2020 17:51 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Do you have optimization enabled?
If so, use -O0

UPDATE:

Using -g3 and trying to stop at main does indeed hang.
However, not stopping at main but on the lst.push_back() works as expected.
Also happens when using -g (equivalent to -g2)

This only seems to happen when the Variables view is being used.
If the Expressions view is selected instead, the debugger acts as expected.
It may be caused by the debugger trying to read the values of the variables before they have been initialized.
This can cause the debugger to appear to hang as it's caught in a never-ending search.

I've seen this behavior with uninitialized sets.

Moving the local variables to global may help and did so in this case.
But it may depend on the containers used.

I say "debugger" here and I mean Eclipse.
gdb won't try to list variables unless asked.

The only surefire way of avoiding this is to never stop the program
when there are uninitialized variables -- particularly if they are STL containers.

Note: the line of code cout << dq.front() << endl; is in error.
Using front() on an empty deque is attempting to fetch an undefined reference.


[Updated on: Wed, 10 June 2020 02:03]

Report message to a moderator

Previous Topic:Launch external translator program according file extension
Next Topic:GNU Tools for ARM embedded processors vs GNU MCU eclipse ARM embedded GCC
Goto Forum:
  


Current Time: Tue Apr 23 17:38:13 GMT 2024

Powered by FUDForum. Page generated in 0.02903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top