This commit is contained in:
Miloslav Ciz 2024-02-27 19:40:51 +01:00
parent 40e30eb386
commit e0e62826e2
4 changed files with 1677 additions and 1674 deletions

View file

@ -19,6 +19,8 @@ Debugging programs mostly happens in these steps:
For debugging your program it may greatly help to make **debugging builds** -- you may pass flags to your compiler that make the program better for debugging, e.g. with [gcc](gcc.md) you will likely want to use `-g` (generate debug symbols) and `-Og` (optimize for debugging) flags. Without this debuggers will still work but may be e.g. unable to tell you the name of function inside which the program crashed etc.
Also as with everything you get better at debugging with practice, especially when you learn about common types of bugs and how they manifest -- for example you'll learn to just quickly scan for the famous *[off by one](off_by_one.md)* bugs near any loop, you'll learn that when a value grows and then jumps to zero it's an [overflow](overflow.md), that your program getting stuck and crashing after a while could mean infinite [recursion](recursion.md) etc.
The following are some of the most common methods used to debug software, roughly in order by which one typically applies them in practice.
### Testing