Commit 19a7f66d authored by hjk's avatar hjk
Browse files

debugger: add gnuplot based display for QVector



Change-Id: Ic24a0d77906a59bc2c216ef0d6dd655695e2033e
(cherry picked from commit 41ac231ddfbabec6c09101345cf4d1370646f027)
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 3841b854
......@@ -2,6 +2,8 @@ import sys
import base64
import __builtin__
import os
import os.path
import subprocess
import tempfile
# Fails on Windows.
......@@ -84,6 +86,20 @@ DisplayProcess \
qqStringCutOff = 1000
#
# Gnuplot based display for array-like structures.
#
gnuplotPipe = {}
gnuplotPid = {}
def hasPlot():
fileName = "/usr/bin/gnuplot"
return os.path.isfile(fileName) and os.access(fileName, os.X_OK)
#
# Threads
#
def hasInferiorThreadList():
#return False
try:
......@@ -92,6 +108,9 @@ def hasInferiorThreadList():
except:
return False
#
# VTable
#
def hasVTable(type):
fields = type.fields()
if len(fields) == 0:
......@@ -1338,6 +1357,45 @@ class Dumper:
self.put('",')
return True
def putPlotData(self, type, base, n, plotFormat):
if self.isExpanded():
self.putArrayData(type, base, n)
if not hasPlot():
return
if not isSimpleType(type):
self.putValue(self.currentValue + " (not plottable)")
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;
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(1, n):
f.write(" %s\n" % base.dereference())
base += 1
f.write("e\n")
def putArrayData(self, type, base, n,
childNumChild = None, maxNumChild = 10000):
base = base.cast(type.pointer())
......
......@@ -11,6 +11,11 @@ from __future__ import with_statement
def mapForms():
return "Normal,Compact"
def arrayForms():
if hasPlot():
return "Normal,Plot"
return "Normal"
def mapCompact(format, keyType, valueType):
if format == 2:
return True # Compact.
......@@ -1658,6 +1663,10 @@ def qedit__QVector(expr, value):
gdb.execute(cmd)
def qform__QVector():
return arrayForms()
def qdump__QVector(d, value):
private = value["d"]
checkRef(private["ref"])
......@@ -1678,8 +1687,7 @@ def qdump__QVector(d, value):
check(0 <= size and size <= alloc and alloc <= 1000 * 1000 * 1000)
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
d.putArrayData(innerType, p, size)
d.putPlotData(innerType, p, size, 2)
def qdump__QWeakPointer(d, value):
......@@ -2733,3 +2741,5 @@ if False:
if d.isExpanded():
with Children(d):
d.putFields(value)
......@@ -4183,11 +4183,13 @@ namespace qvector {
{
// This tests the display of a big vector.
QVector<int> vec(10000);
for (int i = 0; i != vec.size(); ++i)
vec[i] = i * i;
BREAK_HERE;
// Expand vec.
// Check vec <10000 items> QVector<int>.
// Check vec.0 0 int.
// Check vec.1999 0 int.
// Check vec.1999 3996001 int.
// Continue.
// step over
......
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