diff options
author | Strangerke | 2011-06-29 16:15:41 +0200 |
---|---|---|
committer | Strangerke | 2011-06-29 16:15:41 +0200 |
commit | b0c9c9122fc678074aba30068e5b36d347208e65 (patch) | |
tree | 79a99db08ec985f2e5f1e216823b1104d5b753fb /backends/platform/psp/trace.cpp | |
parent | f2f3124246a77036f843dee2d83ad28084234ebc (diff) | |
parent | c32a3ea0d30336771bab460ecccb58c4614e6294 (diff) | |
download | scummvm-rg350-b0c9c9122fc678074aba30068e5b36d347208e65.tar.gz scummvm-rg350-b0c9c9122fc678074aba30068e5b36d347208e65.tar.bz2 scummvm-rg350-b0c9c9122fc678074aba30068e5b36d347208e65.zip |
Merge branch 'master' of github.com:scummvm/scummvm into soltys_wip2
Diffstat (limited to 'backends/platform/psp/trace.cpp')
-rw-r--r-- | backends/platform/psp/trace.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/backends/platform/psp/trace.cpp b/backends/platform/psp/trace.cpp index 373e00415b..b799b4e870 100644 --- a/backends/platform/psp/trace.cpp +++ b/backends/platform/psp/trace.cpp @@ -75,38 +75,38 @@ void PspDebugTrace(bool alsoToScreen, const char *format, ...) { #define GET_RET(retAddr) \ asm volatile ("move %0,$ra\n\t" \ : "=&r" (retAddr) : ) - + #define GET_SP(stackPtr) \ asm volatile ("move %0,$sp\n\t" \ : "=&r" (stackPtr) : ) // Function to retrieve a backtrace for the MIPS processor -// This is not trivial since the MIPS doesn't use a frame pointer. +// This is not trivial since the MIPS doesn't use a frame pointer. // Takes the number of levels wanted above the calling function (included) and an array of void * -// +// void mipsBacktrace(uint32 levels, void **addresses) { - // get the current return address + // get the current return address register byte *retAddr; register byte *stackPointer; - GET_RET(retAddr); + GET_RET(retAddr); GET_SP(stackPointer); char string[100]; - + if (!levels) return; - + memset(addresses, 0, sizeof(void *) * levels); - + uint32 curLevel = 0; - + const uint32 SP_SUBTRACT = 0x27bd8000; // The instruction to subtract from the SP looks like this const uint32 SP_SUB_HIGH_MASK = 0xffff8000; // The mask to check for the subtract SP instruction const uint32 SP_SUB_LOW_MASK = 0x0000ffff; // The mask that gives us how much was subtracted - + // make sure we go out of the stack of this current level // we already have the return address for this level from the register if (curLevel < levels) { - void *thisFunc = (void *)mipsBacktrace; + void *thisFunc = (void *)mipsBacktrace; for (uint32 *seekPtr = (uint32 *)thisFunc; ; seekPtr++) { if ((*seekPtr & SP_SUB_HIGH_MASK) == SP_SUBTRACT) { // we found the $sp subtraction at the beginning of the function @@ -120,10 +120,10 @@ void mipsBacktrace(uint32 levels, void **addresses) { fputs(string, stderr); } break; - } - } + } + } } - + // keep scanning while more levels are requested while (curLevel < levels) { // now scan backwards from the return address to find the size of the stack @@ -139,13 +139,13 @@ void mipsBacktrace(uint32 levels, void **addresses) { sprintf(string, "invalid retAddr %p\n", retAddr); fputs(string, stderr); return; - } + } //sprintf(string, "retAddr[%p]\n", retAddr); //fputs(string, stderr); addresses[curLevel++] = retAddr; break; - } - } + } + } } -} +} |