SuicidalSTDz / EnderAPI

An API by the people, for the people
suicidalstdz.github.io/EnderAPI
3 stars 1 forks source link

Debugging API #11

Open skwerlman opened 10 years ago

skwerlman commented 10 years ago

This is a reminder so I remember to write this API, and also for ideas on how to implement some of the more complex features.

See: http://www.lua.org/manual/5.1/manual.html#5.9 http://www.lua.org/pil/23.html

A couple things will likely never be implemented: debug.debug() - It's an interactive prompt, and has no real use in CC debug.getregistry() - While we /could/ implement this, it has no use since we're not a C/++ application.

dmarcuse commented 10 years ago

how would tracebacks work? injecting a call every single function or something?

skwerlman commented 10 years ago

I considered wrapping all executed code, but it looks kinda impractical, and we'd have to emulate CraftOS.

dmarcuse commented 10 years ago

So then no tracebacks? Injecting a function call between every other function call to log something into a table could work, but it would be slow and clunky...

skwerlman commented 10 years ago

There's always the possibility of just catching the errors, and attempting to look through the source to find where the error was, then trying to follow that line, etc., until we reach something that's entirely native. It won't slow down the code until it errors, but it just sounds really hard to write.

skwerlman commented 10 years ago

Actually, I was just looking at the description at http://www.lua.org/manual/5.1/manual.html#5.9, and based on how hooks work, if we want this to function, it looks like we'll have to wrap the code...

dmarcuse commented 10 years ago

Some features likely won't be possible at all with a pure-lua debug API. I can't imagine how hard it would be to get hooks working properly with accurate delays.

EngineerCoding commented 10 years ago

To wrap code overwrite loadstring, see my comment here: https://github.com/SuicidalSTDz/EnderAPI/commit/90780b9b084b6cc0af710abe931d920ba8e076c6