Luaj's debug library is different from the standard library #86

Closed
opened 2021-04-08 09:26:18 +00:00 by YongdongHe · 1 comment
YongdongHe commented 2021-04-08 09:26:18 +00:00 (Migrated from github.com)

debug.getInfo(0) return nil instead of msg defined in standard lib.

and when call getInfo in hook function, debug.getInfo(1) return is not the hook func self. Because callstack not execute onCall when it is running in hook funtion, as this:

// DebugLib.java
public void onCall(LuaFunction f) {
    LuaThread.State s = globals.running.state;
    // problem occurs
    if (s.inhook) return;
    callstack().onCall(f);
    if (s.hookcall) callHook(s, CALL, NIL);
}

while the standrad ref (http://www.lua.org/manual/5.2/manual.html#6.10)notes that:

debug.getinfo ([thread,] f [, what])
Returns a table with information about a function. You can give the function directly or you can give a number as the value of f, which means the function running at level f of the call stack of the given thread: level 0 is the current function (getinfo itself); level 1 is the function that called getinfo (except for tail calls, which do not count on the stack); and so on. If f is a number larger than the number of active functions, then getinfo returns nil.
The returned table can contain all the fields returned by lua_getinfo, with the string what describing which fields to fill in. The default for what is to get all information available, except the table of valid lines. If present, the option 'f' adds a field named func with the function itself. If present, the option 'L' adds a field named activelines with the table of valid lines.
For instance, the expression debug.getinfo(1,"n").name returns a table with a name for the current function, if a reasonable name can be found, and the expression debug.getinfo(print) returns a table with all available information about the print function.

debug.getInfo(0) return nil instead of msg defined in standard lib. and when call getInfo in hook function, debug.getInfo(1) return is not the hook func self. Because callstack not execute onCall when it is running in hook funtion, as this: ```java // DebugLib.java public void onCall(LuaFunction f) { LuaThread.State s = globals.running.state; // problem occurs if (s.inhook) return; callstack().onCall(f); if (s.hookcall) callHook(s, CALL, NIL); } ``` while the standrad ref (http://www.lua.org/manual/5.2/manual.html#6.10)notes that: > debug.getinfo ([thread,] f [, what]) Returns a table with information about a function. You can give the function directly or you can give a number as the value of f, which means the function running at level f of the call stack of the given thread: level 0 is the current function (getinfo itself); level 1 is the function that called getinfo (except for tail calls, which do not count on the stack); and so on. If f is a number larger than the number of active functions, then getinfo returns nil. The returned table can contain all the fields returned by lua_getinfo, with the string what describing which fields to fill in. The default for what is to get all information available, except the table of valid lines. If present, the option 'f' adds a field named func with the function itself. If present, the option 'L' adds a field named activelines with the table of valid lines. For instance, the expression debug.getinfo(1,"n").name returns a table with a name for the current function, if a reasonable name can be found, and the expression debug.getinfo(print) returns a table with all available information about the print function.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-autonomous-connection/luaj#86