aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpgscm/scheme.h
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-11-18 09:58:18 +0000
committerJustus Winter <[email protected]>2016-12-08 16:15:20 +0000
commit404e8a4136bbbab39df7dd5119841e131998cc15 (patch)
treeb4376ddd421de49fbff9b3bb379e2a1b1e114e46 /tests/gpgscm/scheme.h
parentgpgscm: Add flag TAIL_CONTEXT. (diff)
downloadgnupg-404e8a4136bbbab39df7dd5119841e131998cc15.tar.gz
gnupg-404e8a4136bbbab39df7dd5119841e131998cc15.zip
gpgscm: Keep a history of calls for error messages.
* tests/gpgscm/init.scm (vm-history-print): New function. * tests/gpgscm/opdefines.h: New opcodes 'CALLSTACK_POP', 'APPLY_CODE', and 'VM_HISTORY'. * tests/gpgscm/scheme-private.h (struct history): New definition. (struct scheme): New field 'history'. * tests/gpgscm/scheme.c (gc): Mark objects in the history. (history_free): New function. (history_init): Likewise. (history_mark): Likewise. (add_mod): New macro. (sub_mod): Likewise. (tailstack_clear): New function. (callstack_pop): Likewise. (callstack_push): Likewise. (tailstack_push): Likewise. (tailstack_flatten): Likewise. (callstack_flatten): Likewise. (history_flatten): Likewise. (opexe_0): New variable 'callsite', keep track of the expression if it is a call, implement the new opcodes, record function applications in the history. (opexe_6): Implement new opcode. (scheme_init_custom_alloc): Initialize history. (scheme_deinit): Free history. * tests/gpgscm/scheme.h (USE_HISTORY): New macro. -- This patch makes TinySCHEME keep a history of function calls. This history can be used to produce helpful error messages. The history data structure is inspired by MIT/GNU Scheme. Signed-off-by: Justus Winter <[email protected]> fu history
Diffstat (limited to '')
-rw-r--r--tests/gpgscm/scheme.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/gpgscm/scheme.h b/tests/gpgscm/scheme.h
index 5e7d90d90..8560f7d9d 100644
--- a/tests/gpgscm/scheme.h
+++ b/tests/gpgscm/scheme.h
@@ -45,6 +45,7 @@ extern "C" {
# define USE_PLIST 0
# define USE_SMALL_INTEGERS 0
# define USE_TAGS 0
+# define USE_HISTORY 0
#endif
@@ -82,6 +83,12 @@ extern "C" {
# define USE_TAGS 1
#endif
+/* Keep a history of function calls. This enables a feature similar
+ * to stack traces. */
+#ifndef USE_HISTORY
+# define USE_HISTORY 1
+#endif
+
/* To force system errors through user-defined error handling (see *error-hook*) */
#ifndef USE_ERROR_HOOK
# define USE_ERROR_HOOK 1