 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Cy-4AH
Joined: 31 Jan 2007 Posts: 44 Location: Belarus
|
Posted: Mon Feb 19, 2007 7:14 pm Post subject: Maybe psp-gdb or psp-gcc buged or I do something wrong. |
|
|
The problem is that in psp-gdb breakpoints break program in incorrect places and in running by steps program enter in unrealizable conditions and jump over some lines. But I know that program work like it must to work because on psp screen I see right behavior.
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: |
#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();
}
|
File CyLib.h:
| Code: |
#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
|
File CyLib.cpp
| Code: |
#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;
}
|
makefile:
| Code: |
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 work in windows.
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. |
|
| Back to top |
|
 |
Cy-4AH
Joined: 31 Jan 2007 Posts: 44 Location: Belarus
|
Posted: Tue Feb 20, 2007 7:26 pm Post subject: |
|
|
| Of course sorry for my english. But anyone have any ideas? |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Tue Feb 20, 2007 7:41 pm Post subject: |
|
|
| One thing to bear in mind when debugging is due to optimisation (which can utterly screw up MIPS stuff) then steping and breaking inside code can sometimes cause problem. Try changing your CFLAGS from -O2 to -O0 and see if that helps any. |
|
| Back to top |
|
 |
gbj1
Joined: 08 Feb 2007 Posts: 45
|
Posted: Tue Feb 20, 2007 8:07 pm Post subject: |
|
|
gdb is still buggy, I think. I can see almost every one week there is an update to the psp-gdb on the svn.
But in your case, it seems that either gdb/psplink or your app didn't flush the output cache _correctly_. It was probably caused by code optimizion, but it rarely happens if the compilers/debuggers are fully bug-fixed, try to update your toolchain and see what happens. Also, you can try to add some output status on the psp screen( I mean, not only cycles but 'L_PRESSED' , 'R_PRESSED', 'CYCLE CHANGED FROM N TO N') along with gdb breakpoints, that would be another solution for now. _________________ guo.bojun@gmail.com |
|
| Back to top |
|
 |
Cy-4AH
Joined: 31 Jan 2007 Posts: 44 Location: Belarus
|
Posted: Wed Feb 21, 2007 7:49 pm Post subject: |
|
|
| Thx, TyRaNiD. It's helped. |
|
| Back to top |
|
 |
|
|
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
|