First commit

This commit is contained in:
Dorian Wouters 2016-08-01 15:24:05 +02:00
commit 5194081791
No known key found for this signature in database
GPG Key ID: 6E9DA8063322434B
4 changed files with 64 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "StackTracePlus"]
path = StackTracePlus
url = https://github.com/ignacio/StackTracePlus.git

31
README.md Normal file
View File

@ -0,0 +1,31 @@
# StackTracePlus Minetest mod
StackTracePlus is a Lua module that extends `debug.traceback` to include more
call frame information such as local and globals, locals and parameters
dumps.
This mod merely plugs this module in and replaces `debug.traceback` with
StackTracePlus's traceback dump routine.
# Installing
This repository uses git submodules.
Clone this repo either recursively (`--recursive`) or as usual, but make sure
to `git submodule update --init` afterwards; it must go into the `mods`
directory.
## Mod security
This mod modifies the global `debug` table which is not accessible by normal
mods when mod security is enabled.
If you have enabled mod security (`secure.enable_security` is `true`), then you
must whitelist this mod in `minetest.conf`'s `secure.trusted_mods` config
entry.
# License
WTFPL / CC0 / Public Domain.
StackTracePlus is distributed under the MIT license.

1
StackTracePlus Submodule

@ -0,0 +1 @@
Subproject commit 9b4aef95854ad0cf549850cee6dbd0fef5a82bf6

29
init.lua Normal file
View File

@ -0,0 +1,29 @@
local secenv = _G
local modname = minetest.get_current_modname()
local sec = (minetest.setting_get('secure.enable_security') == 'true')
local ie
if sec then
ie = minetest.request_insecure_environment()
if ie == nil then
error("Mod security is on but " .. modname .. " is not whitelisted as a secure mod")
end
end
if sec then
string, io, debug, coroutine = ie.string, ie.io, ie.debug, ie.coroutine
end
local STP = dofile(minetest.get_modpath(modname) .. '/StackTracePlus/src/StackTracePlus.lua')
-- Remove string/table dump length limits
STP.max_tb_output_len = math.huge
if sec then
ie.debug.traceback = STP.stacktrace
-- StackTracePlus caches the following modules, reset them to the original ones to
-- avoid leaking them
string, io, debug, coroutine = secenv.string, secenv.io, secenv.debug, secenv.coroutine
ie = nil
end
debug.traceback = STP.stacktrace
minetest.log('action', "[" .. modname .. "] replaced debug.traceback")