diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-20 08:54:11 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-20 08:54:11 -0700 |
commit | 928eec90cf2362db71b8e4aa3c7e86ba576962b1 (patch) | |
tree | 7ee4ddad8b3d1a6c78c199c2491685c1d1da4487 /emulator/qtools/check_stack.cpp | |
parent | e25fae58f1fed57476ce9d42d88121b6c1e40012 (diff) | |
parent | c627baa5fe13370895cb36cbff1300bad8bc96de (diff) | |
download | sdk-928eec90cf2362db71b8e4aa3c7e86ba576962b1.zip sdk-928eec90cf2362db71b8e4aa3c7e86ba576962b1.tar.gz sdk-928eec90cf2362db71b8e4aa3c7e86ba576962b1.tar.bz2 |
Merge change 2024 into donut
* changes:
Add support for native (JNI) calls to the trace tools.
Diffstat (limited to 'emulator/qtools/check_stack.cpp')
-rw-r--r-- | emulator/qtools/check_stack.cpp | 38 |
1 files changed, 29 insertions, 9 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); } |