diff mbox

[3/67] Add GDB pretty printer for machine mode classes

Message ID 874m2dp8lt.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford Dec. 9, 2016, 12:53 p.m. UTC
This patch adds gdb hooks for printing machine_modes in the
natural way.

gcc/
	* gdbhooks.py (MachineModePrinter): New class.
	(build_pretty_printer): Use it for machine_modes.
diff mbox

Patch

diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 1212312..95f4b95 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -422,6 +422,16 @@  class VecPrinter:
 
 ######################################################################
 
+class MachineModePrinter:
+    def __init__(self, gdbval):
+        self.gdbval = gdbval
+
+    def to_string (self):
+	name = str(self.gdbval['m_mode'])
+	return name[2:] if name.startswith('E_') else name
+
+######################################################################
+
 # TODO:
 #   * hashtab
 #   * location_t
@@ -518,6 +528,9 @@  def build_pretty_printer():
                              'vec',
                              VecPrinter)
 
+    pp.add_printer_for_types(['machine_mode'],
+			     'machine_mode', MachineModePrinter)
+
     return pp
 
 gdb.printing.register_pretty_printer(