Debugging with Eclipse

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
snow
Posts: 31
Joined: Sat Dec 15, 2007 12:34 pm

Debugging with Eclipse

Post by snow »

Useful info:
PSPLINK 3.0 via USB (latest)
Eclipse 3.3 (Europa) using CDT plugin
PSP Slim 3.71 M33-2
PSPSDK (latest as of a few days ago)

So a debugging session begins in Eclipse and I can begin to step through the code (code listed at the bottom of this post). I step into the InitSnes9x() function and as soon as I attempt to step into ZeroMemory() the line stepping starts going screwy. It skips around lines in a somewhat random order and then periodically gets "back on track" and starts stepping through the code in an almost normal way (some lines will be skipped).

Since I'm still fairly new to PSP development I don't know if this is par for the course or if something else isn't functioning as it should. You can read the code in question below and you can read about my ambitions here: http://forums.ps2dev.org/viewtopic.php?t=9494 Just as an update I've been implementing the port specific functions for snes9x but I'm taking some time out now to start testing the progress I've made with simple system initialization.

Oh and this main.c file is a joke. I grabbed one of the templates from the SDK examples and plugged in code. I just wanted to see if I could make some wheels turn.

Code: Select all

#include <pspkernel.h>
#include <pspdebug.h>
#include "port.h"
#include "snes9x.h"
#include "memmap.h"
#include "controls.h"
#include "apu.h"


#define printf pspDebugScreenPrintf

void InitSnes9x&#40;&#41;;

/* Define the module info section */
PSP_MODULE_INFO&#40;"snes9xPSP", 0, 1, 1&#41;;

/* Define the main thread's attribute value &#40;optional&#41; */
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;
PSP_MAIN_THREAD_STACK_SIZE_KB&#40;256&#41;;

int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	pspDebugScreenInit&#40;&#41;;

	pspDebugScreenPrintf&#40;"Starting up snes9x\n"&#41;;
	
	InitSnes9x&#40;&#41;;

	return 0;
&#125;

void InitSnes9x&#40;&#41;
&#123;
	pspDebugScreenPrintf&#40;"Beginning initialization.\n"&#41;;
	
	ZeroMemory &#40;&Settings, sizeof &#40;Settings&#41;&#41;;
	
	Settings.MouseMaster = TRUE;
	Settings.SuperScopeMaster = TRUE;
	Settings.MultiPlayer5Master = TRUE;
	Settings.JustifierMaster = TRUE;
	Settings.ShutdownMaster = FALSE;
	Settings.BlockInvalidVRAMAccess = TRUE;
	Settings.HDMATimingHack = 100;
	Settings.APUEnabled = TRUE;
	Settings.NextAPUEnabled = TRUE;
	Settings.SoundPlaybackRate = 32000;
	Settings.Stereo = TRUE;
	Settings.SixteenBitSound = TRUE;
	Settings.SoundEnvelopeHeightReading = TRUE;
	Settings.DisableSampleCaching = TRUE;
	Settings.InterpolatedSound = TRUE;
	Settings.Transparency = TRUE;
	Settings.SupportHiRes = TRUE;
	Settings.SDD1Pack = TRUE;
	
	if&#40;!Memory.Init&#40;&#41;&#41;
	&#123;
		pspDebugScreenPrintf&#40;"Failed to initialize memory.\n"&#41;;
	&#125;
	else
	&#123;
		pspDebugScreenPrintf&#40;"Memory Initialized!\n"&#41;;
	&#125;
	
	S9xUnmapAllControls&#40;&#41;;
&#125;

void DeInitSnes9x&#40;&#41;
&#123;
	Memory.Deinit&#40;&#41;;
	S9xGraphicsDeinit&#40;&#41;;
	S9xDeinitAPU&#40;&#41;;
&#125;
kfactor
Posts: 4
Joined: Sat Nov 17, 2007 1:33 am

Post by kfactor »

Hi,

Make sure that you are building with optimizations turned-off (-O0) in your makefile, otherwise the GCC optimizer will kick in and reorder/optimize, and so your source code and the generated code will be slightly different.
snow
Posts: 31
Joined: Sat Dec 15, 2007 12:34 pm

Post by snow »

Hmmm good advice but that wasn't it. I'll keep poking around or maybe actually create a serious main entry point and try again.
snow
Posts: 31
Joined: Sat Dec 15, 2007 12:34 pm

Post by snow »

Actually, that was it. I did a clean/build once and it didn't work but strangely enough after I did it again it took. Thanks again.
Post Reply