/** * Stack frames are labelled 0 to stackTrace->depth * With zero being the topmost or most recent frame. */ CallStackNode* Debugger::locateTrace(int frameNbr) { int count = 0; CallStackNode* trace = core->callStack; while(count++ < frameNbr && trace != NULL) trace = trace->next(); return trace; }
/** * Returns the call stack depth (i.e. number of frames). */ int Debugger::frameCount() { const int MAX_FRAMES = 500; // we need a max, for perf. reasons (bug 175526) CallStackNode* trace = core->callStack; if (trace == NULL) return 0; int count = 1; while( (trace = trace->next()) != 0 && count < MAX_FRAMES ) count++; return count; }
void Sampler::writeRawSample(SampleType sampleType) { CallStackNode *csn = core->callStack; uint32 depth = csn ? csn->depth() : 0; byte *p = currentSample; write(p, GC::ticksToMicros(VMPI_getPerformanceCounter())); write(p, sampleType); if(sampleType != DELETED_OBJECT_SAMPLE) { //if(depth == 0) // AvmDebugMsg(false, "Please add SAMPLE_FRAME's to give this allocation some context."); write(p, depth); while(csn) { write(p, csn->info()); write(p, csn->fakename()); // FIXME: can filename can be stored in the AbstractInfo? write(p, csn->filename()); write(p, csn->linenum()); #ifdef AVMPLUS_64BIT AvmAssert(sizeof(StackTrace::Element) == sizeof(MethodInfo *) + sizeof(Stringp) + sizeof(Stringp) + sizeof(int32_t) + sizeof(int32_t)); write(p, (int) 0); // structure padding #endif csn = csn->next(); depth--; } AvmAssert(depth == 0); } // padding to keep 8 byte alignment align(p); currentSample = p; takeSample = 0; }