[CRIU] [PATCH] ptrace: print PID in error messages

Andrey Vagin avagin at openvz.org
Thu Apr 23 04:35:17 PDT 2015


We want to know which process can not be handled.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 arch/x86/crtools.c | 8 ++++----
 cr-restore.c       | 9 ++++++---
 parasite-syscall.c | 2 +-
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/arch/x86/crtools.c b/arch/x86/crtools.c
index 06d824a..59d589f 100644
--- a/arch/x86/crtools.c
+++ b/arch/x86/crtools.c
@@ -527,7 +527,7 @@ int ptrace_set_breakpoint(pid_t pid, void *addr)
 	if (ptrace(PTRACE_POKEUSER, pid,
 			offsetof(struct user, u_debugreg[DR_FIRSTADDR]),
 			addr)) {
-		pr_err("Unable to setup a breakpoint\n");
+		pr_perror("Unable to setup a breakpoint into %d", pid);
 		return -1;
 	}
 
@@ -535,13 +535,13 @@ int ptrace_set_breakpoint(pid_t pid, void *addr)
 	if (ptrace(PTRACE_POKEUSER, pid,
 			offsetof(struct user, u_debugreg[DR_CONTROL]),
 			X86_DR_LOCAL_ENABLE(DR_FIRSTADDR))) {
-		pr_err("Unable to enable the breakpoint\n");
+		pr_perror("Unable to enable the breakpoint for %d", pid);
 		return -1;
 	}
 
 	ret = ptrace(PTRACE_CONT, pid, NULL, NULL);
 	if (ret) {
-		pr_perror("Unable to restart  the  stopped tracee process");
+		pr_perror("Unable to restart the  stopped tracee process %d", pid);
 		return -1;
 	}
 
@@ -554,7 +554,7 @@ int ptrace_flush_breakpoints(pid_t pid)
 	if (ptrace(PTRACE_POKEUSER, pid,
 			offsetof(struct user, u_debugreg[DR_CONTROL]),
 			0)) {
-		pr_err("Unable to disable the breakpoint\n");
+		pr_perror("Unable to disable the breakpoint for %d", pid);
 		return -1;
 	}
 
diff --git a/cr-restore.c b/cr-restore.c
index f9983a4..e5696d6 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1123,8 +1123,11 @@ static inline int fork_with_pid(struct pstree_item *item)
 	}
 
 
-	if (item == root_item)
+	if (item == root_item) {
 		item->pid.real = ret;
+		pr_debug("PID: real %d virt %d\n",
+				item->pid.real, item->pid.virt);
+	}
 
 	if (opts.pidfile && root_item == item) {
 		int pid;
@@ -1606,13 +1609,13 @@ static int attach_to_tasks(bool root_seized, enum trace_flags *flag)
 				 * and SYSCALL below work.
 				 */
 				if (ptrace(PTRACE_INTERRUPT, pid, 0, 0)) {
-					pr_perror("Can't interrupt task");
+					pr_perror("Can't interrupt the %d task", pid);
 					return -1;
 				}
 			}
 
 			if (wait4(pid, &status, __WALL, NULL) != pid) {
-				pr_perror("waitpid() failed");
+				pr_perror("waitpid(%d) failed", pid);
 				return -1;
 			}
 
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 34c4ce3..6f1bb66 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -1271,7 +1271,7 @@ int ptrace_stop_pie(pid_t pid, void *addr, enum trace_flags *tf)
 	 */
 	ret = ptrace(PTRACE_SYSCALL, pid, NULL, NULL);
 	if (ret) {
-		pr_perror("ptrace");
+		pr_perror("Unable to restart the %d process", pid);
 		return -1;
 	}
 
-- 
2.1.0



More information about the CRIU mailing list