-
Notifications
You must be signed in to change notification settings - Fork 344
[lldb] Add parent address to Task synthetic provider #10936
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
base: swift/release/6.2
Are you sure you want to change the base?
[lldb] Add parent address to Task synthetic provider #10936
Conversation
@swift-ci test |
parent_addr = process_sp->ReadPointerFromMemory( | ||
m_task_ptr + ChildFragmentOffset, status); | ||
if (status.Fail() || parent_addr == LLDB_INVALID_ADDRESS) | ||
parent_addr = 0; |
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.
is this really what we want to do here? When the task has no parent, does the runtime write a 0 to its slot, or do we expect an error?
If the runtime is explicitly writing a 0 and we don't expect the memory read to fail, I think we can just return nullptr
here.
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.
For the case of a parent-less task, should we try to customize the formatter output to say something "root task" or "no parent", instead of 0s?
I think 0s could give users the impression that the debugger failed to get the value
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.
When the task has no parent, does the runtime write a 0 to its slot
A swift Task can have tail allocated "fragments", including a ChildFragment
. Child tasks have a ChildFragment
, while root tasks do not.
One way to model that is to make the existence of a parent
conditional. In other words, for a root task, no parent
member will be shown at all. The reason I didn't do that is:
- Users might find it confusing (why is there a
parent
some times, but not other times) - It makes the synthetic child provider more complex (which is fine if we have good reason)
For the case of a parent-less task, should we try to customize the formatter output to say something "root task" or "no parent", instead of 0s?
The parent
member needs a data type, which currently is UnsafeRawPointer
. To show a task-specific string like "root task", we'd need to use some other data type, one we invent ourselves. This adds complexity, and will be exposed to users who might wonder "what's a LLDBParentTaskPointer?".
We could put a string like "root task" into Task's summary formatter. In which case the parent = 0x0000...
would be accompanied with "root task" in the summary string, which should explain the parent address.
On this subject, one of the questions I have for reviewers is the name of this member. I used parent
, but felt like make it should be parent_addr
. The main reason I didn't do that is the provider has an address
field, and I didn't like the inconsistency of using address
and addr
, and I didn't like the verbose choice of parent_address
. Maybe we can rename address
to addr
, and then use parent_addr
. Thoughts? I think including addr
in the name might make it more clear that a bunch of zeros means root task/no parent.
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.
A swift Task can have tail allocated "fragments", including a
ChildFragment
. Child tasks have aChildFragment
, while root tasks do not.
I misspoke. A root task will of course have a ChildFragment
if it has children.
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.
Adrian's suggestion is to have the parent's type be UnsafeRawPointer?
, and will show nil
when there's no parent. Works for me, what do you think Felipe?
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.
yup that sounds good to me!
@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.
lgtm! excited to see this merged!
@swift-ci test |
Display the address of a Task's parent (or 0x0000000 for root tasks).
Exposing a Task's parent will allow:
task info <addr>
)task backtrace <addr>
)task select <addr>
)rdar://147851193