bool BlockingResourceBase::DeadlockDetectorEntry::Print( const DDT::ResourceAcquisition& aFirstSeen, nsACString& out, bool aPrintFirstSeenCx) const { CallStack lastAcquisition = mAcquisitionContext; // RACY, but benign bool maybeCurrentlyAcquired = (CallStack::kNone != lastAcquisition); CallStack printAcquisition = (aPrintFirstSeenCx || !maybeCurrentlyAcquired) ? aFirstSeen.mCallContext : lastAcquisition; fprintf(stderr, "--- %s : %s", kResourceTypeName[mType], mName); out += BlockingResourceBase::kResourceTypeName[mType]; out += " : "; out += mName; if (maybeCurrentlyAcquired) { fputs(" (currently acquired)", stderr); out += " (currently acquired)\n"; } fputs(" calling context\n", stderr); printAcquisition.Print(stderr); return maybeCurrentlyAcquired; }
TEST(CallStackTestGroup, GetSoName) { CallStack TestCallStack; TestSuiteUnwind5(TestCallStack); STRCMP_EQUAL("utest_edkit_toolbox", strstr(TestCallStack.GetSoName(0), "utest_edkit_toolbox")); };
BpMemoryHeap::~BpMemoryHeap() { if (mHeapId != -1) { close(mHeapId); if (mRealHeap) { // by construction we're the last one if (mBase != MAP_FAILED) { sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder(); if (VERBOSE) { ALOGD("UNMAPPING binder=%p, heap=%p, size=%d, fd=%d", binder.get(), this, mSize, mHeapId); CallStack stack; stack.update(); stack.dump("callstack"); } munmap(mBase, mSize); } } else { // remove from list only if it was mapped before sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder(); free_heap(binder); } } }
TEST(CallStackTestGroup, GetNameBigLevel) { CallStack TestCallStack; TestSuiteUnwind5(TestCallStack); POINTERS_EQUAL(NULL, TestCallStack.GetName(300000)); };
void endOfThread(void *param) { ALOGD("*********** THREAD HAS STOPPPED ***********"); CallStack* cs = new CallStack(); cs->update(0, 100); cs->dump("ExecutionManager terminated: "); // exit(1); }
TEST(CallStackTestGroup, UnwindOneCaller) { CallStack TestCallStack; TestSuiteCaller1(TestCallStack); const void **Stack = TestCallStack.Get(); Dl_info Info; CHECK(dladdr(Stack[0], &Info) != 0); CHECK_EQUAL(0, strcmp(Info.dli_sname, "TestSuiteCaller1")); };
TEST(CallStackTestGroup, SetTo) { CallStack TestCallStack; CallStack TestCallStack2; TestSuiteUnwind5(TestCallStack); TestCallStack2.SetTo(TestCallStack); CHECK_EQUAL(0, memcmp(TestCallStack.Get(), TestCallStack2.Get(), CALLSTACK_MAX_DEPTH*sizeof(void*))); };
void MistUtils::where() { CallStack c = call_stack_; string s = "\n"; while (!c.empty()) { s += " => "; s += c.top()->name().c_str(); s += "()\n"; c.pop(); } s += " => main()"; print(" - call stack: %s", s.c_str()); }
status_t GraphicBufferAllocator::free(buffer_handle_t handle) { // [MTK] {{{ if (true == mIsDumpCallStack) { XLOGD("[GraphicBufferAllocator::free] handle:%p", handle); CallStack cs; cs.update(); cs.dump(" "); } // [MTK] }}} BufferLiberatorThread::queueCaptiveBuffer(handle); return NO_ERROR; }
static int gl_no_context() { if (egl_tls_t::logNoContextCall()) { ALOGE("call to OpenGL ES API with no current context " "(logged once per thread)"); char value[PROPERTY_VALUE_MAX]; property_get("debug.egl.callstack", value, "0"); if (atoi(value)) { CallStack stack; stack.update(); stack.dump(); } } return 0; }
TEST(CallStackTestGroup, GetName) { CallStack TestCallStack; TestSuiteUnwind5(TestCallStack); /* check for names, format is "pointer:name" so we compare the name for * symbols that should be resolved */ CHECK_EQUAL(0, strcmp(strchr(TestCallStack.GetName(0), ':')+1, "TestSuiteUnwind1")); CHECK_EQUAL(0, strcmp(strchr(TestCallStack.GetName(1), ':')+1, "TestSuiteUnwind2")); CHECK_EQUAL(0, strcmp(strchr(TestCallStack.GetName(2), ':')+1, "TestSuiteUnwind3")); CHECK_EQUAL(0, strcmp(strchr(TestCallStack.GetName(3), ':')+1, "TestSuiteUnwind4")); CHECK_EQUAL(0, strcmp(strchr(TestCallStack.GetName(4), ':')+1, "TestSuiteUnwind5(CallStack&)")); };
TEST(CallStackTestGroup, GetNameCaller) { CallStack TestCallStack; TestSuiteCaller1(TestCallStack); /* check for names, format is "pointer:name" so we compare the name for * symbols that should be resolved */ CHECK_EQUAL(0, strcmp(strchr(TestCallStack.GetName(0), ':')+1, "TestSuiteCaller1")); uint32_t Level; for(Level=1;Level<TestCallStack.GetDepth(); Level++) { POINTERS_EQUAL(NULL, TestCallStack.GetName(Level)); } };
~weakref_impl() { bool dumpStack = false; if (!mRetain && mStrongRefs != NULL) { dumpStack = true; #if DEBUG_REFS_FATAL_SANITY_CHECKS LOG_ALWAYS_FATAL("Strong references remain!"); #else ALOGE("Strong references remain:"); #endif ref_entry* refs = mStrongRefs; while (refs) { char inc = refs->ref >= 0 ? '+' : '-'; ALOGD("\t%c ID %p (ref %d):", inc, refs->id, refs->ref); #if DEBUG_REFS_CALLSTACK_ENABLED refs->stack.dump(); #endif refs = refs->next; } } if (!mRetain && mWeakRefs != NULL) { dumpStack = true; #if DEBUG_REFS_FATAL_SANITY_CHECKS LOG_ALWAYS_FATAL("Weak references remain:"); #else ALOGE("Weak references remain!"); #endif ref_entry* refs = mWeakRefs; while (refs) { char inc = refs->ref >= 0 ? '+' : '-'; ALOGD("\t%c ID %p (ref %d):", inc, refs->id, refs->ref); #if DEBUG_REFS_CALLSTACK_ENABLED refs->stack.dump(); #endif refs = refs->next; } } if (dumpStack) { ALOGE("above errors at:"); CallStack stack; stack.update(); stack.dump(); } }
static int gl_no_context() { if (egl_tls_t::logNoContextCall()) { char const* const error = "call to OpenGL ES API with " "no current context (logged once per thread)"; if (LOG_NDEBUG) { ALOGE(error); } else { LOG_ALWAYS_FATAL(error); } char value[PROPERTY_VALUE_MAX]; property_get("debug.egl.callstack", value, "0"); if (atoi(value)) { CallStack stack; stack.update(); stack.dump(); } } return 0; }
TEST(CallStackTestGroup, Unwind) { CallStack TestCallStack; TestSuiteUnwind5(TestCallStack); const void **Stack = TestCallStack.Get(); Dl_info Info; CHECK(dladdr(Stack[0], &Info) != 0); CHECK_EQUAL(0, strcmp(Info.dli_sname, "TestSuiteUnwind1")); CHECK(dladdr(Stack[1], &Info) != 0); CHECK_EQUAL(0, strcmp(Info.dli_sname, "TestSuiteUnwind2")); CHECK(dladdr(Stack[2], &Info) != 0); CHECK_EQUAL(0, strcmp(Info.dli_sname, "TestSuiteUnwind3")); CHECK(dladdr(Stack[3], &Info) != 0); CHECK_EQUAL(0, strcmp(Info.dli_sname, "TestSuiteUnwind4")); CHECK(dladdr(Stack[4], &Info) != 0); CHECK(strstr(Info.dli_sname, "TestSuiteUnwind5") != NULL); };
status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle) { // [MTK] {{{ if (true == mIsDumpCallStack) { XLOGD("[GraphicBufferMapper::unregisterBuffer] handle:%p", handle); CallStack cs; cs.update(); cs.dump(" "); } // [MTK] }}} ATRACE_CALL(); status_t err; err = mAllocMod->unregisterBuffer(mAllocMod, handle); ALOGW_IF(err, "unregisterBuffer(%p) failed %d (%s)", handle, err, strerror(-err)); return err; }
static void sighandler(int signo) { const char *sig_name[64]; sig_name[SIGABRT] = "Abort"; sig_name[SIGSEGV] = "Segmentation violation"; fprintf(stderr, "Caught signal %d (%s)\n", signo, sig_name[signo]); callstack.dump(); exit(EXIT_FAILURE); }
void removeRef(ref_entry** refs, const void* id) { if (mTrackEnabled) { AutoMutex _l(mMutex); ref_entry* const head = *refs; ref_entry* ref = head; while (ref != NULL) { if (ref->id == id) { *refs = ref->next; delete ref; return; } refs = &ref->next; ref = *refs; } #if DEBUG_REFS_FATAL_SANITY_CHECKS LOG_ALWAYS_FATAL("RefBase: removing id %p on RefBase %p" "(weakref_type %p) that doesn't exist!", id, mBase, this); #endif ALOGE("RefBase: removing id %p on RefBase %p" "(weakref_type %p) that doesn't exist!", id, mBase, this); ref = head; while (ref) { char inc = ref->ref >= 0 ? '+' : '-'; ALOGD("\t%c ID %p (ref %d):", inc, ref->id, ref->ref); ref = ref->next; } CallStack stack; stack.update(); stack.dump(); } }
void funcC() { int i; CallStack cs; cs.dump(); }
void __attribute__((noinline)) TestSuiteUnwind(CallStack &Unwinder) { Unwinder.Unwind(); }
TEST(CallStackTestGroup, GetDepth) { CallStack TestCallStack; CHECK_EQUAL(CALLSTACK_MAX_DEPTH, TestCallStack.GetDepth()); };
int main(int argc, char *argv[]) { char ofile[100] = "\0"; int c; char text[100]; opterr = 0; while ((c = getopt(argc, argv, "hvol:")) != -1) switch (c) { case 'v': sprintf(text, "%s Version %d.%d\n", "Leaf Graph Language Compiler", 0, 1); say(text, false); return 0; break; case 'h': fprintf(stdout, "%s", helptext); return 0; break; case 'o': sprintf(ofile, "%s", optarg); break; case 'l': yylineno += atoi(optarg); break; case '?': if (optopt == 'o' || optopt == 'l') { sprintf(text, "option -%c requires an argument.\n", optopt); say(text, false); return 0; } else if (isprint(optopt)) { sprintf(text, "unknown option `-%c'.\n", optopt); say(text); } else { sprintf(text, "unknown option character `\\x%x'.\n", optopt); say(text); } return 1; } if (argc - optind > 1) { say("too many arguments \n"); return 1; } else if (argc - optind < 1) { say("no input files \n"); return 1; } if (ofile[0] == '\0') { strcat(ofile, argv[optind]); strcat(ofile, ".dot"); } fid = fopen(argv[optind], "r"); if (!fid) { sprintf(text, "Error opening file: %s\n", argv[optind]); say(text); return 1; } protname = argv[optind]; Graph *res; f->setEnv(symboltable); yydebug = 0; f->setStream(fid); cs.push(*f); try { res = (Graph *) &(cs.Run()); } catch (int) { return (1); } res->toDot(ofile); return 0; }
status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format, int usage, buffer_handle_t* handle, int32_t* stride) { ATRACE_CALL(); // make sure to not allocate a N x 0 or 0 x N buffer, since this is // allowed from an API stand-point allocate a 1x1 buffer instead. if (!w || !h) w = h = 1; // we have a h/w allocator and h/w buffer is requested status_t err; // If too many async frees are queued up then wait for some of them to // complete before attempting to allocate more memory. This is exercised // by the android.opengl.cts.GLSurfaceViewTest CTS test. BufferLiberatorThread::maybeWaitForLiberation(); err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride); if (err != NO_ERROR) { ALOGW("WOW! gralloc alloc failed, waiting for pending frees!"); BufferLiberatorThread::waitForLiberation(); err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride); } ALOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)", w, h, format, usage, err, strerror(-err)); if (err == NO_ERROR) { Mutex::Autolock _l(sLock); KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); int bpp = bytesPerPixel(format); if (bpp < 0) { // probably a HAL custom format. in any case, we don't know // what its pixel size is. bpp = 0; } alloc_rec_t rec; rec.w = w; rec.h = h; rec.s = *stride; rec.format = format; rec.usage = usage; rec.size = h * stride[0] * bpp; // [MTK] {{{ rec.pid = IPCThreadState::self()->getCallingPid(); // [MTK] }}} list.add(*handle, rec); } // [MTK] {{{ // dump call stack here after handle value got if (true == mIsDumpCallStack) { XLOGD("[GraphicBufferAllocator::alloc] handle:%p", *handle); CallStack cs; cs.update(); cs.dump(" "); } // [MTK] }}} return err; }