Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4dbed85a authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Linus Torvalds
Browse files

uml: stop gdb from deleting breakpoints when running UML



Sometimes when UML is debugged gdb miss breakpoints.

When process traced by gdb do fork, debugger remove breakpoints from
child address space. There is possibility to trace more than one fork,
but this not work with UML, I guess (only guess) there is a deadlock -
gdb waits for UML and UML waits for gdb.

When clone() is called with SIGCHLD and CLONE_VM flags, gdb see this
as PTRACE_EVENT_FORK not as PTRACE_EVENT_CLONE and remove breakpoints
from child and at the same time from traced process, because either
have the same address space.

Maybe it is possible to do fix in gdb, but I'm not sure if there is
easy way to find out if traced and child processes share memory. So I
do fix for UML, it simply do not call clone() with both SIGCHLD and
CLONE_VM flags together.  Additionally __WALL flag is used for
waitpid() to assure not miss clone and normal process events.

[ jdike - checkpatch fixes ]

Signed-off-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: default avatarJeff Dike <jdike@linux.intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5867a78f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ static int change_tramp(char **argv, char *output, int output_len)
	close(fds[1]);

	if (pid > 0)
		CATCH_EINTR(err = waitpid(pid, NULL, 0));
		helper_wait(pid, 0, "change_tramp");
	return pid;
}

+2 −10
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ static int slip_tramp(char **argv, int fd)
{
	struct slip_pre_exec_data pe_data;
	char *output;
	int status, pid, fds[2], err, output_len;
	int pid, fds[2], err, output_len;

	err = os_pipe(fds, 1, 0);
	if (err < 0) {
@@ -109,15 +109,7 @@ static int slip_tramp(char **argv, int fd)
	read_output(fds[0], output, output_len);
	printk("%s", output);

	CATCH_EINTR(err = waitpid(pid, &status, 0));
	if (err < 0)
		err = errno;
	else if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
		printk(UM_KERN_ERR "'%s' didn't exit with status 0\n", argv[0]);
		err = -EINVAL;
	}
	else err = 0;

	err = helper_wait(pid, 0, argv[0]);
	close(fds[0]);

out_free:
+3 −12
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ out:
static void slirp_close(int fd, void *data)
{
	struct slirp_data *pri = data;
	int status,err;
	int err;

	close(fd);
	close(pri->slave);
@@ -98,18 +98,9 @@ static void slirp_close(int fd, void *data)
		       "(%d)\n", pri->pid, errno);
	}
#endif

	CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG));
	if (err < 0) {
		printk(UM_KERN_ERR "slirp_close: waitpid returned %d\n", errno);
		return;
	}

	if (err == 0) {
		printk(UM_KERN_ERR "slirp_close: process %d has not exited\n",
		       pri->pid);
	err = helper_wait(pri->pid, 1, "slirp_close");
	if (err < 0)
		return;
	}

	pri->pid = -1;
}
+1 −2
Original line number Diff line number Diff line
@@ -49,8 +49,7 @@ int start_io_thread(unsigned long sp, int *fd_out)
		goto out_close;
	}

	pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
		    NULL);
	pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM, NULL);
	if(pid < 0){
		err = -errno;
		printk("start_io_thread - clone failed : errno = %d\n", errno);
+1 −1
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ extern int execvp_noalloc(char *buf, const char *file, char *const argv[]);
extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv);
extern int run_helper_thread(int (*proc)(void *), void *arg,
			     unsigned int flags, unsigned long *stack_out);
extern int helper_wait(int pid);
extern int helper_wait(int pid, int nohang, char *pname);


/* tls.c */
Loading