Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit 5194081

Browse files
committed
First commit
0 parents  commit 5194081

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "StackTracePlus"]
2+
path = StackTracePlus
3+
url = https://github.com/ignacio/StackTracePlus.git

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# StackTracePlus Minetest mod
2+
3+
StackTracePlus is a Lua module that extends `debug.traceback` to include more
4+
call frame information such as local and globals, locals and parameters
5+
dumps.
6+
7+
This mod merely plugs this module in and replaces `debug.traceback` with
8+
StackTracePlus's traceback dump routine.
9+
10+
# Installing
11+
12+
This repository uses git submodules.
13+
14+
Clone this repo either recursively (`--recursive`) or as usual, but make sure
15+
to `git submodule update --init` afterwards; it must go into the `mods`
16+
directory.
17+
18+
## Mod security
19+
20+
This mod modifies the global `debug` table which is not accessible by normal
21+
mods when mod security is enabled.
22+
23+
If you have enabled mod security (`secure.enable_security` is `true`), then you
24+
must whitelist this mod in `minetest.conf`'s `secure.trusted_mods` config
25+
entry.
26+
27+
# License
28+
29+
WTFPL / CC0 / Public Domain.
30+
31+
StackTracePlus is distributed under the MIT license.

StackTracePlus

Submodule StackTracePlus added at 9b4aef9

init.lua

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
local secenv = _G
2+
local modname = minetest.get_current_modname()
3+
local sec = (minetest.setting_get('secure.enable_security') == 'true')
4+
local ie
5+
if sec then
6+
ie = minetest.request_insecure_environment()
7+
if ie == nil then
8+
error("Mod security is on but " .. modname .. " is not whitelisted as a secure mod")
9+
end
10+
end
11+
12+
if sec then
13+
string, io, debug, coroutine = ie.string, ie.io, ie.debug, ie.coroutine
14+
end
15+
16+
local STP = dofile(minetest.get_modpath(modname) .. '/StackTracePlus/src/StackTracePlus.lua')
17+
-- Remove string/table dump length limits
18+
STP.max_tb_output_len = math.huge
19+
20+
if sec then
21+
ie.debug.traceback = STP.stacktrace
22+
-- StackTracePlus caches the following modules, reset them to the original ones to
23+
-- avoid leaking them
24+
string, io, debug, coroutine = secenv.string, secenv.io, secenv.debug, secenv.coroutine
25+
ie = nil
26+
end
27+
debug.traceback = STP.stacktrace
28+
29+
minetest.log('action', "[" .. modname .. "] replaced debug.traceback")

0 commit comments

Comments
 (0)