forked from qt-creator/qt-creator
debugger: prepare profiling of python dumpers
This commit is contained in:
@@ -8,6 +8,8 @@ import gdb
|
|||||||
import base64
|
import base64
|
||||||
import __builtin__
|
import __builtin__
|
||||||
import os
|
import os
|
||||||
|
import cProfile
|
||||||
|
|
||||||
|
|
||||||
# Fails on Windows.
|
# Fails on Windows.
|
||||||
try:
|
try:
|
||||||
@@ -776,6 +778,15 @@ class FrameCommand(gdb.Command):
|
|||||||
super(FrameCommand, self).__init__("bb", gdb.COMMAND_OBSCURE)
|
super(FrameCommand, self).__init__("bb", gdb.COMMAND_OBSCURE)
|
||||||
|
|
||||||
def invoke(self, args, from_tty):
|
def invoke(self, args, from_tty):
|
||||||
|
#if args.startswith('options:pp'):
|
||||||
|
# cProfile.run('bb("%s")' % args, '/tmp/fooprof')
|
||||||
|
#else:
|
||||||
|
bb(args)
|
||||||
|
|
||||||
|
FrameCommand()
|
||||||
|
|
||||||
|
|
||||||
|
def bb(args):
|
||||||
options = []
|
options = []
|
||||||
varList = []
|
varList = []
|
||||||
typeformats = {}
|
typeformats = {}
|
||||||
@@ -813,7 +824,7 @@ class FrameCommand(gdb.Command):
|
|||||||
#warn("VARIABLES: %s" % varList)
|
#warn("VARIABLES: %s" % varList)
|
||||||
#warn("EXPANDED INAMES: %s" % expandedINames)
|
#warn("EXPANDED INAMES: %s" % expandedINames)
|
||||||
module = sys.modules[__name__]
|
module = sys.modules[__name__]
|
||||||
self.dumpers = {}
|
dumpers = {}
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
dumpers = ""
|
dumpers = ""
|
||||||
@@ -836,10 +847,10 @@ class FrameCommand(gdb.Command):
|
|||||||
if useFancy:
|
if useFancy:
|
||||||
for key, value in module.__dict__.items():
|
for key, value in module.__dict__.items():
|
||||||
if key.startswith("qdump__"):
|
if key.startswith("qdump__"):
|
||||||
self.dumpers[key[7:]] = value
|
dumpers[key[7:]] = value
|
||||||
|
|
||||||
d = Dumper()
|
d = Dumper()
|
||||||
d.dumpers = self.dumpers
|
d.dumpers = dumpers
|
||||||
d.typeformats = typeformats
|
d.typeformats = typeformats
|
||||||
d.formats = formats
|
d.formats = formats
|
||||||
d.useFancy = useFancy
|
d.useFancy = useFancy
|
||||||
@@ -938,7 +949,7 @@ class FrameCommand(gdb.Command):
|
|||||||
if len(watchers) > 0:
|
if len(watchers) > 0:
|
||||||
for watcher in watchers.split("##"):
|
for watcher in watchers.split("##"):
|
||||||
(exp, iname) = watcher.split("#")
|
(exp, iname) = watcher.split("#")
|
||||||
self.handleWatch(d, exp, iname)
|
handleWatch(d, exp, iname)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Breakpoints
|
# Breakpoints
|
||||||
@@ -949,7 +960,7 @@ class FrameCommand(gdb.Command):
|
|||||||
print('data=[' + d.output + ']')
|
print('data=[' + d.output + ']')
|
||||||
|
|
||||||
|
|
||||||
def handleWatch(self, d, exp, iname):
|
def handleWatch(d, exp, iname):
|
||||||
exp = str(exp)
|
exp = str(exp)
|
||||||
escapedExp = exp.replace('"', '\\"');
|
escapedExp = exp.replace('"', '\\"');
|
||||||
#warn("HANDLING WATCH %s, INAME: '%s'" % (exp, iname))
|
#warn("HANDLING WATCH %s, INAME: '%s'" % (exp, iname))
|
||||||
@@ -968,7 +979,7 @@ class FrameCommand(gdb.Command):
|
|||||||
with Children(d, len(list)):
|
with Children(d, len(list)):
|
||||||
itemNumber = 0
|
itemNumber = 0
|
||||||
for item in list:
|
for item in list:
|
||||||
self.handleWatch(d, item, "%s.%d" % (iname, itemNumber))
|
handleWatch(d, item, "%s.%d" % (iname, itemNumber))
|
||||||
itemNumber += 1
|
itemNumber += 1
|
||||||
except RuntimeError, error:
|
except RuntimeError, error:
|
||||||
warn("EVAL: ERROR CAUGHT %s" % error)
|
warn("EVAL: ERROR CAUGHT %s" % error)
|
||||||
@@ -997,8 +1008,6 @@ class FrameCommand(gdb.Command):
|
|||||||
d.put('value="<invalid>",type="<unknown>",numchild="0",')
|
d.put('value="<invalid>",type="<unknown>",numchild="0",')
|
||||||
|
|
||||||
|
|
||||||
FrameCommand()
|
|
||||||
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user