Kaydet (Commit) 020a02c3 authored tarafından Michael Stahl's avatar Michael Stahl

gdb pretty-printers: avoid segfauls in B2DPolygonPrinter

gdb 8.0.1 tends to sefault while evaluating the getB2DPoint()
calls; it passes some obviously wrong index instead of 0.

Also, add a children method to B2DPolyPolygonPrinter.

Change-Id: Ifbf52ad384d1f60b26ee95f87405eff2c6f2388a
üst 899d7139
...@@ -86,12 +86,12 @@ class B2DPolygonPrinter(object): ...@@ -86,12 +86,12 @@ class B2DPolygonPrinter(object):
def __next__(self): def __next__(self):
if self.index >= self.count: if self.index >= self.count:
raise StopIteration() raise StopIteration()
currPoint = gdb.parse_and_eval( points = self.value['mpPolygon']['m_pimpl'].dereference()['m_value']['maPoints']['maVector']
'((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % ( currPoint = (points['_M_impl']['_M_start'] + self.index).dereference()
self.value.address, self.index)) # doesn't work?
currPoint = gdb.parse_and_eval( #currPoint = gdb.parse_and_eval(
'((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % ( # '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
self.value.address, self.index)) # self.value.address, self.index))
self.index += 1 self.index += 1
return ('point %d' % (self.index-1), return ('point %d' % (self.index-1),
'(%15f, %15f)' % (currPoint['mfX'], currPoint['mfY'])) '(%15f, %15f)' % (currPoint['mfX'], currPoint['mfY']))
...@@ -108,9 +108,11 @@ class B2DPolygonPrinter(object): ...@@ -108,9 +108,11 @@ class B2DPolygonPrinter(object):
def __next__(self): def __next__(self):
if self.index >= self.count: if self.index >= self.count:
raise StopIteration() raise StopIteration()
currPoint = gdb.parse_and_eval( points = self.value['mpPolygon']['m_pimpl'].dereference()['m_value']['maPoints']['maVector']
'((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % ( currPoint = (points['_M_impl']['_M_start'] + self.index).dereference()
self.value.address, self.index)) #currPoint = gdb.parse_and_eval(
# '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
# self.value.address, self.index))
prevControl = gdb.parse_and_eval( prevControl = gdb.parse_and_eval(
'((basegfx::B2DPolygon*)%d)->getPrevControlPoint(%d)' % ( '((basegfx::B2DPolygon*)%d)->getPrevControlPoint(%d)' % (
self.value.address, self.index)) self.value.address, self.index))
...@@ -150,6 +152,12 @@ class B2DPolyPolygonPrinter(object): ...@@ -150,6 +152,12 @@ class B2DPolyPolygonPrinter(object):
def _isEmpty(self): def _isEmpty(self):
return self._count() == 0 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()
printer = None printer = None
def build_pretty_printers(): def build_pretty_printers():
......
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