[gjs/wip/package: 110/110] Package: add gdb integration



commit 89e502167e550723239ba15cde15a79684b0e081
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue May 7 23:51:32 2013 +0200

    Package: add gdb integration
    
    Allow running the launcher program with --debug to replace the
    running instance with a GDB.

 modules/package.js |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/modules/package.js b/modules/package.js
index e2320ca..2865c1c 100644
--- a/modules/package.js
+++ b/modules/package.js
@@ -242,6 +242,18 @@ function _launcherUsage(flags) {
     print('Options:');
     print('  -h, --help   Show this help message');
     print('  --version    Show the application version');
+    print('  -g, --debug  Run the application in a debugger');
+}
+
+function _spawnGDB(args, debugIndex) {
+    args.splice(debugIndex, 1);
+
+    try {
+        System.exec(['gdb', '--args', 'gjs', System.programInvocationName].concat(args));
+    } catch(e) {
+        print('Failed to launch debugger: ' + e.message);
+        System.exit(1);
+    }
 }
 
 function _parseLaunchArgs(args, params) {
@@ -264,6 +276,11 @@ function _parseLaunchArgs(args, params) {
            System.exit(0);
            break;
 
+        case '--debug':
+        case '-g':
+            _spawnGDB(args, i);
+            break;
+
        default:
            newArgs.push(args[i]);
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]