LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
printers.py
Go to the documentation of this file.
1 import gdb
2 import re, sys
3 
4 try:
5  import gdb.printing
6 
7  # example from meas_alg
8  class CRPixelPrinter(object):
9  "Print a CRPixel"
10  def __init__(self, val):
11  self.val = val
12  def to_string(self):
13  return "{id=%d (%d, %d)}" % (self.val["id"], self.val["col"], self.val["row"])
14 
15  printers = []
16 
17  def register(obj):
18  "Register my pretty-printers with objfile Obj."
19 
20  if obj is None:
21  obj = gdb
22 
23  for p in printers:
24  gdb.printing.register_pretty_printer(obj, p)
25 
26  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
27 
29  printer = gdb.printing.RegexpCollectionPrettyPrinter("ip_diffim")
30 
31  # example from meas_alg
32  #printer.add_printer('lsst::meas::algorithms::CRPixel',
33  # '^lsst::meas::algorithms::CRPixel', CRPixelPrinter)
34 
35  return printer
36 
37  printers.append(build_ip_diffim_dictionary())
38 
39 except ImportError:
40  def register(*args, **kwargs):
41  print >> sys.stderr, "Your version of gdb is too old to load the ip.diffim python pretty printers"
42  pass
43 
44  pass
45