Presentation is loading. Please wait.

Presentation is loading. Please wait.

a.k.a how we test Your code

Similar presentations


Presentation on theme: "a.k.a how we test Your code"— Presentation transcript:

1 a.k.a how we test Your code
Debugging a.k.a how we test Your code

2 Some methods Making the compiler (gcc) “furious” Valgrind gdb
Tools provided by the IDE 2017

3 gcc -Wall – show ‘most’ of the default compiler warnings -Wextra – show even more of the default compiler warnings -pedantic – strict ISO C -Wunreachable-code – code, that will never be run -Wfloat-equal – floating point comparisons -Wshadow – two variables with the same name in the same scope -Wconversion – possible errors due to different types -Wmissing-declaration – no previous declaration of function prototype -g – debugging symbols e.t.c. 2017

4 gdb It can run code line by line
You can observe the values of your variables See the last lines executed before program crash Manually assigning values to variables e.t.c. More on the subject: man gdb internet 2017

5 Valgrind – identifying memory issues
For now: Using uninitialized variables Reading from memory locations not belonging to you Writing to memory locations not belonging to you Using NULL pointers Using invalid pointers In the future: Memory leaks (lost pointers) Unreleased resources Recurring frees to resources e.t.c 2017

6 How to use it? Additional flag to compilation -g (same for gdb) gcc -g -o myprogram codefile.c -Wall -g adds debugging symbols to the compiled binary so that you can for example find the line number that causes the error To run it valgrind --tool=memcheck --leak-check=full ./myprogram 2017


Download ppt "a.k.a how we test Your code"

Similar presentations


Ads by Google