Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

断点调试支持查看带__pairs元方法的userdata的成员变量,例如UE4的UObject,UStruct #48

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions Debugger/LuaPanda.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ function this.createWatchedVariableInfo(variableName, variableIns)
xpcall(function() var.value = tostring(variableIns) end , function() var.value = tostring(type(variableIns)) .. " [value can't trans to string]" end );
var.variablesReference = "0"; --这个地方必须用“0”, 以免variableRefTab[0]出错

if var.type == "table" or var.type == "function" then
if var.type == "table" or var.type == "function" or var.type == "userdata" then
var.variablesReference = variableRefIdx;
variableRefTab[variableRefIdx] = variableIns;
variableRefIdx = variableRefIdx + 1;
Expand Down Expand Up @@ -2296,7 +2296,7 @@ function this.getVariableRef( refStr )
var.type = tostring(type(v));
xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .. " [value can't trans to string]" end );
var.variablesReference = "0";
if var.type == "table" or var.type == "function" then
if var.type == "table" or var.type == "function" or var.type == "userdata" then
var.variablesReference = variableRefIdx;
variableRefTab[variableRefIdx] = v;
variableRefIdx = variableRefIdx + 1;
Expand Down Expand Up @@ -2336,6 +2336,28 @@ function this.getVariableRef( refStr )
variableRefTab[variableRefIdx] = udMtTable;
variableRefIdx = variableRefIdx + 1;
table.insert(varTab, var);

if udMtTable.__pairs ~= nil and type(udMtTable.__pairs) == "function" then
for n,v in pairs(variableRefTab[varRef]) do
local var = {};
var.name = tostring(n);
var.type = tostring(type(v));
xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .. " [value can't trans to string]" end );
var.variablesReference = "0";
if var.type == "table" or var.type == "function" or var.type == "userdata" then
var.variablesReference = variableRefIdx;
variableRefTab[variableRefIdx] = v;
variableRefIdx = variableRefIdx + 1;
if var.type == "table" then
local memberNum = this.getTableMemberNum(v);
var.value = memberNum .." Members ".. ( var.value or '' );
end
elseif var.type == "string" then
var.value = '"' ..v.. '"';
end
table.insert(varTab, var);
end
end
end
end
return varTab;
Expand All @@ -2352,7 +2374,7 @@ function this.getGlobalVariable( ... )
var.type = tostring(type(v));
xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .." [value can't trans to string]" end );
var.variablesReference = "0";
if var.type == "table" or var.type == "function" then
if var.type == "table" or var.type == "function" or var.type == "userdata" then
var.variablesReference = variableRefIdx;
variableRefTab[variableRefIdx] = v;
variableRefIdx = variableRefIdx + 1;
Expand Down Expand Up @@ -2395,7 +2417,7 @@ function this.getUpValueVariable( checkFunc , isFormatVariable)

if isGetValue == false then
xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .. " [value can't trans to string]" end );
if var.type == "table" or var.type == "function" then
if var.type == "table" or var.type == "function" or var.type == "userdata" then
var.variablesReference = variableRefIdx;
variableRefTab[variableRefIdx] = v;
variableRefIdx = variableRefIdx + 1;
Expand Down Expand Up @@ -2457,7 +2479,7 @@ function this.getVariable( checkLayer, isFormatVariable , offset)

if isGetValue == false then
xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .. " [value can't trans to string]" end );
if var.type == "table" or var.type == "function" then
if var.type == "table" or var.type == "function" or var.type == "userdata" then
var.variablesReference = variableRefIdx;
variableRefTab[variableRefIdx] = v;
variableRefIdx = variableRefIdx + 1;
Expand Down Expand Up @@ -2530,7 +2552,7 @@ function this.processExp(msgTable)
var.type = tostring(type(retString));
xpcall(function() var.value = tostring(retString) end , function(e) var.value = tostring(type(retString)) .. " [value can't trans to string] ".. e; var.isSuccess = false; end);
var.variablesReference = "0";
if var.type == "table" or var.type == "function" then
if var.type == "table" or var.type == "function" or var.type == "userdata" then
variableRefTab[variableRefIdx] = retString;
var.variablesReference = variableRefIdx;
variableRefIdx = variableRefIdx + 1;
Expand Down Expand Up @@ -2575,7 +2597,7 @@ function this.processWatchedExp(msgTable)
xpcall(function() var.value = tostring(retString) end , function() var.value = tostring(type(retString)) .. " [value can't trans to string]"; var.isSuccess = "false"; end );
var.variablesReference = "0";

if var.type == "table" or var.type == "function" then
if var.type == "table" or var.type == "function" or var.type == "userdata" then
variableRefTab[variableRefIdx] = retString;
var.variablesReference = variableRefIdx;
variableRefIdx = variableRefIdx + 1;
Expand Down