[gnome-weather/wip/egg-flow-box: 2/4] Package: add gdb integration



commit f996ca3f3e2dbaced934089c97503c42f9536544
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Mar 13 19:19:33 2013 +0100

    Package: add gdb integration
    
    Allow running the program with --debug to replace the running instance
    with a GDB.
    Hopefully, by the time package is initialized, the program hasn't
    crashed yet.

 src/package.js |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/package.js b/src/package.js
index 35f3319..15e75a3 100644
--- a/src/package.js
+++ b/src/package.js
@@ -137,6 +137,8 @@ function init(params) {
     imports.searchPath.unshift(moduledir);
     GIRepository.Repository.prepend_search_path(girpath);
     GIRepository.Repository.prepend_library_path(libpath);
+
+    _parseArgs();
 }
 
 /**
@@ -293,3 +295,21 @@ function initSubmodule(name) {
         // Running installed, submodule is in $(pkglibdir), nothing to do
     }
 }
+
+function _spawnGDB(debugIndex) {
+    ARGV.splice(debugIndex, 1);
+
+    try {
+        System.exec(['gdb', '--args', 'gjs', System.programInvocationName].concat(ARGV));
+    } catch(e) {
+        print('Failed to launch debugger: ' + e.message);
+        System.exit(1);
+    }
+}
+
+function _parseArgs() {
+    for (let i = 0; i < ARGV.length; i++) {
+        if (ARGV[i] == '--debug')
+            _spawnGDB(i);
+    }
+}


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