patches/strace/4.5.15/190-undef-syscall.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Dec 13 23:32:39 2011 +0100 (2011-12-13)
branch1.13
changeset 2847 c0bf2319af08
parent 746 b150d6f590fc
permissions -rw-r--r--
scripts: fix dumping execution backtrace

Dumping the backtrace has been broken since changeset #652e56d6d35a:
scripts: execute each steps in a subshell

We can spawn sub-sub-shells in some cases.

The way the fault handler works is to dump the backtrace, but to avoid
printing it once for every sub-shell (which could get quite confusing),
it simply exits when it detects that it is being run in a sub-shell,
leaving to the top-level shell the work to dump the backtrace.

Because each step is executed in its own sub-shell, the variable arrays
that contain the step name, the source file and line number, are lost
when exiting the per-step sub-shell.

Hence, the backtrace is currently limited to printing only the top-level
main procedure of the shell.

Fix this thus:
- when dumping the bckatraces for the steps & the functions, remember
it was dumped, and only dump it if it was not already dumped
- at the top-level shell, print the hints

Also, rename the top-level step label.

Reported-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
(transplanted from 4193d6e6a17430a177fa88c287879c2c35e319f3)
yann@257
     1
diff -dur strace-4.5.15.orig/linux/syscallent.h strace-4.5.15/linux/syscallent.h
yann@257
     2
--- strace-4.5.15.orig/linux/syscallent.h	2006-10-16 03:17:52.000000000 +0200
yann@257
     3
+++ strace-4.5.15/linux/syscallent.h	2007-07-14 19:30:16.000000000 +0200
yann@270
     4
@@ -130,7 +130,11 @@
yann@257
     5
 	{ 2,	TF,	sys_statfs,		"statfs"	}, /* 99 */
yann@257
     6
 	{ 2,	TD,	sys_fstatfs,		"fstatfs"	}, /* 100 */
yann@257
     7
 	{ 3,	0,	sys_ioperm,		"ioperm"	}, /* 101 */
yann@257
     8
-	{ 2,	TD,	sys_socketcall,		"socketcall", SYS_socketcall }, /* 102 */
yann@270
     9
+	{ 2,	TD,	sys_socketcall,		"socketcall"
yann@257
    10
+#ifdef __NR_socketcall
yann@270
    11
+	    , SYS_socketcall
yann@257
    12
+#endif
yann@270
    13
+								}, /* 102 */
yann@257
    14
 	{ 3,	0,	sys_syslog,		"syslog"	}, /* 103 */
yann@257
    15
 	{ 3,	0,	sys_setitimer,		"setitimer"	}, /* 104 */
yann@257
    16
 	{ 2,	0,	sys_getitimer,		"getitimer"	}, /* 105 */
yann@270
    17
@@ -145,7 +149,11 @@
yann@257
    18
 	{ 4,	TP,	sys_wait4,		"wait4", SYS_wait4 }, /* 114 */
yann@257
    19
 	{ 1,	0,	sys_swapoff,		"swapoff"	}, /* 115 */
yann@257
    20
 	{ 1,	0,	sys_sysinfo,		"sysinfo"	}, /* 116 */
yann@257
    21
-	{ 6,	0,	sys_ipc,		"ipc", SYS_ipc }, /* 117 */
yann@270
    22
+	{ 6,	0,	sys_ipc,		"ipc"
yann@257
    23
+#ifdef __NR_ipc
yann@270
    24
+	    , SYS_ipc
yann@257
    25
+#endif
yann@270
    26
+								}, /* 117 */
yann@257
    27
 	{ 1,	TD,	sys_fsync,		"fsync"		}, /* 118 */
yann@257
    28
 	{ 1,	TS,	sys_sigreturn,		"sigreturn"	}, /* 119 */
yann@257
    29
 	{ 5,	TP,	sys_clone,		"clone", SYS_clone }, /* 120 */
yann@270
    30
@@ -282,7 +290,11 @@
yann@257
    31
 	{ 3,	0,	sys_io_cancel,		"io_cancel"	}, /* 249 */
yann@257
    32
 	{ 5,	0,	sys_fadvise64,		"fadvise64"	}, /* 250 */
yann@257
    33
 	{ 5,	0,	printargs,		"SYS_251"	}, /* 251 */
yann@257
    34
-	{ 1,	TP,	sys_exit,		"exit_group", __NR_exit_group }, /* 252 */
yann@257
    35
+	{ 1,	TP,	sys_exit,		"exit_group"
yann@257
    36
+#ifdef __NR_exit_group
yann@257
    37
+	    , __NR_exit_group
yann@257
    38
+#endif
yann@257
    39
+								}, /* 252 */
yann@257
    40
 	{ 4,	0,	printargs,		"lookup_dcookie"}, /* 253 */
yann@257
    41
 	{ 1,	0,	sys_epoll_create,	"epoll_create"	}, /* 254 */
yann@257
    42
 	{ 4,	TD,	sys_epoll_ctl,		"epoll_ctl"	}, /* 255 */
yann@257
    43
diff -dur strace-4.5.15.orig/syscall.c strace-4.5.15/syscall.c
yann@257
    44
--- strace-4.5.15.orig/syscall.c	2007-07-14 19:22:49.000000000 +0200
yann@257
    45
+++ strace-4.5.15/syscall.c	2007-07-14 19:30:16.000000000 +0200
yann@257
    46
@@ -2404,14 +2404,18 @@
yann@257
    47
 	switch (known_scno(tcp)) {
yann@257
    48
 #ifdef LINUX
yann@257
    49
 #if !defined (ALPHA) && !defined(SPARC) && !defined(SPARC64) && !defined(MIPS) && !defined(HPPA)
yann@257
    50
+#ifdef __NR_socketcall
yann@257
    51
 	case SYS_socketcall:
yann@257
    52
 		decode_subcall(tcp, SYS_socket_subcall,
yann@257
    53
 			SYS_socket_nsubcalls, deref_style);
yann@257
    54
 		break;
yann@257
    55
+#endif
yann@257
    56
+#ifdef __NR_ipc
yann@257
    57
 	case SYS_ipc:
yann@257
    58
 		decode_subcall(tcp, SYS_ipc_subcall,
yann@257
    59
 			SYS_ipc_nsubcalls, shift_style);
yann@257
    60
 		break;
yann@257
    61
+#endif
yann@257
    62
 #endif /* !ALPHA && !MIPS && !SPARC && !SPARC64 && !HPPA */
yann@257
    63
 #if defined (SPARC) || defined (SPARC64)
yann@257
    64
 	case SYS_socketcall: