From 2e27e08f7cdfd67d0cb1b5f1cd40cc650af2cb0f Mon Sep 17 00:00:00 2001 From: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Date: Thu, 15 Dec 2016 11:42:51 +0100 Subject: [PATCH] Run gdb as a subprocess, not execv'd If ade execv's gdb then its process will be replaced, potentially causing the ssh connection to the target device to fail which will kill the remote gdb server. So instead run gdb in a subprocess, keeping ade (and thus the ssh connection) alive during the debugging session. Also instead of using gdb, use gdb-multiarch which is a variant capable of interacting with gdbservers of multiple architectures (and understand/parsing the debug symbols of multiple architectures). This means it can be used to debug both ARM and Intel targets, rather then just native targets. Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> Differential Revision: https://phabricator.apertis.org/D5305 --- tools/ade | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/ade b/tools/ade index 474320d..7df0839 100755 --- a/tools/ade +++ b/tools/ade @@ -21,6 +21,7 @@ import pathlib import paramiko import re import shutil +import signal import stat import struct import subprocess @@ -235,11 +236,17 @@ class Debugger: self.project.install(debugdir) cmds = self._get_commands(server, debugdir, libdir) - args = ['gdb'] + args = ['gdb-multiarch'] for cmd in cmds: args.append('-ex') args.append(cmd) - os.execv('/usr/bin/gdb', args) + # While running gdb ignore SIGINT such that it gets passed on to gdb + # (e.g. for stopping the remote execution) without affecting ade. + signal.signal (signal.SIGINT, signal.SIG_IGN) + p = subprocess.Popen(args) + p.wait() + signal.signal (signal.SIGINT, signal.SIG_DFL) + class Simulator: -- GitLab