提交 7cab9af6 编写于 作者: M Megvii Engine Team

fix(debug): skip load user gdb script if

gdb is build with python2

GitOrigin-RevId: 816a15d774183aefd1dabfea8a1726f6bc4edf74
上级 5f02245c
import sys
import gdb
import re
......@@ -199,12 +200,14 @@ class MegengineInfo(gdb.Command):
return ["opr", "trf"]
MegengineBacktrace()
MegengineBreakApply()
MegengineUp()
MegengineDown()
MegengineInfo()
MegengineWatch()
gdb.Breakpoint("mgb::imperative::debug::notify_event(char const*)")
\ No newline at end of file
if sys.version_info.major > 2:
MegengineBacktrace()
MegengineBreakApply()
MegengineUp()
MegengineDown()
MegengineInfo()
MegengineWatch()
gdb.Breakpoint("mgb::imperative::debug::notify_event(char const*)")
else:
print("skip import commands")
import sys
import gdb
import gdb.printing
import gdb.types
......@@ -170,23 +171,26 @@ class SpanPrinter:
yield "[{}]".format(i), (self.begin+i).dereference()
pp = gdb.printing.RegexpCollectionPrettyPrinter("MegEngine")
if sys.version_info.major > 2:
pp = gdb.printing.RegexpCollectionPrettyPrinter("MegEngine")
# megdnn
pp.add_printer('megdnn::SmallVectorImpl', '^megdnn::SmallVector(Impl)?<.*>$', SmallVectorPrinter)
pp.add_printer('megdnn::TensorLayout', '^megdnn::TensorLayout$', ToStringPrinter)
pp.add_printer('megdnn::TensorShape', '^megdnn::TensorShape$', ToStringPrinter)
pp.add_printer('megdnn::SmallVectorImpl', '^megdnn::SmallVector(Impl)?<.*>$', SmallVectorPrinter)
pp.add_printer('megdnn::TensorLayout', '^megdnn::TensorLayout$', ToStringPrinter)
pp.add_printer('megdnn::TensorShape', '^megdnn::TensorShape$', ToStringPrinter)
# megbrain
pp.add_printer('mgb::CompNode', '^mgb::CompNode$', ToStringPrinter)
pp.add_printer('mgb::Maybe', '^mgb::Maybe<.*>$', MaybePrinter)
pp.add_printer('mgb::CompNode', '^mgb::CompNode$', ToStringPrinter)
pp.add_printer('mgb::Maybe', '^mgb::Maybe<.*>$', MaybePrinter)
# imperative
pp.add_printer('mgb::imperative::LogicalTensorDesc', '^mgb::imperative::LogicalTensorDesc$', LogicalTensorDescPrinter)
pp.add_printer('mgb::imperative::OpDef', '^mgb::imperative::OpDef$', OpDefPrinter)
pp.add_printer('mgb::imperative::Subgraph', '^mgb::imperative::Subgraph$', ReprPrinter)
pp.add_printer('mgb::imperative::EncodedSubgraph', '^mgb::imperative::EncodedSubgraph$', ReprPrinter)
pp.add_printer('mgb::imperative::LogicalTensorDesc', '^mgb::imperative::LogicalTensorDesc$', LogicalTensorDescPrinter)
pp.add_printer('mgb::imperative::OpDef', '^mgb::imperative::OpDef$', OpDefPrinter)
pp.add_printer('mgb::imperative::Subgraph', '^mgb::imperative::Subgraph$', ReprPrinter)
pp.add_printer('mgb::imperative::EncodedSubgraph', '^mgb::imperative::EncodedSubgraph$', ReprPrinter)
# imperative dispatch
pp.add_printer('mgb::imperative::ValueRef', '^mgb::imperative::ValueRef$', ToStringPrinter)
pp.add_printer('mgb::imperative::Span', '^mgb::imperative::Span<.*>$', SpanPrinter)
gdb.printing.register_pretty_printer(gdb.current_objfile(), pp)
pp.add_printer('mgb::imperative::ValueRef', '^mgb::imperative::ValueRef$', ToStringPrinter)
pp.add_printer('mgb::imperative::Span', '^mgb::imperative::Span<.*>$', SpanPrinter)
gdb.printing.register_pretty_printer(gdb.current_objfile(), pp)
else:
print("skip import pretty printers")
def override_pretty_printer_for(val):
......@@ -201,4 +205,5 @@ def override_pretty_printer_for(val):
return HandlePrinter(val)
gdb.pretty_printers.append(override_pretty_printer_for)
if sys.version_info.major > 2:
gdb.pretty_printers.append(override_pretty_printer_for)
import sys
import re
import gdb
......@@ -48,4 +49,5 @@ class SmallVectorImplMatcher(gdb.xmethod.XMethodMatcher):
return SmallVectorImplWorker_size(class_type.template_argument(0))
gdb.xmethod.register_xmethod_matcher(None, SmallVectorImplMatcher())
if sys.version_info.major > 2:
gdb.xmethod.register_xmethod_matcher(None, SmallVectorImplMatcher())
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册