summaryrefslogtreecommitdiff
path: root/solenv/gdb
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2019-04-10 10:50:10 -0700
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-04-13 21:14:49 +0200
commit3b3c10cee0d38f9396fdb6cf028ceb8917822bb7 (patch)
tree7ce3fe6e4041541d6d817b240f6c4e6046ad4918 /solenv/gdb
parentacb0cdeedafc5fd38703d4a0a545a33058f1673f (diff)
Fix Python exception in gdb pretty-printer basegfx
Add single quotes around the namespace::class construct, when calling gdb.parse_and_eval(), otherwise this exception is thrown: "Python Exception <class 'gdb.error'> A syntax error in expression, near `)xxx)->count($'.:" The reason is a possible conflict with '::' referring a static variable (https://sourceware.org/gdb/onlinedocs/gdb/Variables.html). Also improved the B2DPolyPolygonPrinter::children method to avoid a segmentation fault, when accessing member m_value. Change-Id: I1c15a4b786e1e374c67ace445d28c1ce210a4c04 Reviewed-on: https://gerrit.libreoffice.org/70537 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'solenv/gdb')
-rw-r--r--solenv/gdb/libreoffice/basegfx.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/solenv/gdb/libreoffice/basegfx.py b/solenv/gdb/libreoffice/basegfx.py
index 81901fe8dae8..c14968c91eb2 100644
--- a/solenv/gdb/libreoffice/basegfx.py
+++ b/solenv/gdb/libreoffice/basegfx.py
@@ -58,15 +58,19 @@ class B2DPolygonPrinter(object):
self.typename)
def _count(self):
+ # It's a call into the inferior (being debugged) process.
+ # Will not work with core dumps and can cause a deadlock.
return int(gdb.parse_and_eval(
- '((basegfx::B2DPolygon*)%d)->count()' % self.value.address))
+ "(('basegfx::B2DPolygon' *) {})->count()".format(self.value.address)))
def _isEmpty(self):
return self._count() == 0
def _hasCurves(self):
+ # It's a call into the inferior (being debugged) process.
+ # Will not work with core dumps and can cause a deadlock.
return int(gdb.parse_and_eval(
- '((basegfx::B2DPolygon*)%d)->areControlPointsUsed()' % self.value.address)) != 0
+ "(('basegfx::B2DPolygon' *) {})->areControlPointsUsed()".format(self.value.address))) != 0
def _children(self):
if self._hasCurves():
@@ -113,12 +117,15 @@ class B2DPolygonPrinter(object):
#currPoint = gdb.parse_and_eval(
# '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
# self.value.address, self.index))
+
+ # It's a call into the inferior (being debugged) process.
+ # Will not work with core dumps and can cause a deadlock.
prevControl = gdb.parse_and_eval(
- '((basegfx::B2DPolygon*)%d)->getPrevControlPoint(%d)' % (
- self.value.address, self.index))
+ "(('basegfx::B2DPolygon' *) {})->getPrevControlPoint({:d})".format(self.value.address, self.index))
+ # It's a call into the inferior (being debugged) process.
+ # Will not work with core dumps and can cause a deadlock.
nextControl = gdb.parse_and_eval(
- '((basegfx::B2DPolygon*)%d)->getNextControlPoint(%d)' % (
- self.value.address, self.index))
+ "(('basegfx::B2DPolygon' *) {})->getNextControlPoint({:d})".format(self.value.address, self.index))
self.index += 1
return ('point %d' % (self.index-1),
'p: (%15f, %15f) c-1: (%15f, %15f) c1: (%15f, %15f)' %
@@ -142,21 +149,31 @@ class B2DPolyPolygonPrinter(object):
self._count())
def _count(self):
+ # It's a call into the inferior (being debugged) process.
+ # Will not work with core dumps and can cause a deadlock.
return int(gdb.parse_and_eval(
- '((basegfx::B2DPolyPolygon*)%d)->count()' % self.value.address))
+ "(('basegfx::B2DPolyPolygon' *) {})->count()".format(self.value.address)))
def _isClosed(self):
+ # It's a call into the inferior (being debugged) process.
+ # Will not work with core dumps and can cause a deadlock.
return int(gdb.parse_and_eval(
- '((basegfx::B2DPolyPolygon*)%d)->isClosed()' % self.value.address)) != 0
+ "(('basegfx::B2DPolyPolygon' *) {})->isClosed()".format(self.value.address))) != 0
def _isEmpty(self):
return self._count() == 0
def children(self):
- impl = self.value['mpPolyPolygon']['m_pimpl']
- vector = self.value['mpPolyPolygon']['m_pimpl'].dereference()['m_value']['maPolygons']
- import libstdcxx.v6.printers as std
- return std.StdVectorPrinter("std::vector", vector).children()
+ if self.value['mpPolyPolygon']['m_pimpl'].type.code in (gdb.TYPE_CODE_PTR, gdb.TYPE_CODE_MEMBERPTR):
+ if self.value['mpPolyPolygon']['m_pimpl']:
+ try:
+ vector = self.value['mpPolyPolygon']['m_pimpl'].dereference()['m_value']['maPolygons']
+ import libstdcxx.v6.printers as std
+ return std.StdVectorPrinter("std::vector", vector).children()
+ except RuntimeError:
+ gdb.write("Cannot access memory at address " + str(self.value['mpPolyPolygon']['m_pimpl'].address))
+
+ return None
printer = None