30 December 2015, 17:37 | #1 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 732
|
Debugging messages in serial (small tutorial, mainly for cross-dev)
This is what I use when cross-developing. (linux host, fs-uae)
First you run this script on linux terminal: Code:
#!/bin/sh echo "1.Leave this running in the background,\n2.Run fs-uae with --serial-port=/tmp/vser at the end" echo "3.On another terminal go type cat /tmp/hser" echo "4.Use redirection from Amiga-side e.g. yourexe >ser: and all your stdout (printfs etc) will appear on linux" OPTS=raw,echo=0,onlcr=0,echoctl=0,echoke=0,echoe=0,iexten=0 exec socat "$@" pty,$OPTS,link=/tmp/vser pty,$OPTS,link=/tmp/hser Now, if you boot amiga in fs-uae, anything you send to serial is echoed in the linux terminal. Try in a CLI: date >ser: Ok, this can be used for any program that can be run from CLI. Even if your program takes over screen, you just run it with >ser: and any printfs you put there for debugging will appear in linux terminal. Now, the cooler thing, how about having this in asm Code:
move.l #1234,d0 move.l d0,speed add #100,d0 DBUG "Alkis was here %ld %ld (stack: %lx)",speed,d0,sp jsr halfd0 DBUG "Alkis was here %ld %ld (stack: %lx)",speed,d0,sp rts section data speed: ds.l 1 Code:
Alkis was here 1234 1334 (stack: 7844CC4) Alkis was here 1234 667 (stack: 7844CC4) Code:
XREF _kprintf _LVORawDoFmt EQU -522 _LVORawPutChar EQU -516 * Private function in Exec _LVORawMayGetChar EQU -510 _AbsExecBase EQU 4 XDEF _LVORawPutChar XDEF _LVORawDoFmt XDEF _LVORawMayGetChar XDEF _AbsExecBase DEBUG EQU 1 DBUG macro ifd DEBUG ; save all regs movem.l d0/d1/a0/a1,-(a7) IFGE NARG-9 move.l \9,-(sp) ; stack arg8 ENDC IFGE NARG-8 move.l \8,-(sp) ; stack arg7 ENDC IFGE NARG-7 move.l \7,-(sp) ; stack arg6 ENDC IFGE NARG-6 move.l \6,-(sp) ; stack arg5 ENDC IFGE NARG-5 move.l \5,-(sp) ; stack arg4 ENDC IFGE NARG-4 move.l \4,-(sp) ; stack arg3 ENDC IFGE NARG-3 move.l \3,-(sp) ; stack arg2 ENDC IFGE NARG-2 move.l \2,-(sp) ; stack arg1 ENDC PULLSP SET (NARG)<<2 pea.l n1\@ jsr _kprintf lea.l PULLSP(sp),sp movem.l (a7)+,d0/d1/a0/a1 bra.s n2\@ n1\@ dc.b \1,10,0 cnop 0,2 n2\@ endc endm Code:
vasmm68k_mot -Fhunk -o foo.o foo.asm vlink -bamigahunk -o dbug foo.o /home/alex/Documents/FS-UAE/Hard\ Drives/AmigaHD/SC/lib/debug.lib The DBUG macro must take a string argument, and then optional a variable number of arguments (0 and upto 8). Accepts the printf syntax, sort of. Also, if you comment out the DEBUG equate then all DBUGs become nothing. And that's it... Hope someone finds it usefull. |
30 December 2015, 19:56 | #2 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,456
|
I do!!
|
30 December 2015, 21:01 | #3 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,611
|
Possible WinUAE configs for similar serial logging:
Option 1: "-log -serlog" command line parameters can be used to see serial output in WinUAE's log window. (Even serial input work) Option 2: config file win32.serial_port=tcp://localhost/<port> Use telnet client to connect. You can append /wait if you want emulation to wait until telnet client has connected. |
31 December 2015, 01:41 | #4 |
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
Thanks Toni - this is exactly what I need atm. Also a big thank you to alkis for starting this topic!
|
31 December 2015, 16:08 | #5 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,381
|
Any clues on how to integrate this in Blitz Basic? It could be quite helpful when debugging BLITZ mode programs.
|
31 December 2015, 17:15 | #6 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Thanks a lot! I knew about debug.lib, but I had no idea you could tell the emulator to capture the serial output like this. Very useful script, it works fine on Mac OS X with no changes.
Is it the same as going to Host -> I/O Ports -> Serial Port, and selecting "tcp://0.0.0.0:1234/wait"? |
01 January 2016, 16:52 | #7 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
|
22 February 2016, 14:16 | #8 |
Oldtimer
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Serial debugging while booting | jman | Coders. General | 1 | 25 March 2012 03:02 |
Private Messages not possible | andreas | project.EAB | 8 | 25 June 2002 23:46 |
Strange Messages | Andrew | support.Hardware | 6 | 18 May 2002 19:29 |
|
|