Here's the script for producing a trace of the instructions executed. It's invoked (from the gdb prompt) as: count , where and are described below, and it's supposed to print out the disassembled code (with a bunch of cruft) to standard output. The only catch in this thing is that I haven't figured out how to give the script an line number (see below). Also, I haven't figured out how to get the -output flag to work (which makes the output got to a file rather than to the gdb session). #arg0 of count is the line number of the # beginning of the region being measured #arg1 is the address of the instruction # right after the region being measured; as # of now, obtained by # info line # where is just after the region # measured define count disable break predi.c:$arg0 <---I've hardwired "predi.c"; should probably be a parameter: it's the file where line $arg0 lives cont while ($pc != $arg1) disass $pc ($pc+4) si end enable end