Giter Club home page Giter Club logo

dlua's Introduction

dLua

类似gdb的lua调试器

特性

  • 支持Linux平台
  • C++编写
  • 通过附加到其他进程上,进行调试
  • gdb风格的调试指令,包括设置条件断点、查看变量、设置变量

编译

  • 下载编译安装lua
  • 用脚本编译dlua,生成dluadluaagent.sodlua是控制台,dluaagent.so是调试插件
# ./build.sh
  • 下载编译hookso,生成hooksohookso是注入工具
  • 最后将dluadluaagent.sohookso放在同级目录即可使用

使用

  • 找到目标进程pid,也可以使用项目中的示例代码。假设pid=1234
# lua test.lua
  • 运行dlua,附加到1234进程,出现如下提示,说明连接正常,可以开始调试
# ./dlua 1234
attack to 1234 ok, use ctrl+c to input command, eg: h
  • 输入ctrl+c,输入h回车查看帮助
(dlua) h
h       help commands
q       quit
bt      show cur call stack
b       add breakpoint, eg: b test.lua:123
i       show info, eg: i b
n       step next line
s       step into next line
c       continue run
dis     disable breakpoint, eg: dis 1
en      enable breakpoint, eg: en 1
d       delete breakpoint, eg: d 1
p       print exp value, eg: p _G.xxx
l       list code
f       select stack frame
fin     finish current call
set     set value, eg: set aa=1
r       run code, eg: r print("test")
  • 其他命令同理,输入ctrl+c,输入命令即可
(dlua) bt
0 in string_time_to_unix_time at test.lua:23
1 in ? at test.lua:50
2 in ? at [C]:-1
  • 退出,则输入q
(dlua) q
#

命令

h

帮助

q

退出

bt

查看调用堆栈

b

打断点,打在某个文件某一行

b test.lua:34

打在当前文件的某一行

b 34

打在当前正执行到的行

b 

打在某个函数的入口

b string_time_to_unix_time_with_tz

打在某个嵌套函数的入口

b _G.test.getweekstart_by_tz_test

条件断点,方括号的tz表示需要的参数,作为输入参与到后面的表达式计算

b string_time_to_unix_time_with_tz if [tz] tz==800

i

罗列当前的断点

i b

n

下一行,如果当前位置是函数,则跳过内部

s

下一行,如果当前位置是函数,则跳进内部

c

取消步进,继续执行

dis

取消断点,取消某个断点

dis 1

取消所有断点

dis

en

生效断点,生效某个断点

en 1

生效所有断点

en

d

删除断点,删除某个断点

d 1

删除所有断点

d

p

查看当前栈的变量,如

p year

或者全局的

p _G.test

或者复杂的,查看table中的某一项,[]表示需要传入的变量,作为输入参与到后面的表达式计算

p [tmp] tmp.abc

l

查看当前栈的附近代码,如

l

查看附近20行的代码

l 20

f

设置当前栈帧,具体编号从bt查看,如

f 0

fin

跳过执行当前函数

set

设置当前栈的变量,如

set year=1234

r

运行特定代码

r print(123)

运行复杂代码,加上变量,[]表示需要传入的变量,作为输入参与到后面的表达式计算

r [tmp] tmp[1]=2

其他

lua全家桶

dlua's People

Contributors

esrrhs avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.