Commit 8ebb6aa9 authored by hjk's avatar hjk

Debugger: Extend use of Dumper.putPlotData

Make backend-agnostic and use it for QFiniteStack and
std::{array,vector}

Change-Id: I1702d4290ee24c957f77b539591313ac83021003
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 86077c99
......@@ -779,6 +779,46 @@ class DumperBase:
format = self.typeformats.get(needle)
return format
def putPlotData(self, type, base, n, plotFormat = 2):
if self.isExpanded():
self.putArrayData(type, base, n)
if not hasPlot():
return
if not self.isSimpleType(type):
#self.putValue(self.currentValue + " (not plottable)")
self.putValue(self.currentValue)
self.putField("plottable", "0")
return
global gnuplotPipe
global gnuplotPid
format = self.currentItemFormat()
iname = self.currentIName
if format != plotFormat:
if iname in gnuplotPipe:
os.kill(gnuplotPid[iname], 9)
del gnuplotPid[iname]
gnuplotPipe[iname].terminate()
del gnuplotPipe[iname]
return
base = self.createPointerValue(base, type)
if not iname in gnuplotPipe:
gnuplotPipe[iname] = subprocess.Popen(["gnuplot"],
stdin=subprocess.PIPE)
gnuplotPid[iname] = gnuplotPipe[iname].pid
f = gnuplotPipe[iname].stdin;
# On Ubuntu install gnuplot-x11
f.write("set term wxt noraise\n")
f.write("set title 'Data fields'\n")
f.write("set xlabel 'Index'\n")
f.write("set ylabel 'Value'\n")
f.write("set grid\n")
f.write("set style data lines;\n")
f.write("plot '-' title '%s'\n" % iname)
for i in range(0, n):
f.write(" %s\n" % base.dereference())
base += 1
f.write("e\n")
def cleanAddress(addr):
if addr is None:
return "<no address>"
......
......@@ -1160,48 +1160,6 @@ class Dumper(DumperBase):
def isStructType(self, typeobj):
return typeobj.code == gdb.TYPE_CODE_STRUCT
def putPlotData(self, type, base, n, plotFormat):
if self.isExpanded():
self.putArrayData(type, base, n)
if not hasPlot():
return
if not self.isSimpleType(type):
#self.putValue(self.currentValue + " (not plottable)")
self.putValue(self.currentValue)
self.putField("plottable", "0")
return
global gnuplotPipe
global gnuplotPid
format = self.currentItemFormat()
iname = self.currentIName
#if False:
if format != plotFormat:
if iname in gnuplotPipe:
os.kill(gnuplotPid[iname], 9)
del gnuplotPid[iname]
gnuplotPipe[iname].terminate()
del gnuplotPipe[iname]
return
base = base.cast(type.pointer())
if not iname in gnuplotPipe:
gnuplotPipe[iname] = subprocess.Popen(["gnuplot"],
stdin=subprocess.PIPE)
gnuplotPid[iname] = gnuplotPipe[iname].pid
f = gnuplotPipe[iname].stdin;
# On Ubuntu install gnuplot-x11
f.write("set term wxt noraise\n")
f.write("set title 'Data fields'\n")
f.write("set xlabel 'Index'\n")
f.write("set ylabel 'Value'\n")
f.write("set grid\n")
f.write("set style data lines;\n")
f.write("plot '-' title '%s'\n" % iname)
for i in range(0, n):
f.write(" %s\n" % base.dereference())
base += 1
f.write("e\n")
def putArrayData(self, type, base, n,
childNumChild = None, maxNumChild = 10000):
if not self.tryPutArrayContents(type, base, n):
......
......@@ -536,13 +536,6 @@ class Dumper(DumperBase):
self.put('",')
return True
def putPlotData(self, type, base, n, plotFormat):
#warn("PLOTDATA: %s %s" % (type, n))
if self.isExpanded():
self.putArrayData(type, base, n)
self.putValue(self.currentValue)
self.putField("plottable", "0")
def putArrayData(self, type, base, n,
childNumChild = None, maxNumChild = 10000):
if not self.tryPutArrayContents(type, base, n):
......
......@@ -472,6 +472,9 @@ def qdump__QFixed(d, value):
d.putNumChild(0)
def qform__QFiniteStack():
return arrayForms()
def qdump__QFiniteStack(d, value):
alloc = int(value["_alloc"])
size = int(value["_size"])
......@@ -480,7 +483,7 @@ def qdump__QFiniteStack(d, value):
d.putNumChild(size)
if d.isExpanded():
innerType = d.templateArgument(value.type, 0)
d.putArrayData(innerType, value["_array"], size)
d.putPlotData(innerType, value["_array"], size)
# Stock gdb 7.2 seems to have a problem with types here:
#
......@@ -1657,6 +1660,9 @@ def qdump__QSizeF(d, value):
d.putPlainChildren(value)
def qform__QStack():
return arrayForms()
def qdump__QStack(d, value):
qdump__QVector(d, value)
......@@ -2036,7 +2042,7 @@ def qdump__QVector(d, value):
d.check(0 <= size and size <= alloc and alloc <= 1000 * 1000 * 1000)
d.putItemCount(size)
d.putNumChild(size)
d.putPlotData(innerType, p, size, 2)
d.putPlotData(innerType, p, size)
def qdump__QWeakPointer(d, value):
......
......@@ -29,14 +29,20 @@
from dumper import *
def qform__std__array():
return arrayForms()
def qdump__std__array(d, value):
size = d.numericTemplateArgument(value.type, 1)
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
innerType = d.templateArgument(value.type, 0)
d.putArrayData(innerType, d.addressOf(value), size)
d.putPlotData(innerType, d.addressOf(value), size)
def qform__std____1__array():
return arrayForms()
def qdump__std____1__array(d, value):
qdump__std__array(d, value)
......@@ -660,6 +666,9 @@ def qdump__std____debug__unordered_set(d, value):
qdump__std__unordered_set(d, value)
def qform__std__vector():
return arrayForms()
def qedit__std__vector(d, value, data):
import gdb
values = data.split(',')
......@@ -713,7 +722,7 @@ def qdump__std__vector(d, value):
d.putBoolItem(str(i),
(int(d.dereference(q)) >> (i % 8)) & 1)
else:
d.putArrayData(type, start, size)
d.putPlotData(type, start, size)
def qdump__std__vector__QNX(d, value):
type = d.templateArgument(value.type, 0)
......@@ -764,12 +773,16 @@ def qdump__std____1__vector(d, value):
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
d.putArrayData(innerType, begin, size)
d.putPlotData(innerType, begin, size)
def qform__std____debug__vector():
return arrayForms()
def qdump__std____debug__vector(d, value):
qdump__std__vector(d, value)
def qedit__std__string(d, value, data):
d.call(value, "assign", '"%s"' % data.replace('"', '\\"'))
......
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