summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc6
-rw-r--r--runtime/thread.cc4
-rw-r--r--runtime/utils.cc22
-rw-r--r--runtime/utils.h4
4 files changed, 19 insertions, 17 deletions
diff --git a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
index 13cd978..0676968 100644
--- a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
+++ b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
@@ -109,8 +109,10 @@ static void ThreadStatsGetterCallback(Thread* t, void* context) {
* be removed from a future version.
*/
char native_thread_state;
- int utime, stime, task_cpu;
- GetTaskStats(t->GetTid(), native_thread_state, utime, stime, task_cpu);
+ int utime;
+ int stime;
+ int 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/runtime/thread.cc b/runtime/thread.cc
index 558ceb4..3e413ab 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -417,7 +417,7 @@ void Thread::SetThreadName(const char* name) {
void Thread::InitStackHwm() {
void* stack_base;
size_t stack_size;
- GetThreadStack(pthread_self_, stack_base, stack_size);
+ GetThreadStack(pthread_self_, &stack_base, &stack_size);
// TODO: include this in the thread dumps; potentially useful in SIGQUIT output?
VLOG(threads) << StringPrintf("Native stack is at %p (%s)", stack_base, PrettySize(stack_size).c_str());
@@ -757,7 +757,7 @@ void Thread::DumpState(std::ostream& os, const Thread* thread, pid_t tid) {
int utime = 0;
int stime = 0;
int task_cpu = 0;
- GetTaskStats(tid, native_thread_state, utime, stime, task_cpu);
+ GetTaskStats(tid, &native_thread_state, &utime, &stime, &task_cpu);
os << " | state=" << native_thread_state
<< " schedstat=( " << scheduler_stats << " )"
diff --git a/runtime/utils.cc b/runtime/utils.cc
index dcfe8a7..ae10c76 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -79,23 +79,23 @@ std::string GetThreadName(pid_t tid) {
return result;
}
-void GetThreadStack(pthread_t thread, void*& stack_base, size_t& stack_size) {
+void GetThreadStack(pthread_t thread, void** stack_base, size_t* stack_size) {
#if defined(__APPLE__)
- stack_size = pthread_get_stacksize_np(thread);
+ *stack_size = pthread_get_stacksize_np(thread);
void* stack_addr = pthread_get_stackaddr_np(thread);
// Check whether stack_addr is the base or end of the stack.
// (On Mac OS 10.7, it's the end.)
int stack_variable;
if (stack_addr > &stack_variable) {
- stack_base = reinterpret_cast<byte*>(stack_addr) - stack_size;
+ *stack_base = reinterpret_cast<byte*>(stack_addr) - *stack_size;
} else {
- stack_base = stack_addr;
+ *stack_base = stack_addr;
}
#else
pthread_attr_t attributes;
CHECK_PTHREAD_CALL(pthread_getattr_np, (thread, &attributes), __FUNCTION__);
- CHECK_PTHREAD_CALL(pthread_attr_getstack, (&attributes, &stack_base, &stack_size), __FUNCTION__);
+ CHECK_PTHREAD_CALL(pthread_attr_getstack, (&attributes, stack_base, stack_size), __FUNCTION__);
CHECK_PTHREAD_CALL(pthread_attr_destroy, (&attributes), __FUNCTION__);
#endif
}
@@ -955,8 +955,8 @@ void SetThreadName(const char* thread_name) {
#endif
}
-void GetTaskStats(pid_t tid, char& state, int& utime, int& stime, int& task_cpu) {
- utime = stime = task_cpu = 0;
+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)) {
return;
@@ -966,10 +966,10 @@ void GetTaskStats(pid_t tid, char& state, int& utime, int& stime, int& task_cpu)
// 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);
+ *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);
}
std::string GetSchedulerGroupName(pid_t tid) {
diff --git a/runtime/utils.h b/runtime/utils.h
index c506fba..34e9459 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -323,10 +323,10 @@ pid_t GetTid();
std::string GetThreadName(pid_t tid);
// Returns details of the given thread's stack.
-void GetThreadStack(pthread_t thread, void*& stack_base, size_t& stack_size);
+void GetThreadStack(pthread_t thread, void** stack_base, size_t* stack_size);
// Reads data from "/proc/self/task/${tid}/stat".
-void GetTaskStats(pid_t tid, char& state, 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);