Add the native thread state to art SIGQUIT dumps.
Bug: 7053953
Change-Id: I9be3f828332e5bbb003644802d7770b58d8298ed
diff --git a/src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc b/src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
index 8e5bbf6..be92068 100644
--- a/src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
+++ b/src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
@@ -128,8 +128,9 @@
* think it warrants full versioning. They might be extraneous and could
* be removed from a future version.
*/
+ char native_thread_state;
int utime, stime, task_cpu;
- GetTaskStats(t->GetTid(), utime, stime, task_cpu);
+ GetTaskStats(t->GetTid(), native_thread_state, utime, stime, task_cpu);
std::vector<uint8_t>& bytes = *reinterpret_cast<std::vector<uint8_t>*>(context);
JDWP::Append4BE(bytes, t->GetThinLockId());
diff --git a/src/thread.cc b/src/thread.cc
index e3bbc4d..935b05c 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -671,12 +671,14 @@
scheduler_stats = "0 0 0";
}
+ char native_thread_state = '?';
int utime = 0;
int stime = 0;
int task_cpu = 0;
- GetTaskStats(tid, utime, stime, task_cpu);
+ GetTaskStats(tid, native_thread_state, utime, stime, task_cpu);
- os << " | schedstat=( " << scheduler_stats << " )"
+ os << " | state=" << native_thread_state
+ << " schedstat=( " << scheduler_stats << " )"
<< " utm=" << utime
<< " stm=" << stime
<< " core=" << task_cpu
diff --git a/src/utils.cc b/src/utils.cc
index 4efb177..bff1f0c 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -913,7 +913,7 @@
#endif
}
-void GetTaskStats(pid_t tid, int& utime, int& stime, int& task_cpu) {
+void GetTaskStats(pid_t tid, char& state, int& utime, int& stime, int& task_cpu) {
utime = stime = task_cpu = 0;
std::string stats;
if (!ReadFileToString(StringPrintf("/proc/self/task/%d/stat", tid), &stats)) {
@@ -924,6 +924,7 @@
// Extract the three fields we care about.
std::vector<std::string> fields;
Split(stats, ' ', fields);
+ state = fields[0][0];
utime = strtoull(fields[11].c_str(), NULL, 10);
stime = strtoull(fields[12].c_str(), NULL, 10);
task_cpu = strtoull(fields[36].c_str(), NULL, 10);
diff --git a/src/utils.h b/src/utils.h
index 7372ee2..b59f114 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -302,7 +302,7 @@
void GetThreadStack(void*& stack_base, size_t& stack_size);
// Reads data from "/proc/self/task/${tid}/stat".
-void GetTaskStats(pid_t tid, int& utime, int& stime, int& task_cpu);
+void GetTaskStats(pid_t tid, char& state, int& utime, int& stime, int& task_cpu);
// Returns the name of the scheduler group for the given thread the current process, or the empty string.
std::string GetSchedulerGroupName(pid_t tid);