Bug 1236983 - add windbg smarts to mozdebug; r=jmaher,aklotz
authorNathan Froyd <froydnj@mozilla.com>
Tue, 05 Jan 2016 12:47:39 -0500
changeset 278827 36c1e4eb0c9141aae4071a917ce4e3a59f5a79c6
parent 278826 0fc4b8fc291124a665df02112c3a12e9721f274b
child 278828 8bd590cba7fd88486e7db3ab49a0db7bfb5978ea
push id29860
push usercbook@mozilla.com
push dateThu, 07 Jan 2016 10:51:20 +0000
treeherdermozilla-central@e0bcd16e1d4b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher, aklotz
bugs1236983
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1236983 - add windbg smarts to mozdebug; r=jmaher,aklotz
testing/mozbase/mozdebug/mozdebug/mozdebug.py
old mode 100644
new mode 100755
--- a/testing/mozbase/mozdebug/mozdebug/mozdebug.py
+++ b/testing/mozbase/mozdebug/mozdebug/mozdebug.py
@@ -45,28 +45,46 @@ To add support for a new debugger, simpl
         'interactive': True,
         'args': ['-debugexe']
     },
 
     # Visual C++ Express Debugger Support.
     'wdexpress.exe': {
         'interactive': True,
         'args': ['-debugexe']
-    }
+    },
+
+    # Windows Development Kit super-debugger.
+    'windbg.exe': {
+        'interactive': True,
+    },
 }
 
 # Maps each OS platform to the preferred debugger programs found in _DEBUGGER_INFO.
 _DEBUGGER_PRIORITIES = {
       'win': ['devenv.exe', 'wdexpress.exe'],
       'linux': ['gdb', 'cgdb', 'lldb'],
       'mac': ['lldb', 'gdb'],
       'android': ['gdb'],
       'unknown': ['gdb']
 }
 
+def _windbg_installation_paths():
+    programFilesSuffixes = ['', ' (x86)']
+    programFiles = "C:/Program Files"
+    # Try the most recent versions first.
+    windowsKitsVersions = ['10', '8.1', '8']
+
+    for suffix in programFilesSuffixes:
+        windowsKitsPrefix = os.path.join(programFiles + suffix,
+                                         'Windows Kits')
+        for version in windowsKitsVersions:
+            yield os.path.join(windowsKitsPrefix, version,
+                               'Debuggers', 'x86', 'windbg.exe')
+
 def get_debugger_info(debugger, debuggerArgs = None, debuggerInteractive = False):
     '''
     Get the information about the requested debugger.
 
     Returns a dictionary containing the |path| of the debugger executable,
     if it will run in |interactive| mode, its arguments and whether it needs
     to escape arguments it passes to the debugged program (|requiresEscapedArgs|).
     If the debugger cannot be found in the system, returns |None|.
@@ -84,16 +102,26 @@ def get_debugger_info(debugger, debugger
         # Append '.exe' to the debugger on Windows if it's not present,
         # so things like '--debugger=devenv' work.
         if (os.name == 'nt'
             and not debugger.lower().endswith('.exe')):
             debugger += '.exe'
 
         debuggerPath = find_executable(debugger)
 
+    # windbg is not installed with the standard set of tools, and it's
+    # entirely possible that the user hasn't added the install location to
+    # PATH, so we have to be a little more clever than normal to locate it.
+    # Just try to look for it in the standard installed location(s).
+    if not debuggerPath and debugger == 'windbg.exe':
+        for candidate in _windbg_installation_paths():
+            if os.path.exists(candidate):
+                debuggerPath = candidate
+                break
+
     if not debuggerPath:
         print 'Error: Could not find debugger %s.' % debugger
         return None
 
     debuggerName = os.path.basename(debuggerPath).lower()
 
     def get_debugger_info(type, default):
         if debuggerName in _DEBUGGER_INFO and type in _DEBUGGER_INFO[debuggerName]: