Coverage for python / lsst / gdb / ip / diffim / printers.py: 0%

24 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-07 08:35 +0000

1 

2import gdb 

3import sys 

4 

5try: 

6 import gdb.printing 

7 

8 # example from meas_alg 

9 class CRPixelPrinter(object): 

10 "Print a CRPixel" 

11 

12 def __init__(self, val): 

13 self.val = val 

14 

15 def to_string(self): 

16 return "{id=%d (%d, %d)}" % (self.val["id"], self.val["col"], self.val["row"]) 

17 

18 printers = [] 

19 

20 def register(obj): 

21 "Register my pretty-printers with objfile Obj." 

22 

23 if obj is None: 

24 obj = gdb 

25 

26 for p in printers: 

27 gdb.printing.register_pretty_printer(obj, p) 

28 

29 def build_ip_diffim_dictionary(): 

30 printer = gdb.printing.RegexpCollectionPrettyPrinter("ip_diffim") 

31 

32 # example from meas_alg 

33 # printer.add_printer('lsst::meas::algorithms::CRPixel', 

34 # '^lsst::meas::algorithms::CRPixel', CRPixelPrinter) 

35 

36 return printer 

37 

38 printers.append(build_ip_diffim_dictionary()) 

39 

40except ImportError: 

41 def register(*args, **kwargs): 

42 print("Your version of gdb is too old to load the ip.diffim python pretty printers", file=sys.stderr) 

43 pass 

44 

45 pass