Set thread name on Mac to make gdb thread info more useful.

This commit is contained in:
Eric Holk 2012-08-02 14:42:12 -07:00
parent f76a46242b
commit ce6d6511c7
2 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,18 @@ void
rust_sched_driver::start_main_loop() {
assert(sched_loop != NULL);
#ifdef __APPLE__
{
char buf[64];
snprintf(buf, sizeof(buf), "scheduler loop %d", sched_loop->get_id());
// pthread_setname_np seems to have a different signature and
// different behavior on different platforms. Thus, this is
// only for Mac at the moment. There are equivalent versions
// for Linux that we can add if needed.
pthread_setname_np(buf);
}
#endif
rust_sched_loop_state state = sched_loop_state_keep_going;
while (state != sched_loop_state_exit) {
DLOG(sched_loop, dom, "pumping scheduler");

View File

@ -130,6 +130,8 @@ public:
// Called by tasks when they need a stack on which to run C code
stk_seg *borrow_c_stack();
void return_c_stack(stk_seg *stack);
int get_id() { return this->id; }
};
inline rust_log &