2
2
Test that we are able to broadcast and receive diagnostic events from lldb
3
3
"""
4
4
import lldb
5
-
5
+ from lldbsuite .test .lldbtest import *
6
+ from lldbsuite .test .decorators import *
6
7
import lldbsuite .test .lldbutil as lldbutil
8
+ import threading
7
9
8
- from lldbsuite .test .lldbtest import *
9
- from lldbsuite .test .eventlistener import EventListenerTestBase
10
10
11
- class TestDiagnosticReporting (EventListenerTestBase ):
11
+ class TestDiagnosticReporting (TestBase ):
12
12
13
13
mydir = TestBase .compute_mydir (__file__ )
14
- event_mask = lldb .SBDebugger .eBroadcastBitWarning | lldb .SBDebugger .eBroadcastBitError
15
- event_data_extractor = lldb .SBDebugger .GetDiagnosticFromEvent
14
+
15
+ eBroadcastBitStopDiagnosticThread = (1 << 0 )
16
+
17
+ def setUp (self ):
18
+ TestBase .setUp (self )
19
+ self .diagnostic_events = []
20
+
21
+ def fetch_events (self ):
22
+ event = lldb .SBEvent ()
23
+
24
+ done = False
25
+ while not done :
26
+ if self .listener .WaitForEvent (1 , event ):
27
+ event_mask = event .GetType ()
28
+ if event .BroadcasterMatchesRef (self .test_broadcaster ):
29
+ if event_mask & self .eBroadcastBitStopDiagnosticThread :
30
+ done = True
31
+ elif event .BroadcasterMatchesRef (self .diagnostic_broadcaster ):
32
+ self .diagnostic_events .append (
33
+ lldb .SBDebugger .GetDiagnosticFromEvent (event ))
16
34
17
35
def test_dwarf_symbol_loading_diagnostic_report (self ):
18
36
"""Test that we are able to fetch diagnostic events"""
37
+ self .listener = lldb .SBListener ("lldb.diagnostic.listener" )
38
+ self .test_broadcaster = lldb .SBBroadcaster ('lldb.broadcaster.test' )
39
+ self .listener .StartListeningForEvents (
40
+ self .test_broadcaster , self .eBroadcastBitStopDiagnosticThread )
41
+
42
+ self .diagnostic_broadcaster = self .dbg .GetBroadcaster ()
43
+ self .diagnostic_broadcaster .AddListener (
44
+ self .listener , lldb .SBDebugger .eBroadcastBitWarning )
45
+ self .diagnostic_broadcaster .AddListener (
46
+ self .listener , lldb .SBDebugger .eBroadcastBitError )
47
+
48
+ listener_thread = threading .Thread (target = self .fetch_events )
49
+ listener_thread .start ()
19
50
20
51
self .yaml2obj ("minidump.yaml" , self .getBuildArtifact ("minidump.core" ))
21
52
@@ -24,9 +55,13 @@ def test_dwarf_symbol_loading_diagnostic_report(self):
24
55
self .process = self .target .LoadCore (
25
56
self .getBuildArtifact ("minidump.core" ))
26
57
27
- self .assertEquals (len (self .events ), 1 )
58
+ self .test_broadcaster .BroadcastEventByType (
59
+ self .eBroadcastBitStopDiagnosticThread )
60
+ listener_thread .join ()
61
+
62
+ self .assertEquals (len (self .diagnostic_events ), 1 )
28
63
29
- diagnostic_event = self .events [0 ]
64
+ diagnostic_event = self .diagnostic_events [0 ]
30
65
self .assertEquals (
31
66
diagnostic_event .GetValueForKey ("type" ).GetStringValue (100 ),
32
67
"warning" )
0 commit comments