-
Notifications
You must be signed in to change notification settings - Fork 342
[lldb] Add Substring type summary #5559
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
[lldb] Add Substring type summary #5559
Conversation
@swift-ci test |
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I just have a couple of questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be a nice improvement!
@swift-ci test |
uint64_t buffer[2] = {raw0, raw1}; | ||
uint64_t rawBuffer[2] = {raw0, raw1}; | ||
auto *buffer = (uint8_t *)&rawBuffer; | ||
applySlice(buffer, count, slice); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong but AFAIU this is technically UB. I don't think any compiler will break this kind of type punning but the recommended way of reading a type through a uint8_t*
is using memcpy
.
The standard doesn't technically permit doing pointer arithmetic on something that isn't pointer-interconvertible. Chances are memcpy
will get optimised away into exactly the same code that reinterpret_cast
produces because memcpy
is compiler magic.
Replace hex literals with binary literals to improve bit masking readability. Follow up to #5559.
Adds a type summary for `Substring` values. With this change, a summary string shows the substring slice. The substring's children show the base string, and start/end indexes. ``` (lldb) v substring (Substring) substring = "bcdefghijklmnopqrstuvwxy" { _slice = { _startIndex = 1[utf8] _endIndex = 25[utf8] _base = "abcdefghijklmnopqrstuvwxyz" } } ``` Before this change, a literal substring was not shown, only the full base string: ``` (lldb) v substring (Substring) substring = { _slice = { _startIndex = 1[utf8] _endIndex = 25[utf8] _base = "abcdefghijklmnopqrstuvwxyz" } } ``` #### Implementation Notes This supports Swift native (utf8) strings. NSString (utf16) are not yet supported, that will be a follow up change. Additionally, this change requires that the indexes be matching encoding. rdar://91431816 (cherry picked from commit a514263)
Adds a type summary for `Substring` values. With this change, a summary string shows the substring slice. The substring's children show the base string, and start/end indexes. ``` (lldb) v substring (Substring) substring = "bcdefghijklmnopqrstuvwxy" { _slice = { _startIndex = 1[utf8] _endIndex = 25[utf8] _base = "abcdefghijklmnopqrstuvwxyz" } } ``` Before this change, a literal substring was not shown, only the full base string: ``` (lldb) v substring (Substring) substring = { _slice = { _startIndex = 1[utf8] _endIndex = 25[utf8] _base = "abcdefghijklmnopqrstuvwxyz" } } ``` #### Implementation Notes This supports Swift native (utf8) strings. NSString (utf16) are not yet supported, that will be a follow up change. Additionally, this change requires that the indexes be matching encoding. rdar://91431816 (cherry picked from commit a514263)
Adds a type summary for `Substring` values. With this change, a summary string shows the substring slice. The substring's children show the base string, and start/end indexes. ``` (lldb) v substring (Substring) substring = "bcdefghijklmnopqrstuvwxy" { _slice = { _startIndex = 1[utf8] _endIndex = 25[utf8] _base = "abcdefghijklmnopqrstuvwxyz" } } ``` Before this change, a literal substring was not shown, only the full base string: ``` (lldb) v substring (Substring) substring = { _slice = { _startIndex = 1[utf8] _endIndex = 25[utf8] _base = "abcdefghijklmnopqrstuvwxyz" } } ``` #### Implementation Notes This supports Swift native (utf8) strings. NSString (utf16) are not yet supported, that will be a follow up change. Additionally, this change requires that the indexes be matching encoding. rdar://91431816 (cherry picked from commit a514263)
Adds a type summary for
Substring
values.With this change, a summary string shows the substring slice. The substring's children show the base string, and start/end indexes.
Before this change, a literal substring was not shown, only the full base string:
Implementation Notes
This supports Swift native (utf8) strings. NSString (utf16) are not yet supported, that will be a follow up change. Additionally, this change requires that the indexes be matching encoding.
rdar://91431816