(lldb) Unsigned print long long in hex

I am trying to debug my Objective-C program and I need to print my variable unsigned long long in hexadecimal format. I am using the lldb debugger.

To print short as hex, you can use this :

 (lldb) type format add --format hex short (lldb) print bit (short) $11 = 0x0000 

However, I cannot get it to work for 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 

I am running an iOS application on a simulator, if that matters.

+10
source share
3 answers

type format add expects the type name as one word - you need to specify an argument if it is several words. eg.

  2 { 3 unsigned long long a = 10; -> 4 a += 5; 5 return a; 6 } (lldb) type form add -fh "unsigned long long" (lldb) pa (unsigned long long) $0 = 0x000000000000000a (lldb) 
+10
source

You can use the letter format. Link to GDB documents (works for LLDB too): https://sourceware.org/gdb/current/onlinedocs/gdb/Output-Formats.html#Output-Formats

 (lldb) pa (unsigned long long) $0 = 10 (lldb) p/xa (unsigned long long) $1 = 0x000000000000000a 
+31
source

After reading the rest of the document, I found out that you can do something like this:

 // ObjC code typedef int A; 

then

 (lldb) type format add --format hex A 

This gave me the idea of typedef unsigned long long BigInt :

 // ObjC code typedef unsigned long long BigInt; 

then

 (lldb) type format add --format hex BigInt 

It works like a charm.

+1
source

All Articles