Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add $nimeq for gdb #12909

Merged
merged 1 commit into from
Dec 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tools/nim-gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
################################################################################
Expand Down