News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

compiler debug code

Started by maxcy, October 17, 2023, 10:46:50 PM

Previous topic - Next topic

maxcy

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

Miguel Gimenez

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.

nenin

Quote from: Miguel Gimenez 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).
Here it is: https://github.com/ssbssa/gdb/

maxcy

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

stahta01

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++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Pecan

Quote from: maxcy 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
Are you sure you have the -g compile option enabled and the optimization option disabled?