Skip to content

[lldb] Add initial formatter for Swift Actors #10367

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

Merged

Conversation

kastiglione
Copy link

@kastiglione kastiglione commented Mar 27, 2025

Adds a synthetic formatter for Builtin.DefaultActorStorage. Each actor instance has a field named $defaultActor which has a type of DefaultActorStorage. Prior to this, that field was shown as opaque bytes. With this change, the value now has a single child, unprioritised_jobs, which represents the job queue for the actor.

This is the first of a few changes, including a summary formatter which will show which state the actor is in (ie "running", "idle", etc).

@kastiglione kastiglione requested a review from a team as a code owner March 27, 2025 22:47
@kastiglione
Copy link
Author

@swift-ci test

}

size_t GetIndexOfChildWithName(ConstString name) override {
if (m_is_supported_target && name == "unprioritised_jobs")

Choose a reason for hiding this comment

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

does ConstString::operator==(const char *) do what we expect here?

Choose a reason for hiding this comment

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

FWIW, it's probably faster to do name.GetStringRef() == "unprioritised_jobs" here unless we cache the constring lookup result.

Copy link
Author

Choose a reason for hiding this comment

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

does ConstString::operator==(const char *) do what we expect here?

I'd say yes:

  bool operator==(const char *rhs) const {
    // ConstString differentiates between empty strings and nullptr strings, but
    // StringRef doesn't. Therefore we have to do this check manually now.
    if (m_string == nullptr && rhs != nullptr)
      return false;
    if (m_string != nullptr && rhs == nullptr)
      return false;

    return GetStringRef() == rhs;
  }

eLanguageTypeSwift)) {
if (auto *ts = llvm::dyn_cast_or_null<TypeSystemSwiftTypeRef>(
ts_or_err->get()))
// TypeMangling for "Swift.UnsafeCurrentTask"

Choose a reason for hiding this comment

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

FWIW, the nice thing to do here would be to wrap this in a TypeSystemSwift::GetUnsafeCurrentTaskType() helper

Copy link
Author

Choose a reason for hiding this comment

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

agreed, should I do that as part of this PR? I plan to do some refactoring like this after the fact, but I can just as easily perform some refactorings in this PR.

Choose a reason for hiding this comment

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

Both options are fine.

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione kastiglione merged commit 23f6dc9 into stable/20240723 Mar 28, 2025
2 checks passed
@kastiglione kastiglione deleted the dl/lldb-Add-initial-formatter-for-Swift-Actors branch March 28, 2025 23:15
kastiglione added a commit that referenced this pull request Mar 31, 2025
Adds a synthetic formatter for `Builtin.DefaultActorStorage`. Each actor instance has a field named `$defaultActor` which has a type of `DefaultActorStorage`. Prior to this, that field was shown as opaque bytes. With this change, the value now has a single child, `unprioritised_jobs`, which represents the job queue for the actor.

This is the first of a few changes, including a summary formatter which will show which state the actor is in (ie "running", "idle", etc).
(cherry-picked from commit 23f6dc9)
kastiglione added a commit that referenced this pull request Mar 31, 2025
Adds a synthetic formatter for `Builtin.DefaultActorStorage`. Each actor instance has a field named `$defaultActor` which has a type of `DefaultActorStorage`. Prior to this, that field was shown as opaque bytes. With this change, the value now has a single child, `unprioritised_jobs`, which represents the job queue for the actor.

This is the first of a few changes, including a summary formatter which will show which state the actor is in (ie "running", "idle", etc).
(cherry-picked from commit 23f6dc9)
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.

2 participants