forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Win32 native Toolchain for PSPSDK
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Thu Mar 26, 2009 6:04 am    Post subject: Reply with quote

Thanks, i just installed cdt 5.0.1 and it worked fine.
Back to top
View user's profile Send private message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Thu Mar 26, 2009 7:27 am    Post subject: Reply with quote

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..
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Thu Mar 26, 2009 8:19 am    Post subject: Reply with quote

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.

that's exactly the part I was talking about :
Quote:
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.

can you give more information about how you deal those other sce functions ?
Back to top
View user's profile Send private message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Thu Mar 26, 2009 10:48 am    Post subject: Reply with quote

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?.
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Thu Mar 26, 2009 9:08 pm    Post subject: Reply with quote

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 :
Quote:
In fact, I need to debug per instruction to be sure to follow the execution flow.


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?.
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) :/.
Back to top
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Fri Mar 27, 2009 2:04 am    Post subject: Reply with quote

I've updated the SDK to make alias for the GCC and G++ and the tutorial.

I've rebuilt the pspsh and usbhostfs_pc and will try it at home today and see if it interferes with firefox and can debug several times in a row...
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Fri Mar 27, 2009 7:04 pm    Post subject: Reply with quote

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 ?


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).

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.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Fri Mar 27, 2009 9:07 pm    Post subject: Reply with quote

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...

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 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.

It makes sense.
Back to top
View user's profile Send private message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Wed Apr 08, 2009 12:21 am    Post subject: Need help with gprof Reply with quote

Hi, i'm trying to profile some code (from timidity++) but this is all i'm getting with gprof.

Code:
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


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.
Back to top
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Wed Apr 08, 2009 2:15 am    Post subject: Reply with quote

Are you compiling and linking everything with -pg ?

It looks like GCC didn't instrument the binary code to add the profilling data.

Check if you have in your CFLAGS = -pg and you did a make clean before...
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Wed Apr 08, 2009 4:53 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Wed Apr 08, 2009 5:44 am    Post subject: Reply with quote

humm... i thought i had patched the SDK to include the gprof stuff but i guess i lost that patch, about the heap i usually always allocate all the heap i never run into that but it is a nice thing for me to add to the tutorial...
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Wed Apr 08, 2009 9:47 am    Post subject: Reply with quote

Mmm, i'm getting the same result with the gprof sample, only the sceKernelRegisterExitCallback is being profiled ...
Back to top
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Thu Apr 09, 2009 3:04 am    Post subject: Reply with quote

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)


Code:
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


With this makefile i managed to get the exact same gmon i used on the tutorial and this is my sample C code:

Code:

#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;
}


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.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Thu Apr 09, 2009 5:35 am    Post subject: Reply with quote

Thanks a lot for your help, it's working as expected now. By the way if you use PSP_HEAP_SIZE_KB( 256 or higher ) in the prx, it does create a gmon file (around the same size) but with only the sceKernelRegisterExitCallback function.

Hope someone can figure it out.
Back to top
View user's profile Send private message
willow :--)



Joined: 13 Jan 2007
Posts: 126

PostPosted: Mon May 18, 2009 9:00 pm    Post subject: Reply with quote

When trying to compile one of my projects with version 0.9.3 (as found on sourceforge.net), I get the following error:

Code:
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:

// 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);
Back to top
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Tue May 19, 2009 6:33 am    Post subject: Reply with quote

you're not it is my fault i build the sdk with my experimental patches, sorry about that...
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
willow :--)



Joined: 13 Jan 2007
Posts: 126

PostPosted: Tue May 19, 2009 10:14 am    Post subject: Reply with quote

Heimdall wrote:
sorry about that...

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)
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Sun May 24, 2009 7:43 pm    Post subject: Reply with quote

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
Code:

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


Beggining of main
Code:

#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");

Commented lines are removed, like ones for command line parameters or window icons. Repeating, log file IS CREATED, but it's EMPTY.
HELP!
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Tue May 26, 2009 1:10 am    Post subject: Reply with quote

I tried compiling on Windows (XP), same error. Newest SDK version.
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Tue May 26, 2009 4:00 am    Post subject: Reply with quote

When I try to run the .elf file with PSPLink, it displays me:
Code:

Failed to Load/Start module 'host0:/meritous.elf' Error: 0x80020148


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:

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 ???
Back to top
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Wed May 27, 2009 6:43 am    Post subject: Reply with quote

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):

Quote:
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.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9
Page 9 of 9

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group