Author Topic: compiler debug code  (Read 9129 times)

Offline maxcy

  • Multiple posting newcomer
  • *
  • Posts: 20
compiler debug code
« on: October 17, 2023, 10:46:50 pm »
main is a part of a pretty large compiler project. The first part shows the output from the parser and 0 syntax errors. The last half, if no errors, shows a pretty print of the symbol table. The first half works but the second half never shows up and the main program exits with 255 code! I put break points (lines 35 & 45) into the code, but they are ignored by the debugger!! The code is executed though all the parser lines and then ignores the errorcount if loop even though the output of the code shows 0 errors! So the code isn't working properly and the debugger isn't working either. This is very frustrating!!
maxcy / wt1v

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1564
Re: compiler debug code
« Reply #1 on: October 18, 2023, 10:20:42 am »
1.- Some GDB are known to have problems with breakpoints, there are some independent GDB you can try (there are links somewhere in the forum).
2.- You must use the debug target for debugging, the release target makes some optimizations that may ditch the line you are trying to break in.
3.- You can insert some debug lines, like cout << "Arrived here OK" and see which is missing.

Offline nenin

  • Almost regular
  • **
  • Posts: 198
Re: compiler debug code
« Reply #2 on: October 18, 2023, 09:37:28 pm »
1.- Some GDB are known to have problems with breakpoints, there are some independent GDB you can try (there are links somewhere in the forum).
Here it is: https://github.com/ssbssa/gdb/

Offline maxcy

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: compiler debug code
« Reply #3 on: October 25, 2023, 03:21:41 am »
This particular code comes from a book of 13 chapters. I've used the debugger in many of the projects throughout this book. Setting breakpoints and adding watches are no problem in any of the other projects!  Compiling in runtime/debug mode is simple!!  This particular project is an adaptation of a project from a modified project developed from the previous chapter and it debugged with no problems! But, in this particular project, when I run it the debug mode, it ignores any break points, even if I put one right after main()! Very perplexing to say the least!
maxcy

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7572
    • My Best Post
Re: compiler debug code
« Reply #4 on: December 27, 2023, 05:56:04 pm »
maxcy: I suggest posting a full debug re-build log and see if someone can see an issue.

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

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2718
Re: compiler debug code
« Reply #5 on: December 27, 2023, 11:21:01 pm »
This particular code comes from a book of 13 chapters. I've used the debugger in many of the projects throughout this book. Setting breakpoints and adding watches are no problem in any of the other projects!  Compiling in runtime/debug mode is simple!!  This particular project is an adaptation of a project from a modified project developed from the previous chapter and it debugged with no problems! But, in this particular project, when I run it the debug mode, it ignores any break points, even if I put one right after main()! Very perplexing to say the least!
maxcy
Are you sure you have the -g compile option enabled and the optimization option disabled?