gdb pretty printer survive reload
This commit is contained in:
parent
f11f36e7d5
commit
ea0c1811c5
1 changed files with 8 additions and 8 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
import gdb
|
import gdb
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -16,8 +15,6 @@ def printErrorOnce(id, message):
|
||||||
errorSet.add(id)
|
errorSet.add(id)
|
||||||
gdb.write(message, gdb.STDERR)
|
gdb.write(message, gdb.STDERR)
|
||||||
|
|
||||||
nimobjfile = gdb.current_objfile() or gdb.objfiles()[0]
|
|
||||||
nimobjfile.type_printers = []
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
##### Type pretty printers
|
##### Type pretty printers
|
||||||
|
|
@ -121,9 +118,6 @@ class NimTypePrinter:
|
||||||
def instantiate(self):
|
def instantiate(self):
|
||||||
return NimTypeRecognizer()
|
return NimTypeRecognizer()
|
||||||
|
|
||||||
|
|
||||||
nimobjfile.type_printers = [NimTypePrinter()]
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
##### GDB Function, equivalent of Nim's $ operator
|
##### GDB Function, equivalent of Nim's $ operator
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
@ -528,5 +522,11 @@ def makematcher(klass):
|
||||||
printErrorOnce(typeName, "No matcher for type '" + typeName + "': " + str(e) + "\n")
|
printErrorOnce(typeName, "No matcher for type '" + typeName + "': " + str(e) + "\n")
|
||||||
return matcher
|
return matcher
|
||||||
|
|
||||||
|
def new_object_handler(event):
|
||||||
|
nimobjfile = gdb.current_objfile() or gdb.objfiles()[0]
|
||||||
|
nimobjfile.type_printers = []
|
||||||
|
nimobjfile.type_printers = [NimTypePrinter()]
|
||||||
nimobjfile.pretty_printers = []
|
nimobjfile.pretty_printers = []
|
||||||
nimobjfile.pretty_printers.extend([makematcher(var) for var in list(vars().values()) if hasattr(var, 'pattern')])
|
nimobjfile.pretty_printers.extend([makematcher(var) for var in list(globals().values()) if hasattr(var, 'pattern')])
|
||||||
|
|
||||||
|
gdb.events.new_objfile.connect(new_object_handler)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue