Browse code

Allow controlling trace level from cmdline.

Török Edvin authored on 2009/12/10 22:17:40
Showing 2 changed files
... ...
@@ -47,6 +47,8 @@ static void help(void)
47 47
     printf("clambc <file> [function] [param1 ...]\n\n");
48 48
     printf("    --help                 -h         Show help\n");
49 49
     printf("    --version              -V         Show version\n");
50
+    printf("    --trace <level>                   Set bytecode trace level 0..7 (default 7)\n");
51
+    printf("    --no-trace-showsource             Don't show source line during tracing\n");
50 52
     printf("    file                              file to test\n");
51 53
     printf("\n");
52 54
     return;
... ...
@@ -120,6 +122,7 @@ int main(int argc, char *argv[])
120 120
     unsigned funcid=0, i;
121 121
     struct cli_all_bc bcs;
122 122
     unsigned int fd = -1;
123
+    unsigned tracelevel;
123 124
 
124 125
     opts = optparse(NULL, argc, argv, 1, OPT_CLAMBC, 0, NULL);
125 126
     if (!opts) {
... ...
@@ -203,8 +206,9 @@ int main(int argc, char *argv[])
203 203
     dbg_state.file = "<libclamav>";
204 204
     dbg_state.line = 0;
205 205
     dbg_state.col = 0;
206
-    dbg_state.showline = 1;
207
-    cli_bytecode_context_set_trace(ctx, trace_val,
206
+    dbg_state.showline = !optget(opts, "no-trace-showsource")->enabled;
207
+    tracelevel = optget(opts, "trace")->numarg;
208
+    cli_bytecode_context_set_trace(ctx, tracelevel,
208 209
 				   tracehook,
209 210
 				   tracehook_op,
210 211
 				   tracehook_val);
... ...
@@ -121,6 +121,8 @@ const struct clam_option __clam_options[] = {
121 121
 
122 122
     { NULL, "force-interpreter", 'f', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Force using the interpreter instead of the JIT", "" },
123 123
     { NULL, "input", 'i', TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMBC, "Input file to run the bytecode n", ""},
124
+    { NULL, "trace", 't', TYPE_NUMBER, MATCH_NUMBER, 7, NULL, 0, OPT_CLAMBC, "bytecode trace level",""},
125
+    { NULL, "no-trace-showsource", 's', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Don't show source line during tracing",""},
124 126
 
125 127
     /* cmdline only - deprecated */
126 128
     { NULL, "http-proxy", 0, TYPE_STRING, NULL, 0, NULL, 0, OPT_FRESHCLAM | OPT_DEPRECATED, "", "" },