Differences between version 20 and predecessor to the previous major change of DeBugging.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 20 | Last edited on Tuesday, September 21, 2004 2:48:05 pm | by JohnMcPherson | Revert |
Older page: | version 19 | Last edited on Friday, September 10, 2004 12:03:03 pm | by PerryLorier | Revert |
@@ -2,14 +2,22 @@
----
!Contents
+* gcc compile-time options
* GDB
* strace
* signals
* Core files
* Debugging running processes
* Other tools/commands
+
+----
+!! [GCC] Compile Options
+* have -g in your CFLAGS (for [C]) or CXXFLAGS (for [C++]) environment variable so that debugging symbols are stored in your binary objects.
+* Compile with -Wall to get all 'standard' compiler warnings.
+* Compile with -Wshadow to get a warning when you declare a variable with the same name as one in an outer scope.
+* If you are using the GNU C library (eg linux systems), you can #include <mcheck.h> to get some extra debugging for malloc(3) - see the [mcheck] page
----
!! [GDB]
@@ -30,8 +38,9 @@
;step: step to the next command, or into a function call (ie go to the instructions within that function).
;next: step to the next command, or over a function call (ie treat the call as a single command)
;frame: change which frame you are working on. eg: "frame 1" will change the scope to frame 1.
+----
!!Other useful debugging tricks and traps:
!strace
strace(1) lets you see what a program is doing in a coarse kind of way, if you think strace(1) is too quiet, perhaps ltrace(1) is for you. for the bsdites amongst us, I believe these are called struss(1) and sotrace(1). [Darwin] ([MacOSX]) has ptrace and ktrace (and kdump to read the created file).