|
|
|
|
Re: how to debug like the tool "decoda"? [message #1416739 is a reply to message #1416737] |
Tue, 13 November 2012 17:45 |
Guangcheng Huang Messages: 9 Registered: May 2012 |
Junior Member |
|
|
1, My lua file is:
-- t.lua
function L_add(x, y)
return x + y
end
2, My C++ program file is:
// test.cpp
#include <stdio.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <lua.h> // lua是用纯c语言写的
#include <lualib.h>
#include <lauxlib.h>
#ifdef __cplusplus
}
#endif /* __cplusplus */
lua_State* L = NULL;
int Add(int x, int y)
{
int savedTop = lua_gettop(L);
int sum = 0;
lua_getglobal(L, "L_add"); // 'L_add' is the function defined in file 't.lua'
lua_pushnumber(L, x); // the first argument
lua_pushnumber(L, y); // the second argument
lua_call(L, 2, 1); // call the function with 2 arguments, return 1 result
sum = (int) lua_tonumber(L, -1);
lua_pop(L, 1);
lua_settop(L, savedTop);
return sum;
}
int main(int argc, char* argv[])
{
L = luaL_newstate();
if (!L)
{
return -1;
}
luaL_dofile(L, "t.lua");
while (true)
{
int sum = Add(10, 15);
printf("The sum is %d\n", sum);
//sleep(1);
}
lua_close(L);
return 0;
}
3, In the C++ program, it calls lua function 'L_add'. Now I want to use koneki/ldt to debug it. I toggle a breakpoint in 'L_add' function and start the C++ program. I expect the breakpoint will be hit when 'L_add' is called in the C++ program. I really confused how to do that even after I read the manual you give. Would you please tell me step by step? Thank you very much!
By addition, I advise you write your manual by runnable example otherwise by spoon-feeding. Welcome to use my code snippet here!
(PS. some diagrams in the manual mismatch the 0.9 milestone executable version itself)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04860 seconds