1 The `trace()` function sets the execution trace level of the VM. 2 3 Throws an exception if trace level argument is not a valid integer. 4 5 Returns the previously used execution trace level. 6 7 -- Testcase -- 8 {% 9 printf("Code before enabling tracing.\n"); 10 11 trace(1); 12 13 printf("Code after enabling tracing.\n"); 14 15 trace(0); 16 17 printf("Code after disabling tracing.\n"); 18 %} 19 -- End -- 20 21 -- Expect stdout -- 22 Code before enabling tracing. 23 Code after enabling tracing. 24 Code after disabling tracing. 25 -- End -- 26 27 -- Expect stderr -- 28 [-2] 1 29 [-1] "function trace(...) { [native code] }" 30 [+1] 0 31 [2;40;97m [stdin]:4 trace(1[22m);[m 32 0000001c POP 33 [-1] 0 34 0000001d LVAR {0x0} ; "printf" 35 [+1] "function printf(...) { [native code] }" 36 [2;40;97m [stdin]:6 [22mprintf("Code after enabling tracing.\n");[m 37 00000022 LOAD {0x3} ; "Code after enabling tracing.\n" 38 [+2] "Code after enabling tracing.\n" 39 [2;40;97m [stdin]:6 printf([22m"Code after enabling tracing.\n");[m 40 00000027 CALL {0x1} 41 [*] CALLFRAME[1] 42 |- stackframe 1/3 43 |- ctx null 44 [-2] "Code after enabling tracing.\n" 45 [-1] "function printf(...) { [native code] }" 46 [+1] 29 47 [2;40;97m [stdin]:6 printf("Code after enabling tracing.\n"[22m);[m 48 0000002c POP 49 [-1] 29 50 0000002d LVAR {0x2} ; "trace" 51 [+1] "function trace(...) { [native code] }" 52 [2;40;97m [stdin]:8 [22mtrace(0);[m 53 00000032 LOAD8 {0} 54 [+2] 0 55 [2;40;97m [stdin]:8 trace([22m0);[m 56 00000034 CALL {0x1} 57 [*] CALLFRAME[1] 58 |- stackframe 1/3 59 |- ctx null 60 -- End -- 61 62 63 Passing an invalid trace value throws an exception. 64 65 -- Testcase -- 66 {% 67 trace("inval"); 68 %} 69 -- End -- 70 71 -- Expect stderr -- 72 Type error: Invalid level specified 73 In line 2, byte 15: 74 75 ` trace("inval");` 76 Near here -------^ 77 78 79 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt