Try   HackMD

使用GDB與Valgrind進行debug

tags: code C debug
撰寫時間 : 2021/08/27

教學文章與影片

案例

在建構時向heap區申請空間,卻沒有在構析函數時釋放

g++ -o main -Wall -ggdb3 main.cpp
valgrind --leak-check=full ./main

此時terminal可顯示可能出錯在第幾行。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
完成debug

file main

結尾出現..., with debug_info, not stripped 在輸入以剝掉一些符號和除錯訊息。

strip hw26