aldol_reaction's blog

By aldol_reaction, history, 4 years ago, In English

Could you give me a suggestion? I wonder that in competitive programming debugging with gdb will improve efficiency or not? Now I just use IDE such as Dev Cpp, print something for debugging. Is necessary for me to learn gdb and use it in debugging for competitive programming? If you could gvie me advice, I would so grateful.

  • Vote: I like it
  • +4
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it +2 Vote: I do not like it

I'm used to debugging through comments, delete(to find which code has segmentation fault or cause Endless loop), and output(to find if the value is correct). And I think it is enough for algorithm competitions. Breakpoint debugging is too slow. But if you want to learn more debugging skills. You could watch this video from our school.

»
4 years ago, # |
  Vote: I like it +10 Vote: I do not like it

ahahhaah firstly, i read title like "debug my gcd or die".

»
4 years ago, # |
  Vote: I like it +8 Vote: I do not like it

I personally use multiple compiler flags which help me cover different runtime errors. It helps in detecting overflows, vector out of bounds ,stack overflow ,divide by zero by giving a better description of issue rather than just segmentation fault.

Compiler flags: -Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector

Note: Using these compiler flags will make the program run slower during testing.

For more information on debugging : Compilation and Debugging

»
16 months ago, # |
  Vote: I like it +1 Vote: I do not like it

is any offline version for it

»
16 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Great website for debugging visually