summary refs log tree commit diff stats
path: root/tests/untestable/gdb/gdb_pretty_printer_test.py
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2018-07-16 19:30:05 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-07-16 19:30:05 +0200
commit97d37aeb0bb1ed2997eddb3b7f8ef53cd04f10ef (patch)
tree889820d6b9e044d8d762543c50088893596453ea /tests/untestable/gdb/gdb_pretty_printer_test.py
parent217a2cf0982302b9d89d2c06fc96eaf72f0518fe (diff)
downloadNim-97d37aeb0bb1ed2997eddb3b7f8ef53cd04f10ef.tar.gz
Gdb pretty printers (#8263)
Diffstat (limited to 'tests/untestable/gdb/gdb_pretty_printer_test.py')
-rw-r--r--tests/untestable/gdb/gdb_pretty_printer_test.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/untestable/gdb/gdb_pretty_printer_test.py b/tests/untestable/gdb/gdb_pretty_printer_test.py
new file mode 100644
index 000000000..54af65d9a
--- /dev/null
+++ b/tests/untestable/gdb/gdb_pretty_printer_test.py
@@ -0,0 +1,33 @@
+import gdb
+# this test should test the gdb pretty printers of the nim
+# library. But be aware this test is not complete. It only tests the
+# command line version of gdb. It does not test anything for the
+# machine interface of gdb. This means if if this test passes gdb
+# frontends might still be broken.
+
+gdb.execute("source ../../../tools/nim-gdb.py")
+# debug all instances of the generic function `myDebug`, should be 8
+gdb.execute("rbreak myDebug")
+gdb.execute("run")
+
+outputs = [
+  'meTwo',
+  '"meTwo"',
+  '{meOne, meThree}',
+  'MyOtherEnum(1)',
+  '5',
+  'array = {1, 2, 3, 4, 5}',
+  'seq(3, 3) = {"one", "two", "three"}',
+  'Table(3, 64) = {["two"] = 2, ["three"] = 3, ["one"] = 1}',
+]
+
+for i, expected in enumerate(outputs):
+  if i == 5:
+    # myArray is passed as pointer to int to myDebug. I look up myArray up in the stack
+    gdb.execute("up")
+    output = str(gdb.parse_and_eval("myArray"))
+  else:
+    output = str(gdb.parse_and_eval("arg"))
+
+  assert output == expected, output + " != " + expected
+  gdb.execute("continue")