brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 583e187 Raw
66 lines · python
1"""2Test that we are able to broadcast and receive progress events from lldb3"""4import lldb5 6import lldbsuite.test.lldbutil as lldbutil7 8from lldbsuite.test.lldbtest import *9 10 11class TestProgressReporting(TestBase):12    def setUp(self):13        TestBase.setUp(self)14        self.broadcaster = self.dbg.GetBroadcaster()15        self.listener = lldbutil.start_listening_from(16            self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress17        )18 19    def test_wait_attach_progress_reporting(self):20        """Test that progress reports for wait attaching work as intended."""21        target = self.dbg.CreateTarget(None)22 23        # The waiting to attach progress message will get emitted upon24        # trying to attach, but it's not going to be the event picked25        # up by checking with fetch_next_event, so go through all emitted26        # progress events and check that the waiting to attach one was emitted at all.27        target.AttachToProcessWithName(28            self.listener,29            "wait-attach-progress-report",30            False,31            lldb.SBError(),32        )33        event = lldb.SBEvent()34        events = []35        while self.listener.GetNextEventForBroadcaster(self.broadcaster, event):36            progress_data = lldb.SBDebugger.GetProgressDataFromEvent(event)37            message = progress_data.GetValueForKey("message").GetStringValue(100)38            events.append(message)39        self.assertTrue("Waiting to attach to process" in events)40 41    def test_dwarf_symbol_loading_progress_report(self):42        """Test that we are able to fetch dwarf symbol loading progress events"""43        self.build()44 45        lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c"))46 47        event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)48        ret_args = lldb.SBDebugger.GetProgressFromEvent(event)49        self.assertGreater(len(ret_args), 0)50        message = ret_args[0]51        self.assertGreater(len(message), 0)52 53    def test_dwarf_symbol_loading_progress_report_structured_data(self):54        """Test that we are able to fetch dwarf symbol loading progress events55        using the structured data API"""56        self.build()57 58        lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c"))59 60        event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)61        progress_data = lldb.SBDebugger.GetProgressDataFromEvent(event)62        message = progress_data.GetValueForKey("message").GetStringValue(100)63        self.assertGreater(len(message), 0)64        details = progress_data.GetValueForKey("details").GetStringValue(100)65        self.assertGreater(len(details), 0)66