如何使用 lldb 从 CLI 自动运行可执行文件?

逆向工程 数据库 命令行
2021-06-29 06:32:10

在 中gdb,我可以自动运行二进制文件(根据这篇文章):

gdb -ex run /bin/true

的等效参数是lldb什么?

这有效:

echo run | lldb /bin/true

但我想回到调试器控制台。

1个回答

LLDB >= 3.4 具有-o/--one-line命令行选项,可用于自动启动您的程序:

lldb -o run /bin/true

这里有两个相关的片段供参考lldb-3.6 --help

...
   -o 
   --one-line 
        Tells the debugger to execute this one-line lldb command
        after any file provided on the command line has been loaded.
...
  Notes:

       Multiple "-s" and "-o" options can be provided.  They will be
       processed from left to right in order, with the source files 
       and commands interleaved. 
...

为了在 Web 浏览器中查看命令行选项——这里是lldb-3.4 手册页的链接

请注意,对于 LLDB < 3.4(以及更新版本),您可以使用-s/--source选项来引导命令,例如run-- 例如:

$ echo run > autorun
$ lldb -s autorun -- /bin/echo arg1 arg2