views:

15

answers:

1

I'm trying to get the call stacks leading to a function, func, each time it gets invoked in my executable, and I don't mind if the way to get this is slow or inefficient, so long as it's automated (because 'func' gets hit thousands of times). I have access to dbx, so I thought I could do something like this:

 (dbx) { when in func { where -q; }; } | awk '{ print }' > out.txt 

but I don't see the call stacks output on the console or in the file (I have confirmed that the function is getting hit). The documentation for dbx states that 'where' is a non-redirectable command, but I'm wondering if there are any workarounds people have used to do this?

A: 

Some dbx commands need to accept arguments that have shell metacharacters. For example: print (a < 34)

For commands like that, you can put the redirection before the command: (dbx) > /tmp/t print (a < 34)

"help redirection" on the dbx command line will explain it.

In your example, the 'where' command accepts function names as arguments, which (in c++) can use < and > characters. So it falls into this special category.

Unfortunately, there's no way to use a pipe operation before the command. So you'll need to use a different scheme involving temporary files to get what you want. There are examples in the help topic I mentioned above.

Chris Quenelle