1

I made my code as a standalone .c file and read that, in order to debug, the file must be in a project. So I made an empty project and added my file to it, set some breakpoints and, when i run the debugger, I get this on console:

Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6.1
Child process PID: 13112
Error in re-setting breakpoint 2: PC register is not available
Error in re-setting breakpoint -3: PC register is not available
In  ()

Tried some tutorials and whatched some videos without success. Does somebody knows a fix for that? Is there a simpler way to debug a .c file?

6
  • The infromation you give is a bit sparse. Some older GDB versions (yours included) have trouble with pathnames that contain spaces and/or commas. There also was once a problem with the Solaris GDB version and debugging 32-bit app-cores with a 64-Bit GDB. Sometimes it is simpler with these IDEs to start from scratch and copy the content of the files instead of importing complete files. Commented Aug 28, 2016 at 0:29
  • You suggest making another project, then? Commented Aug 28, 2016 at 1:44
  • Tried, changed path too... Nothing changed, same error. Commented Aug 28, 2016 at 1:54
  • Feared that, sorry. But those older versions are known to be a bit picky about the input so I thought it would be worth a try. Would you mind to post the culprit, that is: the file standalone.c such that we can try it out ourselves? (would need versions of compiler, Code::Blocks , OS etc., too) Commented Aug 28, 2016 at 2:44
  • I was using the MinGW version that came with Code::Blocks 16.01. I updated MinGW and now everything Works perfectly, thank you! Commented Aug 28, 2016 at 23:56

3 Answers 3

1

For linux system you could use gdb as debugger in this way:

$ vim hello.c
# include <stdio.h>

int main()
{
    printf("hello \n");
}

$ gcc -o hello hello.c

$ ./hello
$ gdb hello
(gdb) break main
(gdb) run

and then you can use: c or continue n or next s or step For more details see this.

Sign up to request clarification or add additional context in comments.

Comments

0

Updated MinGW downloading it from its sourceforge repositor. Downloaded the 6.2.0 version that is available in this link.

Then I unziped it to C:\ and modified the environment variable Path to add the new C:\MinGW\bin folder. To know if you made it correctly just open CMD and type gcc --version.

After that, I modified the compiller and debugger settings of Code::Blocks to use the new version of MinGW and its executables.

Now it is compiling and debugging properly.

Comments

0

According to Free Pascal's GDB Debugger Tips the problem is with GDB and they cite Bug 14018.

It appears you should use a different version of GDB. They suggest downgrading to 7.2. Now I believe other versions are now available, like 8.0. I don't know if GDB 8.0 suffers it too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.