0

I am following the C++ Debugging tutorial section (https://help.eclipse.org/photon/index.jsp) in the Eclipse Photon documentation. I have followed all the instructions creating the first C++ project and I'm at the 'Debugging project' section. My problem is that after I create my debug perspective and hit the 'Debug' button the debugger never stops on my set breakpoint. In the Debug window it just says and the loop of the program doesn't even produce any output at all. If you run the program normally the loop prints to the console, but nothing happens in debug perspective.

I have tried deleting my debug perspective and creating a new one and I'm having the same issues. I have uploaded screenshots of my debug configuration.

https://imgur.com/a/MXYHxJl
https://imgur.com/a/eEU47Ht
https://imgur.com/a/koOf08x

#include <iostream>
using namespace std;

int main () {
    // Say HelloWorld five times
    for (int index = 0; index < 5; ++index)
      cout << "HelloWorld!" << endl;
    char input = 'i';
    cout << "To exit, press 'm' then the 'Enter' key." << endl;
    cin  >> input;
    while(input != 'm') {
        cout << "You just entered '" << input << "'. "
             << "You need to enter 'm' to exit." << endl;
        cin  >> input;
    }
    cout << "Thank you. Exiting." << endl;
    return 0;
}
arooney88
  • 195
  • 1
  • 7
  • 21
  • There are problems in your problems view. Could it have something to do with it? In the Debug perspective there is a view called "Debug" which shows the application being run and its stacktrace. Do you see your application running there? – Benjamin Bihler Jan 15 '19 at 08:15
  • @BenjaminBihler The problems are related to other programs that were written in Java. I am using Photon and those are from old Java projects that need to be updated. I can only see the application being ran when I run the program outside of the debugging perspective. When I run "normally" the application prints to the console and prints out the loop asking for a character input. But when I place a breakpoint and start debugging, I just get the change to debug perspective but then "terminated" status in my debug window. I never see anything printed out in Debug perspective. – arooney88 Jan 15 '19 at 14:02
  • Hmmm, that is strange. In the "Debugger" tab of the debug configuration you can set whether you want to stop on startup at the main method. This could prevent the output, if the debugger immediately stopped there and you didn't tell it to continue. But if the application is reported to have terminated, then there must be another problem. You might want to execute the debugger from the command line to see whether that works. Unfortunately I have no more ideas right now... – Benjamin Bihler Jan 15 '19 at 14:09
  • Perhaps you have misunderstood me. Don't try to figure out whether the application is running by looking at the console. Check the view "Debug" in the debug perspective. While debugging, there should be a tree. The top node should have the name of your application. You could actually set the debug configuration to stop on main. Then in the debug perspective you should be able to investigate your (stopped) application before anything happens. – Benjamin Bihler Jan 15 '19 at 14:15
  • @BenjaminBihler I checked my configuration and I did have the 'stop on startup at: Main' checked. I included screenshots of my debug configuration settings as well. I am looking in the debug perspective when I see the 'terminated' status. The debug tree can expand and when I do that I just see gdb (7.6.1). Any ideas? I am at a loss why this isn't stopping at the breakpoint. I haven't had these issues debugging Java applications. – arooney88 Jan 15 '19 at 15:30
  • C++ is more complicated than Java when it comes to debugging. Still that works fine here with Eclipse CDT. Your screenshots look fine, I cannot spot any error. I am sorry, but I have run out of ideas. – Benjamin Bihler Jan 15 '19 at 15:46

1 Answers1

0

I found a solution to my problem following instructions in this other post: Eclipse C++ MinGW - Can not Lauch Program <Terminated> The 2nd answer is what worked for me.

I had to right click on my project - - > properties - -> Run/Debug settings - - > click your launch configuration and click 'edit'. Once inside the edit screen click the 'environment' tab and add the following variable Name = PATH VALUE = %PATH%;C:\MINGW/BIN

I did not have anything set inside the environment and changing to the above has made the debugger stop at the correct breakpoints within the program.

arooney88
  • 195
  • 1
  • 7
  • 21
  • But you have written that you have been able to run the program normally. What means normally? With a normal eclipse launch configuration? Then you must have already set this path!!! – Benjamin Bihler Jan 16 '19 at 07:14
  • @BenjaminBihler When I ran the 'run configuration' the program would print to console and run the program as intended. But when I ran the debugger, nothing would happen when it changed to the perspective, and I had my error I initially posted about. After finding the post I linked to in the answer, I also had to set my system environment variables and updated PATH to have C:\MinGW\bin be first in my list. Doing this and also following the instructions I posted in my answer made the debugger actually stop at the breakpoint. – arooney88 Jan 16 '19 at 19:29