Debugger: Do not waste CPU when using LLDB

Fixes: QTCREATORBUG-23311
Change-Id: I5b1c40663c7977322e806af2e0393a3730e70049
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2020-01-13 11:02:27 +01:00
parent 499115fd94
commit fefdbdfcd8
2 changed files with 10 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ import platform
import re import re
import sys import sys
import threading import threading
import time
import lldb import lldb
from contextlib import contextmanager from contextlib import contextmanager
@@ -953,14 +954,16 @@ class Dumper(DumperBase):
def loop(self): def loop(self):
event = lldb.SBEvent() event = lldb.SBEvent()
broadcaster = self.target.GetBroadcaster() #broadcaster = self.target.GetBroadcaster()
listener = self.debugger.GetListener() listener = self.debugger.GetListener()
while True: while True:
sys.stdout.flush() # IMPORTANT! to receive process state changes with lldb 1100
while listener.GetNextEvent(event): while listener.GetNextEvent(event):
self.handleEvent(event) self.handleEvent(event)
if listener.WaitForEventForBroadcaster(0, broadcaster, event): time.sleep(0.25)
self.handleEvent(event)
#if listener.WaitForEventForBroadcaster(0, broadcaster, event):
# self.handleEvent(event)
def describeError(self, error): def describeError(self, error):

View File

@@ -203,7 +203,9 @@ void LldbEngine::setupEngine()
const FilePath lldbCmd = runParameters().debugger.executable; const FilePath lldbCmd = runParameters().debugger.executable;
showMessage("STARTING LLDB: " + lldbCmd.toUserOutput()); showMessage("STARTING LLDB: " + lldbCmd.toUserOutput());
m_lldbProc.setEnvironment(runParameters().debugger.environment); Environment environment = runParameters().debugger.environment;
environment.appendOrSet("PYTHONUNBUFFERED", "1"); // avoid flushing problem on macOS
m_lldbProc.setEnvironment(environment);
if (QFileInfo(runParameters().debugger.workingDirectory).isDir()) if (QFileInfo(runParameters().debugger.workingDirectory).isDir())
m_lldbProc.setWorkingDirectory(runParameters().debugger.workingDirectory); m_lldbProc.setWorkingDirectory(runParameters().debugger.workingDirectory);