User forums > Help

Need help how to setup for debugger in CB16.01

<< < (2/2)

BlueHazzard:
it is crossed out because
--- Code: ---[s]
--- End code ---
as you typed starts the crossing

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


--- Quote from: papagym 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.

--- End quote ---
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

oBFusCATed:

--- Quote from: BlueHazzard on July 13, 2016, 09:47:43 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? )

--- End quote ---
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.

papagym:
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/]

--- End code ---

BlueHazzard:

--- Quote from: papagym on July 13, 2016, 08:46:46 pm ---1. Should I always compile a project just before debugging it?

--- End quote ---
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


--- Quote from: papagym on July 13, 2016, 08:46:46 pm ---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?

--- End quote ---
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...


--- Quote from: papagym on July 13, 2016, 08:46:46 pm ---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?

--- End quote ---
Stop and start the debugger again. The logs will get cleared automatically, and the watches will get updated also...

Navigation

[0] Message Index

[*] Previous page

Go to full version