WheretIB / LuaDkmDebugger

Visual Studio C++ debugger extensions for Lua
MIT License
81 stars 32 forks source link

Although the example you provided last time can be debugged. But I still can't debug it myself. #10

Open brinkqiang opened 3 years ago

brinkqiang commented 3 years ago

Case address: https://github.com/brinkqiang/dmlua

This example is more complicated and should be able to cover many usage conditions. If this example can be debugged, many examples will be debugged.

More special points.

  1. Directory problem, the debug directory structure is as follows. path

The compiled exe is in the Debug directory, and the script is loaded as the upper-level directory of the exe.

  1. Calling method The calling method in C++ is as follows. CRole* poRole = CRoleMgr::Instance()->CreateRole(); poRole->SetName("andy"); poRole->SetHp(9999); poRole->SetMp(9999); unsigned int dwTaskID = 100; LResultINT oResult(-1); oDMLuaEngine.Call("script.task.task.AcceptTask", poRole, dwTaskID, &oResult);

  2. seeall The seeall attribute is set in the script. I don't know if it will affect it.

module (..., package.seeall)

dmlua_debug

Your help is very much needed.

brinkqiang commented 3 years ago

-- lua script module (..., package.seeall)

function AcceptTask(role, taskid, ret) print("==================================") print("Player Name = " .. role:GetName()) print("PlayerID = " .. role:GetObjID()) print("AcceptTask taskid = " .. taskid)

if role:AcceptTask(taskid) then
    ret.value = 0
    print("AcceptTask ret = " .. math.ceil(ret.value))
else
    ret.value = -1
    print("AcceptTask ret = " .. math.ceil(ret.value))
end

print("###################################")

end

function FinishTask(role, taskid) print("==================================") print("Player Name = " .. role:GetName()) print("FinishTask taskid = " .. taskid) print("==================================") role:FinishTask(taskid) end

WheretIB commented 3 years ago

I will try to debug your example project to find the issue.

WheretIB commented 3 years ago

I've improved file path search in the extension, but script names in your application (for example, .\script\task\task.lua) cannot be found relative the the executable (in .\bin\Debug) or relative to the launch working directory (.\build)

In the upcoming v0.9.6 update, you can use 'Show Script list' menu item to see the issue: image

You should add lua_dkm_debug.json file with additional search path, for example:

{
  "ScriptPaths": [
    "../bin/"
  ]
}

The debugger will then be able to link scripts to files: image

brinkqiang commented 3 years ago

Hello, the problem has been solved. Thank you very much.

I still have a small question here. Can this be customized globally for the search path? Just don’t use each Each project is to set the way to retrieve the path.

In addition, if the plug-in can obtain the search path of Lua, wouldn't it be more convenient. Because as long as it can be compiled and run, the Lua file can definitely be retrieved. Of course, I may not know the details of the implementation. It is for reference only.