@@ -74,6 +74,8 @@ local config = {
74
74
environment = nil ,
75
75
server_name = nil ,
76
76
no_detour = {},
77
+ capture_locals = true ,
78
+ capture_upvalues = false ,
77
79
}
78
80
79
81
--
@@ -407,8 +409,12 @@ local function sentrifyStack(stack)
407
409
local ret = {}
408
410
for i , frame in ipairs (stack ) do
409
411
local vars = {};
410
- formatStackVariables (frame [" upvalues" ], vars );
411
- formatStackVariables (frame [" locals" ], vars );
412
+ if (config [" capture_upvalues" ] and frame [" upvalues" ]) then
413
+ formatStackVariables (frame [" upvalues" ], vars );
414
+ end
415
+ if (config [" capture_locals" ] and frame [" locals" ]) then
416
+ formatStackVariables (frame [" locals" ], vars );
417
+ end
412
418
413
419
ret [i ] = {
414
420
filename = frame [" source" ]:sub (2 ),
@@ -434,32 +440,32 @@ local function getStack()
434
440
break ;
435
441
end
436
442
437
- local locals = {}
438
- local upvalues = {}
439
-
440
443
if (info .what == " Lua" ) then
441
- -- Capture locals
442
- local i = 1
443
- while true do
444
- local name , value = debug.getlocal (level , i );
445
- if (not isstring (name )) then break ; end
446
-
447
- if (# name > 0 and name [1 ] ~= " (" ) then -- Some locals are internal with names like "(*temporary)"
448
- locals [name ] = value == nil and NIL_REPLACEMENT or value ;
444
+ if (config [" capture_locals" ]) then
445
+ local locals = {}
446
+ local i = 1
447
+ while true do
448
+ local name , value = debug.getlocal (level , i );
449
+ if (not isstring (name )) then break ; end
450
+
451
+ if (# name > 0 and name [1 ] ~= " (" ) then -- Some locals are internal with names like "(*temporary)"
452
+ locals [name ] = value == nil and NIL_REPLACEMENT or value ;
453
+ end
454
+ i = i + 1
449
455
end
450
- i = i + 1
456
+ info . locals = locals ;
451
457
end
452
458
453
- -- Capture upvalues
454
- for j = 1 , info .nups do
455
- local name , value = debug.getupvalue (info .func , j );
456
- upvalues [name ] = value == nil and NIL_REPLACEMENT or value ;
459
+ if (config [" capture_upvalues" ]) then
460
+ local upvalues = {}
461
+ for j = 1 , info .nups do
462
+ local name , value = debug.getupvalue (info .func , j );
463
+ upvalues [name ] = value == nil and NIL_REPLACEMENT or value ;
464
+ end
465
+ info .upvalues = upvalues ;
457
466
end
458
467
end
459
468
460
- info .locals = locals ;
461
- info .upvalues = upvalues ;
462
-
463
469
stack [level - 2 ] = info ;
464
470
465
471
level = level + 1 ;
0 commit comments