Check that debugger is valid before enumerating targets.
authorChaoren Lin <chaorenl@google.com>
Tue, 2 Jun 2015 18:31:57 +0000 (18:31 +0000)
committerChaoren Lin <chaorenl@google.com>
Tue, 2 Jun 2015 18:31:57 +0000 (18:31 +0000)
Reviewers: sivachandra

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D10192

llvm-svn: 238857

lldb/test/lldbutil.py

index 6951a33..2a7de0a 100644 (file)
@@ -949,17 +949,18 @@ def get_signal_number(signal_name):
                     output = 'SIG' + output
                 if output == signal_name:
                     return signal_number
-    for target_index in range(lldb.debugger.GetNumTargets()):
-        target = lldb.debugger.GetTargetAtIndex(target_index)
-        if not target.IsValid():
-            continue
-        process = target.GetProcess()
-        if not process.IsValid():
-            continue
-        signals = process.GetUnixSignals()
-        if not signals.IsValid():
-            continue
-        signal_number = signals.GetSignalNumberFromName(signal_name)
-        if signal_number > 0:
-            return signal_number
+    if lldb.debugger:
+        for target_index in range(lldb.debugger.GetNumTargets()):
+            target = lldb.debugger.GetTargetAtIndex(target_index)
+            if not target.IsValid():
+                continue
+            process = target.GetProcess()
+            if not process.IsValid():
+                continue
+            signals = process.GetUnixSignals()
+            if not signals.IsValid():
+                continue
+            signal_number = signals.GetSignalNumberFromName(signal_name)
+            if signal_number > 0:
+                return signal_number
     return getattr(signal, signal_name)