diff --git a/doc/chibi-scheme.1 b/doc/chibi-scheme.1 index f2eaf5db..f6123921 100644 --- a/doc/chibi-scheme.1 +++ b/doc/chibi-scheme.1 @@ -28,6 +28,9 @@ chibi-scheme \- a tiny Scheme interpreter [-p .I expr ] +[-t +.I module.id +] [-d .I image-file ] @@ -171,6 +174,12 @@ Evaluates the Scheme expression .I expr then prints the result to stdout. .TP +.BI -t module.id +Enables tracing for the given identifier +.I id +in the module +.I module. +.TP .BI -d image-file Dumps the current Scheme heap to .I image-file diff --git a/main.c b/main.c index f6a0d641..98462501 100644 --- a/main.c +++ b/main.c @@ -529,6 +529,21 @@ void run_main (int argc, char **argv) { case 's': init_context(); sexp_global(ctx, SEXP_G_STRICT_P) = SEXP_TRUE; break; + case 't': + mods_loaded = 1; + load_init(0); + arg = ((argv[i][2] == '\0') ? argv[++i] : argv[i]+2); + suffix = strrchr(arg, '.'); + sym = sexp_intern(ctx, suffix + 1, -1); + *(char*)suffix = '\0'; + impmod = make_import(sexp_environment_prefix, arg, sexp_environment_suffix); + tmp = check_exception(ctx, sexp_eval_string(ctx, impmod, -1, sexp_meta_env(ctx))); + free(impmod); + sym = sexp_list1(ctx, sexp_env_cell(ctx, tmp, sym, 0)); + tmp = check_exception(ctx, sexp_eval_string(ctx, "(environment '(chibi trace))", -1, sexp_meta_env(ctx))); + tmp = sexp_env_ref(ctx, tmp, sexp_intern(ctx, "trace-cell", -1), 0); + check_exception(ctx, sexp_apply(ctx, tmp, sym)); + break; default: fprintf(stderr, "unknown option: %s\n", argv[i]); /* ... FALLTHROUGH ... */