From 2a6594de298a3d80e27e1fe6d33d55b68503d30f Mon Sep 17 00:00:00 2001 From: Kolja Brix Date: Sat, 18 Dec 2021 17:34:38 +0000 Subject: [PATCH] Small cleanup of GDB pretty printer code --- debug/gdb/printers.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/debug/gdb/printers.py b/debug/gdb/printers.py index 2ca3fc579..2c3fccfa3 100644 --- a/debug/gdb/printers.py +++ b/debug/gdb/printers.py @@ -27,7 +27,6 @@ import gdb import re -import itertools from bisect import bisect_left @@ -54,18 +53,18 @@ class _MatrixEntryIterator(object): if self.currentCol >= self.cols: raise StopIteration - self.currentRow = self.currentRow + 1 + self.currentRow += 1 if self.currentRow >= self.rows: self.currentRow = 0 - self.currentCol = self.currentCol + 1 + self.currentCol += 1 else: if self.currentRow >= self.rows: raise StopIteration - self.currentCol = self.currentCol + 1 + self.currentCol += 1 if self.currentCol >= self.cols: self.currentCol = 0 - self.currentRow = self.currentRow + 1 + self.currentRow += 1 return row, col @@ -126,7 +125,7 @@ class EigenMatrixPrinter: row, col = super(EigenMatrixPrinter._Iterator, self).__next__() item = self.dataPtr.dereference() - self.dataPtr = self.dataPtr + 1 + self.dataPtr += 1 if self.cols == 1: # if it's a column vector return '[%d]' % (row,), item elif self.rows == 1: # if it's a row vector @@ -134,7 +133,6 @@ class EigenMatrixPrinter: return '[%d,%d]' % (row, col), item def children(self): - return self._Iterator(self.rows, self.cols, self.data, self.rowMajor) def to_string(self): @@ -268,14 +266,13 @@ class EigenQuaternionPrinter: if self.currentElement >= 4: # there are 4 elements in a quaternion raise StopIteration - self.currentElement = self.currentElement + 1 + self.currentElement += 1 item = self.dataPtr.dereference() - self.dataPtr = self.dataPtr + 1 + self.dataPtr += 1 return '[%s]' % (self.elementNames[element],), item def children(self): - return self._Iterator(self.data) def to_string(self): @@ -285,15 +282,15 @@ class EigenQuaternionPrinter: def cast_eigen_block_to_matrix(val): # Get the type of the variable (and convert to a string) # Example: 'const Eigen::Block, -1, -1, false> const, -1, -1, false>' - type = str(val.type) + val_type = str(val.type) # Extract the Eigen::Matrix type from the Block: # From the previous example: Eigen::Matrix - begin = type.find('Eigen::Matrix<') - end = type.find('>', begin) + 1 + begin = val_type.find('Eigen::Matrix<') + end = val_type.find('>', begin) + 1 # Convert the Eigen::Block to an Eigen::Matrix - return val.cast(gdb.lookup_type(type[begin:end])) + return val.cast(gdb.lookup_type(val_type[begin:end])) def build_eigen_dictionary():