Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

Monday, May 11, 2009

xlc Compiler options to be used with debugger

While doing source code debugging, one generally compiles with -g option, and assumes that all compiler optimizations have been turned off. However, as far as the xlc compiler is concerned, this might not necessarily be true. With -g the compiler puts in line-number information and turns off some optimizations, but not all optimizations. To tell the compiler to turn off ALL optimizations, the -qnoopt option should be employed.

Tuesday, July 8, 2008

A few dbx quickies

Here are some of the dbx commands I frequently use to speed things up:

1. addcmd : Whenever I hit a breakpoint, I need to display the stack. I use addcmd to automatically display the stack when a breakpoint is hit.

2. set $repeat : I usually get tired of pressing 's' again and again while stepping through a program. I set this variable to automatically re-execute the last command when enter is pressed.

3. set -o vi : same as ksh's set -o vi

4. -E option : I often have to debug programs with MALLOC DEBUG exported. However, I don't want dbx itself to run with MALLOC DEBUG on. I invoke dbx as follows:
dbx -E MALLOCTYPE=debug -E MALLOCDEBUG=report_allocations,catch_overflow ./a.out

5. goto : Useful if I want to skip executing some code at times. Usually I do this if there is some user input to be read, or some sleep event, I just skip all that by using goto. Goto directly sets the instruction pointer.

I hope you find these tips useful. I'll put some more tips at some later point of time.