debugging - 将字符和不可打印的值作为参数传递到 LLDB
问题描述
使用 lldb,如何将包含十六进制字符的长字符串作为命令行参数传递?一些十六进制字符可能是不可打印的。
(lldb) setting set target.run-args "AAAA\\x66\\x6f\\x6f"
(lldb) settings show target.run-args
target.run-args (array of strings) =
[0]: "AAAA\x66\x6f\x6f"
// when I want it to read: "AAAAfoo"
在 gdb 中我可以使用echo -n -e 'AAAA\x66\x6f\x6f'
.
解决方案
我找到了答案。如果发送到的目标参数lldb
是:
string 1: "AAAABBBBCCCCDDDDEEEEFFFF" appended with 0x00000e30
string 2: "GGGGYYYYZZZZ"
使用printf
而不是echo
以下工作:
B=$(printf "AAAABBBBCCCCDDDDEEEEFFFF\x30\x0e\x00\x00")
lldb my_c_program $B "GGGGYYYYZZZZ"
这是有趣的一点。
(lldb) settings show target.run-args
target.run-args (array of strings) =
[0]: "AAAABBBBCCCCDDDDEEEEFFFF0"
[1]: "GGGGYYYYZZZZ"
由于您有不可打印的字符,很容易认为 lldb 没有收到这些字符。事实并非如此。如果您lldb) run
甚至正确传递了不可打印的字符。
推荐阅读
- python - 无法在 python SQLAlchemy 中执行多处理
- vba - 如何将格式化段落从 Word 2013 复制到 Excel?
- mysql - 自动化 Toad Edge 查询以运行并通过电子邮件发送结果
- java - new WordDocument() com.independentsoft 的异常
- firebase - 查询对象的firestore数组
- angular - 如何在`ngFor`循环中添加`checkbox`
- python-3.x - Python导入差异
- javascript - AngularJS ng-repeat 不显示我的数据
- c++ - 将little endian的位转换并屏蔽为big endian
- java - 如何在 createContents 函数之外编辑标签?