extern unsigned int qflag;
extern bool not_failing_only;
extern bool show_fd_path;
+extern bool hide_log_until_execve;
/* are we filtering traces based on paths? */
extern const char **paths_selected;
#define tracing_paths (paths_selected != NULL)
bool show_fd_path = 0;
static bool detach_on_execve = 0;
-static bool skip_startup_execve = 0;
+/* Are we "strace PROG" and need to skip detach on first execve? */
+static bool skip_one_b_execve = 0;
+/* Are we "strace PROG" and need to hide everything until execve? */
+bool hide_log_until_execve = 0;
static int exit_code = 0;
static int strace_child = 0;
kill_save_errno(pid, SIGKILL);
perror_msg_and_die("Unexpected wait status %x", status);
}
- skip_startup_execve = 1;
}
/* Else: NOMMU case, we have no way to sync.
* Just attach to it as soon as possible.
alloctcb(pid);
/* attaching will be done later, by startup_attach */
/* note: we don't do newoutf(tcp) here either! */
- skip_startup_execve = 1;
/* NOMMU BUG! -D mode is active, we (child) return,
* and we will scribble over parent's stack!
* in the startup_child() mode we kill the spawned process anyway.
*/
if (argv[0]) {
+ hide_log_until_execve = 1;
+ skip_one_b_execve = 1;
startup_child(argv);
}
}
dont_switch_tcbs:
- if (event == PTRACE_EVENT_EXEC && detach_on_execve) {
- if (!skip_startup_execve)
- detach(tcp);
- /* This was initial execve for "strace PROG". Skip. */
- skip_startup_execve = 0;
+ if (event == PTRACE_EVENT_EXEC) {
+ if (detach_on_execve && !skip_one_b_execve)
+ detach(tcp); /* do "-b execve" thingy */
+ skip_one_b_execve = 0;
}
/* Set current output file */
# define PC_FORMAT_STR ""
# define PC_FORMAT_ARG /* nothing */
#endif
- if (qflag < 2) {
+ if (qflag < 2 && !hide_log_until_execve) {
printleader(tcp);
if (!stopped) {
tprintf("--- %s ", signame(sig));
goto ret;
}
+ if ( sys_execve == tcp->s_ent->sys_func
+# if defined(SPARC) || defined(SPARC64)
+ || sys_execv == tcp->s_ent->sys_func
+# endif
+ ) {
+ hide_log_until_execve = 0;
+ }
+
#if defined(SYS_socket_subcall) || defined(SYS_ipc_subcall)
while (1) {
# ifdef SYS_socket_subcall
tcp->flags &= ~TCB_FILTERED;
- if (cflag == CFLAG_ONLY_STATS) {
+ if (cflag == CFLAG_ONLY_STATS || hide_log_until_execve) {
res = 0;
goto ret;
}
get_error(tcp); /* never fails */
if (need_fork_exec_workarounds)
syscall_fixup_for_fork_exec(tcp);
- if (filtered(tcp))
+ if (filtered(tcp) || hide_log_until_execve)
goto ret;
}