Author Topic: Need help how to setup for debugger in CB16.01  (Read 6218 times)

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Need help how to setup for debugger in CB16.01
« on: July 09, 2016, 11:45:23 pm »
This post is kind of wordy and I apologize.  This info may also be beneficial to other users.  I'm using Windows 10 64 pro, mingw GNU W64, and CB 16.01

The code::blocks wiki is of little use on how to setup and uses the debugger in version 16.01 since the last version show in there is 12xx. Then the 16xx dialog box for the compiler setting it totally different.  I have attempted to use the debugger may times without success and searched many websites for help.  I'm adding a screen snip of my complies settings and a copy of the data shown in the debugger screen after trying to run a (debug version) of my project.  Can you please check to make sure I have the setting boxes checked right. Any help you will give me to get the debugger working will be appreciated, Thanks. A current hyperlink would help.

Info from Debugger window:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6.1
Starting the debuggee failed: No executable specified, use `target exec'.
Debugger finished with status 0

Compiler Settings:


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Need help how to setup for debugger in CB16.01
« Reply #1 on: July 10, 2016, 12:21:44 am »
Starting the debuggee failed: No executable specified, use `target exec'.
My guess is that you're using path with spaces or other non-ascii-alphabet characters.
But you have to paste full debugger log to make sure this is the case. You can enable this log in Settings -> Debugger.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Need help how to setup for debugger in CB16.01
« Reply #2 on: July 13, 2016, 02:53:02 am »
If my project compiled ok with the path I used shouldn't it work with the debugger as well?  I have all my projects under D:\CB-Projects but Code::Blocks is under D:\Program Files (x86)\CodeBlocks.

I have the compiler flag Debugger symbols [-g] box checked.  But the old wiki shows another box checked below it checked.  I don't know if I need it or not in CB16.01, since I can't expand the wiki picture to read what it says.  I'm not sure if I need?  The wiki says something about a switch.  Is this available on 16.01 and where?  I know I can resize the compiler settings window to make it bigger.

I'll send in a log once I have ever thing set properly in 16.01.
« Last Edit: July 13, 2016, 02:55:21 am by papagym »

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Need help how to setup for debugger in CB16.01
« Reply #3 on: July 13, 2016, 02:57:56 am »
Why did part of my post got crossed out? It shouldn't be.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: Need help how to setup for debugger in CB16.01
« Reply #4 on: July 13, 2016, 03:06:21 am »
Why did part of my post got crossed out? It shouldn't be.

Likely because you did it. Please look at the B I U S buttons; you likely hit the S button.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Need help how to setup for debugger in CB16.01
« Reply #5 on: July 13, 2016, 09:47:43 am »
it is crossed out because
Code
[s]
as you typed starts the crossing

i don't think there is any parameter other than -g needed...

If my project compiled ok with the path I used shouldn't it work with the debugger as well?  I have all my projects under D:\CB-Projects but Code::Blocks is under D:\Program Files (x86)\CodeBlocks.
No, because the debugger gets started over command line, and there the parameters are separated with a empty space, so if your path contains an empty space gdb thinks that this is a second parameter (@ dev: shouldn't there be escaping for this? )
Also the "-" can make problems, because it flags a new parameter. This all comes from old console times. It is generally good practice in the programming world to use only english characters and no spaces or "-" in filenames and paths, because the compiler are manly used from professionals and they use anyway filenames like i described ;) it helps sharing code between platforms and os versions...

I never had this issue, so if you tell us that all your projects are not working with the debugger i think something with your base project path is wrong, or with your target settings...

greetings
« Last Edit: July 13, 2016, 09:51:51 am by BlueHazzard »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Need help how to setup for debugger in CB16.01
« Reply #6 on: July 13, 2016, 10:42:45 am »
No, because the debugger gets started over command line, and there the parameters are separated with a empty space, so if your path contains an empty space gdb thinks that this is a second parameter (@ dev: shouldn't there be escaping for this? )
I think the main problem when using paths with spaces is setting breakpoints.
Starting the debuggee should work fine. I'm not sure if placing gdb in path with spaces should work, though.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Need help how to setup for debugger in CB16.01
« Reply #7 on: July 13, 2016, 08:46:46 pm »
Thanks for all the feedback.  I was finely able to get the debugger to work with a program I found on line. (For other users, I included the code below into a new project I called Factorial. No other code was added)  I didn't make any changes to the path I showed earlier. I'm now using TDM-GCC-64 5.1.0-2 compiler and I may not have had my default debuggers set to GDB64.

I had no idea of how to use the debugger before.  Although all the project I have compiled, I may not have been using the debugger properly to test them.

To debug this project I set one breakpoint on int main and stepped from there. Also opened the debugger window-watches, then resized it a bit bigger then dragged it into the log area and anchored it there so I could watch it. (This is a nice CB feature)

I did note a few things that I have questions on:
1. Should I always compile a project just before debugging it?
2. In windows 10 the console window disappears out of sight as soon as you run debug, however it gets pinned to the tool bar, so I can open it if I want.  Is this a problem and is there a work around?
3. If I want to restart the debugger on the same project again.  How do I clear all logs and text to restart the debugger? Can this be done with one command?

Code
/* Good Program to test your debugger
 * Fails when n=21
 * Compute the factorial of n, with n=20.
 *    n! = 1*2*3*...*n
 */
#include <iostream>
using namespace std;

int main() {
   int n = 20;         // To compute factorial of n
   int factorial = 1;  // Initialize the product to 1

   int i = 1;
   while (i <= n) {
      factorial = factorial * i;
      i++;
   }
   cout << "The Factorial of " << n << " is " << factorial << endl;
   return 0;
}
[code/]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Need help how to setup for debugger in CB16.01
« Reply #8 on: July 14, 2016, 02:06:55 pm »
1. Should I always compile a project just before debugging it?
well debugging works on the executable, not on your "code", so if you want to debug your actual code, you have to compile it before to a executable... But codeblocks will ask you if you want to build the code before debugging

2. In windows 10 the console window disappears out of sight as soon as you run debug, however it gets pinned to the tool bar, so I can open it if I want.  Is this a problem and is there a work around?
Codeblocks comes to front when the debugger stops, so if you put a breakpoint in the first line of your code, codeblocks will pop up as soon the program starts... If you place your breakpoint later in your code the console window will be  on front as long as you don't reach the breakpoint. This is intended behavior, because if the debugger stops your program is haled and won't react on any action...

3. If I want to restart the debugger on the same project again.  How do I clear all logs and text to restart the debugger? Can this be done with one command?
Stop and start the debugger again. The logs will get cleared automatically, and the watches will get updated also...