(lldb)以十六进制打印无符号长整型

Maz*_*yod 13 debugging hex objective-c unsigned-long-long-int lldb

我正在尝试调试我的Objective-C程序,我需要以unsigned long long十六进制打印我的变量.我正在使用lldb调试器.

short以十六进制打印,您可以使用:

(lldb) type format add --format hex short
(lldb) print bit
(short) $11 = 0x0000
Run Code Online (Sandbox Code Playgroud)

但是,我无法让它发挥作用unsigned long long.

// failed attempts:
(lldb) type format add --format hex (unsigned long long)
(lldb) type format add --format hex unsigned long long
(lldb) type format add --format hex unsigned decimal
(lldb) type format add --format hex long long
(lldb) type format add --format hex long
(lldb) type format add --format hex int
Run Code Online (Sandbox Code Playgroud)

我在模拟器上运行iOS应用程序,如果这有任何区别.

Vla*_*lad 35

您可以使用格式字母.链接到GDB文档(也适用于LLDB):http://www.delorie.com/gnu/docs/gdb/gdb_55.html

(lldb) p a
(unsigned long long) $0 = 10
(lldb) p/x a
(unsigned long long) $1 = 0x000000000000000a
Run Code Online (Sandbox Code Playgroud)

  • 请注意,虽然gdb接受`p`和`/ x`之间的空格,但lldb不接受,所以`p/x`在gdb中起作用,但在lldb中它必须是'p/x`. (3认同)

Jas*_*nda 11

type format add期望类型名称为单个单词 - 如果参数是多个单词,则需要引用该参数.例如

   2    {
   3      unsigned long long a = 10;
-> 4      a += 5;
   5      return a;
   6    }
(lldb) type form add -f h "unsigned long long"
(lldb) p a
(unsigned long long) $0 = 0x000000000000000a
(lldb) 
Run Code Online (Sandbox Code Playgroud)