"InitGoogle"-style argv stashing.
This lets us give the command line in crash dumps when dex2oat dies in the
continuous build on the Mac. I've also taken the opportunity to use the
basename of argv[0] as the default log tag, so dex2oat will now show up in
logcat as "dex2oat" instead of "art" (and we can probably stop manually
prefixing dex2oat log output).
Also stash pthread_self() so we can _correctly_ report "handle=" in the
SIGQUIT output.
Change-Id: Ia8249cd19bab5b816cb94a531a65becdfacaa98b
diff --git a/src/thread.cc b/src/thread.cc
index d854c3b..e1764ef 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -250,6 +250,7 @@
CHECK(runtime != NULL);
thin_lock_id_ = runtime->GetThreadList()->AllocThreadId();
+ pthread_self_ = pthread_self();
InitTid();
InitStackHwm();
@@ -457,10 +458,6 @@
priority = GetNativePriority();
}
- int policy;
- sched_param sp;
- CHECK_PTHREAD_CALL(pthread_getschedparam, (pthread_self(), &policy, &sp), __FUNCTION__);
-
std::string scheduler_group_name(GetSchedulerGroupName(tid));
if (scheduler_group_name.empty()) {
scheduler_group_name = "default";
@@ -483,7 +480,6 @@
}
os << '"' << thread_name << '"'
<< " prio=" << priority
- << " tid=?"
<< " (not attached)\n";
}
@@ -494,12 +490,18 @@
<< " obj=" << reinterpret_cast<void*>(thread->peer_)
<< " self=" << reinterpret_cast<const void*>(thread) << "\n";
}
+
os << " | sysTid=" << tid
<< " nice=" << getpriority(PRIO_PROCESS, tid)
- << " sched=" << policy << "/" << sp.sched_priority
- << " cgrp=" << scheduler_group_name << "\n";
-
- // TODO: fix this; it's never worked in art! << " handle=" << pthread_self() << "\n";
+ << " cgrp=" << scheduler_group_name;
+ if (thread != NULL) {
+ int policy;
+ sched_param sp;
+ CHECK_PTHREAD_CALL(pthread_getschedparam, (thread->pthread_self_, &policy, &sp), __FUNCTION__);
+ os << " sched=" << policy << "/" << sp.sched_priority
+ << " handle=" << reinterpret_cast<void*>(thread->pthread_self_);
+ }
+ os << "\n";
// Grab the scheduler stats for this thread.
std::string scheduler_stats;