[Libreoffice-commits] core.git: solenv/gdb

Michael Stahl mstahl at redhat.com
Wed Nov 8 18:04:00 UTC 2017


 solenv/gdb/libreoffice/basegfx.py |   26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

New commits:
commit 020a02c3477284daa3465e48afcc8257fb5a6201
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Nov 8 18:20:22 2017 +0100

    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

diff --git a/solenv/gdb/libreoffice/basegfx.py b/solenv/gdb/libreoffice/basegfx.py
index ec564b99c903..81901fe8dae8 100644
--- a/solenv/gdb/libreoffice/basegfx.py
+++ b/solenv/gdb/libreoffice/basegfx.py
@@ -86,12 +86,12 @@ class B2DPolygonPrinter(object):
         def __next__(self):
             if self.index >= self.count:
                 raise StopIteration()
-            currPoint = gdb.parse_and_eval(
-                    '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
-                      self.value.address, self.index))
-            currPoint = gdb.parse_and_eval(
-                    '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
-                      self.value.address, self.index))
+            points = self.value['mpPolygon']['m_pimpl'].dereference()['m_value']['maPoints']['maVector']
+            currPoint = (points['_M_impl']['_M_start'] + self.index).dereference()
+            # doesn't work?
+            #currPoint = gdb.parse_and_eval(
+            #        '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
+            #          self.value.address, self.index))
             self.index += 1
             return ('point %d' % (self.index-1),
                     '(%15f, %15f)' % (currPoint['mfX'], currPoint['mfY']))
@@ -108,9 +108,11 @@ class B2DPolygonPrinter(object):
         def __next__(self):
             if self.index >= self.count:
                 raise StopIteration()
-            currPoint = gdb.parse_and_eval(
-                    '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
-                      self.value.address, self.index))
+            points = self.value['mpPolygon']['m_pimpl'].dereference()['m_value']['maPoints']['maVector']
+            currPoint = (points['_M_impl']['_M_start'] + self.index).dereference()
+            #currPoint = gdb.parse_and_eval(
+            #        '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
+            #          self.value.address, self.index))
             prevControl = gdb.parse_and_eval(
                     '((basegfx::B2DPolygon*)%d)->getPrevControlPoint(%d)' % (
                       self.value.address, self.index))
@@ -150,6 +152,12 @@ class B2DPolyPolygonPrinter(object):
     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()
+
 printer = None
 
 def build_pretty_printers():


More information about the Libreoffice-commits mailing list