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 

Dumping heap information?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Wed Jan 23, 2008 4:47 am    Post subject: Dumping heap information? Reply with quote

How would I dump heap information on the PSP? And how from there would I be able to act upon the information given to mess with the heaps?

I know I need to use pspsysmem_kernel.h functions to edit the heaps, but the dumping the heaps is the problem, I need a function that can identify the heaps dumped, and return the uid but I can't seem to find one (maybe it has an obscure name?).

Thanks to anyone who helps.
-Aura
_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Wed Jan 23, 2008 9:36 am    Post subject: Reply with quote

The only way I know of is to parse the uid tree and pull out the sysmem or heap allocations directly :) Needs kernel mode though and depending what you mean by heap you might not get sensible results ;) i.e. if you are talking about malloc then that has little to do with sysmem other than it allocating a large block to begin with.
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Wed Jan 23, 2008 10:08 am    Post subject: Reply with quote

Probably sceKernelQueryHeapInfo, which is not in the pspsdk does what you want. I have never used it, but a quick look to the disassembly makes me believe that the usage is like this:

Code:

typedef HeapInfo
{
    SceSize size;
    u32 unknown[0x3C/4]
} HeapInfo;

HeapInfo heapinfo;
memset(&heapinfo, 0, sizeof(heapinfo));
heapinfo.size = sizeof(heapinfo);
sceKernelQueryHeapInfo(heapuid, &heapinfo);


The unknown will have the info about the heap, as I have never used it, don't know which kind of info will have, but probably easy to understand once you dump the data :)
Back to top
View user's profile Send private message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Thu Jan 24, 2008 5:56 am    Post subject: Reply with quote

Hi, thanks for the reply, the heaps I'm refering to are the ones made with sceKernelCreateHeap.

Umm, I'm looking for a function to find me the uid of the heap, this is proving to be the major problem.

Would sceKernelSysMemDumpBlock refer to the heaps, or other memory? I don't have access to a PSP at the moment so I can't test, all I can do is look through the header files.

Oh, and TyRaNiD, I know its likely to have been posted before, but is there any way to get debug output on 3.52 and above?

Thanks again.
-Aura
_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Jan 26, 2008 3:03 am    Post subject: Reply with quote

Trust me, stdout works just fine on my 3.6 slim :) I don't understand what people are doing wrong unless I forgot to add something to svn which I don't think so.
Back to top
View user's profile Send private message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Sat Jan 26, 2008 3:40 am    Post subject: Reply with quote

Could it possibly be because its a slim? I know that some stdio functions have worked different on the slim to the fat, an example is a flasher I made wrote fine using stdio on the fat PSPs, but not on the slims. Not sure if its likely, but who knows?

-Aura
_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Jan 26, 2008 4:53 am    Post subject: Reply with quote

No...

If you want to see if it is actually working try this, put some code into a module which does
Code:
sceIoWrite(1, "Hello\n", 6);
And see if it prints what you expect (i.e. hello) if that works then it is your newlib.

At some point (I can't be bothered to find out the exact revision) sceKernelStdout and sceKernelStderr started returning UID like file descriptors instead of the previous 1 and 2 although those aliases still work in the kernel. It was probably due in part to their fixing up of the file system to make it harder for user apps to fuck it all up. The old fdman code in newlib had an upper bound on the fd which meant that stdout and stderr were not mapped correctly, realistically you could just set them to 1 and 2 anyway, but ...

Blame Sony ;)
Back to top
View user's profile Send private message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Sat Jan 26, 2008 5:52 am    Post subject: Reply with quote

...Ok, sorry for wasting your time it appears I HAVN'T updated newlib, as I'm getting a printout now. Well anyway, thanks for clearing that up, means I can use PSPLink how I used to :)

-Aura
_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Sat Jan 26, 2008 6:11 am    Post subject: Reply with quote

This is going to sound really stupid... but how do I update? I thought I could get the newlib from svn://svn.ps2dev.org/psp/trunk/newlib-psp but it says no repository, and if I'm honest, I never actually use SVN normally...

-Aura
_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Jan 26, 2008 6:17 am    Post subject: Reply with quote

You need to get psptoolchain from psp/trunk/psptoolchain and for best results just do a complete rebuild, yes it is painful but hey ;)
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Jan 26, 2008 2:17 pm    Post subject: Reply with quote

TyRaNiD wrote:
You need to get psptoolchain from psp/trunk/psptoolchain and for best results just do a complete rebuild, yes it is painful but hey ;)


On my main system, it takes 30-40 minutes to do the entire toolchain. On my old laptop, it takes nearly 3 hours. :)

Even if you're at the hours end of the spectrum, you don't have to do it very often, so it's not that big a deal. Start the script and go eat dinner.
Back to top
View user's profile Send private message AIM Address
yabadabo



Joined: 30 Mar 2007
Posts: 10

PostPosted: Thu Mar 20, 2008 3:01 am    Post subject: Reply with quote

Hi, I just upgrade my FAT-PSP from 3.40OE to 3.90M2 and in a new PC installed cygwin + toolchain(svn) + psplink(svn)
Everything (psp-g++ and examples) compiled and builded fine, but printf stop working has stopped working on the psp prx's connected to the psplink.

Instead, using sceIoWrite(1, ..) works fine.

I have added the following code to overwrite the printf function and redirect it to the sceIOWrite.

extern "C" {
int printf( const char *msg, ... ) {
char buf[ 1024 ];
va_list ap;
va_start (ap, msg);
int n = vsnprintf (buf, 1023, msg, ap);
va_end (ap);
sceIoWrite( 1, buf, strlen( buf ) );
return n;
}
}

Hope can help somebody
Back to top
View user's profile Send private message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Thu Mar 20, 2008 3:05 am    Post subject: Reply with quote

If you read the post carefully you will see what is required, and yes, it really does work (thanks again TyRaNiD).

-Aura
_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
yabadabo



Joined: 30 Mar 2007
Posts: 10

PostPosted: Fri Mar 21, 2008 5:52 pm    Post subject: Reply with quote

Confirmed, it works as expected if I use the toolchain.sh from the svn and recompile everything. Initially, I was using the toolchain.sh from ps2dev.org which based on the differences I guess generated the problem.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
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