From 73359207e42ffde271520a6b8ebc0abb37511aaa Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Mon, 7 Nov 2022 21:18:38 +0100
Subject: [PATCH] Add example scripts

---
 gdb-port/startup_scripts/README.md           |  1 +
 gdb-port/startup_scripts/shell.sh            |  9 +++++++++
 gdb-port/startup_scripts/shell_with_exit.sh  | 11 +++++++++++
 gdb-port/startup_scripts/tests.sh            |  4 ++++
 gdb-port/startup_scripts/tests_with_shell.sh |  4 ++++
 5 files changed, 29 insertions(+)
 create mode 100644 gdb-port/startup_scripts/README.md
 create mode 100755 gdb-port/startup_scripts/shell.sh
 create mode 100755 gdb-port/startup_scripts/shell_with_exit.sh
 create mode 100755 gdb-port/startup_scripts/tests.sh
 create mode 100755 gdb-port/startup_scripts/tests_with_shell.sh

diff --git a/gdb-port/startup_scripts/README.md b/gdb-port/startup_scripts/README.md
new file mode 100644
index 0000000..6efb31b
--- /dev/null
+++ b/gdb-port/startup_scripts/README.md
@@ -0,0 +1 @@
+These scripts serve as examples of loading the hammer commands and various use cases, e.g. non-interactive use, running tests, etc. Primarily for informational purposes, and may be outdated.
diff --git a/gdb-port/startup_scripts/shell.sh b/gdb-port/startup_scripts/shell.sh
new file mode 100755
index 0000000..e32a958
--- /dev/null
+++ b/gdb-port/startup_scripts/shell.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+gdb -ex "set python print-stack full" -ex "source perf-instrumentation/gdb-port/parser.py" -ex "source perf-instrumentation/gdb-port/utility-commands.py" -ex "source perf-instrumentation/gdb-port/commands.py" -ex "source perf-instrumentation/gdb-port/hammer-breakpoints.py" -ex "source perf-instrumentation/gdb-port/ast.py" -ex "source perf-instrumentation/gdb-port/breakpoint-manager.py" -ex "source perf-instrumentation/gdb-port/top-level-parse.py" -ex "hammer-parse-stop-at-pos 50" -ex "source perf-instrumentation/gdb-port/parser-type-instrumentation-gdb.py" -ex "source perf-instrumentation/gdb-port/parser-name-instrumentation-gdb.py" \
+-ex "hammer-parse-step 7" \
+-ex "python [gdb.execute('hammer-parse-apply') for x in range(8)]" \
+--args pdf t/000143.pdf
+
+# hammer-parse-step 7 is arbitrary, but happens to get to a location in the file that's convenient for testing token printing
+
diff --git a/gdb-port/startup_scripts/shell_with_exit.sh b/gdb-port/startup_scripts/shell_with_exit.sh
new file mode 100755
index 0000000..4bd4e6e
--- /dev/null
+++ b/gdb-port/startup_scripts/shell_with_exit.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+gdb -ex "set python print-stack full" -ex "source perf-instrumentation/gdb-port/parser.py" -ex "source perf-instrumentation/gdb-port/utility-commands.py" -ex "source perf-instrumentation/gdb-port/commands.py" -ex "source perf-instrumentation/gdb-port/hammer-breakpoints.py" -ex "source perf-instrumentation/gdb-port/ast.py" -ex "source perf-instrumentation/gdb-port/breakpoint-manager.py" -ex "source perf-instrumentation/gdb-port/top-level-parse.py" -ex "hammer-parse-stop-at-pos 50" -ex "source perf-instrumentation/gdb-port/parser-type-instrumentation-gdb.py" -ex "source perf-instrumentation/gdb-port/parser-name-instrumentation-gdb.py" \
+-ex "hammer-parse-step 7" \
+-ex "python [gdb.execute('hammer-parse-apply') for x in range(8)]" \
+-ex "set confirm off" \
+-ex "q" \
+--args pdf t/000143.pdf
+
+# hammer-parse-step 7 is arbitrary, but happens to get to a location in the file that's convenient for testing token printing
+
diff --git a/gdb-port/startup_scripts/tests.sh b/gdb-port/startup_scripts/tests.sh
new file mode 100755
index 0000000..a7572a6
--- /dev/null
+++ b/gdb-port/startup_scripts/tests.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+gdb -ex "set python print-stack full" -ex "source perf-instrumentation/gdb-port/parser.py" -ex "source perf-instrumentation/gdb-port/utility-commands.py" -ex "source perf-instrumentation/gdb-port/commands.py" -ex "source perf-instrumentation/gdb-port/hammer-breakpoints.py" -ex "source perf-instrumentation/gdb-port/ast.py" -ex "source perf-instrumentation/gdb-port/breakpoint-manager.py" -ex "source perf-instrumentation/gdb-port/top-level-parse.py" -ex "hammer-parse-stop-at-pos 50" -ex "source perf-instrumentation/gdb-port/parser-type-instrumentation-gdb.py" -ex "source perf-instrumentation/gdb-port/parser-name-instrumentation-gdb.py" -ex "source perf-instrumentation/gdb-port/tests/unit/top-level-parse.py" -ex "source perf-instrumentation/gdb-port/tests/unit/breakpoint-manager.py" -ex "source perf-instrumentation/gdb-port/tests/unit/hammer-breakpoints.py" -ex "source perf-instrumentation/gdb-port/tests/unit/ast.py" -ex "source perf-instrumentation/gdb-port/tests/run_unittest_main.py" --args pdf t/000143.pdf
+
diff --git a/gdb-port/startup_scripts/tests_with_shell.sh b/gdb-port/startup_scripts/tests_with_shell.sh
new file mode 100755
index 0000000..f4992f4
--- /dev/null
+++ b/gdb-port/startup_scripts/tests_with_shell.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+gdb -ex "set python print-stack full" -ex "source perf-instrumentation/gdb-port/utility-commands.py" -ex "source perf-instrumentation/gdb-port/commands.py" -ex "source perf-instrumentation/gdb-port/hammer-breakpoints.py" -ex "source perf-instrumentation/gdb-port/ast.py" -ex "source perf-instrumentation/gdb-port/breakpoint-manager.py" -ex "source perf-instrumentation/gdb-port/top-level-parse.py" -ex "hammer-parse-stop-at-pos 50" -ex "source perf-instrumentation/gdb-port/parser-type-instrumentation-gdb.py" -ex "source perf-instrumentation/gdb-port/parser-name-instrumentation-gdb.py" -ex "source perf-instrumentation/gdb-port/tests/unit/top-level-parse.py" -ex "source perf-instrumentation/gdb-port/tests/unit/breakpoint-manager.py" -ex "source perf-instrumentation/gdb-port/tests/unit/hammer-breakpoints.py" -ex "source perf-instrumentation/gdb-port/tests/unit/ast.py" -ex "source perf-instrumentation/gdb-port/tests/run_unittest_main_noexit.py" --args pdf t/000143.pdf
+
-- 
GitLab