--- strace-4.5.14.orig/strace.c 2006-01-12 04:50:49.000000000 -0500 +++ strace-4.5.14/strace.c 2006-05-13 09:00:43.000000000 -0400 @@ -2417,6 +2417,9 @@ } if (iflag) printcall(tcp); + + if (iflag >= 2) + printbtrace(tcp); } void --- strace-4.5.14.orig/util.c 2005-10-21 18:06:46.000000000 -0400 +++ strace-4.5.14/util.c 2006-05-13 09:20:25.000000000 -0400 @@ -1082,6 +1082,57 @@ } #endif +void +printbtrace(tcp) +struct tcb *tcp; +{ +#define PRINTBADEBP tprintf(sizeof(long) == 4 ? "[????????] " : \ + sizeof(long) == 8 ? "[????????????????] " : \ + NULL /* crash */) +#define PRINTBADADDR tprintf(sizeof(long) == 4 ? "????????" : \ + sizeof(long) == 8 ? "????????????????" : \ + NULL /* crash */) + +#ifdef LINUX +#ifdef I386 + long ebp, new_ebp; + long addr_loc, ret_addr; + + if (upeek(tcp->pid, 4*EBP, &ebp) < 0) { + PRINTBADEBP; + return; + } + + /* if ebp is NULL on first entry, exit */ + if (!ebp) + return; + + tprintf("["); + + do { + addr_loc = ebp + sizeof(long); + + if ((ret_addr = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *) addr_loc, 0)) == -1) { + PRINTBADADDR; + break; + } + + tprintf("%08lx", ret_addr); + + if ((new_ebp = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *) ebp, 0)) == -1) { + PRINTBADADDR; + break; + } + + if ((ebp = new_ebp) != 0) + tprintf(","); + } while (ebp); + + tprintf("] "); +#endif +#endif +} + void printcall(tcp) struct tcb *tcp; --- strace-4.5.14.orig/strace.1 2005-12-01 22:59:35.000000000 -0500 +++ strace-4.5.14/strace.1 2006-05-13 09:00:43.000000000 -0400 @@ -273,6 +273,9 @@ .B \-i Print the instruction pointer at the time of the system call. .TP +.B \-ii +Print the backtrace of the system call. +.TP .B \-q Suppress messages about attaching, detaching etc. This happens automatically when output is redirected to a file and the command