Skip to content
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] Introduce command to select task "threads" #9840

Open
wants to merge 6 commits into
base: stable/20240723
Choose a base branch
from

Conversation

kastiglione
Copy link

@kastiglione kastiglione commented Jan 16, 2025

Introduce language swift task select <task>. This uses much of the work done for task backtrace, including the artificial thread class ThreadTask.

This change allows users to select a task, as though it is a thread. From there, they can run other thread commands, such as backtrace. Users can also then run frame navigation commands, such as up/down/frame select.

@kastiglione kastiglione requested a review from a team as a code owner January 16, 2025 00:20
@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

kastiglione commented Jan 16, 2025

Note this PR depends on (and contains) #9787. See 8fd2cbc for this PR's contents.

@adrian-prantl
Copy link

Shouldn't this go on the stable branch instead?

@kastiglione
Copy link
Author

Yes, I will update it shortly (I was waiting first to commit #9845)

@kastiglione kastiglione force-pushed the dl/lldb-Introduce-command-to-select-task-threads branch from 8fd2cbc to b81995b Compare January 17, 2025 22:22
@kastiglione kastiglione reopened this Jan 17, 2025
@kastiglione kastiglione changed the base branch from swift/release/6.1 to stable/20240723 January 17, 2025 22:30
@kastiglione kastiglione force-pushed the dl/lldb-Introduce-command-to-select-task-threads branch from 367ecb2 to d32d287 Compare January 17, 2025 22:31
@kastiglione
Copy link
Author

Now updated to stable.

@kastiglione
Copy link
Author

@swift-ci test

On darwin it's "0x0002" but on linux it's "2".
@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

@swift-ci test linux

1 similar comment
@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

@swift-ci test linux

1 similar comment
@kastiglione
Copy link
Author

@swift-ci test linux

frame_index = frame.idx
self.assertNotEqual(frame_index, -1)

self.expect(

Choose a reason for hiding this comment

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

I would feel better about this test if it would use the SBAPI instead of matching for the precise formatting of the frame rendering. Otherwise we'll need to update this every tome some changes the UI upstream.

Choose a reason for hiding this comment

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

something like getting the current frame from the current thread and checking SBFrame::GetFunctionName() etc ...

Copy link
Author

Choose a reason for hiding this comment

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

done

// GetStatus prints the backtrace.
thread_task.get()->GetStatus(result.GetOutputStream(), 0, UINT32_MAX, 0,
false, true);
auto &thread_list = m_exe_ctx.GetProcessRef().GetThreadList();

Choose a reason for hiding this comment

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

The Process class has a mutex to protect its thread list; should we lock it here?

Copy link
Author

Choose a reason for hiding this comment

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

Good question. The ThreadList references the processes lock. The lock is taken inside AddThread, I would say there's no need to take the lock here explicitly.

Choose a reason for hiding this comment

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

Ah, I wasn't aware that these methods were already thread-safe.
I guess the only argument for locking outside would be if these two operations need to be atomic:

   thread_list.AddThread(thread_task.get());
   thread_list.SetSelectedThreadByID(thread_task.get()->GetID())

If they don't, then no locking is needed

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

@swift-ci test

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