aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ps2
diff options
context:
space:
mode:
authorMax Lingua2014-01-23 01:29:30 -0500
committerMax Lingua2014-01-23 18:34:44 -0500
commitc16c6653a112307d4f5ded3c3533f9621a945cb3 (patch)
tree9eea49b9f03cb9795602640f00d7a643c3f1e37f /backends/platform/ps2
parentab3a1b5e0cfa2090cb0c9df3cf18dfc3fb057bc9 (diff)
downloadscummvm-rg350-c16c6653a112307d4f5ded3c3533f9621a945cb3.tar.gz
scummvm-rg350-c16c6653a112307d4f5ded3c3533f9621a945cb3.tar.bz2
scummvm-rg350-c16c6653a112307d4f5ded3c3533f9621a945cb3.zip
PS2: Improved support for profiling (gprof) build
Diffstat (limited to 'backends/platform/ps2')
-rw-r--r--backends/platform/ps2/Makefile.ps26
-rw-r--r--backends/platform/ps2/fileio.cpp3
-rw-r--r--backends/platform/ps2/systemps2.cpp17
3 files changed, 23 insertions, 3 deletions
diff --git a/backends/platform/ps2/Makefile.ps2 b/backends/platform/ps2/Makefile.ps2
index 2ee47c9a4d..7b010e8440 100644
--- a/backends/platform/ps2/Makefile.ps2
+++ b/backends/platform/ps2/Makefile.ps2
@@ -145,19 +145,19 @@ endif
# Test for debug
ifeq ($(ENABLE_DEBUG),1)
-FLAGS += -G2 -g
DEFINES += -D__PS2_DEBUG__
+FLAGS += -G2 -g
LIBS += -lps2gdbStub -lps2ip -ldebug
else
-FLAGS += -G2 -O2 -s -Wuninitialized
DEFINES += -DRELEASE_BUILD
+FLAGS += -G2 -O2 -s -Wuninitialized
# LDFLAGS += -s
endif
# Test for profiling
ifeq ($(ENABLE_PROFILING),1)
DEFINES += -DENABLE_PROFILING
-CXXFLAGS += -pg -g
+FLAGS += -G2 -pg -g
LDFLAGS += -pg
endif
diff --git a/backends/platform/ps2/fileio.cpp b/backends/platform/ps2/fileio.cpp
index 1ec16a3817..cc1da2e511 100644
--- a/backends/platform/ps2/fileio.cpp
+++ b/backends/platform/ps2/fileio.cpp
@@ -409,7 +409,10 @@ uint32 Ps2File::read(void *dest, uint32 len) {
break; // EOF
}
}
+#ifndef ENABLE_PROFILING
+ // doesn't play nice with -pg
cacheReadAhead();
+#endif
#ifdef __PS2_FILE_SEMA__
SignalSema(_sema);
#endif
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index e800c6cb21..f3807ea91f 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -150,6 +150,10 @@ extern "C" int main(int argc, char *argv[]) {
g_systemPs2->quit();
+#ifdef ENABLE_PROFILING
+ // make sure we can flush "gmon.out"
+ fileXioSetBlockMode(FXIO_WAIT);
+#endif
// control never gets here
return res;
}
@@ -467,15 +471,25 @@ void OSystem_PS2::initTimer(void) {
_timerStack = (uint8 *)memalign(64, TIMER_STACK_SIZE);
_soundStack = (uint8 *)memalign(64, SOUND_STACK_SIZE);
+ // gprof doesn't cope with higher thread priority too well
+ #ifdef ENABLE_PROFILING
+ timerThread.initial_priority = thisThread.current_priority;
+ #else
// give timer thread a higher priority than main thread
timerThread.initial_priority = thisThread.current_priority - 1;
+ #endif
timerThread.stack = _timerStack;
timerThread.stack_size = TIMER_STACK_SIZE;
timerThread.func = (void *)systemTimerThread;
timerThread.gp_reg = &_gp;
+ // gprof doesn't cope with higher thread priority too well
+ #ifdef ENABLE_PROFILING
+ soundThread.initial_priority = thisThread.current_priority;
+ #else
// soundthread's priority is higher than main- and timerthread
soundThread.initial_priority = thisThread.current_priority - 2;
+ #endif
soundThread.stack = _soundStack;
soundThread.stack_size = SOUND_STACK_SIZE;
soundThread.func = (void *)systemSoundThread;
@@ -883,7 +897,10 @@ void OSystem_PS2::quit(void) {
printf("OSystem_PS2::quit called\n");
if (_bootDevice == HOST_DEV) {
printf("OSystem_PS2::quit (HOST)\n");
+ #ifndef ENABLE_PROFILING
SleepThread();
+ #endif
+ // exit(0);
} else {
printf("OSystem_PS2::quit (bootdev=%d)\n", _bootDevice);
if (_useHdd) {