From 909eb4cf22e5a0ebdd2b86515d50f5dfefd2f3e3 Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Sun, 18 May 2025 12:35:29 -0500 Subject: [PATCH] Add new test program for pretty printing structures. --- tests/helloprettyprint/.gitignore | 3 +++ tests/helloprettyprint/Makefile | 10 ++++++++ tests/helloprettyprint/README | 15 ++++++++++++ tests/helloprettyprint/helloprettyprint.cpp | 27 +++++++++++++++++++++ tests/helloprettyprint/project.seer | 25 +++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 tests/helloprettyprint/.gitignore create mode 100644 tests/helloprettyprint/Makefile create mode 100644 tests/helloprettyprint/README create mode 100644 tests/helloprettyprint/helloprettyprint.cpp create mode 100644 tests/helloprettyprint/project.seer diff --git a/tests/helloprettyprint/.gitignore b/tests/helloprettyprint/.gitignore new file mode 100644 index 0000000..463f0aa --- /dev/null +++ b/tests/helloprettyprint/.gitignore @@ -0,0 +1,3 @@ +helloprettyprint +*.o + diff --git a/tests/helloprettyprint/Makefile b/tests/helloprettyprint/Makefile new file mode 100644 index 0000000..cd012d0 --- /dev/null +++ b/tests/helloprettyprint/Makefile @@ -0,0 +1,10 @@ +.PHONY: all +all: helloprettyprint + +helloprettyprint: helloprettyprint.cpp + g++ -g -o helloprettyprint helloprettyprint.cpp + +.PHONY: clean +clean: + rm -f helloprettyprint helloprettyprint.o + diff --git a/tests/helloprettyprint/README b/tests/helloprettyprint/README new file mode 100644 index 0000000..3b82dbe --- /dev/null +++ b/tests/helloprettyprint/README @@ -0,0 +1,15 @@ + +Seer has a problem with enabling 'pretty printing' and structs have have \n characters. + + https://github.com/epasveer/seer/issues/313 + + (gdb) set print pretty on + +Without pretty print + 10^done,value="{B = 1, C = 0, D = \"asd\", E = std::vector of length 1, capacity 64 = {true}}" + 11^done,value="1" + +With pretty print + 10^done,value="{\n B = 1,\n C = 0,\n D = \"asd\",\n E = std::vector of length 1, capacity 64 = {true}\n}" + 11^done,value="1" + diff --git a/tests/helloprettyprint/helloprettyprint.cpp b/tests/helloprettyprint/helloprettyprint.cpp new file mode 100644 index 0000000..726885d --- /dev/null +++ b/tests/helloprettyprint/helloprettyprint.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +struct A +{ + int B; + float C; + std::string D; + std::vector E; +}; + +struct A f(int p) +{ + A a; + a.B = p; + a.D = "asd"; + a.E.push_back(p > 0); + return a; +} + +int main() +{ + A a = f(1); + std::cout << a.E[0] << std::endl; + return 0; +} diff --git a/tests/helloprettyprint/project.seer b/tests/helloprettyprint/project.seer new file mode 100644 index 0000000..8756d64 --- /dev/null +++ b/tests/helloprettyprint/project.seer @@ -0,0 +1,25 @@ +{ + "seerproject": { + "executable": "helloprettyprint", + "postgdbcommands": [ + "" + ], + "pregdbcommands": [ + "# Comment the next line out to disable \"pretty printing\".", + "set pretty printer on" + ], + "startmode": { + "arguments": "", + "breakinfunction": false, + "breakinfunctionname": "", + "breakinmain": true, + "breakpointsfile": "", + "nobreak": false, + "nonstopmode": false, + "randomizestartaddress": false, + "showassemblytab": false + }, + "symbolfile": "", + "workingdirectory": "" + } +}