Skip to content

Commit

Permalink
add $nimeq for gdb (#12909)
Browse files Browse the repository at this point in the history
krux02 authored and Araq committed Dec 17, 2019

Verified

This commit was signed with the committer’s verified signature.
chenrui333 Rui Chen
1 parent 7650617 commit 5848f00
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tools/nim-gdb.py
Original file line number Diff line number Diff line change
@@ -161,6 +161,35 @@ def invoke(self, arg):

DollarPrintFunction()


################################################################################
##### GDB Function, Nim string comparison
################################################################################

class NimStringEqFunction (gdb.Function):
"""Compare Nim strings for example in conditionals for breakpoints."""

def __init__ (self):
super (NimStringEqFunction, self).__init__("nimstreq")

@staticmethod
def invoke_static(arg1,arg2):
if arg1.type.code == gdb.TYPE_CODE_PTR and arg1.type.target().name == "NimStringDesc":
str1 = NimStringPrinter(arg1).to_string()
else:
str1 = arg1.string()
if arg2.type.code == gdb.TYPE_CODE_PTR and arg2.type.target().name == "NimStringDesc":
str2 = NimStringPrinter(arg1).to_string()
else:
str2 = arg2.string()

return str1 == str2

def invoke(self, arg1, arg2):
return self.invoke_static(arg1, arg2)

NimStringEqFunction()

################################################################################
##### GDB Command, equivalent of Nim's $ operator
################################################################################

0 comments on commit 5848f00

Please sign in to comment.