2016-01-15 14:53:55 +01:00
|
|
|
############################################################################
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
# Contact: https://www.qt.io/licensing/
|
|
|
|
#
|
|
|
|
# This file is part of Qt Creator.
|
|
|
|
#
|
|
|
|
# Commercial License Usage
|
|
|
|
# Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
# accordance with the commercial license agreement provided with the
|
|
|
|
# Software or, alternatively, in accordance with the terms contained in
|
|
|
|
# a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
# and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
# information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
#
|
|
|
|
# GNU General Public License Usage
|
|
|
|
# Alternatively, this file may be used under the terms of the GNU
|
|
|
|
# General Public License version 3 as published by the Free Software
|
|
|
|
# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
# included in the packaging of this file. Please review the following
|
|
|
|
# information to ensure the GNU General Public License requirements will
|
|
|
|
# be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
#
|
|
|
|
############################################################################
|
2013-04-11 18:11:54 +02:00
|
|
|
|
2013-09-11 21:35:39 +02:00
|
|
|
try:
|
|
|
|
import __builtin__
|
|
|
|
except:
|
|
|
|
import builtins
|
|
|
|
|
2016-09-20 12:07:46 +02:00
|
|
|
import gdb
|
2013-04-11 18:11:54 +02:00
|
|
|
import os
|
2013-05-15 15:42:55 +02:00
|
|
|
import os.path
|
2013-04-12 16:58:25 +02:00
|
|
|
import sys
|
2013-09-11 21:35:39 +02:00
|
|
|
import struct
|
2014-10-14 21:13:22 +02:00
|
|
|
import types
|
2013-09-11 21:35:39 +02:00
|
|
|
|
|
|
|
from dumper import *
|
2014-10-14 21:13:22 +02:00
|
|
|
|
2013-04-10 13:55:15 +02:00
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
#
|
|
|
|
# Infrastructure
|
|
|
|
#
|
|
|
|
#######################################################################
|
|
|
|
|
2015-06-25 09:10:25 +02:00
|
|
|
def safePrint(output):
|
2013-04-10 13:55:15 +02:00
|
|
|
try:
|
|
|
|
print(output)
|
|
|
|
except:
|
|
|
|
out = ""
|
|
|
|
for c in output:
|
|
|
|
cc = ord(c)
|
|
|
|
if cc > 127:
|
|
|
|
out += "\\\\%d" % cc
|
|
|
|
elif cc < 0:
|
|
|
|
out += "\\\\%d" % (cc + 256)
|
|
|
|
else:
|
|
|
|
out += c
|
|
|
|
print(out)
|
|
|
|
|
|
|
|
def registerCommand(name, func):
|
|
|
|
|
|
|
|
class Command(gdb.Command):
|
|
|
|
def __init__(self):
|
|
|
|
super(Command, self).__init__(name, gdb.COMMAND_OBSCURE)
|
|
|
|
def invoke(self, args, from_tty):
|
2015-06-25 09:10:25 +02:00
|
|
|
safePrint(func(args))
|
2013-04-10 13:55:15 +02:00
|
|
|
|
|
|
|
Command()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
#
|
|
|
|
# Convenience
|
|
|
|
#
|
|
|
|
#######################################################################
|
|
|
|
|
|
|
|
# Just convienience for 'python print ...'
|
|
|
|
class PPCommand(gdb.Command):
|
|
|
|
def __init__(self):
|
|
|
|
super(PPCommand, self).__init__("pp", gdb.COMMAND_OBSCURE)
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
print(eval(args))
|
|
|
|
|
|
|
|
PPCommand()
|
|
|
|
|
|
|
|
# Just convienience for 'python print gdb.parse_and_eval(...)'
|
|
|
|
class PPPCommand(gdb.Command):
|
|
|
|
def __init__(self):
|
|
|
|
super(PPPCommand, self).__init__("ppp", gdb.COMMAND_OBSCURE)
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
print(gdb.parse_and_eval(args))
|
|
|
|
|
|
|
|
PPPCommand()
|
|
|
|
|
|
|
|
|
|
|
|
def scanStack(p, n):
|
2013-09-11 21:35:39 +02:00
|
|
|
p = int(p)
|
2013-04-10 13:55:15 +02:00
|
|
|
r = []
|
|
|
|
for i in xrange(n):
|
|
|
|
f = gdb.parse_and_eval("{void*}%s" % p)
|
|
|
|
m = gdb.execute("info symbol %s" % f, to_string=True)
|
|
|
|
if not m.startswith("No symbol matches"):
|
|
|
|
r.append(m)
|
|
|
|
p += f.type.sizeof
|
|
|
|
return r
|
|
|
|
|
|
|
|
class ScanStackCommand(gdb.Command):
|
|
|
|
def __init__(self):
|
|
|
|
super(ScanStackCommand, self).__init__("scanStack", gdb.COMMAND_OBSCURE)
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
if len(args) == 0:
|
|
|
|
args = 20
|
2015-06-25 09:10:25 +02:00
|
|
|
safePrint(scanStack(gdb.parse_and_eval("$sp"), int(args)))
|
2013-04-10 13:55:15 +02:00
|
|
|
|
|
|
|
ScanStackCommand()
|
|
|
|
|
2013-04-11 18:11:54 +02:00
|
|
|
|
2013-04-12 16:58:25 +02:00
|
|
|
#######################################################################
|
|
|
|
#
|
|
|
|
# Import plain gdb pretty printers
|
|
|
|
#
|
|
|
|
#######################################################################
|
|
|
|
|
|
|
|
class PlainDumper:
|
|
|
|
def __init__(self, printer):
|
|
|
|
self.printer = printer
|
2015-07-10 10:09:34 +02:00
|
|
|
self.typeCache = {}
|
2013-04-12 16:58:25 +02:00
|
|
|
|
|
|
|
def __call__(self, d, value):
|
2016-08-22 13:45:15 +02:00
|
|
|
try:
|
|
|
|
printer = self.printer.gen_printer(value)
|
|
|
|
except:
|
|
|
|
printer = self.printer.invoke(value)
|
2013-04-12 16:58:25 +02:00
|
|
|
lister = getattr(printer, "children", None)
|
|
|
|
children = [] if lister is None else list(lister())
|
|
|
|
d.putType(self.printer.name)
|
2015-01-14 15:00:09 +01:00
|
|
|
val = printer.to_string()
|
|
|
|
if isinstance(val, str):
|
|
|
|
d.putValue(val)
|
2016-03-23 08:53:30 +01:00
|
|
|
elif sys.version_info[0] <= 2 and isinstance(val, unicode):
|
|
|
|
d.putValue(val)
|
2015-01-14 15:00:09 +01:00
|
|
|
else: # Assuming LazyString
|
2016-09-06 08:54:43 +02:00
|
|
|
d.putCharArrayHelper(val.address, val.length, val.type)
|
2015-01-14 15:00:09 +01:00
|
|
|
|
2013-04-12 16:58:25 +02:00
|
|
|
d.putNumChild(len(children))
|
|
|
|
if d.isExpanded():
|
|
|
|
with Children(d):
|
|
|
|
for child in children:
|
|
|
|
d.putSubItem(child[0], child[1])
|
|
|
|
|
|
|
|
def importPlainDumpers(args):
|
2015-01-25 01:36:08 +01:00
|
|
|
if args == "off":
|
2016-05-23 13:49:47 +02:00
|
|
|
try:
|
|
|
|
gdb.execute("disable pretty-printer .* .*")
|
|
|
|
except:
|
|
|
|
# Might occur in non-ASCII directories
|
|
|
|
warn("COULD NOT DISABLE PRETTY PRINTERS")
|
2015-01-25 01:36:08 +01:00
|
|
|
else:
|
|
|
|
theDumper.importPlainDumpers()
|
2013-04-12 16:58:25 +02:00
|
|
|
|
|
|
|
registerCommand("importPlainDumpers", importPlainDumpers)
|
|
|
|
|
|
|
|
|
2013-05-15 15:42:55 +02:00
|
|
|
|
|
|
|
class OutputSafer:
|
|
|
|
def __init__(self, d):
|
|
|
|
self.d = d
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
self.savedOutput = self.d.output
|
|
|
|
self.d.output = []
|
|
|
|
|
|
|
|
def __exit__(self, exType, exValue, exTraceBack):
|
|
|
|
if self.d.passExceptions and not exType is None:
|
|
|
|
showException("OUTPUTSAFER", exType, exValue, exTraceBack)
|
|
|
|
self.d.output = self.savedOutput
|
|
|
|
else:
|
|
|
|
self.savedOutput.extend(self.d.output)
|
|
|
|
self.d.output = self.savedOutput
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
#
|
|
|
|
# The Dumper Class
|
|
|
|
#
|
|
|
|
#######################################################################
|
|
|
|
|
|
|
|
|
2013-09-11 21:35:39 +02:00
|
|
|
class Dumper(DumperBase):
|
|
|
|
|
2013-10-30 12:38:29 +01:00
|
|
|
def __init__(self):
|
2013-09-11 21:35:39 +02:00
|
|
|
DumperBase.__init__(self)
|
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
# These values will be kept between calls to 'fetchVariables'.
|
2013-09-11 21:35:39 +02:00
|
|
|
self.isGdb = True
|
2015-07-10 10:09:34 +02:00
|
|
|
self.typeCache = {}
|
2015-10-09 15:00:20 +02:00
|
|
|
self.interpreterBreakpointResolvers = []
|
2013-10-30 12:38:29 +01:00
|
|
|
|
Debugger: Make dumpers somewhat work in command line GDB
With
python sys.path.insert(1, '/data/dev/creator/share/qtcreator/debugger/')
python from gdbbridge import *
in .gdbinit there's a new "GDB command", called "pp".
With code like
int main(int argc, char *argv[])
{
QString ss = "Hello";
QApplication app(argc, argv);
app.setObjectName(ss);
// break here
}
the 'pp' command can be used as follows:
(gdb) pp app
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = <Myns::QObjectList> = {"<3 items>"}
[properties] = "<>0 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp app [properties],[children]
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = [
<Myns::QObject> = {""}
<Myns::QObject> = {""}
<Myns::QObject> = {"fusion"}
],<Myns::QObjectList> = {"<3 items>"}
[properties] = [
windowIcon = <Myns::QVariant (QIcon)> = {""}
cursorFlashTime = <Myns::QVariant (int)> = {"1000"}
doubleClickInterval = <Myns::QVariant (int)> = {"400"}
keyboardInputInterval = <Myns::QVariant (int)> = {"400"}
wheelScrollLines = <Myns::QVariant (int)> = {"3"}
globalStrut = <Myns::QVariant (QSize)> = {"(0, 0)"}
startDragTime = <Myns::QVariant (int)> = {"500"}
startDragDistance = <Myns::QVariant (int)> = {"10"}
styleSheet = <Myns::QVariant (QString)> = {""}
autoSipEnabled = <Myns::QVariant (bool)> = {"true"}
],"<10 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp ss
ss =
<Myns::QString> = {"Hello"}
Change-Id: I6e4714a5cfe34c38917500d114ad9a70d20cff39
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-06-13 17:45:34 +02:00
|
|
|
def prepare(self, args):
|
2013-05-15 15:42:55 +02:00
|
|
|
self.output = []
|
|
|
|
self.currentIName = ""
|
|
|
|
self.currentPrintsAddress = True
|
|
|
|
self.currentChildType = ""
|
|
|
|
self.currentChildNumChild = -1
|
|
|
|
self.currentMaxNumChild = -1
|
|
|
|
self.currentNumChild = -1
|
2014-05-16 00:18:17 +02:00
|
|
|
self.currentValue = ReportItem()
|
|
|
|
self.currentType = ReportItem()
|
2013-05-15 15:42:55 +02:00
|
|
|
self.currentAddress = None
|
|
|
|
|
2015-02-11 17:51:15 +01:00
|
|
|
self.resultVarName = args.get("resultvarname", "")
|
|
|
|
self.expandedINames = set(args.get("expanded", []))
|
|
|
|
self.stringCutOff = int(args.get("stringcutoff", 10000))
|
2015-02-12 11:31:02 +01:00
|
|
|
self.displayStringLimit = int(args.get("displaystringlimit", 100))
|
|
|
|
self.typeformats = args.get("typeformats", {})
|
|
|
|
self.formats = args.get("formats", {})
|
2015-02-11 17:51:15 +01:00
|
|
|
self.watchers = args.get("watchers", {})
|
|
|
|
self.useDynamicType = int(args.get("dyntype", "0"))
|
|
|
|
self.useFancy = int(args.get("fancy", "0"))
|
|
|
|
self.forceQtNamespace = int(args.get("forcens", "0"))
|
2015-10-27 15:50:41 +01:00
|
|
|
self.passExceptions = int(args.get("passexceptions", "0"))
|
2015-12-16 14:13:44 +01:00
|
|
|
self.showQObjectNames = int(args.get("qobjectnames", "0"))
|
2015-02-11 17:51:15 +01:00
|
|
|
self.nativeMixed = int(args.get("nativemixed", "0"))
|
|
|
|
self.autoDerefPointers = int(args.get("autoderef", "0"))
|
|
|
|
self.partialUpdate = int(args.get("partial", "0"))
|
2014-03-07 15:48:13 +01:00
|
|
|
self.fallbackQtVersion = 0x50200
|
2015-05-29 08:23:52 +02:00
|
|
|
|
2013-10-30 15:07:54 +01:00
|
|
|
#warn("NAMESPACE: '%s'" % self.qtNamespace())
|
2013-05-15 15:42:55 +02:00
|
|
|
#warn("EXPANDED INAMES: %s" % self.expandedINames)
|
Debugger: Make dumpers somewhat work in command line GDB
With
python sys.path.insert(1, '/data/dev/creator/share/qtcreator/debugger/')
python from gdbbridge import *
in .gdbinit there's a new "GDB command", called "pp".
With code like
int main(int argc, char *argv[])
{
QString ss = "Hello";
QApplication app(argc, argv);
app.setObjectName(ss);
// break here
}
the 'pp' command can be used as follows:
(gdb) pp app
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = <Myns::QObjectList> = {"<3 items>"}
[properties] = "<>0 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp app [properties],[children]
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = [
<Myns::QObject> = {""}
<Myns::QObject> = {""}
<Myns::QObject> = {"fusion"}
],<Myns::QObjectList> = {"<3 items>"}
[properties] = [
windowIcon = <Myns::QVariant (QIcon)> = {""}
cursorFlashTime = <Myns::QVariant (int)> = {"1000"}
doubleClickInterval = <Myns::QVariant (int)> = {"400"}
keyboardInputInterval = <Myns::QVariant (int)> = {"400"}
wheelScrollLines = <Myns::QVariant (int)> = {"3"}
globalStrut = <Myns::QVariant (QSize)> = {"(0, 0)"}
startDragTime = <Myns::QVariant (int)> = {"500"}
startDragDistance = <Myns::QVariant (int)> = {"10"}
styleSheet = <Myns::QVariant (QString)> = {""}
autoSipEnabled = <Myns::QVariant (bool)> = {"true"}
],"<10 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp ss
ss =
<Myns::QString> = {"Hello"}
Change-Id: I6e4714a5cfe34c38917500d114ad9a70d20cff39
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-06-13 17:45:34 +02:00
|
|
|
#warn("WATCHERS: %s" % self.watchers)
|
|
|
|
|
2016-07-05 16:52:32 +02:00
|
|
|
# The guess does not need to be updated during a fetchVariables()
|
|
|
|
# as the result is fixed during that time (ignoring "active"
|
|
|
|
# dumpers causing loading of shared objects etc).
|
|
|
|
self.currentQtNamespaceGuess = None
|
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
def fromNativeDowncastableValue(self, nativeValue):
|
|
|
|
if self.useDynamicType:
|
|
|
|
try:
|
|
|
|
return self.fromNativeValue(nativeValue.cast(nativeValue.dynamic_type))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return self.fromNativeValue(nativeValue)
|
|
|
|
|
|
|
|
def fromNativeValue(self, nativeValue):
|
|
|
|
#self.check(isinstance(nativeType, gdb.Value))
|
|
|
|
val = self.Value(self)
|
|
|
|
val.nativeValue = nativeValue
|
|
|
|
if not nativeValue.address is None:
|
|
|
|
val.laddress = toInteger(nativeValue.address)
|
|
|
|
val.type = self.fromNativeType(nativeValue.type)
|
|
|
|
val.lIsInScope = not nativeValue.is_optimized_out
|
|
|
|
return val
|
|
|
|
|
|
|
|
def fromNativeType(self, nativeType):
|
|
|
|
self.check(isinstance(nativeType, gdb.Type))
|
|
|
|
typeobj = self.Type(self)
|
|
|
|
typeobj.nativeType = nativeType.unqualified()
|
|
|
|
typeobj.name = str(typeobj.nativeType)
|
|
|
|
typeobj.lbitsize = nativeType.sizeof * 8
|
2016-09-19 12:05:16 +02:00
|
|
|
typeobj.code = {
|
|
|
|
gdb.TYPE_CODE_TYPEDEF : TypeCodeTypedef,
|
|
|
|
gdb.TYPE_CODE_METHOD : TypeCodeFunction,
|
|
|
|
gdb.TYPE_CODE_VOID : TypeCodeVoid,
|
|
|
|
gdb.TYPE_CODE_FUNC : TypeCodeFunction,
|
|
|
|
gdb.TYPE_CODE_METHODPTR : TypeCodeFunction,
|
|
|
|
gdb.TYPE_CODE_MEMBERPTR : TypeCodeFunction,
|
|
|
|
gdb.TYPE_CODE_PTR : TypeCodePointer,
|
|
|
|
gdb.TYPE_CODE_REF : TypeCodeReference,
|
|
|
|
gdb.TYPE_CODE_BOOL : TypeCodeIntegral,
|
|
|
|
gdb.TYPE_CODE_CHAR : TypeCodeIntegral,
|
|
|
|
gdb.TYPE_CODE_INT : TypeCodeIntegral,
|
|
|
|
gdb.TYPE_CODE_FLT : TypeCodeFloat,
|
|
|
|
gdb.TYPE_CODE_ENUM : TypeCodeEnum,
|
|
|
|
gdb.TYPE_CODE_ARRAY : TypeCodeArray,
|
|
|
|
gdb.TYPE_CODE_STRUCT : TypeCodeStruct,
|
|
|
|
gdb.TYPE_CODE_UNION : TypeCodeStruct,
|
|
|
|
gdb.TYPE_CODE_COMPLEX : TypeCodeComplex,
|
|
|
|
gdb.TYPE_CODE_STRING : TypeCodeFortranString,
|
|
|
|
}[nativeType.code]
|
2016-09-06 08:54:43 +02:00
|
|
|
return typeobj
|
|
|
|
|
|
|
|
def nativeValueDereference(self, nativeValue):
|
|
|
|
return self.nativeValueDownCast(nativeValue.dereference())
|
|
|
|
|
|
|
|
def nativeValueCast(self, nativeValue, nativeType):
|
|
|
|
try:
|
|
|
|
return self.fromNativeValue(nativeValue.cast(nativeType))
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def nativeValueAddressOf(self, nativeValue):
|
|
|
|
return toInteger(nativeValue.address)
|
|
|
|
|
|
|
|
def nativeTypeDereference(self, nativeType):
|
|
|
|
return self.fromNativeType(nativeType.strip_typedefs().target())
|
|
|
|
|
|
|
|
def nativeTypeUnqualified(self, nativeType):
|
|
|
|
return self.fromNativeType(nativeType.unqualified())
|
|
|
|
|
|
|
|
def nativeTypePointer(self, nativeType):
|
|
|
|
return self.fromNativeType(nativeType.pointer())
|
|
|
|
|
|
|
|
def nativeTypeTarget(self, nativeType):
|
2016-09-19 12:05:16 +02:00
|
|
|
while nativeType.code == gdb.TYPE_CODE_TYPEDEF:
|
2016-09-06 08:54:43 +02:00
|
|
|
nativeType = nativeType.strip_typedefs().unqualified()
|
|
|
|
return self.fromNativeType(nativeType.target())
|
|
|
|
|
|
|
|
def nativeTypeFirstBase(self, nativeType):
|
|
|
|
nativeFields = nativeType.fields()
|
|
|
|
if len(nativeFields) and nativeFields[0].is_base_class:
|
|
|
|
return self.fromNativeType(nativeFields[0].type)
|
|
|
|
|
2016-09-15 12:31:28 +02:00
|
|
|
def nativeTypeEnumDisplay(self, nativeType, intval):
|
|
|
|
try:
|
2016-09-16 13:46:19 +02:00
|
|
|
val = gdb.parse_and_eval("(%s)%d" % (nativeType, intval))
|
2016-09-15 12:31:28 +02:00
|
|
|
return "%s (%d)" % (val, intval)
|
|
|
|
except:
|
|
|
|
return "%d" % intval
|
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
def nativeTypeFields(self, nativeType):
|
2016-09-21 13:01:48 +02:00
|
|
|
if nativeType.code == gdb.TYPE_CODE_TYPEDEF:
|
|
|
|
return self.nativeTypeFields(nativeType.strip_typedefs())
|
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
fields = []
|
2016-09-19 12:05:16 +02:00
|
|
|
if nativeType.code == gdb.TYPE_CODE_ARRAY:
|
2016-09-06 08:54:43 +02:00
|
|
|
# An array.
|
|
|
|
typeobj = nativeType.strip_typedefs()
|
|
|
|
innerType = typeobj.target()
|
|
|
|
for i in xrange(int(typeobj.sizeof / innerType.sizeof)):
|
|
|
|
field = self.Field(self)
|
|
|
|
field.ltype = self.fromNativeType(innerType)
|
|
|
|
field.parentType = self.fromNativeType(nativeType)
|
|
|
|
field.isBaseClass = False
|
|
|
|
field.lbitsize = innerType.sizeof
|
|
|
|
field.lbitpos = i * innerType.sizeof * 8
|
|
|
|
fields.append(field)
|
|
|
|
return fields
|
|
|
|
|
2016-09-19 12:05:16 +02:00
|
|
|
if not nativeType.code in (gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION):
|
2016-09-06 08:54:43 +02:00
|
|
|
return fields
|
|
|
|
|
|
|
|
nativeIndex = 0
|
|
|
|
baseIndex = 0
|
|
|
|
nativeFields = nativeType.fields()
|
|
|
|
#warn("NATIVE FIELDS: %s" % nativeFields)
|
|
|
|
for nativeField in nativeFields:
|
|
|
|
#warn("FIELD: %s" % nativeField)
|
|
|
|
#warn(" DIR: %s" % dir(nativeField))
|
|
|
|
#warn(" BITSIZE: %s" % nativeField.bitsize)
|
|
|
|
#warn(" ARTIFICIAL: %s" % nativeField.artificial)
|
|
|
|
#warn("FIELD NAME: %s" % nativeField.name)
|
|
|
|
#warn("FIELD TYPE: %s" % nativeField.type)
|
|
|
|
#self.check(isinstance(nativeField, gdb.Field))
|
|
|
|
field = self.Field(self)
|
|
|
|
field.ltype = self.fromNativeType(nativeField.type)
|
|
|
|
field.parentType = self.fromNativeType(nativeType)
|
|
|
|
field.name = nativeField.name
|
|
|
|
field.isBaseClass = nativeField.is_base_class
|
|
|
|
if hasattr(nativeField, 'bitpos'):
|
|
|
|
field.lbitpos = nativeField.bitpos
|
|
|
|
if hasattr(nativeField, 'bitsize') and nativeField.bitsize != 0:
|
|
|
|
field.lbitsize = nativeField.bitsize
|
|
|
|
else:
|
|
|
|
field.lbitsize = 8 * nativeField.type.sizeof
|
|
|
|
|
|
|
|
if nativeField.is_base_class:
|
|
|
|
# Field is base type. We cannot use nativeField.name as part
|
|
|
|
# of the iname as it might contain spaces and other
|
|
|
|
# strange characters.
|
|
|
|
field.name = nativeField.name
|
|
|
|
field.baseIndex = baseIndex
|
|
|
|
baseIndex += 1
|
|
|
|
else:
|
|
|
|
# Since GDB commit b5b08fb4 anonymous structs get also reported
|
|
|
|
# with a 'None' name.
|
|
|
|
if nativeField.name is None or len(nativeField.name) == 0:
|
|
|
|
# Something without a name.
|
|
|
|
# Anonymous union? We need a dummy name to distinguish
|
|
|
|
# multiple anonymous unions in the struct.
|
|
|
|
self.anonNumber += 1
|
|
|
|
field.name = "#%s" % self.anonNumber
|
|
|
|
else:
|
|
|
|
# Normal named field.
|
|
|
|
field.name = nativeField.name
|
|
|
|
|
|
|
|
field.nativeIndex = nativeIndex
|
|
|
|
fields.append(field)
|
|
|
|
nativeIndex += 1
|
|
|
|
|
|
|
|
#warn("FIELDS: %s" % fields)
|
|
|
|
return fields
|
|
|
|
|
|
|
|
def nativeTypeStripTypedefs(self, typeobj):
|
|
|
|
typeobj = typeobj.unqualified()
|
2016-09-19 12:05:16 +02:00
|
|
|
while typeobj.code == gdb.TYPE_CODE_TYPEDEF:
|
2016-09-06 08:54:43 +02:00
|
|
|
typeobj = typeobj.strip_typedefs().unqualified()
|
|
|
|
return self.fromNativeType(typeobj)
|
|
|
|
|
|
|
|
def nativeValueChildFromField(self, nativeValue, field):
|
|
|
|
#warn("EXTRACTING: %s FROM %s" % (field, nativeValue))
|
|
|
|
if field.nativeIndex is not None:
|
|
|
|
nativeField = nativeValue.type.fields()[field.nativeIndex]
|
|
|
|
#warn("NATIVE FIELD: %s" % nativeField)
|
|
|
|
if nativeField.is_base_class:
|
|
|
|
return self.fromNativeValue(nativeValue.cast(nativeField.type))
|
|
|
|
try:
|
|
|
|
# Fails with GDB 7.5.
|
|
|
|
return self.nativeValueDownCast(nativeValue[nativeField])
|
|
|
|
except:
|
|
|
|
# The generic handling is almost good enough, but does not
|
|
|
|
# downcast the produced values.
|
|
|
|
return None
|
|
|
|
if field.name is not None:
|
|
|
|
return self.nativeValueDownCast(nativeValue[field.name])
|
|
|
|
error("FIELD EXTARCTION FAILED: %s" % field)
|
|
|
|
return None
|
|
|
|
|
2016-09-20 11:52:06 +02:00
|
|
|
def listOfLocals(self, partialVar):
|
2014-12-12 10:12:18 +01:00
|
|
|
frame = gdb.selected_frame()
|
|
|
|
|
|
|
|
try:
|
|
|
|
block = frame.block()
|
|
|
|
#warn("BLOCK: %s " % block)
|
|
|
|
except RuntimeError as error:
|
|
|
|
#warn("BLOCK IN FRAME NOT ACCESSIBLE: %s" % error)
|
|
|
|
return []
|
|
|
|
except:
|
|
|
|
warn("BLOCK NOT ACCESSIBLE FOR UNKNOWN REASONS")
|
|
|
|
return []
|
|
|
|
|
|
|
|
items = []
|
|
|
|
shadowed = {}
|
|
|
|
while True:
|
|
|
|
if block is None:
|
|
|
|
warn("UNEXPECTED 'None' BLOCK")
|
|
|
|
break
|
|
|
|
for symbol in block:
|
2015-10-08 16:05:29 +02:00
|
|
|
|
|
|
|
# Filter out labels etc.
|
|
|
|
if symbol.is_variable or symbol.is_argument:
|
2014-12-12 10:12:18 +01:00
|
|
|
name = symbol.print_name
|
|
|
|
|
|
|
|
if name == "__in_chrg" or name == "__PRETTY_FUNCTION__":
|
|
|
|
continue
|
|
|
|
|
2016-09-20 11:52:06 +02:00
|
|
|
if not partialVar is None and partialVar != name:
|
|
|
|
continue
|
|
|
|
|
2014-12-12 10:12:18 +01:00
|
|
|
# "NotImplementedError: Symbol type not yet supported in
|
|
|
|
# Python scripts."
|
|
|
|
#warn("SYMBOL %s (%s, %s)): " % (symbol, name, symbol.name))
|
|
|
|
try:
|
2016-09-06 08:54:43 +02:00
|
|
|
value = self.fromNativeDowncastableValue(frame.read_var(name, block))
|
|
|
|
#warn("READ 1: %s" % value)
|
2016-09-20 11:52:06 +02:00
|
|
|
value.name = name
|
2016-09-06 08:54:43 +02:00
|
|
|
items.append(value)
|
2014-12-12 10:12:18 +01:00
|
|
|
continue
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
#warn("READ 2: %s" % item.value)
|
2016-09-06 08:54:43 +02:00
|
|
|
value = self.fromNativeDowncastableValue(frame.read_var(name))
|
2016-09-20 11:52:06 +02:00
|
|
|
value.name = name
|
2016-09-06 08:54:43 +02:00
|
|
|
items.append(value)
|
2014-12-12 10:12:18 +01:00
|
|
|
continue
|
|
|
|
except:
|
|
|
|
# RuntimeError: happens for
|
|
|
|
# void foo() { std::string s; std::wstring w; }
|
|
|
|
# ValueError: happens for (as of 2010/11/4)
|
|
|
|
# a local struct as found e.g. in
|
|
|
|
# gcc sources in gcc.c, int execute()
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
#warn("READ 3: %s %s" % (name, item.value))
|
|
|
|
#warn("ITEM 3: %s" % item.value)
|
2016-09-06 08:54:43 +02:00
|
|
|
value = self.fromNativeDowncastableValue(gdb.parse_and_eval(name))
|
|
|
|
items.append(value)
|
2014-12-12 10:12:18 +01:00
|
|
|
except:
|
|
|
|
# Can happen in inlined code (see last line of
|
|
|
|
# RowPainter::paintChars(): "RuntimeError:
|
|
|
|
# No symbol \"__val\" in current context.\n"
|
|
|
|
pass
|
|
|
|
|
|
|
|
# The outermost block in a function has the function member
|
|
|
|
# FIXME: check whether this is guaranteed.
|
|
|
|
if not block.function is None:
|
|
|
|
break
|
|
|
|
|
|
|
|
block = block.superblock
|
|
|
|
|
|
|
|
return items
|
|
|
|
|
2015-04-15 12:38:11 +02:00
|
|
|
# Hack to avoid QDate* dumper timeouts with GDB 7.4 on 32 bit
|
|
|
|
# due to misaligned %ebx in SSE calls (qstring.cpp:findChar)
|
|
|
|
# This seems to be fixed in 7.9 (or earlier)
|
|
|
|
def canCallLocale(self):
|
2016-09-14 14:44:58 +02:00
|
|
|
return self.ptrSize() == 8
|
2014-12-12 10:12:18 +01:00
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
def fetchVariables(self, args):
|
2016-07-22 10:20:01 +02:00
|
|
|
self.resetStats()
|
Debugger: Make dumpers somewhat work in command line GDB
With
python sys.path.insert(1, '/data/dev/creator/share/qtcreator/debugger/')
python from gdbbridge import *
in .gdbinit there's a new "GDB command", called "pp".
With code like
int main(int argc, char *argv[])
{
QString ss = "Hello";
QApplication app(argc, argv);
app.setObjectName(ss);
// break here
}
the 'pp' command can be used as follows:
(gdb) pp app
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = <Myns::QObjectList> = {"<3 items>"}
[properties] = "<>0 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp app [properties],[children]
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = [
<Myns::QObject> = {""}
<Myns::QObject> = {""}
<Myns::QObject> = {"fusion"}
],<Myns::QObjectList> = {"<3 items>"}
[properties] = [
windowIcon = <Myns::QVariant (QIcon)> = {""}
cursorFlashTime = <Myns::QVariant (int)> = {"1000"}
doubleClickInterval = <Myns::QVariant (int)> = {"400"}
keyboardInputInterval = <Myns::QVariant (int)> = {"400"}
wheelScrollLines = <Myns::QVariant (int)> = {"3"}
globalStrut = <Myns::QVariant (QSize)> = {"(0, 0)"}
startDragTime = <Myns::QVariant (int)> = {"500"}
startDragDistance = <Myns::QVariant (int)> = {"10"}
styleSheet = <Myns::QVariant (QString)> = {""}
autoSipEnabled = <Myns::QVariant (bool)> = {"true"}
],"<10 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp ss
ss =
<Myns::QString> = {"Hello"}
Change-Id: I6e4714a5cfe34c38917500d114ad9a70d20cff39
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-06-13 17:45:34 +02:00
|
|
|
self.prepare(args)
|
2015-03-26 13:03:38 +01:00
|
|
|
|
2015-10-09 15:00:20 +02:00
|
|
|
(ok, res) = self.tryFetchInterpreterVariables(args)
|
|
|
|
if ok:
|
|
|
|
safePrint(res)
|
|
|
|
return
|
2015-10-08 16:19:57 +02:00
|
|
|
|
Debugger: Make dumpers somewhat work in command line GDB
With
python sys.path.insert(1, '/data/dev/creator/share/qtcreator/debugger/')
python from gdbbridge import *
in .gdbinit there's a new "GDB command", called "pp".
With code like
int main(int argc, char *argv[])
{
QString ss = "Hello";
QApplication app(argc, argv);
app.setObjectName(ss);
// break here
}
the 'pp' command can be used as follows:
(gdb) pp app
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = <Myns::QObjectList> = {"<3 items>"}
[properties] = "<>0 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp app [properties],[children]
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = [
<Myns::QObject> = {""}
<Myns::QObject> = {""}
<Myns::QObject> = {"fusion"}
],<Myns::QObjectList> = {"<3 items>"}
[properties] = [
windowIcon = <Myns::QVariant (QIcon)> = {""}
cursorFlashTime = <Myns::QVariant (int)> = {"1000"}
doubleClickInterval = <Myns::QVariant (int)> = {"400"}
keyboardInputInterval = <Myns::QVariant (int)> = {"400"}
wheelScrollLines = <Myns::QVariant (int)> = {"3"}
globalStrut = <Myns::QVariant (QSize)> = {"(0, 0)"}
startDragTime = <Myns::QVariant (int)> = {"500"}
startDragDistance = <Myns::QVariant (int)> = {"10"}
styleSheet = <Myns::QVariant (QString)> = {""}
autoSipEnabled = <Myns::QVariant (bool)> = {"true"}
],"<10 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp ss
ss =
<Myns::QString> = {"Hello"}
Change-Id: I6e4714a5cfe34c38917500d114ad9a70d20cff39
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-06-13 17:45:34 +02:00
|
|
|
self.output.append('data=[')
|
2015-02-05 12:51:25 +01:00
|
|
|
|
2016-09-20 11:52:06 +02:00
|
|
|
partialVar = args.get("partialvar", "")
|
|
|
|
isPartial = len(partialVar) > 0
|
|
|
|
partialName = partialVar.split('.')[1].split('@')[0] if isPartial else None
|
2013-05-15 15:42:55 +02:00
|
|
|
|
2016-09-20 11:52:06 +02:00
|
|
|
variables = self.listOfLocals(partialName)
|
2015-12-16 17:17:38 +01:00
|
|
|
|
2013-05-15 15:42:55 +02:00
|
|
|
# Take care of the return value of the last function call.
|
Debugger: Make dumpers somewhat work in command line GDB
With
python sys.path.insert(1, '/data/dev/creator/share/qtcreator/debugger/')
python from gdbbridge import *
in .gdbinit there's a new "GDB command", called "pp".
With code like
int main(int argc, char *argv[])
{
QString ss = "Hello";
QApplication app(argc, argv);
app.setObjectName(ss);
// break here
}
the 'pp' command can be used as follows:
(gdb) pp app
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = <Myns::QObjectList> = {"<3 items>"}
[properties] = "<>0 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp app [properties],[children]
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = [
<Myns::QObject> = {""}
<Myns::QObject> = {""}
<Myns::QObject> = {"fusion"}
],<Myns::QObjectList> = {"<3 items>"}
[properties] = [
windowIcon = <Myns::QVariant (QIcon)> = {""}
cursorFlashTime = <Myns::QVariant (int)> = {"1000"}
doubleClickInterval = <Myns::QVariant (int)> = {"400"}
keyboardInputInterval = <Myns::QVariant (int)> = {"400"}
wheelScrollLines = <Myns::QVariant (int)> = {"3"}
globalStrut = <Myns::QVariant (QSize)> = {"(0, 0)"}
startDragTime = <Myns::QVariant (int)> = {"500"}
startDragDistance = <Myns::QVariant (int)> = {"10"}
styleSheet = <Myns::QVariant (QString)> = {""}
autoSipEnabled = <Myns::QVariant (bool)> = {"true"}
],"<10 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp ss
ss =
<Myns::QString> = {"Hello"}
Change-Id: I6e4714a5cfe34c38917500d114ad9a70d20cff39
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-06-13 17:45:34 +02:00
|
|
|
if len(self.resultVarName) > 0:
|
2013-05-15 15:42:55 +02:00
|
|
|
try:
|
2016-09-06 08:54:43 +02:00
|
|
|
value = self.parseAndEvaluate(self.resultVarName)
|
|
|
|
value.name = self.resultVarName
|
|
|
|
value.iname = "return." + self.resultVarName
|
|
|
|
variables.append(value)
|
2013-05-15 15:42:55 +02:00
|
|
|
except:
|
|
|
|
# Don't bother. It's only supplementary information anyway.
|
|
|
|
pass
|
|
|
|
|
2016-09-20 11:52:06 +02:00
|
|
|
self.handleLocals(variables)
|
|
|
|
self.handleWatches(args)
|
2013-05-15 15:42:55 +02:00
|
|
|
|
2013-10-31 10:28:11 +01:00
|
|
|
self.output.append('],typeinfo=[')
|
|
|
|
for name in self.typesToReport.keys():
|
2014-01-24 15:13:20 +01:00
|
|
|
typeobj = self.typesToReport[name]
|
2013-10-31 10:28:11 +01:00
|
|
|
# Happens e.g. for '(anonymous namespace)::InsertDefOperation'
|
2016-09-06 08:54:43 +02:00
|
|
|
#if not typeobj is None:
|
|
|
|
# self.output.append('{name="%s",size="%s"}'
|
|
|
|
# % (self.hexencode(name), typeobj.sizeof))
|
2013-10-31 10:28:11 +01:00
|
|
|
self.output.append(']')
|
|
|
|
self.typesToReport = {}
|
2014-01-24 15:13:20 +01:00
|
|
|
|
2015-02-11 17:51:15 +01:00
|
|
|
if self.forceQtNamespace:
|
2014-07-24 13:22:19 +02:00
|
|
|
self.qtNamepaceToReport = self.qtNamespace()
|
2014-03-07 15:48:13 +01:00
|
|
|
|
2014-02-27 12:54:20 +01:00
|
|
|
if self.qtNamespaceToReport:
|
|
|
|
self.output.append(',qtnamespace="%s"' % self.qtNamespaceToReport)
|
|
|
|
self.qtNamespaceToReport = None
|
2015-03-26 13:03:38 +01:00
|
|
|
|
|
|
|
self.output.append(',partial="%d"' % isPartial)
|
|
|
|
|
2016-07-22 10:20:01 +02:00
|
|
|
self.preping('safePrint')
|
2015-06-25 09:10:25 +02:00
|
|
|
safePrint(''.join(self.output))
|
2016-07-22 10:20:01 +02:00
|
|
|
self.ping('safePrint')
|
|
|
|
safePrint('"%s"' % str(self.dumpStats()))
|
2013-05-23 15:47:28 +02:00
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
def parseAndEvaluate(self, exp):
|
|
|
|
#warn("EVALUATE '%s'" % exp)
|
2013-09-11 21:35:39 +02:00
|
|
|
try:
|
2016-09-06 08:54:43 +02:00
|
|
|
val = gdb.parse_and_eval(exp)
|
|
|
|
except RuntimeError as error:
|
|
|
|
warn("Cannot evaluate '%s': %s" % (exp, error))
|
|
|
|
if self.passExceptions:
|
|
|
|
raise error
|
2013-09-11 21:35:39 +02:00
|
|
|
else:
|
2016-09-06 08:54:43 +02:00
|
|
|
return None
|
|
|
|
return self.fromNativeValue(val)
|
2013-09-11 21:35:39 +02:00
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
def nativeValueAsBytes(self, nativeValue, size):
|
|
|
|
# Assume it's a (backend specific) Value.
|
|
|
|
if nativeValue.address:
|
|
|
|
return self.readRawMemory(nativeValue.address, size)
|
|
|
|
# No address. Possibly the result of an inferior call.
|
|
|
|
# Note: Only a cast to unsigned char[sizeof(origtype)] succeeds
|
|
|
|
# in this situation in gdb.
|
|
|
|
chars = self.lookupNativeType("unsigned char")
|
|
|
|
y = nativeValue.cast(chars.array(0, int(nativeValue.type.sizeof - 1)))
|
|
|
|
buf = bytearray(struct.pack('x' * size))
|
|
|
|
for i in range(size):
|
|
|
|
buf[i] = int(y[i])
|
|
|
|
return bytes(buf)
|
2013-10-16 16:50:26 +02:00
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
def callHelper(self, rettype, value, function, args):
|
2013-09-11 21:35:39 +02:00
|
|
|
# args is a tuple.
|
|
|
|
arg = ""
|
|
|
|
for i in range(len(args)):
|
|
|
|
if i:
|
|
|
|
arg += ','
|
|
|
|
a = args[i]
|
|
|
|
if (':' in a) and not ("'" in a):
|
|
|
|
arg = "'%s'" % a
|
|
|
|
else:
|
|
|
|
arg += a
|
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
#warn("CALL: %s -> %s(%s)" % (value, function, arg))
|
2016-09-06 08:54:43 +02:00
|
|
|
typeName = self.stripClassTag(value.type.name)
|
2014-01-29 00:41:48 +01:00
|
|
|
if typeName.find(":") >= 0:
|
|
|
|
typeName = "'" + typeName + "'"
|
2013-09-11 21:35:39 +02:00
|
|
|
# 'class' is needed, see http://sourceware.org/bugzilla/show_bug.cgi?id=11912
|
2015-10-08 16:19:57 +02:00
|
|
|
#exp = "((class %s*)%s)->%s(%s)" % (typeName, value.address, function, arg)
|
2016-09-06 08:54:43 +02:00
|
|
|
addr = value.address()
|
|
|
|
if not addr:
|
|
|
|
addr = self.pokeValue(value)
|
|
|
|
#warn("PTR: %s -> %s(%s)" % (value, function, addr))
|
|
|
|
exp = "((%s*)0x%x)->%s(%s)" % (typeName, addr, function, arg)
|
2013-09-11 21:35:39 +02:00
|
|
|
#warn("CALL: %s" % exp)
|
2014-01-29 00:41:48 +01:00
|
|
|
result = gdb.parse_and_eval(exp)
|
2013-09-11 21:35:39 +02:00
|
|
|
#warn(" -> %s" % result)
|
2016-09-06 08:54:43 +02:00
|
|
|
if not value.address():
|
|
|
|
gdb.parse_and_eval("free((void*)0x%x)" % addr)
|
|
|
|
return self.fromNativeValue(result)
|
2013-10-16 17:04:34 +02:00
|
|
|
|
|
|
|
def makeExpression(self, value):
|
2016-09-06 08:54:43 +02:00
|
|
|
typename = "::" + self.stripClassTag(value.type.name)
|
2014-12-12 09:00:30 +01:00
|
|
|
#warn(" TYPE: %s" % typename)
|
2016-09-06 08:54:43 +02:00
|
|
|
exp = "(*(%s*)(0x%x))" % (typename, value.address())
|
2013-10-16 17:04:34 +02:00
|
|
|
#warn(" EXP: %s" % exp)
|
|
|
|
return exp
|
|
|
|
|
|
|
|
def makeStdString(init):
|
|
|
|
# Works only for small allocators, but they are usually empty.
|
|
|
|
gdb.execute("set $d=(std::string*)calloc(sizeof(std::string), 2)");
|
|
|
|
gdb.execute("call($d->basic_string(\"" + init +
|
|
|
|
"\",*(std::allocator<char>*)(1+$d)))")
|
2014-02-21 17:34:08 +01:00
|
|
|
value = gdb.parse_and_eval("$d").dereference()
|
2013-10-16 17:04:34 +02:00
|
|
|
#warn(" TYPE: %s" % value.type)
|
|
|
|
#warn(" ADDR: %s" % value.address)
|
|
|
|
#warn(" VALUE: %s" % value)
|
|
|
|
return value
|
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
def nativeTypeTemplateArgument(self, nativeType, position, numeric):
|
|
|
|
#warn("NATIVE TYPE: %s" % dir(nativeType))
|
|
|
|
arg = nativeType.template_argument(position)
|
|
|
|
if numeric:
|
|
|
|
return int(str(arg))
|
|
|
|
return self.fromNativeType(arg)
|
2013-05-15 15:42:55 +02:00
|
|
|
|
2013-05-17 13:53:49 +02:00
|
|
|
def intType(self):
|
2013-10-31 10:28:11 +01:00
|
|
|
self.cachedIntType = self.lookupType('int')
|
|
|
|
self.intType = lambda: self.cachedIntType
|
|
|
|
return self.cachedIntType
|
2013-05-17 13:53:49 +02:00
|
|
|
|
|
|
|
def charType(self):
|
2013-06-13 17:56:35 +02:00
|
|
|
return self.lookupType('char')
|
2013-05-17 13:53:49 +02:00
|
|
|
|
|
|
|
def sizetType(self):
|
2013-06-13 17:56:35 +02:00
|
|
|
return self.lookupType('size_t')
|
2013-05-17 13:53:49 +02:00
|
|
|
|
|
|
|
def charPtrType(self):
|
2013-06-13 17:56:35 +02:00
|
|
|
return self.lookupType('char*')
|
2013-05-17 13:53:49 +02:00
|
|
|
|
|
|
|
def voidPtrType(self):
|
2013-06-13 17:56:35 +02:00
|
|
|
return self.lookupType('void*')
|
2013-05-17 13:53:49 +02:00
|
|
|
|
2013-06-28 14:04:05 +02:00
|
|
|
def ptrSize(self):
|
2016-09-06 08:54:43 +02:00
|
|
|
self.cachedPtrSize = self.lookupNativeType('void*').sizeof
|
2013-10-31 13:32:12 +01:00
|
|
|
self.ptrSize = lambda: self.cachedPtrSize
|
|
|
|
return self.cachedPtrSize
|
2013-06-28 14:04:05 +02:00
|
|
|
|
2014-01-29 00:41:48 +01:00
|
|
|
def pokeValue(self, value):
|
2016-09-06 08:54:43 +02:00
|
|
|
# Allocates inferior memory and copies the contents of value.
|
|
|
|
# Returns a pointer to the copy.
|
2014-01-29 00:41:48 +01:00
|
|
|
# Avoid malloc symbol clash with QVector
|
2016-09-06 08:54:43 +02:00
|
|
|
size = value.type.size()
|
|
|
|
data = value.data()
|
|
|
|
h = self.hexencode(data)
|
|
|
|
#warn("DATA: %s" % h
|
|
|
|
string = ''.join("\\x" + h[2*i:2*i+2] for i in range(size))
|
|
|
|
exp = '(%s*)memcpy(calloc(%d, 1), "%s", %d)' % (value.type.name, size, string, size)
|
2014-01-29 00:41:48 +01:00
|
|
|
#warn("EXP: %s" % exp)
|
2016-09-06 08:54:43 +02:00
|
|
|
res = gdb.parse_and_eval(exp)
|
|
|
|
#warn("RES: %s" % res)
|
|
|
|
return toInteger(res)
|
2013-06-28 14:04:05 +02:00
|
|
|
|
2014-12-12 09:00:30 +01:00
|
|
|
def setValue(self, address, typename, value):
|
|
|
|
cmd = "set {%s}%s=%s" % (typename, address, value)
|
2013-11-20 18:55:09 +01:00
|
|
|
gdb.execute(cmd)
|
|
|
|
|
2014-12-12 09:00:30 +01:00
|
|
|
def setValues(self, address, typename, values):
|
2013-11-20 18:55:09 +01:00
|
|
|
cmd = "set {%s[%s]}%s={%s}" \
|
2014-12-12 09:00:30 +01:00
|
|
|
% (typename, len(values), address, ','.join(map(str, values)))
|
2013-11-20 18:55:09 +01:00
|
|
|
gdb.execute(cmd)
|
|
|
|
|
2013-10-30 11:40:53 +01:00
|
|
|
def selectedInferior(self):
|
|
|
|
try:
|
2013-10-30 12:38:29 +01:00
|
|
|
# gdb.Inferior is new in gdb 7.2
|
2013-10-30 15:07:54 +01:00
|
|
|
self.cachedInferior = gdb.selected_inferior()
|
2013-10-30 11:40:53 +01:00
|
|
|
except:
|
|
|
|
# Pre gdb 7.4. Right now we don't have more than one inferior anyway.
|
2013-10-30 15:07:54 +01:00
|
|
|
self.cachedInferior = gdb.inferiors()[0]
|
|
|
|
|
|
|
|
# Memoize result.
|
|
|
|
self.selectedInferior = lambda: self.cachedInferior
|
|
|
|
return self.cachedInferior
|
2013-10-30 11:40:53 +01:00
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
def readRawMemory(self, address, size):
|
2016-09-06 08:54:43 +02:00
|
|
|
return self.selectedInferior().read_memory(address, size)
|
2013-07-09 14:19:45 -07:00
|
|
|
|
2014-12-12 09:00:30 +01:00
|
|
|
def findStaticMetaObject(self, typename):
|
2016-09-06 08:54:43 +02:00
|
|
|
symbolName = typename + "::staticMetaObject"
|
|
|
|
symbol = gdb.lookup_global_symbol(symbolName, gdb.SYMBOL_VAR_DOMAIN)
|
|
|
|
if not symbol:
|
|
|
|
return 0
|
2014-02-28 12:05:48 +01:00
|
|
|
try:
|
2016-09-06 08:54:43 +02:00
|
|
|
# Older GDB ~7.4 don't have gdb.Symbol.value()
|
|
|
|
return toInteger(symbol.value().address)
|
2014-02-28 12:05:48 +01:00
|
|
|
except:
|
|
|
|
pass
|
2016-09-06 08:54:43 +02:00
|
|
|
|
|
|
|
address = gdb.parse_and_eval("&'%s'" % symbolName)
|
|
|
|
return toInteger(address)
|
2014-02-25 15:52:22 +01:00
|
|
|
|
2013-05-15 15:42:55 +02:00
|
|
|
def put(self, value):
|
|
|
|
self.output.append(value)
|
|
|
|
|
|
|
|
def childRange(self):
|
|
|
|
if self.currentMaxNumChild is None:
|
2013-09-11 21:35:39 +02:00
|
|
|
return xrange(0, toInteger(self.currentNumChild))
|
|
|
|
return xrange(min(toInteger(self.currentMaxNumChild), toInteger(self.currentNumChild)))
|
2013-05-15 15:42:55 +02:00
|
|
|
|
2013-11-11 09:54:54 +01:00
|
|
|
def isArmArchitecture(self):
|
|
|
|
return 'arm' in gdb.TARGET_CONFIG.lower()
|
|
|
|
|
|
|
|
def isQnxTarget(self):
|
|
|
|
return 'qnx' in gdb.TARGET_CONFIG.lower()
|
|
|
|
|
2014-04-01 18:11:57 +02:00
|
|
|
def isWindowsTarget(self):
|
|
|
|
# We get i686-w64-mingw32
|
|
|
|
return 'mingw' in gdb.TARGET_CONFIG.lower()
|
|
|
|
|
2014-03-07 18:46:44 +01:00
|
|
|
def qtVersionString(self):
|
|
|
|
try:
|
|
|
|
return str(gdb.lookup_symbol("qVersion")[0].value()())
|
|
|
|
except:
|
|
|
|
pass
|
2013-10-30 15:07:54 +01:00
|
|
|
try:
|
2014-01-30 12:40:24 +01:00
|
|
|
ns = self.qtNamespace()
|
2014-03-07 18:46:44 +01:00
|
|
|
return str(gdb.parse_and_eval("((const char*(*)())'%sqVersion')()" % ns))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return None
|
|
|
|
|
|
|
|
def qtVersion(self):
|
2015-08-13 12:12:54 +02:00
|
|
|
try:
|
|
|
|
# Only available with Qt 5.3+
|
2016-06-03 09:36:34 +02:00
|
|
|
qtversion = int(str(gdb.parse_and_eval("((void**)&qtHookData)[2]")), 16)
|
2015-08-13 12:12:54 +02:00
|
|
|
self.qtVersion = lambda: qtversion
|
|
|
|
return qtversion
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2014-03-07 18:46:44 +01:00
|
|
|
try:
|
|
|
|
version = self.qtVersionString()
|
2013-10-31 10:28:11 +01:00
|
|
|
(major, minor, patch) = version[version.find('"')+1:version.rfind('"')].split('.')
|
2014-03-07 18:46:44 +01:00
|
|
|
qtversion = 0x10000 * int(major) + 0x100 * int(minor) + int(patch)
|
|
|
|
self.qtVersion = lambda: qtversion
|
|
|
|
return qtversion
|
2013-10-30 15:07:54 +01:00
|
|
|
except:
|
2014-03-07 15:48:13 +01:00
|
|
|
# Use fallback until we have a better answer.
|
|
|
|
return self.fallbackQtVersion
|
2013-10-30 15:07:54 +01:00
|
|
|
|
2013-11-11 09:54:54 +01:00
|
|
|
def isQt3Support(self):
|
|
|
|
if self.qtVersion() >= 0x050000:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
# This will fail on Qt 4 without Qt 3 support
|
|
|
|
gdb.execute("ptype QChar::null", to_string=True)
|
|
|
|
self.cachedIsQt3Suport = True
|
|
|
|
except:
|
|
|
|
self.cachedIsQt3Suport = False
|
|
|
|
|
|
|
|
# Memoize good results.
|
|
|
|
self.isQt3Support = lambda: self.cachedIsQt3Suport
|
|
|
|
return self.cachedIsQt3Suport
|
|
|
|
|
2014-01-20 15:03:27 +01:00
|
|
|
def readCString(self, base):
|
|
|
|
inferior = self.selectedInferior()
|
|
|
|
mem = ""
|
|
|
|
while True:
|
|
|
|
char = inferior.read_memory(base, 1)[0]
|
|
|
|
if not char:
|
|
|
|
break
|
|
|
|
mem += char
|
|
|
|
base += 1
|
|
|
|
return mem
|
|
|
|
|
2015-11-02 16:01:43 +01:00
|
|
|
def createSpecialBreakpoints(self, args):
|
|
|
|
self.specialBreakpoints = []
|
|
|
|
def newSpecial(spec):
|
|
|
|
class SpecialBreakpoint(gdb.Breakpoint):
|
|
|
|
def __init__(self, spec):
|
|
|
|
super(SpecialBreakpoint, self).\
|
|
|
|
__init__(spec, gdb.BP_BREAKPOINT, internal=True)
|
|
|
|
self.spec = spec
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
print("Breakpoint on '%s' hit." % self.spec)
|
|
|
|
return True
|
|
|
|
return SpecialBreakpoint(spec)
|
|
|
|
|
|
|
|
# FIXME: ns is accessed too early. gdb.Breakpoint() has no
|
|
|
|
# 'rbreak' replacement, and breakpoints created with
|
|
|
|
# 'gdb.execute("rbreak...") cannot be made invisible.
|
|
|
|
# So let's ignore the existing of namespaced builds for this
|
|
|
|
# fringe feature here for now.
|
|
|
|
ns = self.qtNamespace()
|
|
|
|
if args.get('breakonabort', 0):
|
|
|
|
self.specialBreakpoints.append(newSpecial("abort"))
|
|
|
|
|
|
|
|
if args.get('breakonwarning', 0):
|
|
|
|
self.specialBreakpoints.append(newSpecial(ns + "qWarning"))
|
|
|
|
self.specialBreakpoints.append(newSpecial(ns + "QMessageLogger::warning"))
|
|
|
|
|
|
|
|
if args.get('breakonfatal', 0):
|
|
|
|
self.specialBreakpoints.append(newSpecial(ns + "qFatal"))
|
|
|
|
self.specialBreakpoints.append(newSpecial(ns + "QMessageLogger::fatal"))
|
|
|
|
|
2014-03-11 13:24:19 +01:00
|
|
|
#def threadname(self, maximalStackDepth, objectPrivateType):
|
|
|
|
# e = gdb.selected_frame()
|
|
|
|
# out = ""
|
|
|
|
# ns = self.qtNamespace()
|
|
|
|
# while True:
|
|
|
|
# maximalStackDepth -= 1
|
|
|
|
# if maximalStackDepth < 0:
|
|
|
|
# break
|
|
|
|
# e = e.older()
|
|
|
|
# if e == None or e.name() == None:
|
|
|
|
# break
|
|
|
|
# if e.name() == ns + "QThreadPrivate::start" \
|
|
|
|
# or e.name() == "_ZN14QThreadPrivate5startEPv@4":
|
|
|
|
# try:
|
|
|
|
# thrptr = e.read_var("thr").dereference()
|
|
|
|
# d_ptr = thrptr["d_ptr"]["d"].cast(objectPrivateType).dereference()
|
|
|
|
# try:
|
|
|
|
# objectName = d_ptr["objectName"]
|
|
|
|
# except: # Qt 5
|
|
|
|
# p = d_ptr["extraData"]
|
|
|
|
# if not self.isNull(p):
|
|
|
|
# objectName = p.dereference()["objectName"]
|
|
|
|
# if not objectName is None:
|
2016-09-06 08:54:43 +02:00
|
|
|
# (data, size, alloc) = self.stringData(objectName)
|
2014-03-11 13:24:19 +01:00
|
|
|
# if size > 0:
|
|
|
|
# s = self.readMemory(data, 2 * size)
|
|
|
|
#
|
|
|
|
# thread = gdb.selected_thread()
|
2015-12-11 13:28:21 +01:00
|
|
|
# inner = '{valueencoded="uf16:2:0",id="'
|
2014-03-11 13:24:19 +01:00
|
|
|
# inner += str(thread.num) + '",value="'
|
|
|
|
# inner += s
|
|
|
|
# #inner += self.encodeString(objectName)
|
|
|
|
# inner += '"},'
|
|
|
|
#
|
|
|
|
# out += inner
|
|
|
|
# except:
|
|
|
|
# pass
|
|
|
|
# return out
|
2013-10-30 12:38:29 +01:00
|
|
|
|
|
|
|
def threadnames(self, maximalStackDepth):
|
2013-11-20 00:34:58 +01:00
|
|
|
# FIXME: This needs a proper implementation for MinGW, and only there.
|
2014-03-11 13:24:19 +01:00
|
|
|
# Linux, Mac and QNX mirror the objectName() to the underlying threads,
|
2013-11-20 00:34:58 +01:00
|
|
|
# so we get the names already as part of the -thread-info output.
|
|
|
|
return '[]'
|
2014-03-11 13:24:19 +01:00
|
|
|
#out = '['
|
|
|
|
#oldthread = gdb.selected_thread()
|
|
|
|
#if oldthread:
|
|
|
|
# try:
|
|
|
|
# objectPrivateType = gdb.lookup_type(ns + "QObjectPrivate").pointer()
|
|
|
|
# inferior = self.selectedInferior()
|
|
|
|
# for thread in inferior.threads():
|
|
|
|
# thread.switch()
|
|
|
|
# out += self.threadname(maximalStackDepth, objectPrivateType)
|
|
|
|
# except:
|
|
|
|
# pass
|
|
|
|
# oldthread.switch()
|
|
|
|
#return out + ']'
|
2013-10-30 12:38:29 +01:00
|
|
|
|
|
|
|
|
2013-10-30 15:07:54 +01:00
|
|
|
def importPlainDumper(self, printer):
|
|
|
|
name = printer.name.replace("::", "__")
|
|
|
|
self.qqDumpers[name] = PlainDumper(printer)
|
|
|
|
self.qqFormats[name] = ""
|
|
|
|
|
|
|
|
def importPlainDumpers(self):
|
|
|
|
for obj in gdb.objfiles():
|
|
|
|
for printers in obj.pretty_printers + gdb.pretty_printers:
|
|
|
|
for printer in printers.subprinters:
|
|
|
|
self.importPlainDumper(printer)
|
|
|
|
|
|
|
|
def qtNamespace(self):
|
2014-03-27 13:53:33 +01:00
|
|
|
if not self.currentQtNamespaceGuess is None:
|
|
|
|
return self.currentQtNamespaceGuess
|
|
|
|
|
2014-03-07 15:48:13 +01:00
|
|
|
# This only works when called from a valid frame.
|
|
|
|
try:
|
|
|
|
cand = "QArrayData::shared_null"
|
|
|
|
symbol = gdb.lookup_symbol(cand)[0]
|
|
|
|
if symbol:
|
|
|
|
ns = symbol.name[:-len(cand)]
|
|
|
|
self.qtNamespaceToReport = ns
|
|
|
|
self.qtNamespace = lambda: ns
|
|
|
|
return ns
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2013-10-30 15:07:54 +01:00
|
|
|
try:
|
2014-03-07 15:48:13 +01:00
|
|
|
# This is Qt, but not 5.x.
|
|
|
|
cand = "QByteArray::shared_null"
|
|
|
|
symbol = gdb.lookup_symbol(cand)[0]
|
|
|
|
if symbol:
|
|
|
|
ns = symbol.name[:-len(cand)]
|
|
|
|
self.qtNamespaceToReport = ns
|
|
|
|
self.qtNamespace = lambda: ns
|
|
|
|
self.fallbackQtVersion = 0x40800
|
|
|
|
return ns
|
2013-10-30 15:07:54 +01:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2014-07-24 13:22:19 +02:00
|
|
|
try:
|
2014-10-10 12:05:47 +02:00
|
|
|
# Last fall backs.
|
2014-07-24 13:22:19 +02:00
|
|
|
s = gdb.execute("ptype QByteArray", to_string=True)
|
2014-10-10 12:05:47 +02:00
|
|
|
if s.find("QMemArray") >= 0:
|
|
|
|
# Qt 3.
|
|
|
|
self.qtNamespaceToReport = ""
|
|
|
|
self.qtNamespace = lambda: ""
|
|
|
|
self.qtVersion = lambda: 0x30308
|
|
|
|
self.fallbackQtVersion = 0x30308
|
|
|
|
return ""
|
|
|
|
# Seemingly needed with Debian's GDB 7.4.1
|
2016-06-03 09:36:34 +02:00
|
|
|
pos1 = s.find("class")
|
|
|
|
pos2 = s.find("QByteArray")
|
|
|
|
if pos1 > -1 and pos2 > -1:
|
|
|
|
ns = s[s.find("class") + 6:s.find("QByteArray")]
|
2014-07-24 13:22:19 +02:00
|
|
|
self.qtNamespaceToReport = ns
|
|
|
|
self.qtNamespace = lambda: ns
|
|
|
|
return ns
|
|
|
|
except:
|
|
|
|
pass
|
2014-03-27 13:53:33 +01:00
|
|
|
self.currentQtNamespaceGuess = ""
|
2014-03-07 15:48:13 +01:00
|
|
|
return ""
|
2013-10-30 15:07:54 +01:00
|
|
|
|
2015-02-10 13:40:26 +01:00
|
|
|
def assignValue(self, args):
|
|
|
|
typeName = self.hexdecode(args['type'])
|
|
|
|
expr = self.hexdecode(args['expr'])
|
|
|
|
value = self.hexdecode(args['value'])
|
|
|
|
simpleType = int(args['simpleType'])
|
2013-10-30 15:07:54 +01:00
|
|
|
ns = self.qtNamespace()
|
2013-11-20 18:55:09 +01:00
|
|
|
if typeName.startswith(ns):
|
|
|
|
typeName = typeName[len(ns):]
|
|
|
|
typeName = typeName.replace("::", "__")
|
|
|
|
pos = typeName.find('<')
|
2013-10-30 15:07:54 +01:00
|
|
|
if pos != -1:
|
2013-11-20 18:55:09 +01:00
|
|
|
typeName = typeName[0:pos]
|
2015-02-10 13:40:26 +01:00
|
|
|
if typeName in self.qqEditable and not simpleType:
|
|
|
|
#self.qqEditable[typeName](self, expr, value)
|
|
|
|
expr = gdb.parse_and_eval(expr)
|
|
|
|
self.qqEditable[typeName](self, expr, value)
|
2013-10-30 15:07:54 +01:00
|
|
|
else:
|
2015-02-10 13:40:26 +01:00
|
|
|
cmd = "set variable (%s)=%s" % (expr, value)
|
2013-11-20 18:55:09 +01:00
|
|
|
gdb.execute(cmd)
|
2013-10-30 15:07:54 +01:00
|
|
|
|
2014-12-12 09:00:30 +01:00
|
|
|
def hasVTable(self, typeobj):
|
|
|
|
fields = typeobj.fields()
|
2013-10-31 10:28:11 +01:00
|
|
|
if len(fields) == 0:
|
|
|
|
return False
|
2016-09-06 08:54:43 +02:00
|
|
|
if fields[0].isBaseClass:
|
2013-10-31 10:28:11 +01:00
|
|
|
return hasVTable(fields[0].type)
|
|
|
|
return str(fields[0].type) == "int (**)(void)"
|
|
|
|
|
|
|
|
def dynamicTypeName(self, value):
|
|
|
|
if self.hasVTable(value.type):
|
2014-02-21 17:34:08 +01:00
|
|
|
#vtbl = str(gdb.parse_and_eval("{int(*)(int)}%s" % int(value.address)))
|
2013-10-31 10:28:11 +01:00
|
|
|
try:
|
|
|
|
# Fails on 7.1 due to the missing to_string.
|
|
|
|
vtbl = gdb.execute("info symbol {int*}%s" % int(value.address),
|
|
|
|
to_string = True)
|
|
|
|
pos1 = vtbl.find("vtable ")
|
|
|
|
if pos1 != -1:
|
|
|
|
pos1 += 11
|
|
|
|
pos2 = vtbl.find(" +", pos1)
|
|
|
|
if pos2 != -1:
|
|
|
|
return vtbl[pos1 : pos2]
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return str(value.type)
|
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
def nativeValueDownCast(self, nativeValue):
|
2013-10-31 10:28:11 +01:00
|
|
|
try:
|
2016-09-06 08:54:43 +02:00
|
|
|
return self.fromNativeValue(nativeValue.cast(nativeValue.dynamic_type))
|
2013-10-31 10:28:11 +01:00
|
|
|
except:
|
2016-09-06 08:54:43 +02:00
|
|
|
return self.fromNativeValue(nativeValue)
|
2013-10-31 10:28:11 +01:00
|
|
|
|
|
|
|
def expensiveDowncast(self, value):
|
|
|
|
try:
|
|
|
|
return value.cast(value.dynamic_type)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
return value.cast(self.lookupType(self.dynamicTypeName(value)))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return value
|
|
|
|
|
2014-01-10 20:01:35 +01:00
|
|
|
def enumExpression(self, enumType, enumValue):
|
|
|
|
return self.qtNamespace() + "Qt::" + enumValue
|
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
def lookupType(self, typeName):
|
|
|
|
return self.fromNativeType(self.lookupNativeType(typeName))
|
|
|
|
|
|
|
|
def lookupNativeType(self, typeName):
|
|
|
|
nativeType = self.lookupNativeTypeHelper(typeName)
|
|
|
|
if not nativeType is None:
|
|
|
|
self.check(isinstance(nativeType, gdb.Type))
|
|
|
|
return nativeType
|
|
|
|
|
|
|
|
def lookupNativeTypeHelper(self, typeName):
|
|
|
|
typeobj = self.typeCache.get(typeName)
|
|
|
|
#warn("LOOKUP 1: %s -> %s" % (typeName, typeobj))
|
2014-12-12 09:00:30 +01:00
|
|
|
if not typeobj is None:
|
|
|
|
return typeobj
|
2013-10-31 10:28:11 +01:00
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
if typeName == "void":
|
|
|
|
typeobj = gdb.lookup_type(typeName)
|
|
|
|
self.typeCache[typeName] = typeobj
|
|
|
|
self.typesToReport[typeName] = typeobj
|
2014-12-12 09:00:30 +01:00
|
|
|
return typeobj
|
2013-10-31 10:28:11 +01:00
|
|
|
|
|
|
|
#try:
|
2016-09-06 08:54:43 +02:00
|
|
|
# typeobj = gdb.parse_and_eval("{%s}&main" % typeName).typeobj
|
2014-12-12 09:00:30 +01:00
|
|
|
# if not typeobj is None:
|
2016-09-06 08:54:43 +02:00
|
|
|
# self.typeCache[typeName] = typeobj
|
|
|
|
# self.typesToReport[typeName] = typeobj
|
2014-12-12 09:00:30 +01:00
|
|
|
# return typeobj
|
2013-10-31 10:28:11 +01:00
|
|
|
#except:
|
|
|
|
# pass
|
|
|
|
|
|
|
|
# See http://sourceware.org/bugzilla/show_bug.cgi?id=13269
|
|
|
|
# gcc produces "{anonymous}", gdb "(anonymous namespace)"
|
|
|
|
# "<unnamed>" has been seen too. The only thing gdb
|
|
|
|
# understands when reading things back is "(anonymous namespace)"
|
2016-09-06 08:54:43 +02:00
|
|
|
if typeName.find("{anonymous}") != -1:
|
|
|
|
ts = typeName
|
2013-10-31 10:28:11 +01:00
|
|
|
ts = ts.replace("{anonymous}", "(anonymous namespace)")
|
2016-09-06 08:54:43 +02:00
|
|
|
typeobj = self.lookupNativeType(ts)
|
2014-12-12 09:00:30 +01:00
|
|
|
if not typeobj is None:
|
2016-09-06 08:54:43 +02:00
|
|
|
self.typeCache[typeName] = typeobj
|
|
|
|
self.typesToReport[typeName] = typeobj
|
2014-12-12 09:00:30 +01:00
|
|
|
return typeobj
|
2013-10-31 10:28:11 +01:00
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
#warn(" RESULT FOR 7.2: '%s': %s" % (typeName, typeobj))
|
2013-10-31 10:28:11 +01:00
|
|
|
|
|
|
|
# This part should only trigger for
|
|
|
|
# gdb 7.1 for types with namespace separators.
|
|
|
|
# And anonymous namespaces.
|
|
|
|
|
2016-09-06 08:54:43 +02:00
|
|
|
ts = typeName
|
2013-10-31 10:28:11 +01:00
|
|
|
while True:
|
|
|
|
#warn("TS: '%s'" % ts)
|
|
|
|
if ts.startswith("class "):
|
|
|
|
ts = ts[6:]
|
|
|
|
elif ts.startswith("struct "):
|
|
|
|
ts = ts[7:]
|
|
|
|
elif ts.startswith("const "):
|
|
|
|
ts = ts[6:]
|
|
|
|
elif ts.startswith("volatile "):
|
|
|
|
ts = ts[9:]
|
|
|
|
elif ts.startswith("enum "):
|
|
|
|
ts = ts[5:]
|
|
|
|
elif ts.endswith(" const"):
|
|
|
|
ts = ts[:-6]
|
|
|
|
elif ts.endswith(" volatile"):
|
|
|
|
ts = ts[:-9]
|
|
|
|
elif ts.endswith("*const"):
|
|
|
|
ts = ts[:-5]
|
|
|
|
elif ts.endswith("*volatile"):
|
|
|
|
ts = ts[:-8]
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
|
|
|
|
if ts.endswith('*'):
|
2016-09-06 08:54:43 +02:00
|
|
|
typeobj = self.lookupNativeType(ts[0:-1])
|
2014-12-12 09:00:30 +01:00
|
|
|
if not typeobj is None:
|
|
|
|
typeobj = typeobj.pointer()
|
2016-09-06 08:54:43 +02:00
|
|
|
self.typeCache[typeName] = typeobj
|
|
|
|
self.typesToReport[typeName] = typeobj
|
2014-12-12 09:00:30 +01:00
|
|
|
return typeobj
|
2013-10-31 10:28:11 +01:00
|
|
|
|
|
|
|
try:
|
2016-09-06 08:54:43 +02:00
|
|
|
#warn("LOOKING UP 1 '%s'" % ts)
|
2014-12-12 09:00:30 +01:00
|
|
|
typeobj = gdb.lookup_type(ts)
|
2013-10-31 10:28:11 +01:00
|
|
|
except RuntimeError as error:
|
2016-09-06 08:54:43 +02:00
|
|
|
#warn("LOOKING UP 2 '%s' ERROR %s" % (ts, error))
|
2013-10-31 10:28:11 +01:00
|
|
|
# See http://sourceware.org/bugzilla/show_bug.cgi?id=11912
|
|
|
|
exp = "(class '%s'*)0" % ts
|
|
|
|
try:
|
2016-09-06 08:54:43 +02:00
|
|
|
typeobj = self.parse_and_eval(exp).type.target()
|
|
|
|
#warn("LOOKING UP 3 '%s'" % typeobj)
|
2013-10-31 10:28:11 +01:00
|
|
|
except:
|
|
|
|
# Can throw "RuntimeError: No type named class Foo."
|
|
|
|
pass
|
|
|
|
except:
|
|
|
|
#warn("LOOKING UP '%s' FAILED" % ts)
|
|
|
|
pass
|
|
|
|
|
2014-12-12 09:00:30 +01:00
|
|
|
if not typeobj is None:
|
2016-09-06 08:54:43 +02:00
|
|
|
#warn("CACHING: %s" % typeobj)
|
|
|
|
self.typeCache[typeName] = typeobj
|
|
|
|
self.typesToReport[typeName] = typeobj
|
2013-10-31 10:28:11 +01:00
|
|
|
|
|
|
|
# This could still be None as gdb.lookup_type("char[3]") generates
|
|
|
|
# "RuntimeError: No type named char[3]"
|
2016-09-06 08:54:43 +02:00
|
|
|
#self.typeCache[typeName] = typeobj
|
|
|
|
#self.typesToReport[typeName] = typeobj
|
2014-12-12 09:00:30 +01:00
|
|
|
return typeobj
|
2013-10-31 10:28:11 +01:00
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
def doContinue(self):
|
|
|
|
gdb.execute('continue')
|
|
|
|
|
2015-10-27 16:13:04 +01:00
|
|
|
def fetchStack(self, args):
|
2015-03-01 11:49:19 +02:00
|
|
|
def fromNativePath(str):
|
2015-05-09 14:49:19 +01:00
|
|
|
return str.replace('\\', '/')
|
2015-03-01 11:49:19 +02:00
|
|
|
|
2015-02-11 16:05:55 +01:00
|
|
|
limit = int(args['limit'])
|
|
|
|
if limit <= 0:
|
|
|
|
limit = 10000
|
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
self.prepare(args)
|
2014-12-05 18:45:54 +01:00
|
|
|
self.output = []
|
|
|
|
|
|
|
|
frame = gdb.newest_frame()
|
|
|
|
i = 0
|
2015-01-22 12:05:00 +01:00
|
|
|
self.currentCallContext = None
|
2015-02-11 16:05:55 +01:00
|
|
|
while i < limit and frame:
|
2014-12-05 18:45:54 +01:00
|
|
|
with OutputSafer(self):
|
|
|
|
name = frame.name()
|
|
|
|
functionName = "??" if name is None else name
|
|
|
|
fileName = ""
|
|
|
|
objfile = ""
|
2015-10-08 16:19:57 +02:00
|
|
|
symtab = ""
|
2014-12-05 18:45:54 +01:00
|
|
|
pc = frame.pc()
|
|
|
|
sal = frame.find_sal()
|
|
|
|
line = -1
|
|
|
|
if sal:
|
|
|
|
line = sal.line
|
|
|
|
symtab = sal.symtab
|
|
|
|
if not symtab is None:
|
2015-03-01 11:49:19 +02:00
|
|
|
objfile = fromNativePath(symtab.objfile.filename)
|
2015-11-20 09:29:51 -06:00
|
|
|
fullname = symtab.fullname()
|
|
|
|
if fullname is None:
|
|
|
|
fileName = ""
|
|
|
|
else:
|
|
|
|
fileName = fromNativePath(fullname)
|
2015-10-08 16:19:57 +02:00
|
|
|
|
2015-10-14 13:26:22 +02:00
|
|
|
if self.nativeMixed and functionName == "qt_qmlDebugMessageAvailable":
|
2015-10-08 16:19:57 +02:00
|
|
|
interpreterStack = self.extractInterpreterStack()
|
|
|
|
#print("EXTRACTED INTEPRETER STACK: %s" % interpreterStack)
|
|
|
|
for interpreterFrame in interpreterStack.get('frames', []):
|
|
|
|
function = interpreterFrame.get('function', '')
|
|
|
|
fileName = interpreterFrame.get('file', '')
|
|
|
|
language = interpreterFrame.get('language', '')
|
|
|
|
lineNumber = interpreterFrame.get('line', 0)
|
|
|
|
context = interpreterFrame.get('context', 0)
|
|
|
|
|
|
|
|
self.put(('frame={function="%s",file="%s",'
|
|
|
|
'line="%s",language="%s",context="%s"}')
|
|
|
|
% (function, fileName, lineNumber, language, context))
|
|
|
|
|
|
|
|
if False and self.isInternalInterpreterFrame(functionName):
|
2015-01-22 12:05:00 +01:00
|
|
|
frame = frame.older()
|
2015-10-08 16:19:57 +02:00
|
|
|
self.put(('frame={address="0x%x",function="%s",'
|
|
|
|
'file="%s",line="%s",'
|
|
|
|
'module="%s",language="c",usable="0"}') %
|
|
|
|
(pc, functionName, fileName, line, objfile))
|
2015-01-22 12:05:00 +01:00
|
|
|
i += 1
|
|
|
|
frame = frame.older()
|
|
|
|
continue
|
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
self.put(('frame={level="%s",address="0x%x",function="%s",'
|
|
|
|
'file="%s",line="%s",module="%s",language="c"}') %
|
|
|
|
(i, pc, functionName, fileName, line, objfile))
|
2014-12-05 18:45:54 +01:00
|
|
|
|
|
|
|
frame = frame.older()
|
|
|
|
i += 1
|
2015-10-08 16:19:57 +02:00
|
|
|
safePrint('frames=[' + ','.join(self.output) + ']')
|
2014-12-05 18:45:54 +01:00
|
|
|
|
2015-02-04 16:27:46 +01:00
|
|
|
def createResolvePendingBreakpointsHookBreakpoint(self, args):
|
2015-02-04 10:48:33 +01:00
|
|
|
class Resolver(gdb.Breakpoint):
|
2015-02-04 16:27:46 +01:00
|
|
|
def __init__(self, dumper, args):
|
2015-02-04 10:48:33 +01:00
|
|
|
self.dumper = dumper
|
2015-02-04 16:27:46 +01:00
|
|
|
self.args = args
|
2015-10-08 16:19:57 +02:00
|
|
|
spec = "qt_qmlDebugConnectorOpen"
|
2015-02-04 10:48:33 +01:00
|
|
|
super(Resolver, self).\
|
|
|
|
__init__(spec, gdb.BP_BREAKPOINT, internal=True, temporary=False)
|
|
|
|
|
|
|
|
def stop(self):
|
2015-10-14 13:26:22 +02:00
|
|
|
self.dumper.resolvePendingInterpreterBreakpoint(args)
|
2015-02-04 10:48:33 +01:00
|
|
|
self.enabled = False
|
|
|
|
return False
|
|
|
|
|
2015-10-09 15:00:20 +02:00
|
|
|
self.interpreterBreakpointResolvers.append(Resolver(self, args))
|
2015-02-04 10:48:33 +01:00
|
|
|
|
2015-02-11 12:20:21 +01:00
|
|
|
def exitGdb(self, _):
|
|
|
|
gdb.execute("quit")
|
2015-02-04 10:48:33 +01:00
|
|
|
|
2015-03-18 16:48:57 +01:00
|
|
|
def loadDumpers(self, args):
|
2015-09-09 16:34:09 +02:00
|
|
|
print(self.setupDumpers())
|
2015-03-18 16:48:57 +01:00
|
|
|
|
2015-02-11 17:51:15 +01:00
|
|
|
def profile1(self, args):
|
|
|
|
"""Internal profiling"""
|
|
|
|
import tempfile
|
|
|
|
import cProfile
|
|
|
|
tempDir = tempfile.gettempdir() + "/bbprof"
|
2015-10-08 16:19:57 +02:00
|
|
|
cProfile.run('theDumper.fetchVariables(%s)' % args, tempDir)
|
2015-02-11 17:51:15 +01:00
|
|
|
import pstats
|
|
|
|
pstats.Stats(tempDir).sort_stats('time').print_stats()
|
|
|
|
|
|
|
|
def profile2(self, args):
|
|
|
|
import timeit
|
2015-10-08 16:19:57 +02:00
|
|
|
print(timeit.repeat('theDumper.fetchVariables(%s)' % args,
|
2015-02-11 17:51:15 +01:00
|
|
|
'from __main__ import theDumper', number=10))
|
|
|
|
|
|
|
|
|
2015-02-04 10:48:33 +01:00
|
|
|
|
Debugger: Make dumpers somewhat work in command line GDB
With
python sys.path.insert(1, '/data/dev/creator/share/qtcreator/debugger/')
python from gdbbridge import *
in .gdbinit there's a new "GDB command", called "pp".
With code like
int main(int argc, char *argv[])
{
QString ss = "Hello";
QApplication app(argc, argv);
app.setObjectName(ss);
// break here
}
the 'pp' command can be used as follows:
(gdb) pp app
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = <Myns::QObjectList> = {"<3 items>"}
[properties] = "<>0 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp app [properties],[children]
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = [
<Myns::QObject> = {""}
<Myns::QObject> = {""}
<Myns::QObject> = {"fusion"}
],<Myns::QObjectList> = {"<3 items>"}
[properties] = [
windowIcon = <Myns::QVariant (QIcon)> = {""}
cursorFlashTime = <Myns::QVariant (int)> = {"1000"}
doubleClickInterval = <Myns::QVariant (int)> = {"400"}
keyboardInputInterval = <Myns::QVariant (int)> = {"400"}
wheelScrollLines = <Myns::QVariant (int)> = {"3"}
globalStrut = <Myns::QVariant (QSize)> = {"(0, 0)"}
startDragTime = <Myns::QVariant (int)> = {"500"}
startDragDistance = <Myns::QVariant (int)> = {"10"}
styleSheet = <Myns::QVariant (QString)> = {""}
autoSipEnabled = <Myns::QVariant (bool)> = {"true"}
],"<10 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp ss
ss =
<Myns::QString> = {"Hello"}
Change-Id: I6e4714a5cfe34c38917500d114ad9a70d20cff39
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-06-13 17:45:34 +02:00
|
|
|
class CliDumper(Dumper):
|
|
|
|
def __init__(self):
|
|
|
|
Dumper.__init__(self)
|
|
|
|
self.childrenPrefix = '['
|
|
|
|
self.chidrenSuffix = '] '
|
|
|
|
self.indent = 0
|
|
|
|
self.isCli = True
|
|
|
|
|
2015-04-15 12:38:11 +02:00
|
|
|
def reportDumpers(self, msg):
|
|
|
|
return msg
|
Debugger: Make dumpers somewhat work in command line GDB
With
python sys.path.insert(1, '/data/dev/creator/share/qtcreator/debugger/')
python from gdbbridge import *
in .gdbinit there's a new "GDB command", called "pp".
With code like
int main(int argc, char *argv[])
{
QString ss = "Hello";
QApplication app(argc, argv);
app.setObjectName(ss);
// break here
}
the 'pp' command can be used as follows:
(gdb) pp app
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = <Myns::QObjectList> = {"<3 items>"}
[properties] = "<>0 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp app [properties],[children]
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = [
<Myns::QObject> = {""}
<Myns::QObject> = {""}
<Myns::QObject> = {"fusion"}
],<Myns::QObjectList> = {"<3 items>"}
[properties] = [
windowIcon = <Myns::QVariant (QIcon)> = {""}
cursorFlashTime = <Myns::QVariant (int)> = {"1000"}
doubleClickInterval = <Myns::QVariant (int)> = {"400"}
keyboardInputInterval = <Myns::QVariant (int)> = {"400"}
wheelScrollLines = <Myns::QVariant (int)> = {"3"}
globalStrut = <Myns::QVariant (QSize)> = {"(0, 0)"}
startDragTime = <Myns::QVariant (int)> = {"500"}
startDragDistance = <Myns::QVariant (int)> = {"10"}
styleSheet = <Myns::QVariant (QString)> = {""}
autoSipEnabled = <Myns::QVariant (bool)> = {"true"}
],"<10 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp ss
ss =
<Myns::QString> = {"Hello"}
Change-Id: I6e4714a5cfe34c38917500d114ad9a70d20cff39
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-06-13 17:45:34 +02:00
|
|
|
|
|
|
|
def put(self, line):
|
|
|
|
if self.output.endswith('\n'):
|
|
|
|
self.output = self.output[0:-1]
|
|
|
|
self.output += line
|
|
|
|
|
|
|
|
def putNumChild(self, numchild):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def putOriginalAddress(self, value):
|
|
|
|
pass
|
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
def fetchVariables(self, args):
|
2015-04-15 12:38:11 +02:00
|
|
|
args['fancy'] = 1
|
2015-10-27 15:50:41 +01:00
|
|
|
args['passexception'] = 1
|
2015-04-15 12:38:11 +02:00
|
|
|
args['autoderef'] = 1
|
2015-12-16 14:13:44 +01:00
|
|
|
args['qobjectnames'] = 1
|
2015-04-15 12:38:11 +02:00
|
|
|
name = args['varlist']
|
|
|
|
self.prepare(args)
|
Debugger: Make dumpers somewhat work in command line GDB
With
python sys.path.insert(1, '/data/dev/creator/share/qtcreator/debugger/')
python from gdbbridge import *
in .gdbinit there's a new "GDB command", called "pp".
With code like
int main(int argc, char *argv[])
{
QString ss = "Hello";
QApplication app(argc, argv);
app.setObjectName(ss);
// break here
}
the 'pp' command can be used as follows:
(gdb) pp app
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = <Myns::QObjectList> = {"<3 items>"}
[properties] = "<>0 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp app [properties],[children]
app =
[
<Myns::QGuiApplication> = {"Hello"}
staticMetaObject = <Myns::QMetaObject> = {""}
[parent] = <Myns::QObject *> = {"0x0"}
[children] = [
<Myns::QObject> = {""}
<Myns::QObject> = {""}
<Myns::QObject> = {"fusion"}
],<Myns::QObjectList> = {"<3 items>"}
[properties] = [
windowIcon = <Myns::QVariant (QIcon)> = {""}
cursorFlashTime = <Myns::QVariant (int)> = {"1000"}
doubleClickInterval = <Myns::QVariant (int)> = {"400"}
keyboardInputInterval = <Myns::QVariant (int)> = {"400"}
wheelScrollLines = <Myns::QVariant (int)> = {"3"}
globalStrut = <Myns::QVariant (QSize)> = {"(0, 0)"}
startDragTime = <Myns::QVariant (int)> = {"500"}
startDragDistance = <Myns::QVariant (int)> = {"10"}
styleSheet = <Myns::QVariant (QString)> = {""}
autoSipEnabled = <Myns::QVariant (bool)> = {"true"}
],"<10 items>"
[methods] = "<6 items>"
[signals] = "<1 items>"
],<Myns::QApplication> = {"Hello"}
(gdb) pp ss
ss =
<Myns::QString> = {"Hello"}
Change-Id: I6e4714a5cfe34c38917500d114ad9a70d20cff39
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-06-13 17:45:34 +02:00
|
|
|
self.output = name + ' = '
|
|
|
|
frame = gdb.selected_frame()
|
|
|
|
value = frame.read_var(name)
|
|
|
|
with TopLevelItem(self, name):
|
|
|
|
self.putItem(value)
|
|
|
|
return self.output
|
|
|
|
|
2013-10-30 12:38:29 +01:00
|
|
|
# Global instance.
|
2015-09-25 08:45:20 +02:00
|
|
|
#if gdb.parameter('height') is None:
|
|
|
|
theDumper = Dumper()
|
|
|
|
#else:
|
|
|
|
# import codecs
|
|
|
|
# theDumper = CliDumper()
|
2013-10-30 12:38:29 +01:00
|
|
|
|
2015-02-11 17:51:15 +01:00
|
|
|
######################################################################
|
2013-10-30 12:38:29 +01:00
|
|
|
#
|
|
|
|
# ThreadNames Command
|
|
|
|
#
|
|
|
|
#######################################################################
|
2013-06-06 18:28:53 +02:00
|
|
|
|
|
|
|
def threadnames(arg):
|
2013-10-30 12:38:29 +01:00
|
|
|
return theDumper.threadnames(int(arg))
|
2013-05-15 15:42:55 +02:00
|
|
|
|
|
|
|
registerCommand("threadnames", threadnames)
|
|
|
|
|
2015-01-22 12:05:00 +01:00
|
|
|
#######################################################################
|
|
|
|
#
|
|
|
|
# Native Mixed
|
|
|
|
#
|
|
|
|
#######################################################################
|
|
|
|
|
2015-10-14 13:26:22 +02:00
|
|
|
class InterpreterMessageBreakpoint(gdb.Breakpoint):
|
2015-10-08 16:19:57 +02:00
|
|
|
def __init__(self):
|
2015-10-14 13:26:22 +02:00
|
|
|
spec = "qt_qmlDebugMessageAvailable"
|
|
|
|
super(InterpreterMessageBreakpoint, self).\
|
2015-10-08 16:19:57 +02:00
|
|
|
__init__(spec, gdb.BP_BREAKPOINT, internal=True)
|
|
|
|
|
|
|
|
def stop(self):
|
2015-10-09 15:00:20 +02:00
|
|
|
print("Interpreter event received.")
|
2015-10-14 13:26:22 +02:00
|
|
|
return theDumper.handleInterpreterMessage()
|
2015-10-08 16:19:57 +02:00
|
|
|
|
2015-10-14 13:26:22 +02:00
|
|
|
InterpreterMessageBreakpoint()
|