Win32 native Toolchain for PSPSDK
Just to let you know, i have compiled successfully the simple cube demo following your tutorial, wich is really nice hope you can continue working on it, specially the debugging part.
When i start debugging the app there is some error with the sceDisplayWaitVblankStart function, it complains about something like
"GDB is unable to find the start of the function at 0x880a408", i have managed to Step into other sce functions by pointing to the corrent source path, but does not work with this function. Will take a look at it.
Anyway, thanks for your work on this..
When i start debugging the app there is some error with the sceDisplayWaitVblankStart function, it complains about something like
"GDB is unable to find the start of the function at 0x880a408", i have managed to Step into other sce functions by pointing to the corrent source path, but does not work with this function. Will take a look at it.
Anyway, thanks for your work on this..
that's exactly the part I was talking about :theHobbit wrote:When i start debugging the app there is some error with the sceDisplayWaitVblankStart function, it complains about something like
"GDB is unable to find the start of the function at 0x880a408", i have managed to Step into other sce functions by pointing to the corrent source path, but does not work with this function.
can you give more information about how you deal those other sce functions ?There is also an issue with stepping over sce-like functions : it breaks in the stub function (jr $ra; syscall ...) and trying to step out is like resuming execution. Quite an annoyance.
Well enabling the Instruction Stepping Mode in the Debug view, allows me to step over any function withow breaking the program, even the sceDisplay* or sceGe* ones, but it does show a "No source available for "" " warning with these.
Maybe because these functions are part of an external prx, like the audio and display drivers from the psp firmware?. Speaking of wich have anyone managed to debug a prx loaded at runtime?. Is it posible?.
Maybe because these functions are part of an external prx, like the audio and display drivers from the psp firmware?. Speaking of wich have anyone managed to debug a prx loaded at runtime?. Is it posible?.
theHobbit wrote:Well enabling the Instruction Stepping Mode in the Debug view, allows me to step over any function withow breaking the program, even the sceDisplay* or sceGe* ones, but it does show a "No source available for "" " warning with these.
so it is like I said :
In fact, I need to debug per instruction to be sure to follow the execution flow.
kernel sce-like functions are external and are called through a stub like "jr $ra; syscall ..." and debug probably cannot find any reference to a source line as it is external (no debug description) :/.theHobbit wrote:Maybe because these functions are part of an external prx, like the audio and display drivers from the psp firmware?. Speaking of wich have anyone managed to debug a prx loaded at runtime?. Is it posible?.
So i've been trying the psplink stuff in a clean pc installation. I've installed my eclipse 5.0.1 (Ganymede SR1) setup the cube project for debugging (CFLAGS += -g) and (BUILD_PRX=1).hlide wrote:Some progress but just some. I need to close FireFox so PSPSH can run properly (displaying a prompt like "host0:>") .
And yes debugging is not working properly. When I tried cube.prx (-g -O0), it seemed to work. But with my source (-g O2), I have kind of erratic behavior in the source windows.
In fact, I need to debug per instruction to be sure to follow the execution flow. And the normal "step in", "step over" and "step out" don't seem to work as I used to with visual studio, making them mostly unusable.
There is also an issue with stepping over sce-like functions : it breaks in the stub function (jr $ra; syscal ...) and trying to step out is like resuming execution. Quite an annoyance.
Is that normal ?
Setup the 2 external tools:
usbhostfs_pc and pspsh.
Then rebuild the cube projet.
Once I've the cube project compiled, I've started the external tool usbhostfs_pc, since I configured it to use the project location, I need to highlight it from the project explorer before run the tool, once I get it ok, I get on the console a connected to device.
This i just leave running all the time, so now i start the other tool, the pspsh, after the credits i type:
./cube.prx
and I see the cube rotating on the PSP, so everything is OK. I then type reset and prepare for the debugging session by typing:
debug cube.prx
I get a message saying the prx is loaded so i start my debugger from eclipse, it stops in the start of the main function and then i let it run. Everything OK here, so I stop the debugger session on the stop button.
Now, to debug again I need to go to the console window, and select the pspsh console (which you can select by using the second icon from the right to the left, if i'm not mistaken, the tooltip can lead you better) and type again:
debug cube.prx
and start the eclipse debugger and it works.
I've done this a couple of times in a row and I managed to debug as many times as I wanted.
About the stepping issues, I have the same issue and also get it if I debug native applications, so I guess... it is again either some bug on gdb or the eclipse gdb frontend, but I need to look into it further...
About firefox, I get no issues, I got however a problem in my work machine because some service was already binded to the 10000 port, make sure that your firefox has no plugin or something that binds to the ports 10000 to 10010. That could be it.
yes, those are the left issues with Eclipse debug (and when I don't run FireFox of course) right now for me.Heimdall wrote:About the stepping issues, I have the same issue and also get it if I debug native applications, so I guess... it is again either some bug on gdb or the eclipse gdb frontend, but I need to look into it further...
It makes sense.Heimdall wrote:About firefox, I get no issues, I got however a problem in my work machine because some service was already binded to the 10000 port, make sure that your firefox has no plugin or something that binds to the ports 10000 to 10010. That could be it.
Need help with gprof
Hi, i'm trying to profile some code (from timidity++) but this is all i'm getting with gprof.
I'm calling gprof_cleanup() before sceKernelExitGame() as suggested in your tutorial. Also i had to remove a call to sceKernelDeleteThread wich deletes some controller/hprm thread because it was hanging the app, and gprof complained about an unexpected end of file.
Code: Select all
Flat profile:
Each sample counts as 0.001 seconds.
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 7755950 0.00 0.00 sceKernelRegisterExitCallback
Call graph
granularity: each sample hit covers 2 byte(s) no time propagated
index % time self children called name
0.00 0.00 7755950/7755950 <hicore> (2)
[1] 0.0 0.00 0.00 7755950 sceKernelRegisterExitCallback [1]
-----------------------------------------------
Index by function name
[1] sceKernelRegisterExitCallback
Yes everything is compiled and linked with -pg. Now just to let you know, I thought gprof was already part of the pspsdk but when i tryied to compile the code there was an error about some undefined reference to _mcount and there was no gprof sample in the pspsdk samples either. So i downloaded this file http://urch.in/gprof/gprof.zip and added the prof.c and mcount.S file to the project and everything compiled fine, but i'm not getting the desired results.
Also just tryied the gprof sample from the gprof.zip file but the gmon.out file is not being created :(. Am I missing something?
[EDIT]
Ok, putting PSP_HEAP_SIZE_KB( 256 ); in the gprof sample did the trick, tryied with lower heap values but with no luck. Is this normal? I'm working with a PSP Slim 5.00 m33-6.
Also just tryied the gprof sample from the gprof.zip file but the gmon.out file is not being created :(. Am I missing something?
[EDIT]
Ok, putting PSP_HEAP_SIZE_KB( 256 ); in the gprof sample did the trick, tryied with lower heap values but with no luck. Is this normal? I'm working with a PSP Slim 5.00 m33-6.
Ok, so I've debugged this and here are my findings:
BUILD_PRX = 1 will not give you a gmon.out (profiler doesn't work, don't know why yet)
With this makefile i managed to get the exact same gmon i used on the tutorial and this is my sample C code:
If i enable -O2 GCC is smart enough to inline everything in the main method and I get the same result you were having, without automatic optimizations it works as expected.
BUILD_PRX = 1 will not give you a gmon.out (profiler doesn't work, don't know why yet)
Code: Select all
TARGET = gprof
OBJS = main.o
LIBS = -lpspprof
INCDIR =
CFLAGS = -G0 -Wall -pg
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = gprof test
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Code: Select all
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspprof.h>
#include <pspdisplay.h>
#include <stdio.h>
#include <stdlib.h>
PSP_MODULE_INFO("GPROF", 0x0000, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
extern void gprof_cleanup();
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
static int dummy = 0;
static int dummy2 = 0;
void nested()
{
dummy2++;
}
void loops_10_times()
{
if (dummy & 1)
{
nested();
}
dummy++;
}
void wait1second()
{
sceKernelDelayThread(1000000);
}
void wait2seconds()
{
sceKernelDelayThread(2000000);
}
int main(void)
{
int i;
pspDebugScreenInit();
SetupCallbacks();
for(i = 0; i < 10; i++)
{
loops_10_times();
}
wait1second();
wait2seconds();
wait1second();
gprof_cleanup();
sceKernelExitGame();
return 0;
}
-
- Posts: 107
- Joined: Sat Jan 13, 2007 11:50 am
When trying to compile one of my projects with version 0.9.3 (as found on sourceforge.net), I get the following error:
Commenting out the following lines in pspmpeg.h seems to solve my issues. Could someone confirm I'm not doing something completely stupid?
Code: Select all
C:/pspsdk/psp/sdk/include/pspmpeg.h:356: error: 'SceMpegAuMode' has not been declared
Commenting out the following lines in pspmpeg.h seems to solve my issues. Could someone confirm I'm not doing something completely stupid?
Code: Select all
// Missing API
SceInt32 sceMpegQueryPcmEsSize(SceMpeg *mp, SceInt32 *iEsSize, SceInt32 *iOutSize);
SceInt32 sceMpegChangeGetAuMode(SceMpeg *mp, SceMpegStream *pStream, SceMpegAuMode iAuMode);
SceInt32 sceMpegGetPcmAu(SceMpeg *mp, SceMpegStream *pStream, SceMpegAu *pAu, SceInt32 *iAttr);
SceInt32 sceMpegFlushStream(SceMpeg *mp, SceMpegStream *pStream);
SceInt32 sceMpegAvcDecodeDetail(SceMpeg *mp, SceMpegAvcDecodeDetailInfo *pDetail);
-
- Posts: 107
- Joined: Sat Jan 13, 2007 11:50 am
Haha, don't be, I'm very thankful for this toolchain, it's made the development process for JGE applications way easier! (JGE allows to create both a windows and a psp binary with the same code. It's easier to debug a windows application than a PSP one, but switching between Linux and windows for compilation all the time was a nightmare. And cygwin was not my cup of tea)Heimdall wrote:sorry about that...
I use newest SDK version for Ubuntu 9.04, made a fresh install (!) especially for this SDK! I am making a PSP port of game Meritous. I already ported the source code from C to C++ and compiled it sucessfully, but it gives me just a black screen and popping noise. Version compiled on Ubuntu standard gcc works fine. I decided to make some log file fprintfs, but neither setbuf(log, NULL) or fflush(log) does NOT save anything to log file! I don't use any IDE. Game uses SDL, SDL_mixer and SDL_image. Here's some code:
Makefile
Beggining of main
Commented lines are removed, like ones for command line parameters or window icons. Repeating, log file IS CREATED, but it's EMPTY.
HELP!
Makefile
Code: Select all
TARGET = meritous
OBJS = src/levelblit.o \
src/mapgen.o \
src/demon.o \
src/gamemap.o \
src/tiles.o \
src/save.o \
src/help.o \
src/audio.o \
src/boss.o \
src/ending.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS = -lSDL_mixer -logg -lvorbis -lvorbisenc -lvorbisidec -lvorbisfile -lSDL_image -ljpeg -lpng -lz -lSDLmain -lSDL -lm -lc
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Meritous
PSPSDK=/home/marach/pspsdk/psp/sdk
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
include $(PSPSDK)/lib/build.mak
Code: Select all
#define SCREEN_W 480
#define SCREEN_H 272
#define BPP 8
/* some code ... */
extern "C" int main(int, char**)
{
FILE* log = fopen("Log.txt", "w");
setbuf(log, NULL);
fprintf(log, "App start\n");
fflush(log);
int on_title = 1;
int executable_running = 1;
SDL_Surface *title, *title_pr, *asceai;
Uint8 *src_p, *col_p;
int i;
int light = 0;
int x, y;
int pulse[SCREEN_W * SCREEN_H];
int precalc_sine[400];
int tick = 10000000;
int option = 0;
int can_continue = 0;
int maxoptions;
int last_key = 0;
int ticker_tick = 0;
unsigned int stime = 0;
fprintf(log, "Init 1\n");
if ((RECORDING) && (PLAYBACK)) {
exit(1);
}
srand(time(NULL));
if (RECORDING) {
record_file = fopen(record_filename, "wb");
stime = time(NULL);
fputc(stime & 0x000000FF, record_file);
fputc((stime & 0x0000FF00) >> 8, record_file);
fputc((stime & 0x00FF0000) >> 16, record_file);
fputc((stime & 0xFF000000) >> 24, record_file);
srand(stime);
}
if (PLAYBACK) {
record_file = fopen(record_filename, "rb");
stime = fgetc(record_file);
stime |= fgetc(record_file) << 8;
stime |= fgetc(record_file) << 16;
stime |= fgetc(record_file) << 24;
srand(stime);
}
fprintf(log, "Init 2\n");
asceai = IMG_Load("dat/i/asceai.png");
screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, BPP, SDL_SWSURFACE | SDL_FULLSCREEN);
InitAudio();
fprintf(log, "Init 3\n");
text_init();
for (i = 0; i < 400; i++) {
precalc_sine[i] = sin((float)i / 400 * M_PI * 2)*24+24;
}
for (i = 0; i < screen->w * screen->h; i++) {
x = i % SCREEN_W;
y = i / SCREEN_W;
pulse[i] = dist(x, y, SCREEN_W / 2, SCREEN_H / 2);
}
SetGreyscalePalette();
fprintf(log, "Init 4\n");
// asceai logo
SDL_BlitSurface(asceai, NULL, screen, NULL);
for (i = 0; i < 75; i++) {
SetTitlePalette(i * 5 - 375, i * 5 - 120);
VideoUpdate();
DummyEventPoll();
EndCycle(20);
}
SDL_Delay(500);
for (i = 0; i < 50; i++) {
SetTitlePalette(i * 5, 255 - (i * 5));
VideoUpdate();
DummyEventPoll();
EndCycle(20);
}
SDL_Delay(500);
for (i = 0; i < 50; i++) {
SetTitlePalette(255, (i * 5)+5);
VideoUpdate();
DummyEventPoll();
EndCycle(20);
}
fprintf(log, "Init 5\n");
HELP!
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
marach5 (at) gmail (dot) com ???
When I try to run the .elf file with PSPLink, it displays me:
Any ideas? Help please!
EDIT:
Nevermind, fixed, i had to build a prx.
BUT, when I tried to run that prx, console screen just went off and pspsh stopped responding after writing exprint. help...
EDIT:
That's wat I received in usbhostfs screen:
?
Code: Select all
Failed to Load/Start module 'host0:/meritous.elf' Error: 0x80020148
EDIT:
Nevermind, fixed, i had to build a prx.
BUT, when I tried to run that prx, console screen just went off and pspsh stopped responding after writing exprint. help...
EDIT:
That's wat I received in usbhostfs screen:
Code: Select all
Error reading open data cmd->extralen 9d, ret -116
Error in open command
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
marach5 (at) gmail (dot) com ???
I think from the psplink documentation if you use an OE firmware you must use PRX elf's won't work. From the documentation (page 10):
Try and build the sprite sample now as a PRX file. Edit the Makefile and add the line BUILD_PRX=1 after the ASFLAGS line and type make clean; make. You should now have a sprite.prx file in the sample directory. NOTE: This is important when running code on 3.XOE
which only supports PRXes.