Why pstack is much faster than gdb with just attaching, saving stacks and quitting?

734 views Asked by At

I have a script, which runs gdb with command file like this:

set logging file file_name
set logging on
thread apply all bt
q
y

Why pstack is much faster than this script? Can I achive that fastness with gdb somehow?

EDIT: The difference was gdb versions. I used gdb-7.10, and it took about 14 sec to dump stack traces. with gdb 7.0.1, which pstack used, it took 2 sec. Most of time went for gdb-7.10 on loading symbols from our lib, and I couldn't found the appropriate option for -readnever in the new version.

1

There are 1 answers

5
Andrew On BEST ANSWER

On my system at least pstack is a shell script that runs gdb, so you can probably see exactly what is being run by just looking in the pstack executable.

I suspect that the interesting part of the script might well be:

set width 0
set height 0
set pagination no

Actually set pagination no is the same as set height 0, so you can forget the set pagination no part.

The set height 0 and set width 0 turn off any attempt by gdb to display the output wrapped to your terminal width, and presented page at a time.

I expect that this wrapping, and page at a time output, causes a lot of additional processing everytime gdb prints anything.

There's not much else in the pstack script that is different to your script, so I don't see what else it could be.