summaryrefslogtreecommitdiff
path: root/tools
diff options
authorMichal Hruby <michal.mhr@gmail.com>2011-12-20 11:16:23 +0100
committerMichal Hruby <michal.mhr@gmail.com>2011-12-20 11:16:23 +0100
commit41ac81d5a76c0dc499af2bd7e4366b119f934053 (patch)
treec51499777532cc57701951ed387e497a4090cd66 /tools
parent3de93693c866ed2b61a336070766a6bd2e44729e (diff)
Add --debug option to unity to start it in gdb and print backtrace if it crashes
(bzr r1793.4.1)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/unity.cmake19
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/unity.cmake b/tools/unity.cmake
index 6fd8444d5..a1694ce81 100755
--- a/tools/unity.cmake
+++ b/tools/unity.cmake
@@ -111,16 +111,18 @@ def reset_launcher_icons ():
'''Reset the default launcher icon and restart it.'''
subprocess.Popen(["gsettings", "reset" ,"com.canonical.Unity.Launcher" , "favorites"])
-def process_and_start_unity (verbose, debug, compiz_args, log_file):
+def process_and_start_unity (verbose, debug_mode, compiz_args, log_file):
'''launch unity under compiz (replace the current shell in any case)'''
cli = []
- if debug:
+ if debug_mode > 0:
# we can do more check later as if it's in PATH...
if not os.path.isfile('/usr/bin/gdb'):
print("ERROR: you don't have gdb in your system. Please install it to run in advanced debug mode.")
sys.exit(1)
+ elif debug_mode == 1:
+ cli.extend(['gdb', '-ex', 'run', '-ex', 'bt', '--batch', '--args'])
elif 'DESKTOP_SESSION' in os.environ:
print("ERROR: it seems you are under a graphical environment. That's incompatible with executing advanced-debug option. You should be in a tty.")
sys.exit(1)
@@ -129,7 +131,7 @@ def process_and_start_unity (verbose, debug, compiz_args, log_file):
cli.extend(['compiz', '--replace'])
if options.verbose:
- cli.append("--debug")
+ cli.append("--debug")
if args:
cli.extend(compiz_args)
@@ -142,11 +144,12 @@ def process_and_start_unity (verbose, debug, compiz_args, log_file):
return subprocess.Popen(" ".join(cli), env=dict(os.environ), shell=True)
-def run_unity (verbose, debug, compiz_args, log_file):
+def run_unity (verbose, debug, advanced_debug, compiz_args, log_file):
'''run the unity shell and handle Ctrl + C'''
try:
- unity_instance = process_and_start_unity (verbose, debug, compiz_args, log_file)
+ debug_mode = 2 if advanced_debug else 1 if debug else 0
+ unity_instance = process_and_start_unity (verbose, debug_mode, compiz_args, log_file)
subprocess.Popen(["killall", "unity-panel-service"])
unity_instance.wait()
except KeyboardInterrupt, e:
@@ -189,7 +192,9 @@ if __name__ == '__main__':
parser = OptionParser(version= "%prog @UNITY_VERSION@", usage=usage)
parser.add_option("--advanced-debug", action="store_true",
- help="Run unity under debugging to help debugging an issue. /!\ Only if devs ask for it.")
+ help="Run unity under debugging to help debugging an issue. /!\ Only if devs ask for it.")
+ parser.add_option("--debug", action="store_true",
+ help="Run unity under gdb and print a backtrace on crash. /!\ Only if devs ask for it.")
parser.add_option("--distro", action="store_true",
help="Remove local build if present with default values to return to the package value (this doesn't run unity and need root access)")
parser.add_option("--log", action="store",
@@ -218,4 +223,4 @@ if __name__ == '__main__':
if options.replace:
print ("WARNING: This is for compatibility with other desktop interfaces please use unity without --replace")
- run_unity (options.verbose, options.advanced_debug, args, options.log)
+ run_unity (options.verbose, options.debug, options.advanced_debug, args, options.log)