I have that problem before and thinked that it's psp-gdb bug, but yesterday I complelety reinstalled toolchain with gdb and problem stayed.
Maybe I do somethins wrong, can you correct me?
So, there is soure of my program:
File main.cpp:
Code: Select all
#include "../CyLib/Include/CyLib.h"
#define getPad sceCtrlReadBufferPositive
#define getLatch sceCtrlReadLatch
PSP_MODULE_INFO("Control Test", PSP_MODULE_USER, 1, 1);
int main()
{
pspDebugScreenInit();
SetupCallbacks();
printf("Control Test Programm\n");
int cycle = 200000;
sceCtrlSetSamplingCycle(cycle);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
SceCtrlData pad_data;
SceCtrlLatch pad_latch;
while (gRunning)
{
int cyr_cycle;
char x;
getPad(&pad_data, 1);
getLatch(&pad_latch);
sceCtrlGetSamplingCycle(&cyr_cycle);
pspDebugScreenSetXY(0, 0);
if (pad_data.Buttons & PSP_CTRL_RIGHT) cycle += 10;
if (pad_data.Buttons & PSP_CTRL_LEFT && cycle >= 10) cycle -= 10;
if (pad_data.Buttons & PSP_CTRL_UP) cycle += 100;
if (pad_data.Buttons & PSP_CTRL_DOWN && cycle >= 100) cycle -= 100;
if (pad_data.Buttons & PSP_CTRL_RTRIGGER)
cycle += 1000; // <- Line 33 I know it exactly
if (pad_data.Buttons & PSP_CTRL_LTRIGGER && cycle >= 1000)
cycle -= 1000; // <- Line 35
if (pad_data.Buttons & PSP_CTRL_TRIANGLE) break;
x = pad_data.Buttons & PSP_CTRL_CROSS ? 'X' : 'O';
if (cycle >= 1) cycle--;
printf("Current sampling cycle: %8d\nCurrent value try cycle: %8d\nX [%c]\n", cyr_cycle, cycle, x);
printf("Latch: MAKE: %8X BREAK %8X PRESS %8X RELEASE %8X\n", pad_latch.uiMake, pad_latch.uiBreak, pad_latch.uiPress, pad_latch.uiRelease);
sceCtrlSetSamplingCycle(cycle);
}
sceKernelExitGame();
}
Code: Select all
#ifndef _CY_LIB_
#define _CY_LIB_
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#define printf pspDebugScreenPrintf
int exit_callback(int arg1, int arg2, void *common);
int CallbackThread(SceSize args, void *argp);
int SetupCallbacks();
extern bool gRunning;
#endif
Code: Select all
#include "../Include/CyLib.h"
bool gRunning;
int exit_callback(int arg1, int arg2, void *common)
{
gRunning = false;
return 1;
}
/* 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()
{
int thid = 0;
gRunning = true;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, NULL);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
Code: Select all
TARGET = Control_Tst
OBJS = main.o ../CyLib/Src/CyLib.o
CFLAGS = -g -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
#LIBS=-lstdc++
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Control Test
#PSPSDK = c:/cygwin/usr/local/pspdev/psp/sdk
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
I added to PATH variable value C:\cygwin\bin, so I run all executables not via bash just like ordinal exe file.
PSP FW is 3.03OE-C
In psplink.ini enabled usbhost, usbshell, usbgdb.
So when I get Control_Tst.elf compiled I do:
Run usbshell -v.
Run pcterm.
In pcterm type debug Contrl_Tst.elf.
Run psp-gdb Control_Tst.elf.
In psp-gdb type:
target remote localhost:10001 //all is work, successfully connected
break main
c //successfully breaked on main entry point
break 35
c //program run until left trigger pressed, it is correct behavior
//when left trigger pressed psp-gdb write ... stoped... at line cycle-=1000;
//then when program stoped I type:
break 33
c //and program instantly stop and psp-gdb write ...stoped .. at line cycle+=1000
c
c
c //always the same
But! RTRIGGER wasn't pressed and on psp screen I see that cycle not increased by 1000.