-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Call the OS function to set the main thread's name on program init #97191
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
(rust-highfive has picked a reviewer for you, use r? to override) |
This looks reasonable to me and I confirmed it worked. It would be good to add a test for it but I can see that would be awkward considering it's inherently platform-specific and I'm pretty sure the |
Could probably do it via debuginfo-style tests |
b55e054
to
7f4d65d
Compare
Good idea! I've added a debuginfo test. |
Since most of the libs team have a lot on their plate atm and I'm already invested here... r? @ChrisDenton |
7f4d65d
to
d8990a7
Compare
This comment has been minimized.
This comment has been minimized.
d8990a7
to
79ea288
Compare
This comment has been minimized.
This comment has been minimized.
Normally, `Thread::spawn` takes care of setting the thread's name, if one was provided, but since the main thread wasn't created by calling `Thread::spawn`, we need to call that function in `std::rt::init`. This is mainly useful for system tools like debuggers and profilers which might show the thread name to a user. Prior to these changes, gdb and WinDbg would show all thread names except the main thread's name to a user. I've validated that this patch resolves the issue for both debuggers.
79ea288
to
820ffc8
Compare
@bors r+ |
📌 Commit 820ffc8 has been approved by |
⌛ Testing commit 820ffc8 with merge 32cac736087efb4919a56641d90152aac6b4ca2b... |
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit 7cb538b has been approved by |
…isDenton Call the OS function to set the main thread's name on program init Normally, `Thread::spawn` takes care of setting the thread's name, if one was provided, but since the main thread wasn't created by calling `Thread::spawn`, we need to call that function in `std::rt::init`. This is mainly useful for system tools like debuggers and profilers which might show the thread name to a user. Prior to these changes, gdb and WinDbg would show all thread names except the main thread's name to a user. I've validated that this patch resolves the issue for both debuggers.
Failed in rollup: #97727 (comment) |
Co-authored-by: Chris Denton <ChrisDenton@users.noreply.github.com>
7cb538b
to
cb87ce2
Compare
Added |
@bors r+ |
📌 Commit cb87ce2 has been approved by |
☀️ Test successful - checks-actions |
Tested on commit rust-lang/rust@4e725ba. Direct link to PR: <rust-lang/rust#97191> 💔 miri on windows: test-pass → test-fail (cc @oli-obk @RalfJung @eddyb).
Finished benchmarking commit (4e725ba): comparison url. Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
Normally,
Thread::spawn
takes care of setting the thread's name, ifone was provided, but since the main thread wasn't created by calling
Thread::spawn
, we need to call that function instd::rt::init
.This is mainly useful for system tools like debuggers and profilers
which might show the thread name to a user. Prior to these changes, gdb
and WinDbg would show all thread names except the main thread's name to
a user. I've validated that this patch resolves the issue for both
debuggers.