Skip to content
Snippets Groups Projects
Commit 80c81ed2 authored by Maxim Cournoyer's avatar Maxim Cournoyer
Browse files

build.py: Really run in GDB when using --debug.

The usage (--help) says: "Build with debug support; run in GDB", but
GDB was only used when using the D-Bus daemon.  Run a libwrap built
Jami with GDB as well.

* build.py (run_run): Disable SIGINT when using GDB, and invoke the
Jami client with GDB.  Disable output redirection to logs when using GDB.

Change-Id: Icf3415a3d1fbb87f193d0ede07cb1e1fbb179ce2
parent 9f284088
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ import multiprocessing ...@@ -23,6 +23,7 @@ import multiprocessing
import os import os
import platform import platform
import shlex import shlex
import signal
import shutil import shutil
import subprocess import subprocess
import sys import sys
...@@ -458,6 +459,13 @@ def run_clean(): ...@@ -458,6 +459,13 @@ def run_clean():
def run_run(args): def run_run(args):
run_env = os.environ run_env = os.environ
if args.debug:
# Ignore the interruption signal when using GDB, as it's
# common to use C-c when debugging and we do not want the
# Python script to abort the debugging session.
signal.signal(signal.SIGINT, signal.SIG_IGN)
try: try:
if args.no_libwrap: if args.no_libwrap:
jamid_log = open("daemon.log", 'a') jamid_log = open("daemon.log", 'a')
...@@ -474,10 +482,18 @@ def run_run(args): ...@@ -474,10 +482,18 @@ def run_run(args):
client_log = open('jami.log', 'a') client_log = open('jami.log', 'a')
client_log.write('=== Starting client (%s) ===' % client_log.write('=== Starting client (%s) ===' %
time.strftime("%d/%m/%Y %H:%M:%S")) time.strftime("%d/%m/%Y %H:%M:%S"))
client_process = subprocess.Popen(["./install/bin/jami", "-d"], jami_cmdline = ['install/bin/jami', '-d']
stdout=client_log, if args.debug:
stderr=client_log, jami_cmdline = ['gdb', '-ex', 'run', '--args'] + jami_cmdline
env=run_env)
print('Invoking jami with: {}'.format(str.join(' ', jami_cmdline)))
if args.debug:
print('Debugging with GDB; NOT redirecting output to log file')
client_process = subprocess.Popen(
jami_cmdline,
stdout=False if args.debug else client_log,
stderr=False if args.debug else client_log,
env=run_env)
with open('jami.pid', 'w') as f: with open('jami.pid', 'w') as f:
f.write(str(client_process.pid)+'\n') f.write(str(client_process.pid)+'\n')
...@@ -494,7 +510,10 @@ def run_run(args): ...@@ -494,7 +510,10 @@ def run_run(args):
print("\nCaught KeyboardInterrupt...") print("\nCaught KeyboardInterrupt...")
finally: finally:
if args.background == False: if args.debug:
# Restore the default signal handler for SIGINT.
signal.signal(signal.SIGINT, signal.SIG_DFL)
if not args.background:
try: try:
# Only kill the processes if they are running, as they # Only kill the processes if they are running, as they
# could have been closed by the user. # could have been closed by the user.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment