Skip to content

Return a SwiftArrayEmptyBufferHandler if loc points to an EmptyArray Symbol. #10920

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

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

rastogishubham
Copy link

If we have a ValueObjectSP who's storage_location points to a S_swiftEmptyArrayStorage symbol, return a SwiftArrayEmptyBufferHandler

…Symbol.

If we have a ValueObjectSP who's storage_location points to a
S_swiftEmptyArrayStorage symbol, return a SwiftArrayEmptyBufferHandler
// a SwiftArrayEmptyBufferHandler.
if (auto *symbol = addr.CalculateSymbolContextSymbol()) {
auto mangledName = symbol->GetMangled().GetMangledName().GetStringRef();
if (mangledName == "$ss19__EmptyArrayStorageCN") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be _swiftEmptyArrayStorage?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am checking the mangled name:

> xcrun swift-demangle ss19__EmptyArrayStorageCN 
$ss19__EmptyArrayStorageCN ---> type metadata for Swift.__EmptyArrayStorage

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I inspect an empty array, I see:

(lldb) v -R -T -d no-dynamic-values
(Swift.Array<main.P>) x = {
  (Swift._ArrayBuffer<main.P>) _buffer = {
    (Swift._BridgeStorage<Swift.__ContiguousArrayStorageBase>) _storage = {
      (Builtin.BridgeObject) rawValue = 0x00000001f52cd120 _swiftEmptyArrayStorage
    }
  }
}

I don't see where $ss19__EmptyArrayStorageCN comes into play. Also the PR description mentions _swiftEmptyArrayStorage but the changed code does not.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mangled name is for the type metadata for Swift.__EmptyArrayStorage.

  1. You probably want to match against Swift.__EmptyArrayStorage itself.
  2. Instead of depending on the mangling it would be better to use the helpers in SwiftDemangling.h to make sure you have the expected demangle tree for a class with the right name in STDLIB_MODULENAME.

target, process, thread, breakpoint1 = lldbutil.run_to_source_breakpoint(
self, "break here", filespec
)
self.expect("p x", substrs=["([a.P]) 0 values {}"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for tests we use frame var or expr to be explicit whether it's use expression evaluation or not.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better would be

x = self.frame().FindVariable("x")
lldbutil.check_variable(self, x, summary="0 values")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or self.assertEqual(x.GetSummary(), "0 values")


self.build()
filespec = lldb.SBFileSpec("main.swift")
target, process, thread, breakpoint1 = lldbutil.run_to_source_breakpoint(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target, process, thread, breakpoint1 = lldbutil.run_to_source_breakpoint(
lldbutil.run_to_source_breakpoint(

self.build()
filespec = lldb.SBFileSpec("main.swift")
target, process, thread, breakpoint1 = lldbutil.run_to_source_breakpoint(
self, "break here", filespec

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self, "break here", filespec
self, "break here", lldb.SBFileSpec("main.swift")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants