-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb] Add summary for NSIndirectTaggedPointerString #136025
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,12 +63,17 @@ bool lldb_private::formatters::NSStringSummaryProvider( | |
| if (class_name.empty()) | ||
| return false; | ||
|
|
||
| bool is_tagged_ptr = class_name == "NSTaggedPointerString" && | ||
| descriptor->GetTaggedPointerInfo(); | ||
| // for a tagged pointer, the descriptor has everything we need | ||
| if (is_tagged_ptr) | ||
| return NSTaggedString_SummaryProvider(valobj, descriptor, stream, | ||
| summary_options); | ||
| // for tagged pointers, the descriptor has everything needed. | ||
| bool is_tagged = descriptor->GetTaggedPointerInfo(); | ||
| if (is_tagged) { | ||
| if (class_name == "NSTaggedPointerString") | ||
| return NSTaggedString_SummaryProvider(valobj, descriptor, stream, | ||
| summary_options); | ||
|
|
||
| if (class_name == "NSIndirectTaggedPointerString") | ||
| return NSIndirectTaggedString_SummaryProvider(valobj, descriptor, stream, | ||
| summary_options); | ||
| } | ||
|
|
||
| auto &additionals_map(NSString_Additionals::GetAdditionalSummaries()); | ||
| auto iter = additionals_map.find(class_name_cs), end = additionals_map.end(); | ||
|
|
@@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( | |
| stream << suffix; | ||
| return true; | ||
| } | ||
|
|
||
| bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( | ||
| ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, | ||
| Stream &stream, const TypeSummaryOptions &summary_options) { | ||
| if (!descriptor) | ||
| return false; | ||
|
|
||
| uint64_t payload = 0; | ||
| if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) | ||
| return false; | ||
|
|
||
| // First 47 bits are the address of the contents. | ||
| addr_t ptr = payload & 0x7fffffffffffULL; | ||
| // Next 13 bits are the string's length. | ||
| size_t size = (payload >> 47) & 0x1fff; | ||
|
|
||
| Status status; | ||
| char buf[8192]; | ||
|
||
| if (auto process_sp = valobj.GetProcessSP()) | ||
| if (process_sp->ReadMemory(ptr, buf, size, status)) { | ||
| llvm::StringRef prefix, suffix; | ||
| if (auto *language = Language::FindPlugin(summary_options.GetLanguage())) | ||
| std::tie(prefix, suffix) = | ||
| language->GetFormatterPrefixSuffix("NSString"); | ||
| stream << prefix << '"'; | ||
| stream.PutCString({buf, size}); | ||
| stream << '"' << suffix; | ||
| return true; | ||
| } | ||
|
|
||
| if (status.Fail()) | ||
| stream.Format("<{0}>", status); | ||
| return false; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| OBJC_SOURCES := main.m | ||
| LD_EXTRAS := -framework Foundation | ||
| include Makefile.rules |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import lldb | ||
| from lldbsuite.test.decorators import * | ||
| from lldbsuite.test.lldbtest import * | ||
| from lldbsuite.test import lldbutil | ||
|
|
||
|
|
||
| class TestCase(TestBase): | ||
| def test(self): | ||
| """Verify summary formatter for tagged strings.""" | ||
| self.build() | ||
| lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.m")) | ||
| self.expect("v str1 str2", patterns=['@"nineDigit"', '@"tenDigitXX"']) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #import <Foundation/Foundation.h> | ||
|
|
||
| @interface NSObject (Fake) | ||
| // 9 digit selector | ||
| - (void)nineDigit; | ||
| // 10 digit selector | ||
| - (void)tenDigitXX; | ||
| @end | ||
|
|
||
| int main() { | ||
| SEL sel1 = @selector(nineDigit); | ||
| NSString *str1 = NSStringFromSelector(sel1); | ||
| SEL sel2 = @selector(tenDigitXX); | ||
| NSString *str2 = NSStringFromSelector(sel2); | ||
| NSLog(@"break here %@, %@", str1, str2); | ||
| return 0; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.