Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: maxcy on October 17, 2023, 10:46:50 pm

Title: compiler debug code
Post by: maxcy 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
Title: Re: compiler debug code
Post by: 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).
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.
Title: Re: compiler debug code
Post by: nenin 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/
Title: Re: compiler debug code
Post by: 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
Title: Re: compiler debug code
Post by: stahta01 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.
Title: Re: compiler debug code
Post by: Pecan 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?