Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support debug information for 64-bit or unsigned enums #14081

Merged

Conversation

HertzDevil
Copy link
Contributor

Previously, Crystal assumed all enums are 32-bit and signed when emitting debug information:

enum SignedEnum : Int64
  X = 0x0123_4567_89ab_cdef_i64
end

enum UnsignedEnum : UInt64
  Y = 0xfedc_ba98_7654_3210_u64
end

x = SignedEnum::X
y = UnsignedEnum::Y
debugger
(lldb) p x
(SignedEnum) 81985529216486895
(lldb) p y
(UnsignedEnum) 18364758544493064720
(lldb) p (int64_t)SignedEnum::X
(int64_t) -1985229329
(lldb) p (uint64_t)UnsignedEnum::Y
(uint64_t) 1985229328

Support for 64-bit or unsigned values is present in all LLVM versions we support. This PR leverages that:

(lldb) p x
(SignedEnum) X
(lldb) p y
(UnsignedEnum) Y
(lldb) p (int64_t)SignedEnum::X
(int64_t) 81985529216486895
(lldb) p (uint64_t)UnsignedEnum::Y
(uint64_t) 18364758544493064720

Enum values larger than 64 bits require LLVM 11, plus a corresponding C API.

@straight-shoota straight-shoota added this to the 1.11.0 milestone Dec 11, 2023
@straight-shoota straight-shoota merged commit 8942394 into crystal-lang:master Dec 13, 2023
55 checks passed
@HertzDevil HertzDevil deleted the feature/debug-large-enum branch December 13, 2023 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants