Commit 24afad2c authored by hjk's avatar hjk

Debugger: Adjust Native Mixed to new JSON based protocol

Change-Id: I4a9b9b31bba24a81824303f343115ba7c3709107
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 72036361
...@@ -2030,18 +2030,18 @@ registerCommand("exitGdb", exitGdb) ...@@ -2030,18 +2030,18 @@ registerCommand("exitGdb", exitGdb)
# #
####################################################################### #######################################################################
class QmlEngineCreationTracker(gdb.Breakpoint): #class QmlEngineCreationTracker(gdb.Breakpoint):
def __init__(self): # def __init__(self):
spec = "QQmlEnginePrivate::init" # spec = "QQmlEnginePrivate::init"
super(QmlEngineCreationTracker, self).\ # super(QmlEngineCreationTracker, self).\
__init__(spec, gdb.BP_BREAKPOINT, internal=True) # __init__(spec, gdb.BP_BREAKPOINT, internal=True)
#
def stop(self): # def stop(self):
engine = gdb.parse_and_eval("q_ptr") # engine = gdb.parse_and_eval("q_ptr")
print("QML engine created: %s" % engine) # print("QML engine created: %s" % engine)
theDumper.qmlEngines.append(engine) # theDumper.qmlEngines.append(engine)
return False # return False
#
#QmlEngineCreationTracker() #QmlEngineCreationTracker()
class TriggeredBreakpointHookBreakpoint(gdb.Breakpoint): class TriggeredBreakpointHookBreakpoint(gdb.Breakpoint):
...@@ -2074,53 +2074,60 @@ class ResolvePendingBreakpointsHookBreakpoint(gdb.Breakpoint): ...@@ -2074,53 +2074,60 @@ class ResolvePendingBreakpointsHookBreakpoint(gdb.Breakpoint):
self.enabled = False self.enabled = False
return False return False
def sendQmlCommand(command, data = ""):
data += '"version":"1","command":"%s"' % command
data = data.replace('"', '\\"')
expr = 'qt_v4DebuggerHook("{%s}")' % data
try:
res = gdb.parse_and_eval(expr)
print("QML command ok, RES: %s, CMD: %s" % (res, expr))
gdb.execute("p qt_v4Output")
except RuntimeError as error:
print("QML command failed: gdb.parse_and_eval(%s): %s" % (expr, error))
res = None
return res
def doInsertQmlBreakPoint(fullName, lineNumber): def doInsertQmlBreakPoint(fullName, lineNumber):
pos = fullName.rfind('/') pos = fullName.rfind('/')
engineName = "qrc:/" + fullName[pos+1:] engineName = "qrc:/" + fullName[pos+1:]
cmd = 'qt_v4InsertBreakpoint("%s",%s,"%s","")' \ bp = sendQmlCommand('insertBreakpoint',
% (fullName, lineNumber, engineName) '"fullName":"%s","lineNumber":"%s","engineName":"%s",'
try: % (fullName, lineNumber, engineName))
bp = gdb.parse_and_eval(cmd) if bp is None:
print("Resolving QML breakpoint: %s" % bp) print("Direct QML breakpoint insertion failed.")
return int(bp)
except RuntimeError as error:
print("Direct QML breakpoint insertion failed: %s" % error)
print("Make pending.") print("Make pending.")
ResolvePendingBreakpointsHookBreakpoint(fullName, lineNumber) ResolvePendingBreakpointsHookBreakpoint(fullName, lineNumber)
return 0 return 0
print("Resolving QML breakpoint: %s" % bp)
return int(bp)
def insertQmlBreakpoint(arg): def insertQmlBreakpoint(arg):
(fullName, lineNumber) = arg.split(' ') (fullName, lineNumber) = arg.split(' ')
print("Insert QML breakpoint %s:%s" % (fullName, lineNumber)) print("Insert QML breakpoint %s:%s" % (fullName, lineNumber))
bp = doInsertQmlBreakPoint(fullName, lineNumber) bp = doInsertQmlBreakPoint(fullName, lineNumber)
try: res = sendQmlCommand('prepareStep')
gdb.execute("set variable qt_v4IsStepping=0") if res is None:
except RuntimeError as error: print("Resetting stepping failed.")
print("Resetting stepping failed: %s" % error)
return str(bp) return str(bp)
registerCommand("insertQmlBreakpoint", insertQmlBreakpoint) registerCommand("insertQmlBreakpoint", insertQmlBreakpoint)
def removeQmlBreakpoint(arg): def removeQmlBreakpoint(arg):
(fullName, lineNumber) = arg.split(' ') (fullName, lineNumber) = arg.split(' ')
pos = fullName.rfind('/')
engineName = "qrc:/" + fullName[pos+1:]
fsName = fullName
cmd = 'qt_v4RemoveBreakpoint("%s",%s)' % (fullName, lineNumber)
print("Remove QML breakpoint %s:%s" % (fullName, lineNumber)) print("Remove QML breakpoint %s:%s" % (fullName, lineNumber))
try: bp = sendQmlCommand('removeBreakpoint',
res = gdb.parse_and_eval(cmd) '"fullName":"%s","lineNumber":"%s",'
print("Removing QML breakpoint: %s" % (cmd, res)) % (fullName, lineNumber))
return int(res) if bp is None:
except RuntimeError as error: print("Direct QML breakpoint removal failed: %s.")
print("Direct QML breakpoint removal failed: %s." % error)
return 0 return 0
return str(bp) print("Removing QML breakpoint: %s" % bp)
return int(bp)
registerCommand("removeQmlBreakpoint", removeQmlBreakpoint) registerCommand("removeQmlBreakpoint", removeQmlBreakpoint)
def prepareQmlStep(arg): def prepareQmlStep(arg):
gdb.execute("set variable qt_v4IsStepping=1") sendQmlCommand('prepareStep')
return ""
registerCommand("prepareQmlStep", prepareQmlStep) registerCommand("prepareQmlStep", prepareQmlStep)
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