How can I get a call stack listing in Perl?

You can use Devel::StackTrace. use Devel::StackTrace; my $trace = Devel::StackTrace->new; print $trace->as_string; # like carp It behaves like Carp’s trace, but you can get more control over the frames. The one problem is that references are stringified and if a referenced value changes, you won’t see it. However, you could whip up some stuff with … Read more

Why does the stack address grow towards decreasing memory addresses?

First, it’s platform dependent. In some architectures, stack is allocated from the bottom of the address space and grows upwards. Assuming an architecture like x86 that stack grown downwards from the top of address space, the idea is pretty simple: =============== Highest Address (e.g. 0xFFFF) | | | STACK | | | |————-| <- Stack … Read more

Why does gcc use movl instead of push to pass function args?

Here is what the gcc manual has to say about it: -mpush-args -mno-push-args Use PUSH operations to store outgoing parameters. This method is shorter and usually equally fast as method using SUB/MOV operations and is enabled by default. In some cases disabling it may improve performance because of improved scheduling and reduced dependencies. -maccumulate-outgoing-args If … Read more

Is there any way to set a breakpoint in gdb that is conditional on the call stack?

Update: There is now a better answer to this question: use GDB _is_caller convenience function. The need you describe comes up quite often, usually in the context of some_utility_fn being called a lot, but you only are interested in the call which comes from some_other_fn. You could probably script this entire interaction using the new … Read more