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



commit fe82e8a269fade8749be0d2a35670f76f93ed939
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 2b491ee..9338f8f 100644
--- a/modules/package.js
+++ b/modules/package.js
@@ -255,6 +255,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) {
@@ -277,6 +289,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]