[PATCH 1/4] Do not set TCB_STARTUP on tcb until we performed attach

Denys Vlasenko dvlasenk at redhat.com
Fri Sep 2 14:14:23 UTC 2011


On Fri, 2011-09-02 at 16:13 +0200, Denys Vlasenko wrote:
> Patch 1: Do not set TCB_STARTUP on tcb until we performed attach.

diff -d -urpN strace.1/process.c strace.2/process.c
--- strace.1/process.c	2011-09-01 10:00:21.000000000 +0200
+++ strace.2/process.c	2011-09-01 18:30:57.848409673 +0200
@@ -485,6 +485,7 @@ internal_fork(struct tcb *tcp)
 		if (syserror(tcp))
 			return 0;
 		tcpchild = alloctcb(tcp->u_rval);
+		tcpchild->flags |= TCB_STARTUP;
 		if (proc_open(tcpchild, 2) < 0)
 			droptcb(tcpchild);
 	}
@@ -858,7 +859,7 @@ internal_fork(struct tcb *tcp)
 		}
 #endif /* !oldway */
 #endif /* SUNOS4 */
-		tcpchild->flags |= TCB_ATTACHED;
+		tcpchild->flags |= TCB_ATTACHED | TCB_STARTUP;
 		/* Child has BPT too, must be removed on first occasion */
 		if (bpt) {
 			tcpchild->flags |= TCB_BPTSET;
diff -d -urpN strace.1/strace.c strace.2/strace.c
--- strace.1/strace.c	2011-09-02 16:00:38.417925623 +0200
+++ strace.2/strace.c	2011-09-02 16:08:29.976955668 +0200
@@ -489,7 +489,7 @@ startup_attach(void)
 							fprintf(stderr, "attach to pid %d succeeded\n", tid);
 						if (tid != tcp->pid) {
 							struct tcb *new_tcp = alloctcb(tid);
-							new_tcp->flags |= TCB_ATTACHED|TCB_ATTACH_DONE;
+							new_tcp->flags |= TCB_ATTACHED|TCB_ATTACH_DONE|TCB_STARTUP;
 						}
 					}
 					if (interactive) {
@@ -521,6 +521,7 @@ startup_attach(void)
 			droptcb(tcp);
 			continue;
 		}
+		tcp->flags |= TCB_STARTUP;
 		if (debug)
 			fprintf(stderr, "attach to pid %d (main) succeeded\n", tcp->pid);
 
@@ -714,6 +715,7 @@ startup_child(char **argv)
 
 	if (!daemonized_tracer) {
 		tcp = alloctcb(pid);
+		tcp->flags |= TCB_STARTUP;
 	}
 	else {
 		/* With -D, *we* are child here, IOW: different pid. Fetch it: */
@@ -1270,7 +1272,7 @@ alloc_tcb(int pid, int command_options_p
 		if ((tcp->flags & TCB_INUSE) == 0) {
 			memset(tcp, 0, sizeof(*tcp));
 			tcp->pid = pid;
-			tcp->flags = TCB_INUSE | TCB_STARTUP;
+			tcp->flags = TCB_INUSE;
 			tcp->outf = outf; /* Initialise to current out file */
 #ifdef USE_PROCFS
 			tcp->pfd = -1;
@@ -2417,7 +2419,7 @@ trace()
 				   child so that we know how to do clearbpt
 				   in the child.  */
 				tcp = alloctcb(pid);
-				tcp->flags |= TCB_ATTACHED;
+				tcp->flags |= TCB_ATTACHED | TCB_STARTUP;
 				if (!qflag)
 					fprintf(stderr, "Process %d attached\n",
 						pid);






More information about the Strace-devel mailing list