diff mx/commands.py @ 5875:000fb0550afe

Add an option to launch the vm from a debugger in mx's commands Differentiate between, 32 and 64 bits BSR
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 25 Jul 2012 13:06:52 +0200
parents 576460f7e740
children 0e54d9bb922d
line wrap: on
line diff
--- a/mx/commands.py	Tue Jul 24 17:32:42 2012 +0200
+++ b/mx/commands.py	Wed Jul 25 13:06:52 2012 +0200
@@ -49,6 +49,8 @@
 
 _jacoco = 'off'
 
+_native_dbg = None
+
 _make_eclipse_launch = False
 
 _copyrightTemplate = """/*
@@ -588,7 +590,8 @@
         }
         args = ['-javaagent:' + jacocoagent.get_path(True) + '=' + ','.join([k + '=' + v for k, v in agentOptions.items()])] + args
     exe = join(jdk, 'bin', mx.exe_suffix('java'))
-    return mx.run([exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout)
+    dbg = _native_dbg.split() if _native_dbg is not None else []
+    return mx.run(dbg + [exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout)
 
 def _find_classes_with_annotations(p, pkgRoot, annotations, includeInnerClasses=False):
     """
@@ -1006,6 +1009,9 @@
         mx.add_argument('--debug', action='store_const', dest='vmbuild', const='debug', help='select the debug build of the VM')
         mx.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug build of the VM')
         mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse')
+        mx.add_argument('--native-dbg', action='store', dest='native_dbg', help='Start the vm inside a debugger', metavar='<debugger>')
+        mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='native_dbg', help='alias for --native-dbg /usr/bin/gdb -- args')
+        
 
         commands.update({
             'export': [export, '[-options] [zipfile]'],
@@ -1034,3 +1040,5 @@
         _make_eclipse_launch = getattr(opts, 'make_eclipse_launch', False)
     global _jacoco
     _jacoco = opts.jacoco
+    global _native_dbg
+    _native_dbg = opts.native_dbg