【问题标题】:Passing characters and non-printable values into LLDB as arguments将字符和不可打印的值作为参数传递到 LLDB
【发布时间】:2018-10-01 16:46:12
【问题描述】:

使用 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'

【问题讨论】:

    标签: debugging gdb lldb


    【解决方案1】:

    我找到了答案。如果发送到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,即使是不可打印的字符也可以正确传递。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-15
      • 1970-01-01
      • 1970-01-01
      • 2017-10-30
      • 2015-07-31
      • 1970-01-01
      相关资源
      最近更新 更多