This bugzilla service is closed. All entries have been migrated to

Bug 1539

Summary: Eigen GDB pretty printer does not work for Eigen::Block types
Product: Eigen Reporter: Allan Leal <allanmulin>
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: NEW ---    
Severity: Feature Request CC: chtz, gael.guennebaud, jacob.benoit.1
Priority: Normal    
Version: 3.3 (current stable)   
Hardware: All   
OS: All   
Description Flags
Fix the GDB pretty printing behavior for matrix and vector block views none

Description Allan Leal 2018-04-09 08:03:09 UTC
Created attachment 848 [details]
Fix the GDB pretty printing behavior for matrix and vector block views

When using GDB pretty printers to print views in Eigen matrices and vectors, the contents of the view is not displayed nicely as it is done for Eigen::Matrix, Eigen::Array, etc.

For example:

MatrixXd A = MatrixXd::Random(10, 10);

auto Aview = A.topLeftCorner(3, 3);

Printing `Aview` variable (or inspecting it in an IDE like Eclipse, QtCreator, etc.) does not print useful state.

In the attachment to this bug, there is a modified `` file that allows matrix and vector blocks to be printed nicely.

The modifications were:

def cast_eigen_block_to_matrix(val):
	# Get the type of the variable (and convert to a string)
	# Example: 'const Eigen::Block<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const, -1, -1, false>'
	type = str(val.type)

	# Extract the Eigen::Matrix type from the Block:
	# From the previous example: Eigen::Matrix<double, -1, -1, 0, -1, -1>
	begin = type.find('Eigen::Matrix<')
	end = type.find('>', begin) + 1

	# Convert the Eigen::Block to an Eigen::Matrix
	return val.cast(gdb.lookup_type(type[begin:end]))

def build_eigen_dictionary ():
	pretty_printers_dict[re.compile('^Eigen::Quaternion<.*>$')] = lambda val: EigenQuaternionPrinter(val)
	pretty_printers_dict[re.compile('^Eigen::Matrix<.*>$')] = lambda val: EigenMatrixPrinter("Matrix", val)
	pretty_printers_dict[re.compile('^Eigen::Block<.*>$')] = lambda val: EigenMatrixPrinter("Matrix", cast_eigen_block_to_matrix(val))
	pretty_printers_dict[re.compile('^Eigen::VectorBlock<.*>$')] = lambda val: EigenMatrixPrinter("Matrix", cast_eigen_block_to_matrix(val))
	pretty_printers_dict[re.compile('^Eigen::SparseMatrix<.*>$')] = lambda val: EigenSparseMatrixPrinter(val)
	pretty_printers_dict[re.compile('^Eigen::Array<.*>$')]  = lambda val: EigenMatrixPrinter("Array",  val)
Comment 1 Nobody 2019-12-04 17:36:52 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: