Skip to content

[LLDB] static const fields of type unsigned char cannot be inspected #119101

Open
@Walnut356

Description

@Walnut356

The sample code is roughly the debuginfo layout of Rust enums, written in C++ and compiled via cl.exe. Worth pointing out that Rust uses TypeSystemClangCommon at the moment. For the enum type and non-uchar integer types, SBTypeStaticField::GetConstantValue() returns the static field's initializer value. For unsigned char it always returns an invalid SBValue

version: 19.1.1

main.cpp:

#include <stdio.h>

union enum2 {
    enum VariantNames { First, Second };
    struct Variant0 {
        struct First {
            int a;
        } value;
        const static VariantNames NAME = enum2::VariantNames::First;
        const static unsigned char DISCR_EXACT = 1; // <-- relevant value
    } variant0;

    unsigned long tag;
};

int main()
{
    enum2 val = enum2{};
    printf("Hello World!");
}

Output:

(lldb) script lldb.frame.FindVariable("val").GetType()
union enum2 {
    struct Variant0 {
        struct First {
            int a;
        };
        static const enum2::VariantNames NAME = 0;
        static const unsigned char DISCR_EXACT;
    ...
}

Output if DISCR_EXACT is changed to unsigned long long:

(lldb) script lldb.frame.FindVariable("val").GetType()
union enum2 {
    struct Variant0 {
        struct First {
            int a;
        };
        static const enum2::VariantNames NAME = 0;
        static const unsigned long long DISCR_EXACT = 1ULL;
    ...
}

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