{"id":21071619,"url":"https://github.com/esrrhs/dlua","last_synced_at":"2025-05-16T05:31:44.202Z","repository":{"id":87695492,"uuid":"314764798","full_name":"esrrhs/dLua","owner":"esrrhs","description":"类似gdb的lua调试器。Lua debugger like gdb","archived":false,"fork":false,"pushed_at":"2023-02-23T11:21:02.000Z","size":65,"stargazers_count":45,"open_issues_count":0,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T20:51:17.639Z","etag":null,"topics":["debugging","lua"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/esrrhs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-21T08:15:54.000Z","updated_at":"2025-03-06T01:03:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ba350de-3c5c-4d19-bac1-3143fd84bd38","html_url":"https://github.com/esrrhs/dLua","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esrrhs%2FdLua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esrrhs%2FdLua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esrrhs%2FdLua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esrrhs%2FdLua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esrrhs","download_url":"https://codeload.github.com/esrrhs/dLua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254474296,"owners_count":22077260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debugging","lua"],"created_at":"2024-11-19T18:53:46.483Z","updated_at":"2025-05-16T05:31:44.196Z","avatar_url":"https://github.com/esrrhs.png","language":"C++","readme":"# dLua\r\n\r\n[\u003cimg src=\"https://img.shields.io/github/license/esrrhs/dLua\"\u003e](https://github.com/esrrhs/dLua)\r\n[\u003cimg src=\"https://img.shields.io/github/languages/top/esrrhs/dLua\"\u003e](https://github.com/esrrhs/dLua)\r\n[\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/esrrhs/dLua/cmake.yml?branch=master\"\u003e](https://github.com/esrrhs/dLua/actions)\r\n\r\n类似gdb的lua调试器\r\n\r\n# 特性\r\n* 支持Linux平台\r\n* C++编写\r\n* 通过附加到其他进程上，进行调试\r\n* gdb风格的调试指令，包括设置条件断点、查看变量、设置变量\r\n\r\n# 编译\r\n* 下载编译安装[lua](https://www.lua.org/download.html)\r\n* 用脚本编译dlua，生成```dlua```与```dluaagent.so```，```dlua```是控制台，```dluaagent.so```是调试插件\r\n```\r\n# ./build.sh\r\n```\r\n* 下载编译[hookso](https://github.com/esrrhs/hookso)，生成```hookso```，```hookso```是注入工具\r\n* 最后将```dlua```、```dluaagent.so```、```hookso```放在同级目录即可使用\r\n\r\n# 使用\r\n* 找到目标进程pid，也可以使用项目中的示例代码。假设pid=1234\r\n```\r\n# lua test.lua\r\n```\r\n\r\n* 运行dlua，附加到1234进程，出现如下提示，说明连接正常，可以开始调试\r\n```\r\n# ./dlua 1234\r\nattack to 1234 ok, use ctrl+c to input command, eg: h\r\n```\r\n\r\n* 输入ctrl+c，输入h回车查看帮助\r\n```\r\n(dlua) h\r\nh       help commands\r\nq       quit\r\nbt      show cur call stack\r\nb       add breakpoint, eg: b test.lua:123\r\ni       show info, eg: i b\r\nn       step next line\r\ns       step into next line\r\nc       continue run\r\ndis     disable breakpoint, eg: dis 1\r\nen      enable breakpoint, eg: en 1\r\nd       delete breakpoint, eg: d 1\r\np       print exp value, eg: p _G.xxx\r\nl       list code\r\nf       select stack frame\r\nfin     finish current call\r\nset     set value, eg: set aa=1\r\nr       run code, eg: r print(\"test\")\r\n```\r\n\r\n* 其他命令同理，输入ctrl+c，输入命令即可\r\n```\r\n(dlua) bt\r\n0 in string_time_to_unix_time at test.lua:23\r\n1 in ? at test.lua:50\r\n2 in ? at [C]:-1\r\n```\r\n\r\n* 退出，则输入q\r\n```\r\n(dlua) q\r\n#\r\n```\r\n\r\n# 命令\r\n### h\r\n帮助\r\n### q\r\n退出\r\n### bt\r\n查看调用堆栈\r\n### b\r\n打断点，打在某个文件某一行\r\n```\r\nb test.lua:34\r\n```\r\n打在当前文件的某一行\r\n```\r\nb 34\r\n```\r\n打在当前正执行到的行\r\n```\r\nb \r\n```\r\n打在某个函数的入口\r\n```\r\nb string_time_to_unix_time_with_tz\r\n```\r\n打在某个嵌套函数的入口\r\n```\r\nb _G.test.getweekstart_by_tz_test\r\n```\r\n条件断点，方括号的tz表示需要的参数，作为输入参与到后面的表达式计算\r\n```\r\nb string_time_to_unix_time_with_tz if [tz] tz==800\r\n```\r\n### i\r\n罗列当前的断点\r\n```\r\ni b\r\n``` \r\n### n\r\n下一行，如果当前位置是函数，则跳过内部\r\n### s\r\n下一行，如果当前位置是函数，则跳进内部\r\n### c\r\n取消步进，继续执行\r\n### dis\r\n取消断点，取消某个断点\r\n```\r\ndis 1\r\n```\r\n取消所有断点\r\n```\r\ndis\r\n```\r\n### en\r\n生效断点，生效某个断点\r\n```\r\nen 1\r\n```\r\n生效所有断点\r\n```\r\nen\r\n```\r\n### d\r\n删除断点，删除某个断点\r\n```\r\nd 1\r\n```\r\n删除所有断点\r\n```\r\nd\r\n```\r\n### p\r\n查看当前栈的变量，如\r\n```\r\np year\r\n```\r\n或者全局的\r\n```\r\np _G.test\r\n```\r\n或者复杂的，查看table中的某一项，[]表示需要传入的变量，作为输入参与到后面的表达式计算\r\n```\r\np [tmp] tmp.abc\r\n```\r\n### l\r\n查看当前栈的附近代码，如\r\n```\r\nl\r\n```\r\n查看附近20行的代码\r\n```\r\nl 20\r\n```\r\n### f\r\n设置当前栈帧，具体编号从bt查看，如\r\n```\r\nf 0\r\n```\r\n### fin\r\n跳过执行当前函数\r\n### set\r\n设置当前栈的变量，如\r\n```\r\nset year=1234\r\n```\r\n或者全局的\r\n```\r\nset _G.test = 123\r\n```\r\n或者复杂的，设置table中的某一项，[]表示需要传入的变量，作为输入参与到后面的表达式计算\r\n```\r\nset [tmp] tmp.abc = 1\r\n```\r\n### r\r\n运行特定代码\r\n```\r\nr print(123)\r\n```\r\n运行复杂代码，加上变量，[]表示需要传入的变量，作为输入参与到后面的表达式计算\r\n```\r\nr [tmp] tmp[1]=2\r\n```\r\n\r\n## 其他\r\n[lua全家桶](https://github.com/esrrhs/lua-family-bucket)\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesrrhs%2Fdlua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesrrhs%2Fdlua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesrrhs%2Fdlua/lists"}