gdb_pretty_printer_test.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import gdb
  2. # this test should test the gdb pretty printers of the nim
  3. # library. But be aware this test is not complete. It only tests the
  4. # command line version of gdb. It does not test anything for the
  5. # machine interface of gdb. This means if if this test passes gdb
  6. # frontends might still be broken.
  7. gdb.execute("source ../../../tools/nim-gdb.py")
  8. # debug all instances of the generic function `myDebug`, should be 8
  9. gdb.execute("rbreak myDebug")
  10. gdb.execute("run")
  11. outputs = [
  12. 'meTwo',
  13. '"meTwo"',
  14. '{meOne, meThree}',
  15. 'MyOtherEnum(1)',
  16. '5',
  17. 'array = {1, 2, 3, 4, 5}',
  18. 'seq(3, 3) = {"one", "two", "three"}',
  19. 'Table(3, 64) = {["two"] = 2, ["three"] = 3, ["one"] = 1}',
  20. ]
  21. for i, expected in enumerate(outputs):
  22. if i == 5:
  23. # myArray is passed as pointer to int to myDebug. I look up myArray up in the stack
  24. gdb.execute("up")
  25. output = str(gdb.parse_and_eval("myArray"))
  26. else:
  27. output = str(gdb.parse_and_eval("arg"))
  28. assert output == expected, output + " != " + expected
  29. gdb.execute("continue")