dovecot-2.0-pigeonhole: Variables extension: added proper trace ...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sat Jun 19 18:36:23 EEST 2010
details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/1ce19ab1379e
changeset: 1297:1ce19ab1379e
user: Stephan Bosch <stephan at rename-it.nl>
date: Sat Jun 19 17:36:18 2010 +0200
description:
Variables extension: added proper trace support.
diffstat:
src/lib-sieve/plugins/include/cmd-global.c | 31 +-
src/lib-sieve/plugins/include/ext-include-binary.c | 14 +-
src/lib-sieve/plugins/include/ext-include-binary.h | 2 +-
src/lib-sieve/plugins/include/ext-include-common.c | 58 ++-
src/lib-sieve/plugins/include/ext-include-variables.c | 81 +---
src/lib-sieve/plugins/include/ext-include-variables.h | 8 +-
src/lib-sieve/plugins/variables/cmd-set.c | 19 +-
src/lib-sieve/plugins/variables/ext-variables-common.c | 313 ++++++++++++++++----
src/lib-sieve/plugins/variables/ext-variables-common.h | 2 +-
src/lib-sieve/plugins/variables/ext-variables-dump.c | 45 +--
src/lib-sieve/plugins/variables/ext-variables-operands.c | 28 +-
src/lib-sieve/plugins/variables/sieve-ext-variables.h | 58 +++-
src/lib-sieve/sieve-runtime-trace.h | 8 +
13 files changed, 438 insertions(+), 229 deletions(-)
diffs (truncated from 1340 to 300 lines):
diff -r 84a0495b9b50 -r 1ce19ab1379e src/lib-sieve/plugins/include/cmd-global.c
--- a/src/lib-sieve/plugins/include/cmd-global.c Sat Jun 19 13:07:10 2010 +0200
+++ b/src/lib-sieve/plugins/include/cmd-global.c Sat Jun 19 17:36:18 2010 +0200
@@ -241,7 +241,8 @@
{
const struct sieve_extension *this_ext = denv->oprtn->ext;
unsigned int count, i, var_count;
- struct sieve_variable_scope *scope;
+ struct sieve_variable_scope_binary *global_vars;
+ struct sieve_variable_scope *global_scope;
struct sieve_variable * const *vars;
if ( !sieve_binary_read_unsigned(denv->sblock, address, &count) )
@@ -249,8 +250,9 @@
sieve_code_dumpf(denv, "GLOBAL (count: %u):", count);
- scope = ext_include_binary_get_global_scope(this_ext, denv->sbin);
- vars = sieve_variable_scope_get_variables(scope, &var_count);
+ global_vars = ext_include_binary_get_global_scope(this_ext, denv->sbin);
+ global_scope = sieve_variable_scope_binary_get(global_vars);
+ vars = sieve_variable_scope_get_variables(global_scope, &var_count);
sieve_code_descend(denv);
@@ -262,7 +264,7 @@
index >= var_count )
return FALSE;
- sieve_code_dumpf(denv, "VAR[%d]: '%s'", index, vars[index]->identifier);
+ sieve_code_dumpf(denv, "%d: VAR[%d]: '%s'", i, index, vars[index]->identifier);
}
return TRUE;
@@ -276,18 +278,21 @@
(const struct sieve_runtime_env *renv, sieve_size_t *address)
{
const struct sieve_extension *this_ext = renv->oprtn->ext;
- struct sieve_variable_scope *scope;
+ struct sieve_variable_scope_binary *global_vars;
+ struct sieve_variable_scope *global_scope;
struct sieve_variable_storage *storage;
struct sieve_variable * const *vars;
unsigned int var_count, count, i;
if ( !sieve_binary_read_unsigned(renv->sblock, address, &count) ) {
- sieve_runtime_trace_error(renv, "invalid count operand");
+ sieve_runtime_trace_error(renv,
+ "global: count operand invalid");
return SIEVE_EXEC_BIN_CORRUPT;
}
- scope = ext_include_binary_get_global_scope(this_ext, renv->sbin);
- vars = sieve_variable_scope_get_variables(scope, &var_count);
+ global_vars = ext_include_binary_get_global_scope(this_ext, renv->sbin);
+ global_scope = sieve_variable_scope_binary_get(global_vars);
+ vars = sieve_variable_scope_get_variables(global_scope, &var_count);
storage = ext_include_interpreter_get_global_variables
(this_ext, renv->interp);
@@ -295,19 +300,21 @@
unsigned int index;
if ( !sieve_binary_read_unsigned(renv->sblock, address, &index) ) {
- sieve_runtime_trace_error(renv, "invalid global variable operand");
+ sieve_runtime_trace_error(renv,
+ "global: variable index operand invalid");
return SIEVE_EXEC_BIN_CORRUPT;
}
if ( index >= var_count ) {
- sieve_runtime_trace_error(renv, "invalid global variable index (%u > %u)",
+ sieve_runtime_trace_error(renv,
+ "global: variable index %u is invalid in global storage (> %u)",
index, var_count);
return SIEVE_EXEC_BIN_CORRUPT;
}
sieve_runtime_trace(renv, SIEVE_TRLVL_COMMANDS,
- "exporting global variable '%s' (index: %u)", vars[index]->identifier,
- index);
+ "global: exporting variable '%s' [gvid: %u, vid: %u]",
+ vars[index]->identifier, i, index);
/* Make sure variable is initialized (export) */
(void)sieve_variable_get_modifiable(storage, index, NULL);
diff -r 84a0495b9b50 -r 1ce19ab1379e src/lib-sieve/plugins/include/ext-include-binary.c
--- a/src/lib-sieve/plugins/include/ext-include-binary.c Sat Jun 19 13:07:10 2010 +0200
+++ b/src/lib-sieve/plugins/include/ext-include-binary.c Sat Jun 19 17:36:18 2010 +0200
@@ -55,7 +55,7 @@
struct hash_table *included_scripts;
ARRAY_DEFINE(include_index, struct ext_include_script_info *);
- struct sieve_variable_scope *global_vars;
+ struct sieve_variable_scope_binary *global_vars;
};
@@ -107,8 +107,9 @@
sieve_binary_extension_create_block(sbin, this_ext);
if ( ctx->global_vars == NULL ) {
- ctx->global_vars = ast_ctx->global_vars;
- sieve_variable_scope_ref(ctx->global_vars);
+ ctx->global_vars =
+ sieve_variable_scope_binary_create(ast_ctx->global_vars);
+ sieve_variable_scope_binary_ref(ctx->global_vars);
}
return ctx;
@@ -186,7 +187,7 @@
* Variables
*/
-struct sieve_variable_scope *ext_include_binary_get_global_scope
+struct sieve_variable_scope_binary *ext_include_binary_get_global_scope
(const struct sieve_extension *this_ext, struct sieve_binary *sbin)
{
struct ext_include_binary_context *binctx =
@@ -364,7 +365,7 @@
hash_table_destroy(&binctx->included_scripts);
if ( binctx->global_vars != NULL )
- sieve_variable_scope_unref(&binctx->global_vars);
+ sieve_variable_scope_binary_unref(&binctx->global_vars);
}
/*
@@ -418,7 +419,8 @@
struct ext_include_context *ectx = ext_include_get_context(ext);
sieve_ext_variables_dump_set_scope
- (ectx->var_ext, denv, ext, binctx->global_vars);
+ (ectx->var_ext, denv, ext,
+ sieve_variable_scope_binary_get(binctx->global_vars));
return TRUE;
}
diff -r 84a0495b9b50 -r 1ce19ab1379e src/lib-sieve/plugins/include/ext-include-binary.h
--- a/src/lib-sieve/plugins/include/ext-include-binary.h Sat Jun 19 13:07:10 2010 +0200
+++ b/src/lib-sieve/plugins/include/ext-include-binary.h Sat Jun 19 17:36:18 2010 +0200
@@ -22,7 +22,7 @@
* Variables
*/
-struct sieve_variable_scope *ext_include_binary_get_global_scope
+struct sieve_variable_scope_binary *ext_include_binary_get_global_scope
(const struct sieve_extension *this_ext, struct sieve_binary *sbin);
/*
diff -r 84a0495b9b50 -r 1ce19ab1379e src/lib-sieve/plugins/include/ext-include-common.c
--- a/src/lib-sieve/plugins/include/ext-include-common.c Sat Jun 19 13:07:10 2010 +0200
+++ b/src/lib-sieve/plugins/include/ext-include-common.c Sat Jun 19 17:36:18 2010 +0200
@@ -45,7 +45,8 @@
struct ext_include_interpreter_global {
ARRAY_DEFINE(included_scripts, struct sieve_script *);
- struct sieve_variable_storage *variables;
+ struct sieve_variable_scope_binary *var_scope;
+ struct sieve_variable_storage *var_storage;
};
struct ext_include_interpreter_context {
@@ -272,20 +273,23 @@
struct ext_include_interpreter_context *ctx =
(struct ext_include_interpreter_context *) context;
struct ext_include_context *ectx = ext_include_get_context(this_ext);
+
if ( ctx->parent == NULL ) {
ctx->global = p_new(ctx->pool, struct ext_include_interpreter_global, 1);
p_array_init(&ctx->global->included_scripts, ctx->pool, 10);
- ctx->global->variables = sieve_variable_storage_create
- (ctx->pool, ext_include_binary_get_global_scope(this_ext, renv->sbin), 0);
+ ctx->global->var_scope =
+ ext_include_binary_get_global_scope(this_ext, renv->sbin);
+ ctx->global->var_storage =
+ sieve_variable_storage_create(ctx->pool, ctx->global->var_scope);
} else {
ctx->global = ctx->parent->global;
}
- sieve_ext_variables_set_storage
- (ectx->var_ext, renv->interp, ctx->global->variables, this_ext);
+ sieve_ext_variables_runtime_set_storage
+ (ectx->var_ext, renv, this_ext, ctx->global->var_storage);
}
static struct sieve_interpreter_extension include_interpreter_extension = {
@@ -372,7 +376,7 @@
struct ext_include_interpreter_context *ctx =
ext_include_get_interpreter_context(this_ext, interp);
- return ctx->global->variables;
+ return ctx->global->var_storage;
}
/*
@@ -551,7 +555,8 @@
/* Check for invalid include id (== corrupt binary) */
included = ext_include_binary_script_get_included(binctx, include_id);
if ( included == NULL ) {
- sieve_runtime_trace_error(renv, "invalid include id: %d", include_id);
+ sieve_runtime_trace_error(renv, "include: include id %d is invalid",
+ include_id);
return SIEVE_EXEC_BIN_CORRUPT;
}
@@ -562,13 +567,13 @@
/* If :once modifier is specified, check for duplicate include */
if ( ext_include_runtime_include_mark(ctx, included, once) ) {
sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
- "include script '%s' (id: %d, block: %d) STARTED ::",
+ "include: start script '%s' [inc id: %d, block: %d]",
sieve_script_name(included->script), include_id, block_id);
} else {
/* skip */
sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
- "include script '%s' (id: %d, block: %d); "
- "SKIPPED, because already run once",
+ "include: skipped include for script '%s' [inc id: %d, block: %d]; "
+ "already run once",
sieve_script_name(included->script), include_id, block_id);
return result;
}
@@ -578,8 +583,8 @@
*/
if ( ext_include_runtime_check_circular(ctx, included) ) {
sieve_runtime_trace_error(renv,
- "circular include for script: %s [%d]",
- sieve_script_name(included->script), block_id);
+ "include: circular include of script '%s' [inc id: %d, block: %d]",
+ sieve_script_name(included->script), include_id, block_id);
/* Situation has no valid way to emerge at runtime */
return SIEVE_EXEC_BIN_CORRUPT;
@@ -622,18 +627,19 @@
if ( ( (interrupted && curctx->returned) || (!interrupted) ) &&
curctx->parent != NULL ) {
+ const struct ext_include_script_info *ended_script =
+ curctx->script_info;
/* Sub-interpreter ended or executed return */
-
- sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
- "included script '%s' (id: %d, block: %d) ENDED ::",
- sieve_script_name(curctx->script_info->script),
- curctx->script_info->id,
- sieve_binary_block_get_id(curctx->script_info->block));
/* Ascend interpreter stack */
curctx = curctx->parent;
sieve_interpreter_free(&subinterp);
+
+ sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
+ "include: script '%s' ended [inc id: %d, block: %d]",
+ sieve_script_name(ended_script->script), ended_script->id,
+ sieve_binary_block_get_id(ended_script->block));
/* This is the top-most sub-interpreter, bail out */
if ( curctx->parent == NULL ) break;
@@ -679,22 +685,23 @@
}
}
}
- } else {
- sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
- "included script '%s' (id: %d, block: %d) ENDED ::",
- sieve_script_name(curctx->script_info->script),
- curctx->script_info->id,
- sieve_binary_block_get_id(curctx->script_info->block));
}
/* Free any sub-interpreters that might still be active */
while ( curctx != NULL && curctx->parent != NULL ) {
struct ext_include_interpreter_context *nextctx = curctx->parent;
struct sieve_interpreter *killed_interp = curctx->interp;
+ const struct ext_include_script_info *ended_script =
+ curctx->script_info;
/* This kills curctx too */
sieve_interpreter_free(&killed_interp);
+ sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
+ "include: script '%s' ended [id: %d, block: %d]",
+ sieve_script_name(ended_script->script),
+ ended_script->id, sieve_binary_block_get_id(ended_script->block));
+
/* Luckily we recorded the parent earlier */
curctx = nextctx;
}
@@ -716,7 +723,8 @@
struct ext_include_interpreter_context *ctx =
ext_include_get_interpreter_context(this_ext, renv->interp);
- sieve_runtime_trace(renv, SIEVE_TRLVL_COMMANDS, "return");
+ sieve_runtime_trace(renv, SIEVE_TRLVL_COMMANDS,
More information about the dovecot-cvs
mailing list