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 

psp-addr2line question / help

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



Joined: 20 Oct 2008
Posts: 355

PostPosted: Mon Jun 15, 2009 5:25 am    Post subject: psp-addr2line question / help Reply with quote

i have no idea how to use this so can someone explain it and i've looked it up and not really sure of the options etc

now the main reason is my app consit of alot of prx's can psp-addr2line find out which file/line the problem occured on if it occures in a prx and not in the main

how can i use psplink with eclipse on ubuntu 9.04 to debug this app with its prxs because debugging is becomming a pain
Back to top
View user's profile Send private message MSN Messenger
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Mon Jun 15, 2009 5:59 am    Post subject: Reply with quote

When you use PSPLINK and your app is crashing you gat an exeption.

If you type right after the crash:
calc $epc-$mod

you get an number like:
0x00015A45

Now you can run:
psp-addr2line -e appname.elf 0x00015A45

The program will output the line in your code which causes the crash.
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Mon Jun 15, 2009 6:36 am    Post subject: Reply with quote

well i added -g option and got this when trying to compile

got that same error above with the relocation and i cant figure out how to fix any suggestion would be appreciated

Code:
Code:
relocation truncated to fit: R_MIPS_GPREL16 against `_ftext'



full:
Code:
Code:
exception/exception.o: In function `ExceptionHandler':
exception.c:(.text+0xa8): relocation truncated to fit: R_MIPS_GPREL16 against `_ftext'
collect2: ld returned 1 exit status
make: *** [make.elf] Error 1


here is the thing i'm using for exception handling
Code:
#include <pspkernel.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

PspDebugRegBlock exception_regs;

extern SceModule module_info;
extern int _ftext;

static const char *codeTxt[32] =
{
    "Interrupt", "TLB modification", "TLB load/inst fetch", "TLB store",
    "Address load/inst fetch", "Address store", "Bus error (instr)",
    "Bus error (data)", "Syscall", "Breakpoint", "Reserved instruction",
    "Coprocessor unusable", "Arithmetic overflow", "Unknown 14",
    "Unknown 15", "Unknown 16", "Unknown 17", "Unknown 18", "Unknown 19",
    "Unknown 20", "Unknown 21", "Unknown 22", "Unknown 23", "Unknown 24",
    "Unknown 25", "Unknown 26", "Unknown 27", "Unknown 28", "Unknown 29",
    "Unknown 31"
};

static const unsigned char regName[32][5] =
{
    "zr", "at", "v0", "v1", "a0", "a1", "a2", "a3",
    "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
    "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
    "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"
};

void ExceptionHandler(PspDebugRegBlock * regs)
{
    int i;
    SceCtrlData pad;

    pspDebugScreenInit();
    pspDebugScreenSetBackColor(0x00FF0000);
    pspDebugScreenSetTextColor(0xFFFFFFFF);
    pspDebugScreenClear();
    pspDebugScreenPrintf("Your PSP has just crashed!\n");
    pspDebugScreenPrintf("Exception details:\n\n");

    pspDebugScreenPrintf("Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]);
    pspDebugScreenPrintf("EPC       - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext));
    pspDebugScreenPrintf("Cause     - %08X\n", (int)regs->cause);
    pspDebugScreenPrintf("Status    - %08X\n", (int)regs->status);
    pspDebugScreenPrintf("BadVAddr  - %08X\n", (int)regs->badvaddr);
    for(i=0; i<32; i+=4) pspDebugScreenPrintf("%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]);

    sceKernelDelayThread(1000000);
    pspDebugScreenPrintf("\n\nPress X to dump information on file exception.log and quit");
    pspDebugScreenPrintf("\nPress O to quit");

    for (;;){
        sceCtrlReadBufferPositive(&pad, 1);
        if (pad.Buttons & PSP_CTRL_CROSS){
            FILE *log = fopen("exception.log", "w");
            if (log != NULL){
                char testo[512];
                snprintf(testo, sizeof(testo), "Exception details:\n\n");
                fwrite(testo, 1, strlen(testo), log);
                snprintf(testo, sizeof(testo), "Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]);
                fwrite(testo, 1, strlen(testo), log);
                snprintf(testo, sizeof(testo), "EPC       - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext));
                fwrite(testo, 1, strlen(testo), log);
                snprintf(testo, sizeof(testo), "Cause     - %08X\n", (int)regs->cause);
                fwrite(testo, 1, strlen(testo), log);
                snprintf(testo, sizeof(testo), "Status    - %08X\n", (int)regs->status);
                fwrite(testo, 1, strlen(testo), log);
                snprintf(testo, sizeof(testo), "BadVAddr  - %08X\n", (int)regs->badvaddr);
                fwrite(testo, 1, strlen(testo), log);
                for(i=0; i<32; i+=4){
                    snprintf(testo, sizeof(testo), "%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]);
                    fwrite(testo, 1, strlen(testo), log);
                }
                fclose(log);
            }
            break;
        }else if (pad.Buttons & PSP_CTRL_CIRCLE){
            break;
        }
      sceKernelDelayThread(100000);
    }
    sceKernelExitGame();
}

void initExceptionHandler()
{
   SceKernelLMOption option;
   int args[2], fd, modid;

   memset(&option, 0, sizeof(option));
   option.size = sizeof(option);
   option.mpidtext = PSP_MEMORY_PARTITION_KERNEL;
   option.mpiddata = PSP_MEMORY_PARTITION_KERNEL;
   option.position = 0;
   option.access = 1;

   if((modid = sceKernelLoadModule("exception.prx", 0, &option)) >= 0)
   {
      args[0] = (int)ExceptionHandler;
      args[1] = (int)&exception_regs;
      sceKernelStartModule(modid, 8, args, &fd, NULL);
   }
}
Back to top
View user's profile Send private message MSN Messenger
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Mon Jun 15, 2009 9:47 pm    Post subject: Reply with quote

What's the makefile look like?

Specifically the -G* flag.
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Mon Jun 15, 2009 10:01 pm    Post subject: Reply with quote

makefile:

Code:
PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = $(PSPSDK)/../bin
MAKE = $(shell make)

TARGET = make
 
EVENTS = events/Callbacks.o \
       events/sys_redraw.o \
       events/control_callbacks.o
      
IMPORTS = ../controls/control_bridge.o \
        ../initconf/initconf_lib.o
       
EXPORTS = exports/exports.o \
        exports/graphics.o

OBJS =    main.o \
      exception/exception.o \
      global.o \
      MagnificentG.o \
      Logger.o \
      MagControls.o \
      $(IMPORTS) \
      $(EVENTS) \
      $(EXPORTS)

INCDIR =
LIBDIR =

#CFLAGS = -O3 -frename-registers -ffast-math -fomit-frame-pointer -g -G0 -Wall
CFLAGS = -Wall -g -G0
CXXFLAGS = $(CFLAGS) -fexceptions -frtti
#-fno-rtti
ASFLAGS = $(CFLAGS) 

LDFLAGS =

INCS = -I/usr/local/pspdev/include \
      -I/usr/local/pspdev/psp/include \
      -I/usr/local/pspdev/psp/sdk/include

CFLAGS := $(INCS)

STDLIBS =
STDLIBS += -lGL -lpspvfpu -lpspirkeyb
STDLIBS += -lpspctrl -lpspumd -lpsprtc -lpsppower
STDLIBS += -lpspaudio -lpsphprm -lpspgu -lpspgum
STDLIBS += -lpspmpeg -lpsprtc -lpspsdk -lmikmod
STDLIBS += -lpspaudiocodec -lpspatrac3 -lpng
STDLIBS += -lAac -lFLAC -lvorbisidec -lmad
STDLIBS += -lpspusb -lpspusbstor -lpspkubridge
STDLIBS += -lpspsystemctrl_user -lpspinit
STDLIBS += -lc -lm -lz -lstdc++ -ljpeg

YOURLIBS = -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL -lconfig++ -lanytype -lunzip

LIBS = $(YOURLIBS) $(STDLIBS)

PSP_FW_VERSION = 500
BUILD_PRX = 1
PRX_EXPORTS = exports.exp

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = MagnificentG
PSP_EBOOT_ICON = NULL

include ../locations.mak
include $(PSPSDK)/lib/build.mak

dump: $(shell psp-objdump -t make.elf > objdump.txt)

s_file:   
   $(shell psp-build-exports -s exports.exp)

install:
   mkdir -p $(MAIN_LOC)
   cp -fT EBOOT.PBP $(MAIN_DEST)
   
Back to top
View user's profile Send private message MSN Messenger
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Wed Jun 17, 2009 4:24 am    Post subject: Reply with quote

i did that and i got

Code:
host0:/> Exception - Bus error (data)
Thread ID - 0x04DB5479
Th Name   - user_main
Module ID - 0x00CDFA6D
Mod Name  - "desktop"
EPC       - 0x08F5565C
Cause     - 0x1000001C
BadVAddr  - 0x80020166
Status    - 0x20008613
zr:0x00000000 at:0x09040000 v0:0x00000000 v1:0x00000078
a0:0x09046890 a1:0x00000001 a2:0x09F7FE10 a3:0x00000154
t0:0x00000078 t1:0x00000000 t2:0x00000000 t3:0x00000000
t4:0x0000003F t5:0x0904C490 t6:0x00000000 t7:0x00000078
s0:0x0904C450 s1:0x09020000 s2:0x00000000 s3:0x09F7FEE0
s4:0x09030000 s5:0x00000013 s6:0xDEADBEEF s7:0xDEADBEEF
t8:0x00000154 t9:0x880107E0 k0:0x09F7FF00 k1:0x00000000
gp:0x09026C00 sp:0x09F7FDE8 fp:0x09F7FEA0 ra:0x08F55950
calc $epc-$mod
Unknown register 'mod'
Error could not calculate address
Back to top
View user's profile Send private message 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
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