Commit a081fee8 authored by hjk's avatar hjk
Browse files

Debugger: Cleanup lldbbridge.py



Move reusable Breakpoint enum to base, use 'theDumper' uniformly
across backends as name for the Dumper singleton. Signal
engine setup only if the Dumper successfully initializes.

Change-Id: If1b6be9d054f249d0d46061e4949cbecf4fd09cb
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent a7fce391
......@@ -81,6 +81,22 @@ SeparateLatin1StringFormat, \
SeparateUtf8StringFormat \
= range(100, 112)
# Breakpoints. Keep synchronized with BreakpointType in breakpoint.h
UnknownType, \
BreakpointByFileAndLine, \
BreakpointByFunction, \
BreakpointByAddress, \
BreakpointAtThrow, \
BreakpointAtCatch, \
BreakpointAtMain, \
BreakpointAtFork, \
BreakpointAtExec, \
BreakpointAtSysCall, \
WatchpointAtAddress, \
WatchpointAtExpression, \
BreakpointOnQmlSignalEmit, \
BreakpointAtJavaScriptThrow, \
= range(0, 14)
#
# matplot based display for array-like structures.
#
......
......@@ -28,18 +28,15 @@
#
#############################################################################
import atexit
import inspect
import os
import platform
import re
import sys
import subprocess
import threading
import lldb
currentDir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
sys.path.insert(1, currentDir)
sys.path.insert(1, os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
from dumper import *
......@@ -51,8 +48,6 @@ from dumper import *
qqWatchpointOffset = 10000
lldb.theDumper = None
def warn(message):
print('\n\nWARNING="%s",\n' % message.encode("latin1").replace('"', "'"))
......@@ -66,22 +61,6 @@ def fileName(file):
return str(file) if file.IsValid() else ''
# Breakpoints. Keep synchronized with BreakpointType in breakpoint.h
UnknownType = 0
BreakpointByFileAndLine = 1
BreakpointByFunction = 2
BreakpointByAddress = 3
BreakpointAtThrow = 4
BreakpointAtCatch = 5
BreakpointAtMain = 6
BreakpointAtFork = 7
BreakpointAtExec = 8
BreakpointAtSysCall = 9
WatchpointAtAddress = 10
WatchpointAtExpression = 11
BreakpointOnQmlSignalEmit = 12
BreakpointAtJavaScriptThrow = 13
def check(exp):
if not exp:
raise RuntimeError("Check failed")
......@@ -187,8 +166,6 @@ class Dumper(DumperBase):
def __init__(self):
DumperBase.__init__(self)
lldb.theDumper = self
self.outputLock = threading.Lock()
self.debugger = lldb.SBDebugger.Create()
#self.debugger.SetLoggingCallback(loggingCallback)
......@@ -255,6 +232,9 @@ class Dumper(DumperBase):
self.qmlBreakpointResolvers = {}
self.qmlTriggeredBreakpoint = None
self.report('lldbversion=\"%s\"' % lldb.SBDebugger.GetVersionString())
self.reportState("enginesetupok")
def enterSubItem(self, item):
if isinstance(item.name, lldb.SBValue):
# Avoid $$__synth__ suffix on Mac.
......@@ -1719,7 +1699,6 @@ class Dumper(DumperBase):
# Used in dumper auto test.
# Usage: python lldbbridge.py /path/to/testbinary comma-separated-inames
class Tester(Dumper):
def __init__(self, binary, expandedINames):
Dumper.__init__(self)
......
......@@ -118,7 +118,6 @@ LldbEngine::~LldbEngine()
m_stubProc.disconnect(); // Avoid spurious state transitions from late exiting stub
}
void LldbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages)
{
DebuggerCommand cmd("executeDebuggerCommand");
......@@ -133,7 +132,7 @@ void LldbEngine::runCommand(const DebuggerCommand &command)
QByteArray token = QByteArray::number(m_lastToken);
QByteArray cmd = command.function + "({" + command.args + "})";
showMessage(_(token + cmd + '\n'), LogInput);
m_lldbProc.write("sc db." + cmd + "\n");
m_lldbProc.write("script theDumper." + cmd + "\n");
}
void LldbEngine::debugLastCommand()
......@@ -269,14 +268,10 @@ void LldbEngine::startLldb()
const QByteArray dumperSourcePath =
ICore::resourcePath().toLocal8Bit() + "/debugger/";
m_lldbProc.write("sc sys.path.insert(1, '" + dumperSourcePath + "')\n");
m_lldbProc.write("sc from lldbbridge import *\n");
m_lldbProc.write("sc print(dir())\n");
m_lldbProc.write("sc db = Dumper()\n");
m_lldbProc.write("sc db.report('lldbversion=\"%s\"' % lldb.SBDebugger.GetVersionString())\n");
showMessage(_("ENGINE SUCCESSFULLY STARTED"));
notifyEngineSetupOk();
m_lldbProc.write("script sys.path.insert(1, '" + dumperSourcePath + "')\n");
m_lldbProc.write("script from lldbbridge import *\n");
m_lldbProc.write("script print(dir())\n");
m_lldbProc.write("script theDumper = Dumper()\n"); // This triggers reportState("enginesetupok")
}
void LldbEngine::setupInferior()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment