[nim-gdb] Fixed enums and flag output [ci skip] (#17634)

Debugger works for enums again. Additionally, flags work better than before.

Reworked object printer as well, but the approach needs much more work or has
to be replaced all together. This is mostly to save the work and myself or
someone else can revisit it.
This commit is contained in:
Saem Ghani 2021-04-05 02:37:28 -07:00 • committed by GitHub
commit 5261579175
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 204 additions and 71 deletions

View file

@ -25,6 +25,7 @@ outputs = [
'seq(3, 3) = {"one", "two", "three"}',
'Table(3, 64) = {[4] = "four", [5] = "five", [6] = "six"}',
'Table(3, 8) = {["two"] = 2, ["three"] = 3, ["one"] = 1}',
'{a = 1, b = "some string"}'
]
for i, expected in enumerate(outputs):
@ -32,7 +33,7 @@ for i, expected in enumerate(outputs):
gdb.flush()
functionSymbol = gdb.selected_frame().block().function
assert functionSymbol.line == 21
assert functionSymbol.line == 41, str(functionSymbol.line)
if i == 6:
# myArray is passed as pointer to int to myDebug. I look up myArray up in the stack
@ -47,6 +48,6 @@ for i, expected in enumerate(outputs):
output = str(raw)
assert output == expected, output + " != " + expected
assert output == expected, "{0} : output: ({1}) != expected: ({2})".format(i, output, expected)
gdb.write(f"passed\n", gdb.STDLOG)
gdb.execute("continue")

View file

@ -14,7 +14,27 @@ type
moTwo,
moThree,
moFoure,
MyObj = object
a*: int
b*: string
# MyVariant = ref object
# id*: int
# case kind*: MyEnum
# of meOne: mInt*: int
# of meTwo, meThree: discard
# of meFour:
# moInt*: int
# babies*: seq[MyVariant]
# after: float
# MyIntVariant = ref object
# stuff*: int
# case myKind*: range[0..32766]
# of 0: mFloat*: float
# of 2: mString*: string
# else: mBabies*: seq[MyIntVariant]
var counter = 0
@ -74,6 +94,18 @@ proc testProc(): void =
var myOtherTable = {"one": 1, "two": 2, "three": 3}.toTable
myDebug(myOtherTable) #14
var obj = MyObj(a: 1, b: "some string")
myDebug(obj) #15
# var varObj = MyVariant(id: 13, kind: meFour, moInt: 94,
# babies: @[MyVariant(id: 18, kind: meOne, mInt: 7, after: 1.0),
# MyVariant(id: 21, kind: meThree, after: 2.0)],
# after: 3.0)
# myDebug(varObj) #16
# var varObjInt = MyIntVariant(stuff: 5, myKind: 2, mString: "this is my sweet string")
# myDebug(varObjInt) #17
echo(counter)