本文整理汇总了C++中SAVEAREA_FROM_FP函数的典型用法代码示例。如果您正苦于以下问题:C++ SAVEAREA_FROM_FP函数的具体用法?C++ SAVEAREA_FROM_FP怎么用?C++ SAVEAREA_FROM_FP使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SAVEAREA_FROM_FP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dvmPopLocalFrame
/*
* Pop one frame pushed on by JNI PushLocalFrame.
*
* If we've gone too far, the previous frame is either a break frame or
* an interpreted frame. Either way, the method pointer won't match.
*/
bool dvmPopLocalFrame(Thread* self)
{
StackSaveArea* saveBlock = SAVEAREA_FROM_FP(self->interpSave.curFrame);
assert(!dvmIsBreakFrame((u4*)self->interpSave.curFrame));
if (saveBlock->method != SAVEAREA_FROM_FP(saveBlock->prevFrame)->method) {
/*
* The previous frame doesn't have the same method pointer -- we've
* been asked to pop too much.
*/
assert(dvmIsBreakFrame((u4*)saveBlock->prevFrame) ||
!dvmIsNativeMethod(
SAVEAREA_FROM_FP(saveBlock->prevFrame)->method));
return false;
}
LOGVV("POP JNI local frame: removing %s, now %s",
saveBlock->method->name,
SAVEAREA_FROM_FP(saveBlock->prevFrame)->method->name);
dvmPopJniLocals(self, saveBlock);
self->interpSave.curFrame = saveBlock->prevFrame;
#ifdef WITH_OFFLOAD
offStackFramePopped(self);
#endif
return true;
}
示例2: dvmGetCallerFP
/*
* Get the calling frame. Pass in the current fp.
*
* Skip "break" frames and reflection invoke frames.
*/
void* dvmGetCallerFP(const void* curFrame)
{
void* caller = SAVEAREA_FROM_FP(curFrame)->prevFrame;
StackSaveArea* saveArea;
retry:
if (dvmIsBreakFrame((u4*)caller)) {
/* pop up one more */
caller = SAVEAREA_FROM_FP(caller)->prevFrame;
if (caller == NULL)
return NULL; /* hit the top */
/*
* If we got here by java.lang.reflect.Method.invoke(), we don't
* want to return Method's class loader. Shift up one and try
* again.
*/
saveArea = SAVEAREA_FROM_FP(caller);
if (dvmIsReflectionMethod(saveArea->method)) {
caller = saveArea->prevFrame;
assert(caller != NULL);
goto retry;
}
}
return caller;
}
示例3: dvmFillStackTraceArray
/*
* Fill a flat array of methods that comprise the current interpreter
* stack trace. Pass in the current frame ptr. Break frames are
* skipped, but reflection invocations are not.
*
* The current frame will be in element 0.
*/
void dvmFillStackTraceArray(const void* fp, const Method** array, size_t length)
{
assert(fp != NULL);
assert(array != NULL);
size_t i = 0;
while (fp != NULL) {
if (!dvmIsBreakFrame((u4*)fp)) {
assert(i < length);
array[i++] = SAVEAREA_FROM_FP(fp)->method;
}
fp = SAVEAREA_FROM_FP(fp)->prevFrame;
}
}
示例4: dvmGetCaller2Class
/*
* Get the caller's caller's class. Pass in the current fp.
*
* This is used by e.g. java.lang.Class, which wants to know about the
* class loader of the method that called it.
*/
ClassObject* dvmGetCaller2Class(const void* curFrame)
{
void* caller = SAVEAREA_FROM_FP(curFrame)->prevFrame;
void* callerCaller;
/* at the top? */
if (dvmIsBreakFrame(caller) && SAVEAREA_FROM_FP(caller)->prevFrame == NULL)
return NULL;
/* go one more */
callerCaller = dvmGetCallerFP(caller);
if (callerCaller == NULL)
return NULL;
return SAVEAREA_FROM_FP(callerCaller)->method->clazz;
}
示例5: dvmPopFrame
/*
* Pop a frame we added. There should be one method frame and one break
* frame.
*
* If JNI Push/PopLocalFrame calls were mismatched, we might end up
* popping multiple method frames before we find the break.
*
* Returns "false" if there was no frame to pop.
*/
static bool dvmPopFrame(Thread* self)
{
StackSaveArea* saveBlock;
if (self->interpSave.curFrame == NULL)
return false;
saveBlock = SAVEAREA_FROM_FP(self->interpSave.curFrame);
assert(!dvmIsBreakFrame((u4*)self->interpSave.curFrame));
/*
* Remove everything up to the break frame. If this was a call into
* native code, pop the JNI local references table.
*/
while (saveBlock->prevFrame != NULL && saveBlock->method != NULL) {
/* probably a native->native JNI call */
if (dvmIsNativeMethod(saveBlock->method)) {
LOGVV("Popping JNI stack frame for %s.%s%s",
saveBlock->method->clazz->descriptor,
saveBlock->method->name,
(SAVEAREA_FROM_FP(saveBlock->prevFrame)->method == NULL) ?
"" : " (JNI local)");
dvmPopJniLocals(self, saveBlock);
}
saveBlock = SAVEAREA_FROM_FP(saveBlock->prevFrame);
}
if (saveBlock->method != NULL) {
ALOGE("PopFrame missed the break");
assert(false);
dvmAbort(); // stack trashed -- nowhere to go in this thread
}
LOGVV("POP frame: cur=%p new=%p",
self->interpSave.curFrame, saveBlock->prevFrame);
self->interpSave.curFrame = saveBlock->prevFrame;
#ifdef WITH_OFFLOAD
offStackFramePopped(self);
self->breakFrames--;
CHECK_BREAK_FRAMES();
#endif
return true;
}
示例6: dvmGetCaller3Class
/*
* Get the caller's caller's caller's class. Pass in the current fp.
*
* This is used by e.g. java.lang.Class, which wants to know about the
* class loader of the method that called it.
*/
ClassObject* dvmGetCaller3Class(const void* curFrame)
{
void* caller = SAVEAREA_FROM_FP(curFrame)->prevFrame;
int i;
/* at the top? */
if (dvmIsBreakFrame(caller) && SAVEAREA_FROM_FP(caller)->prevFrame == NULL)
return NULL;
/* Walk up two frames if possible. */
for (i = 0; i < 2; i++) {
caller = dvmGetCallerFP(caller);
if (caller == NULL)
return NULL;
}
return SAVEAREA_FROM_FP(caller)->method->clazz;
}
示例7: dvmPopFrame
/*
* Pop a frame we added. There should be one method frame and one break
* frame.
*
* If JNI Push/PopLocalFrame calls were mismatched, we might end up
* popping multiple method frames before we find the break.
*
* Returns "false" if there was no frame to pop.
*/
static bool dvmPopFrame(Thread* self)
{
StackSaveArea* saveBlock;
if (self->curFrame == NULL)
return false;
saveBlock = SAVEAREA_FROM_FP(self->curFrame);
assert(!dvmIsBreakFrame(self->curFrame));
/*
* Remove everything up to the break frame. If this was a call into
* native code, pop the JNI local references table.
*/
while (saveBlock->prevFrame != NULL && saveBlock->method != NULL) {
/* probably a native->native JNI call */
if (dvmIsNativeMethod(saveBlock->method)) {
LOGVV("Popping JNI stack frame for %s.%s%s\n",
saveBlock->method->clazz->descriptor,
saveBlock->method->name,
(SAVEAREA_FROM_FP(saveBlock->prevFrame)->method == NULL) ?
"" : " (JNI local)");
assert(saveBlock->xtra.localRefCookie != 0);
//assert(saveBlock->xtra.localRefCookie >= self->jniLocalRefTable.table &&
// saveBlock->xtra.localRefCookie <=self->jniLocalRefTable.nextEntry);
dvmPopJniLocals(self, saveBlock);
}
saveBlock = SAVEAREA_FROM_FP(saveBlock->prevFrame);
}
if (saveBlock->method != NULL) {
LOGE("PopFrame missed the break\n");
assert(false);
dvmAbort(); // stack trashed -- nowhere to go in this thread
}
LOGVV("POP frame: cur=%p new=%p\n",
self->curFrame, saveBlock->prevFrame);
self->curFrame = saveBlock->prevFrame;
return true;
}
示例8: dvmPushLocalFrame
/*
* This is used by the JNI PushLocalFrame call. We push a new frame onto
* the stack that has no ins, outs, or locals, and no break frame above it.
* It's strictly used for tracking JNI local refs, and will be popped off
* by dvmPopFrame if it's not removed explicitly.
*/
bool dvmPushLocalFrame(Thread* self, const Method* method)
{
StackSaveArea* saveBlock;
int stackReq;
u1* stackPtr;
assert(dvmIsNativeMethod(method));
stackReq = sizeof(StackSaveArea); // regular frame
assert(self->curFrame != NULL);
stackPtr = (u1*) SAVEAREA_FROM_FP(self->curFrame);
if (stackPtr - stackReq < self->interpStackEnd) {
/* not enough space; let JNI throw the exception */
LOGW("Stack overflow on PushLocal "
"(req=%d top=%p cur=%p size=%d '%s')\n",
stackReq, self->interpStackStart, self->curFrame,
self->interpStackSize, method->name);
dvmHandleStackOverflow(self, method);
assert(dvmCheckException(self));
return false;
}
/*
* Shift the stack pointer down, leaving space for just the stack save
* area for the break frame, then shift down farther for the full frame.
*/
stackPtr -= sizeof(StackSaveArea);
saveBlock = (StackSaveArea*) stackPtr;
#if !defined(NDEBUG) && !defined(PAD_SAVE_AREA)
/* debug -- memset the new stack */
memset(stackPtr, 0xaf, stackReq);
#endif
#ifdef EASY_GDB
saveBlock->prevSave = FP_FROM_SAVEAREA(self->curFrame);
#endif
saveBlock->prevFrame = self->curFrame;
saveBlock->savedPc = NULL; // not required
#ifdef USE_INDIRECT_REF
saveBlock->xtra.localRefCookie = self->jniLocalRefTable.segmentState.all;
#else
saveBlock->xtra.localRefCookie = self->jniLocalRefTable.nextEntry;
#endif
saveBlock->method = method;
LOGVV("PUSH JNI local frame: old=%p new=%p (size=%d)\n",
self->curFrame, FP_FROM_SAVEAREA(saveBlock),
(u1*)self->curFrame - (u1*)FP_FROM_SAVEAREA(saveBlock));
self->curFrame = FP_FROM_SAVEAREA(saveBlock);
return true;
}
示例9: dvmInterpretPortable
/*
* Main interpreter loop.
*
* This was written with an ARM implementation in mind.
*/
void dvmInterpretPortable(Thread* self)
{
#if defined(EASY_GDB)
StackSaveArea* debugSaveArea = SAVEAREA_FROM_FP(self->interpSave.curFrame);
#endif
DvmDex* methodClassDex; // curMethod->clazz->pDvmDex
JValue retval;
/* core state */
const Method* curMethod; // method we're interpreting
const u2* pc; // program counter
u4* fp; // frame pointer
u2 inst; // current instruction
/* instruction decoding */
u4 ref; // 16 or 32-bit quantity fetched directly
u2 vsrc1, vsrc2, vdst; // usually used for register indexes
/* method call setup */
const Method* methodToCall;
bool methodCallRange;
/* static computed goto table */
DEFINE_GOTO_TABLE(handlerTable);
/* copy state in */
curMethod = self->interpSave.method;
pc = self->interpSave.pc;
fp = self->interpSave.curFrame;
retval = self->interpSave.retval; /* only need for kInterpEntryReturn? */
methodClassDex = curMethod->clazz->pDvmDex;
LOGVV("threadid=%d: %s.%s pc=%#x fp=%p",
self->threadId, curMethod->clazz->descriptor, curMethod->name,
pc - curMethod->insns, fp);
/*
* Handle any ongoing profiling and prep for debugging.
*/
if (self->interpBreak.ctl.subMode != 0) {
TRACE_METHOD_ENTER(self, curMethod);
self->debugIsMethodEntry = true; // Always true on startup
}
/*
* DEBUG: scramble this to ensure we're not relying on it.
*/
methodToCall = (const Method*) -1;
#if 0
if (self->debugIsMethodEntry) {
ILOGD("|-- Now interpreting %s.%s", curMethod->clazz->descriptor,
curMethod->name);
DUMP_REGS(curMethod, self->interpSave.curFrame, false);
}
#endif
FINISH(0); /* fetch and execute first instruction */
示例10: dvmGetCallerClass
/*
* Get the caller's class. Pass in the current fp.
*
* This is used by e.g. java.lang.Class.
*/
ClassObject* dvmGetCallerClass(const void* curFrame)
{
void* caller;
caller = dvmGetCallerFP(curFrame);
if (caller == NULL)
return NULL;
return SAVEAREA_FROM_FP(caller)->method->clazz;
}
示例11: dvmComputeExactFrameDepth
/*
* Compute the frame depth.
*
* Excludes "break" frames.
*/
int dvmComputeExactFrameDepth(const void* fp)
{
int count = 0;
for ( ; fp != NULL; fp = SAVEAREA_FROM_FP(fp)->prevFrame) {
if (!dvmIsBreakFrame((u4*)fp))
count++;
}
return count;
}
示例12: dvmCreateStackTraceArray
/*
* Create a flat array of methods that comprise the current interpreter
* stack trace. Pass in the current frame ptr.
*
* Allocates a new array and fills it with method pointers. Break frames
* are skipped, but reflection invocations are not. The caller must free
* "*pArray".
*
* The current frame will be in element 0.
*
* Returns "true" on success, "false" on failure (e.g. malloc failed).
*/
bool dvmCreateStackTraceArray(const void* fp, const Method*** pArray,
int* pLength)
{
const Method** array;
int idx, depth;
depth = dvmComputeExactFrameDepth(fp);
array = (const Method**) malloc(depth * sizeof(Method*));
if (array == NULL)
return false;
for (idx = 0; fp != NULL; fp = SAVEAREA_FROM_FP(fp)->prevFrame) {
if (!dvmIsBreakFrame(fp))
array[idx++] = SAVEAREA_FROM_FP(fp)->method;
}
assert(idx == depth);
*pArray = array;
*pLength = depth;
return true;
}
示例13: dvmDumpFp
/*
* Dump the StackSaveArea for the specified frame pointer.
*/
void dvmDumpFp(void* fp, StackSaveArea* otherSaveArea)
{
StackSaveArea* saveArea = SAVEAREA_FROM_FP(fp);
printf("StackSaveArea for fp %p [%p/%p]:\n", fp, saveArea, otherSaveArea);
#ifdef EASY_GDB
printf(" prevSave=%p, prevFrame=%p savedPc=%p meth=%p curPc=%p\n",
saveArea->prevSave, saveArea->prevFrame, saveArea->savedPc,
saveArea->method, saveArea->xtra.currentPc);
#else
printf(" prevFrame=%p savedPc=%p meth=%p curPc=%p fp[0]=0x%08x\n",
saveArea->prevFrame, saveArea->savedPc,
saveArea->method, saveArea->xtra.currentPc,
*(u4*)fp);
#endif
}
示例14: crawlDalvikStack
static void crawlDalvikStack(Thread *thread, bool print)
{
void *fp = thread->interpSave.curFrame;
StackSaveArea* saveArea = NULL;
int stackLevel = 0;
/* Crawl the Dalvik stack frames to clear the returnAddr field */
while (fp != NULL) {
saveArea = SAVEAREA_FROM_FP(fp);
stackLevel++;
saveArea->returnAddr = NULL;
assert(fp != saveArea->prevFrame);
fp = saveArea->prevFrame;
}
/* Make sure the stack is fully unwound to the bottom */
assert(saveArea == NULL ||
(u1 *) (saveArea+1) == thread->interpStackStart);
}
示例15: dvmHandleStackOverflow
/*
* Open up the reserved area and throw an exception. The reserved area
* should only be needed to create and initialize the exception itself.
*
* If we already opened it and we're continuing to overflow, abort the VM.
*
* We have to leave the "reserved" area open until the "catch" handler has
* finished doing its processing. This is because the catch handler may
* need to resolve classes, which requires calling into the class loader if
* the classes aren't already in the "initiating loader" list.
*/
void dvmHandleStackOverflow(Thread* self, const Method* method)
{
/*
* Can we make the reserved area available?
*/
if (self->stackOverflowed) {
/*
* Already did, nothing to do but bail.
*/
LOGE("DalvikVM: double-overflow of stack in threadid=%d; aborting\n",
self->threadId);
dvmDumpThread(self, false);
dvmAbort();
}
/* open it up to the full range */
LOGI("threadid=%d: stack overflow on call to %s.%s:%s\n",
self->threadId,
method->clazz->descriptor, method->name, method->shorty);
StackSaveArea* saveArea = SAVEAREA_FROM_FP(self->curFrame);
LOGI(" method requires %d+%d+%d=%d bytes, fp is %p (%d left)\n",
method->registersSize * 4, sizeof(StackSaveArea), method->outsSize * 4,
(method->registersSize + method->outsSize) * 4 + sizeof(StackSaveArea),
saveArea, (u1*) saveArea - self->interpStackEnd);
LOGI(" expanding stack end (%p to %p)\n", self->interpStackEnd,
self->interpStackStart - self->interpStackSize);
//dvmDumpThread(self, false);
self->interpStackEnd = self->interpStackStart - self->interpStackSize;
self->stackOverflowed = true;
/*
* If we were trying to throw an exception when the stack overflowed,
* we will blow up when doing the class lookup on StackOverflowError
* because of the pending exception. So, we clear it and make it
* the cause of the SOE.
*/
Object* excep = dvmGetException(self);
if (excep != NULL) {
LOGW("Stack overflow while throwing exception\n");
dvmClearException(self);
}
dvmThrowChainedExceptionByClass(gDvm.classJavaLangStackOverflowError,
NULL, excep);
}