Unhandled exception: error's in kos

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Unhandled exception: error's in kos

Post by Ian Micheal »

Can any one tell me what this really means i can see some thing about cpu regster but other then that i cant work out how to track down this problem in a program.

Code: Select all

Unhandled exception: PC 8c02bbb8, code 1, evt 00e0 
R0-R7: 0000011a 8c5285c0 00000000 00000010 0000011a fffffffc 00000001 00000130 
R8-R15: 8c161044 00000d00 0000011a 8c0c7780 8c0d5dd8 8c0c7260 8c16102c 8cffff90 
SR 40000000 PR 8c010fec 
kernel panic: unhandled IRQ/Exception 
arch: aborting the system
Dreamcast forever!!!
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7499
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 10 times
Contact:

Post by Quzar »

what it pritns out is what is in each register at the time that the exception happened, what event codes this was classified as and what the kernel is returning. i doubt without close examination of the asm version of your code, anyone would understand exactly what the problem is based on that.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

I was troubleshooting a problem like this once don't know if it will help but heres the link to the message

http://www.dcemulation.org/phpBB/viewto ... highlight=

humandislocation had an idea that might work if you understand how to do what he suggests.

Troy
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

just read what he said i dont know how to do that i think he means a compiler flag that turnes that on but im not sure.

hmmm...
Dreamcast forever!!!
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

yeah its some kind of compiler flag, I have only seen the flag -fomit-frame-pointer which mean to not compile with frame-pointers so it probably pretty close to this flag.

What we need is to be able to run gdb over the serial port, so we can step through code, that would be a lot better for debugging.

Troy
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

I think i have to use -01 or some thing as -02 Turns that flag on.

hit a major barrier this time it looks like heh.
Dreamcast forever!!!
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

compile with flag -DFRAME_POINTERS and also use -g to enable debugging, then you should get a stack track that you can run through
dc-addr2line to figure out the line number the error is occuring on.

-------- Stack Trace (innermost first) ---------
8c01016a
8c0101e0
8c010478
8c010062
-------------- End Stack Trace -----------------

>] dc-addr2line -e asserthnd.elf 8c01016a 8c0101e0 8c010478
/usr/local/home/bard/prj/kos/examples/dreamcast/basic/asserthnd/asserthnd.c:46
/usr/local/home/bard/prj/kos/examples/dreamcast/basic/asserthnd/asserthnd.c:69
/usr/local/home/bard/prj/kos/kernel/arch/dreamcast/kernel/main.c:129


This is from the comments for the asserthnd.c example in KOS. but I believe from the other thread that this should work for your code also.

Try it out, It would be neat to have another debug tool, that has been tested :)

Troy
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

Im not exact sure how to do this if i sent you a elf could you try it? or is it pretty easy to do how would i do this dc-addr2line were is this app or is it a command line thing.

Cant find it yet.

sorry for the newbie ? on this it's completly new to me.
Dreamcast forever!!!
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

Is the question about how to compile with the flags or is it how to run dc-addr2line?

dc-addr2line is a commandline function, should be in your sh-elf/bin folder. depending on how you built your gcc toolchain it could be called
sh-elf-addr2line.exe instead. Actually mine is called that instead. Wierd, I must have a compiled the tool-chain differently at work. I have never actually run it for dreamcast code, I have run it for debugging normal cygwin window apps once before so I am by no means an expert. :)

Troy
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

I changed the compiler flags and have the elf ready i was trying to find out were is dc-addr2line was. and how to envoke it from the commandline do i just start cygwin as normal run my environ file then cd to the directory or just type dc-addr2line -e asserthnd.elf

how do i get the stack trace nothing showed up when i compiled the elf.

confused at that step on how to get the stack trace to run throu this program.
Dreamcast forever!!!
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

You should now upload the "special" elf with dc-tool, and execute it, when it gets to the part in your code where there is a problem there should be additional information in the dc-tool window output a stack trace with addresses.

then from the cygwin bash command type

sh-elf-addr2line.exe -e ianscode.elf address1 address2 address3

the address are from the stack track that I believe should be in the dc-tool output.

if you don't get the stack trace in the dc-tool output let me know.

Troy
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

Im not geting any thing much new in the log file.

Code: Select all

Console enabled
>Opening com1 at 115200
Upload <test.elf>
File format is elf32-little, start address is 0x8c010000
Section .text, lma 0x8c010000, size 755710
send_data: CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
Section .rodata, lma 0x8c0c8800, size 640004
send_data: CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCUUCCUUCUUUCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
Section .data, lma 0x8c164c84, size 42560
send_data: CCCCCC
Section .ctors, lma 0x8c16f2c4, size 8
send_data: U
Section .dtors, lma 0x8c16f2cc, size 8
send_data: U
effective: 24359.217546 bytes / sec
Executing at <0x8c010000>
Sending execute command (0x8c010000, console=1)...executing

--
KallistiOS 1.1.9: Fri Nov 28 04:47:53 AUSEDT 2003
maple: active drivers:
    VMU Driver: Clock, LCD, MemoryCard
    Mouse Driver: Mouse
    Keyboard Driver: Keyboard
    Controller Driver: Controller
  DMA Buffer at ac4d3f00
vid_set_mode: 640x480IL NTSC
fs_romdisk: mounting image at 0x8c0c8e20 at /rd
dc-load console support enabled
maple: attached devices:
  A0: Dreamcast Controller          (01000000: Controller)
  A1: Visual Memory                 (0e000000: Clock, LCD, MemoryCard)
  B0: Keyboard                      (40000000: Keyboard)
NeoCD/SDL LITE 0.3.0
Compiled on: Mar 25 2004 14:51:09
NEOGEO: Allocating memory...
PRG (2MB) ... OK!
SPR (4MB) ... OK!
ROM (512kb) ... OK!
FIX (128kb) ... OK!
PCM (1Mb) ... OK!
vid_set_mode: 320x240 NTSC

Opened Joystick 0
Name: Dreamcast Controller         
Number of Axes: 6
Number of Buttons: 8

Detecting CD-ROM drives... 1 CD-ROM drives found
Trying /cd
fs_iso9660: disc change detected
Found Neogeo CD in drive: /cd
CD Audio OK!
Unhandled exception: PC 00000033, code 1, evt 00e0
 R0-R7: 00000004 00000000 00000000 00000000 0000000a 8c164dbc 00000034 66666667
 R8-R15: 0000001a 8c164d90 00000d00 8c164d8c 8c192b78 00000000 0000000f 8cffffd8
 SR 40000000 PR 00000033
kernel panic: unhandled IRQ/Exception
arch: aborting the system
well the code now has sound disabled and no none cleared gpl bits i could give it to you but to test you need a burned neo geo game or a real one.

dont know whats the problem i use dctool 1.02 could that be it?
Dreamcast forever!!!
humandislocation
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 29
Joined: Tue Sep 30, 2003 7:40 am
Has thanked: 0
Been thanked: 0

Post by humandislocation »

I could be wrong here, but I think I recall having to recompile KOS with frame pointers enabled in order to get the callstack to work. Otherwise it doesn't show up.

It was a few weeks ago now, and I've not had time to mess around with my dreamcast since then, so my memory is a little fuzzy on the subject.
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

will have to try that humandislocation it would be a great help if it indeed works.. :D
Dreamcast forever!!!
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

I added the -DFRAME_POINTERS to my KOS_FLAGS and removed -fomit-frame-pointer and recompiled KOS, also recompiled my code.

I am not getting any kind of stack trace either. Do I have to change my code, or add anything to get the stack trace ?

Thank,
Troy
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

found some more information from Dan Potter over in this thread
http://www.consolevision.com/forums/YaB ... 60;start=1

Quote:Well you see it compiles fine but then i run it and in my code there is this one big function that does a lot of stuff, and at the end of the function (when it should return to the main program loop), KOS gives me an unhandled exception error as such:

Unhandled exception: PC 8c012882, code 1, evt 0100
R0-R7: 8c012840 054d104a 0fffffff 0000001f 3f010101 f54d104a 8cffff5c 00000101
R8-R15: f54d004e 00000060 00000000 8cffff2c 00000009 ffffffff 00000060 8cffff20
SR 40000001 PR 8c012aca
unhandled IRQ/Exception
arch: shutting down kernel

Now for all intents and purposes, this big function once finished should shoot you back to the main loop which is basically the start of the app, so i was thinking maybe just do a soft reset at the end of the function and that will eliminate the problem. hence the 1st part of the question.



It sounds kinda like you have a stack buffer overrun somewhere. Try this with the PC and PR addresses (replace the dc- with your toolchain prefix)--

dc-addr2line -e yourbin.elf 8c012882

If you compiled with -g then that should give you a file and line number of the offending code (if applicable). If you can interpret the assembly then you might also be able to make some sense of the registers in the dump:

dc-objdump -d -S yourbin.elf
so I took the information from your original exception from this thread

Code: Select all

Unhandled exception: PC 8c02bbb8, code 1, evt 00e0 
R0-R7: 0000011a 8c5285c0 00000000 00000010 0000011a fffffffc 00000001 00000130 
R8-R15: 8c161044 00000d00 0000011a 8c0c7780 8c0d5dd8 8c0c7260 8c16102c 8cffff90 
SR 40000000 PR 8c010fec 
kernel panic: unhandled IRQ/Exception 
arch: aborting the system
and passed the PC and PR address and got the following results

Code: Select all

tdavis@TDATHLON ~/prj/neoDC
$ sh-elf-addr2line.exe -e neogeocd.elf 8c02bbb8 8c010fec
/home/tdavis/prj/neoDC/pd4990agpf.c:152
/home/tdavis/prj/neoDC/neocd.c:655 
which seems reasonable since I believe the exception you were getting was from the changes I made for you to the pd4990agpf.c file.

Try it and see if it give you any help

Troy
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

works GPF this is really cool .. going to help a lot doing not just this but many things. wow thanks man.
Dreamcast forever!!!
Post Reply