* [[Perf]] * [[VTune]] * [[SystemTap]] * [[http://code.google.com/p/kgtp/|KGTP]] * [[http://lenky.info/2011/11/22/kgtp%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/|kgtp使用总结]] ====== GNU gprof ====== * [[http://www.thegeekstuff.com/2012/08/gprof-tutorial/|GPROF Tutorial – How to use Linux GNU GCC Profiling Tool]] ====== Valgrind ====== $ valgrind --tool=callgrind qemu-system-i386 linux-0.2.img -vnc 0.0.0.0:1 ==20950== Callgrind, a call-graph generating cache profiler ==20950== Copyright (C) 2002-2011, and GNU GPL'd, by Josef Weidendorfer et al. ==20950== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==20950== Command: /nfs_home/chenwj/install/bin/qemu-system-i386 linux-0.2.img -vnc 0.0.0.0:1 ==20950== ==20950== For interactive control, run 'callgrind_control -h'. * [[http://valgrind.org/docs/manual/index.html|Valgrind]] * [[http://blog.dccmx.com/2011/01/callgrind/|让程序飞 之 性能工具:valgrind –tool=callgrind & kcachegrind]] * [[http://valgrind.org/docs/manual/cl-manual.html|Callgrind: a call-graph generating cache and branch prediction profiler]] * [[http://www.cprogramming.com/debugging/valgrind.html|Using Valgrind to Find Memory Leaks and Invalid Memory Use]] * [[http://sourceforge.net/projects/valgrind4win/|Valgrind for Windows]] * [[http://www.mingw.org/wiki/howto_compile_and_use_the_mpatrol_memory_leak_detection_library|HOWTO compile and use the mpatrol memory leak detection library]] ====== Address Sanitizer ====== * [[wp>AddressSanitizer]] * [[https://fuzzing-project.org/tutorial2.html|Part 2: Find more Bugs with Address Sanitizer]] * [[http://stackoverflow.com/questions/31144000/mingw-w64s-gcc-and-address-sanitizer|MinGW-w64's gcc and Address Sanitizer]] * MinGW 目前不支援 AddressSanitizer。 ====== Dr. Memory ====== * [[http://www.drmemory.org/|Dr. Memory]] * [[https://latedev.wordpress.com/2012/05/19/valgrind-for-windows/|Dr. Memory – Valgrind For Windows?]] * 下載 Windows 安裝包並安裝。目前只能處理 32 位元的執行檔。 * 參考 [[http://drmemory.org/docs/page_prep.html|Preparing Your Application]] 編譯 32 位元的執行檔。 * [[http://drmemory.org/docs/page_types.html|Error Types Reported by Dr. Memory]] * [[http://drmemory.org/docs/page_unaddr.html|Unaddressable Access]]: 存取尚未配置的內存空間。 * [[http://drmemory.org/docs/page_uninit.html|Uninitialized Read]]: 讀取尚未初始化的內存空間。 * [[http://drmemory.org/docs/page_invarg.html|Invalid Heap Argument]]: 指針配置和釋放錯誤。 * [[http://drmemory.org/docs/page_leaks.html|Memory Leaks]]: 內存洩漏。 * [[http://drmemory.org/docs/page_gdi.html|GDI Usage Errors]]: [[https://msdn.microsoft.com/zh-tw/library/windows/desktop/dd145203(v=vs.85).aspx|Windows GDI]] API 使用上的錯誤。''-no_check_gdi'' 選項可以禁用此類報告。 * [[http://drmemory.org/docs/page_handle.html|Handle Leaks]]: Windows 句柄洩漏。''-no_check_handle_leaks'' 選項可以禁用此類報告。 * [[http://drmemory.org/docs/page_options.html|Dr. Memory Runtime Option Reference]] ====== Embedded ====== * [[http://stackoverflow.com/questions/8703441/profiling-on-baremetal-embedded-systems-arm|Profiling on baremetal embedded systems (ARM)]] * [[https://istarc.wordpress.com/2014/09/06/stm32f4-bug-hunting-with-profiler/|STM32F4 – On Hunting Bugs with a Profiler]] * [[http://mcuoneclipse.com/2015/08/11/sneak-preview-profiling-bare-metal-microcontroller-applications-with-gnu-gprof/|Sneak Preview: Profiling Bare Metal Microcontroller Applications with GNU gprof]] * [[http://mcuoneclipse.com/2015/08/23/tutorial-using-gnu-profiling-gprof-with-arm-cortex-m/|Tutorial: Using GNU Profiling (gprof) with ARM Cortex-M]] ====== 其它 ====== * [[http://stackoverflow.com/questions/1761125/gcc-memory-leak-detection-equivalent-to-microsoft-crtdbg-h|GCC memory leak detection equivalent to Microsoft crtdbg.h?]] * [[http://wyw.dcweb.cn/leakage.htm|A Cross-Platform Memory Leak Detector]] * 僅針對 C++ 的 new/delete,對 C 的 malloc/free 不起作用。 * 近似 Dr. Memory 偵測 Memory Leaks 錯誤。 * [[http://stackoverflow.com/questions/15909788/how-does-gcc-behave-if-passed-conflicting-compiler-flags|How does GCC behave if passed conflicting compiler flags?]] * [[http://superuser.com/questions/105731/does-the-order-of-command-options-in-linux-matter|Does the order of command options in linux matter?]] * 相同類型選項,一般處理方式以後者為主。例如: ''-mthumb -marm'' 中,以 ''-marm'' 為主。''-O3 -O2'' 中,以 ''-O2'' 為主。 * [[https://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html|3 GCC Command Options]] * ''-L/Path1 -L/Path2'' 則會依序從 ''/Path1'' 和 ''Path2'' 尋找欲鏈結的函式庫。