diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-20 09:21:20 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-05-20 09:21:20 -0700 |
commit | faba7ee37b15cd01594c6cd7ab2ff54651da3593 (patch) | |
tree | df8b994d26e36ee113b7c35e222f071636d0921f /emulator | |
parent | 4d0c73f186563e16df2fa39655a7ca3019fe5653 (diff) | |
parent | 928eec90cf2362db71b8e4aa3c7e86ba576962b1 (diff) | |
download | sdk-faba7ee37b15cd01594c6cd7ab2ff54651da3593.zip sdk-faba7ee37b15cd01594c6cd7ab2ff54651da3593.tar.gz sdk-faba7ee37b15cd01594c6cd7ab2ff54651da3593.tar.bz2 |
am b260872e: Merge change 2024 into donut
Merge commit 'b260872ea4ab52286e1abfa4e79d12feb3d46253'
* commit 'b260872ea4ab52286e1abfa4e79d12feb3d46253':
Add support for native (JNI) calls to the trace tools.
Diffstat (limited to 'emulator')
-rw-r--r-- | emulator/qtools/check_stack.cpp | 38 | ||||
-rw-r--r-- | emulator/qtools/profile_pid.cpp | 5 | ||||
-rw-r--r-- | emulator/qtools/read_method.cpp | 15 | ||||
-rw-r--r-- | emulator/qtools/stack_dump.cpp | 28 |
4 files changed, 67 insertions, 19 deletions
diff --git a/emulator/qtools/check_stack.cpp b/emulator/qtools/check_stack.cpp index b95890c..b4d14d3 100644 --- a/emulator/qtools/check_stack.cpp +++ b/emulator/qtools/check_stack.cpp @@ -32,11 +32,13 @@ struct frame { uint64_t time; uint32_t addr; const char *name; + bool isNative; - frame(uint64_t time, uint32_t addr, const char *name) { + frame(uint64_t time, uint32_t addr, const char *name, bool isNative) { this->time = time; this->addr = addr; this->name = name; + this->isNative = isNative; } }; @@ -125,9 +127,11 @@ int main(int argc, char **argv) mStacks[proc->pid] = mStack; } - if (method_record.flags == 0) { + int flags = method_record.flags; + if (flags == kMethodEnter || flags == kNativeEnter) { pframe = new frame(method_record.time, method_record.addr, - sym == NULL ? NULL: sym->name); + sym == NULL ? NULL: sym->name, + method_record.flags == kNativeEnter); mStack->push(pframe); } else { pframe = mStack->pop(); @@ -171,12 +175,22 @@ int main(int argc, char **argv) void compareStacks(uint64_t time, int pid) { CallStackType *eStack = eStacks[pid]; Stack *mStack = mStacks[pid]; + frame **mFrames = mStack->frames; frame *mframe; int mTop = mStack->top; int eTop = eStack->mTop; CallStackType::frame_type *eFrames = eStack->mFrames; + // Count the number of non-native methods (ie, Java methods) on the + // Java method stack + int numNonNativeMethods = 0; + for (int ii = 0; ii < mTop; ++ii) { + if (!mFrames[ii]->isNative) { + numNonNativeMethods += 1; + } + } + // Count the number of Java methods on the native stack int numMethods = 0; for (int ii = 0; ii < eTop; ++ii) { @@ -188,9 +202,9 @@ void compareStacks(uint64_t time, int pid) { // Verify that the number of Java methods on both stacks are the same. // Allow the native stack to have one less Java method because the // native stack might be pushing a native function first. - if (mTop != numMethods && mTop != numMethods + 1) { - printf("\nDiff at time %llu pid %d: mtop %d numMethods %d\n", - time, pid, mTop, numMethods); + if (numNonNativeMethods != numMethods && numNonNativeMethods != numMethods + 1) { + printf("\nDiff at time %llu pid %d: non-native %d numMethods %d\n", + time, pid, numNonNativeMethods, numMethods); dumpStacks(pid); numErrors += 1; if (numErrors >= kMaxErrors) @@ -206,7 +220,12 @@ void compareStacks(uint64_t time, int pid) { continue; uint32_t addr = eFrames[ii].function->addr; addr += eFrames[ii].function->region->vstart; - if (addr != mStack->frames[mIndex]->addr) { + while (mIndex < mTop && mFrames[mIndex]->isNative) { + mIndex += 1; + } + if (mIndex >= mTop) + break; + if (addr != mFrames[mIndex]->addr) { printf("\nDiff at time %llu pid %d: frame %d\n", time, pid, ii); dumpStacks(pid); exit(1); @@ -224,8 +243,9 @@ void dumpStacks(int pid) { printf("\nJava method stack\n"); for (int ii = 0; ii < mTop; ii++) { mframe = mStack->frames[ii]; - printf(" %d: %llu 0x%x %s\n", - ii, mframe->time, mframe->addr, + const char *native = mframe->isNative ? "n" : " "; + printf(" %s %d: %llu 0x%x %s\n", + native, ii, mframe->time, mframe->addr, mframe->name == NULL ? "" : mframe->name); } diff --git a/emulator/qtools/profile_pid.cpp b/emulator/qtools/profile_pid.cpp index 589abe9..11acbf9 100644 --- a/emulator/qtools/profile_pid.cpp +++ b/emulator/qtools/profile_pid.cpp @@ -84,10 +84,11 @@ int main(int argc, char **argv) { printf("%5d %5d %10llu %6.2f %6.2f %5s %s", pstate->pid, pstate->parent_pid, pstate->cpu_time, per, sum_per, print_flags, pstate->name); - for (int ii = 1; ii < pstate->argc; ++ii) { - printf(" %s", pstate->argv[ii]); + for (int jj = 1; jj < pstate->argc; ++jj) { + printf(" %s", pstate->argv[jj]); } printf("\n"); } + delete trace; return 0; } diff --git a/emulator/qtools/read_method.cpp b/emulator/qtools/read_method.cpp index 48be25a..6aa0c1a 100644 --- a/emulator/qtools/read_method.cpp +++ b/emulator/qtools/read_method.cpp @@ -13,11 +13,13 @@ struct frame { uint64_t time; uint32_t addr; const char *name; + bool isNative; - frame(uint64_t time, uint32_t addr, const char *name) { + frame(uint64_t time, uint32_t addr, const char *name, bool isNative) { this->time = time; this->addr = addr; this->name = name; + this->isNative = isNative; } }; @@ -57,8 +59,9 @@ void Stack::dump() { for (int ii = 0; ii < top; ii++) { pframe = frames[ii]; - printf(" %d: %llu 0x%x %s\n", - ii, pframe->time, pframe->addr, + const char *native = pframe->isNative ? "n" : " "; + printf(" %s %d: %llu 0x%x %s\n", + native, ii, pframe->time, pframe->addr, pframe->name == NULL ? "" : pframe->name); } } @@ -118,9 +121,11 @@ int main(int argc, char **argv) { stacks[proc->pid] = pStack; } - if (method_record.flags == 0) { + int flags = method_record.flags; + if (flags == kMethodEnter || flags == kNativeEnter) { pframe = new frame(method_record.time, method_record.addr, - sym == NULL ? NULL: sym->name); + sym == NULL ? NULL: sym->name, + method_record.flags == kNativeEnter); pStack->push(pframe); } else { pframe = pStack->pop(); diff --git a/emulator/qtools/stack_dump.cpp b/emulator/qtools/stack_dump.cpp index 35ee61c..f685cd0 100644 --- a/emulator/qtools/stack_dump.cpp +++ b/emulator/qtools/stack_dump.cpp @@ -22,15 +22,33 @@ class MyFrame : public StackFrame<symbol_type> { public: void push(int stackLevel, uint64_t time, CallStackBase *base); void pop(int stackLevel, uint64_t time, CallStackBase *base); + void getFrameType(char *type); }; typedef CallStack<MyFrame> CallStackType; +void MyFrame::getFrameType(char *type) +{ + strcpy(type, "----"); + if (flags & kCausedException) + type[0] = 'e'; + if (flags & kInterpreted) + type[1] = 'm'; + if (function->region->flags & region_type::kIsKernelRegion) + type[2] = 'k'; + if (function->flags & symbol_type::kIsVectorTable) + type[3] = 'v'; +} + void MyFrame::push(int stackLevel, uint64_t time, CallStackBase *base) { + char type[5]; + if (dumpTime > 0) return; - printf("%llu en thr %d %3d", time, base->getId(), stackLevel); + + getFrameType(type); + printf("%llu en thr %d %s %3d", time, base->getId(), type, stackLevel); for (int ii = 0; ii < stackLevel; ++ii) printf("."); printf(" 0x%08x %s\n", addr, function->name); @@ -38,9 +56,13 @@ void MyFrame::push(int stackLevel, uint64_t time, CallStackBase *base) void MyFrame::pop(int stackLevel, uint64_t time, CallStackBase *base) { + char type[5]; + if (dumpTime > 0) return; - printf("%llu x thr %d %3d", time, base->getId(), stackLevel); + + getFrameType(type); + printf("%llu x thr %d %s %3d", time, base->getId(), type, stackLevel); for (int ii = 0; ii < stackLevel; ++ii) printf("."); printf(" 0x%08x %s\n", addr, function->name); @@ -52,7 +74,7 @@ CallStackType *stacks[kMaxThreads]; void Usage(const char *program) { - fprintf(stderr, "Usage: %s [options] trace_name elf_file\n", + fprintf(stderr, "Usage: %s [options] [-- -d dumpTime] trace_name elf_file\n", program); OptionsUsage(); } |