2 Code that works with gdb 7.1's python pretty printing. When gdb >= 7.2 is widely available this
3 file should be deleted (it's only used after importing gdb.printing fails)
15 return "{0x%x %d %s 0x%x}" % (self.
val, self.
val[
"_CitizenId"],
16 self.
val[
"_typeName"], self.
val[
"_sentinel"])
22 "Print a BaseSourceAttributes"
28 return "Base: {id=%d astrom=(%.3f, %.3f)}" % (self.
val[
"_id"], self.
val[
"_xAstrom"], self.
val[
"_yAstrom"])
37 return "{id=%d astrom=(%.3f, %.3f)}" % (self.
val[
"_id"], self.
val[
"_xAstrom"], self.
val[
"_yAstrom"])
46 return "RHL Footprint (fixme when gdb 7.3 arrives)"
51 "Print a CoordinateBase"
59 if type.code == gdb.TYPE_CODE_REF:
62 return self.
val[
"_vector"][
"m_storage"][
"m_data"][
"array"]
70 "Print an ImageBase or derived class"
78 if type.code == gdb.TYPE_CODE_REF:
81 gilView = val[
"_gilView"]
82 arr = val[
"_origin"][
"_vector"][
"m_storage"][
"m_data"][
"array"]
84 return "%dx%d+%d+%d" % (
86 gilView[
"_dimensions"][
"x"], gilView[
"_dimensions"][
"y"],
90 return self.typename.split(
":")[-1]
100 "Print a MaskedImage"
110 self.
dimenStr(self.
val[
"_maskedImage"][
"_image"][
"px"].dereference()))
116 Usage: image x0 y0 [nx [ny] [centerPatch] [obeyXY0]]
120 super (PrintImageCommand, self).__init__ (
"show image",
126 return var[
"operator()(int, int, bool)"](x, y,
True)
128 dimensions = var[
"_gilView"][
"_dimensions"]
129 if x < 0
or x >= dimensions[
"x"]
or y < 0
or y >= dimensions[
"y"]:
130 raise gdb.GdbError(
"Pixel (%d, %d) is out of range 0:%d, 0:%d" %
131 (x, y, dimensions[
"x"] - 1, dimensions[
"y"] - 1))
133 pixels = var[
"_gilView"][
"_pixels"][
"_p"]
134 step = pixels[
"_step_fn"][
"_step"]/var.type.template_argument(0).sizeof
136 return pixels[
"m_iterator"][x + y*step][
"_v0"]
141 args = gdb.string_to_argv(args)
143 raise gdb.GdbError(
"Please specify an image")
144 imgName = args.pop(0)
145 var = gdb.parse_and_eval(imgName)
147 if re.search(
r"MaskedImage", str(var.type)):
148 print "N.b. %s is a MaskedImage; showing image" % (imgName)
151 if re.search(
r"shared_ptr<", str(var.type)):
152 var = var[
"px"].dereference()
154 if var.type.code == gdb.TYPE_CODE_PTR:
155 var = var.dereference()
157 pixelTypeName = str(var.type.template_argument(0))
160 raise gdb.GdbError(
"Please specify a pixel's x and y indexes")
162 x0 = gdb.parse_and_eval(args.pop(0))
163 y0 = gdb.parse_and_eval(args.pop(0))
166 print "%g" % self.
get(var, x0, y0)
169 nx = int(args.pop(0))
171 ny = int(args.pop(0))
176 centerPatch = gdb.parse_and_eval(args.pop(0))
182 obeyXY0 = gdb.parse_and_eval(args.pop(0))
185 arr = var[
"_origin"][
"_vector"][
"m_storage"][
"m_data"][
"array"]
191 raise gdb.GdbError(
'Unexpected trailing arguments: "%s"' %
'", "'.join(args))
195 if pixelTypeName
in [
"short",
"unsigned short"]:
197 elif pixelTypeName
in [
"int",
"unsigned int"]:
203 for x
in range(x0, x0 + nx):
207 for y
in reversed(range(y0, y0 + ny)):
209 for x
in range(x0, x0 + nx):
210 print "%8s" % (dataFmt % self.
get(var, x, y)),
247 def add(self, name, function):
250 if not self.compiled_rx.match(name +
'<>'):
251 raise ValueError,
'libstdc++ programming error: "%s" does not match' % name
253 self.subprinters.append(printer)
254 self.
lookup[name] = printer
259 if type.code == gdb.TYPE_CODE_REF:
260 type = type.target ()
263 type = type.unqualified ().strip_typedefs ()
274 match = self.compiled_rx.match(typename)
278 basename = match.group(1)
279 if basename
in self.
lookup:
280 return self.
lookup[basename].invoke(val)
290 "Register my pretty-printers with objfile Obj."
296 obj.pretty_printers.insert(0, p)
303 printer.add(
'lsst::afw::detection::Footprint', FootprintPrinter)
304 printer.add(
'lsst::afw::detection::Source', SourcePrinter)
305 printer.add(
'lsst::afw::detection::BaseSourceAttributes', BaseSourceAttributesPrinter)
307 printer.add(
'lsst::afw::geom::Point', CoordinateBasePrinter)
308 printer.add(
'lsst::afw::geom::Extent', CoordinateBasePrinter)
310 printer.add(
'lsst::afw::image::ImageBase', ImagePrinter)
311 printer.add(
'lsst::afw::image::Image', ImagePrinter)
312 printer.add(
'lsst::afw::image::Mask', ImagePrinter)
313 printer.add(
'lsst::afw::image::MaskedImage', MaskedImagePrinter)
314 printer.add(
'lsst::afw::image::Exposure', ExposurePrinter)
323 printer.add(
'lsst::daf::base::Citizen', CitizenPrinter)
def build_daf_base_dictionary