How does GDB call functions?
I'm surprised the author opted for guesswork and reverse-engineering GDB when it's of course open source. Admittedly GDB's source code can be a bit daunting but at least you'll have all the nasty details.<p>The relevant code appears to be in gdb/infcall.c in the `call_function_by_hand` method. It's pretty well commented too and shows that while the author gets the basics right there are many, many corner cases to consider to get it right all the time (threads, signals, exceptions, architecture and ABI quirks, etc...): <a href="https://github.com/rofl0r/gdb/blame/master/gdb/infcall.c#L467" rel="nofollow">https://github.com/rofl0r/gdb/blame/master/gdb/infcall.c#L46...</a>