Skip to content

Commit ce6d651

Browse files
committed
Set thread name on Mac to make gdb thread info more useful.
1 parent f76a462 commit ce6d651

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/rt/rust_sched_driver.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ void
2222
rust_sched_driver::start_main_loop() {
2323
assert(sched_loop != NULL);
2424

25+
#ifdef __APPLE__
26+
{
27+
char buf[64];
28+
snprintf(buf, sizeof(buf), "scheduler loop %d", sched_loop->get_id());
29+
// pthread_setname_np seems to have a different signature and
30+
// different behavior on different platforms. Thus, this is
31+
// only for Mac at the moment. There are equivalent versions
32+
// for Linux that we can add if needed.
33+
pthread_setname_np(buf);
34+
}
35+
#endif
36+
2537
rust_sched_loop_state state = sched_loop_state_keep_going;
2638
while (state != sched_loop_state_exit) {
2739
DLOG(sched_loop, dom, "pumping scheduler");

src/rt/rust_sched_loop.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ struct rust_sched_loop
130130
// Called by tasks when they need a stack on which to run C code
131131
stk_seg *borrow_c_stack();
132132
void return_c_stack(stk_seg *stack);
133+
134+
int get_id() { return this->id; }
133135
};
134136

135137
inline rust_log &

0 commit comments

Comments
 (0)