Skip to content

lldb cannot change formatting of uint8_t[35] to print as an array of integers #137468

@dmlary

Description

@dmlary

I've been fighting with this across multiple versions of lldb. I'm trying to print a uint8_t[32] as an array of unsigned integers, but it keeps printing as a binary string. What follows is all the different ways I tried manually setting the format manually to dwim-print, and using type format add. Regardless of what I do, the variable is always formatted as a binary string.

# uint8_t PatternIndex[6][35] = {...}
(lldb) dwim-print -f int8_t[] -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) dwim-print -f a -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) dwim-print -f A -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) type format clear
(lldb) dwim-print -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) dwim-print -f b -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) dwim-print -f x -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) dwim-print -f uint8_t[] -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) dwim-print -f int -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) dwim-print -f E -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) type format add --format int uint8_t
(lldb) dwim-print -- PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"
(lldb) type format info PatternIndex[1]
no format applies to (const uint8_t[35]) PatternIndex[1]
(lldb) type format add --format int uint8_t[35]
(lldb) type format info PatternIndex[1]
format applied to (const uint8_t[35]) PatternIndex[1] is: int8_t[]
(lldb) p PatternIndex[1]
(const uint8_t[35]) "\0\U00000001\b\U0000001b\"\a\U00000002\U00000003\U00000004\U00000005\U00000006\U0000000e\t\n\v\f\r!\U0000001c\U0000001d\U0000001e\U0000001f \U00000019\U0000001a\U0000000f\U00000010\U00000011\U00000012\U00000013\U00000014\U00000015\U00000016\U00000017\U00000018"

LLDB versions tested:

  • lldb version 20.1.3
  • lldb-1600.0.39.10 (Apple clang)

Anyone got a suggestion how to just print it as an array of integer values?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions