2.7. Working with the Target

M68K Ada also supports debugging on the target computer. Before you can do this, you must connect the target board to the host computer using two serial cables that include a null modem. One cable connects the board's serial connector A to the host, and is used to down-load the monitor and for application program input and output. The other cable connects to the board's serial connector B, and is used by the debugger to load programs, and to perform debugging operations.

2.7.1. How to Down-load the Debug Monitor

Before we can use the debugger to down-load and debug programs running on the target, we must down-load the M68K Ada debug monitor. This is a small program that resides in the upper 32K bytes of RAM, and communicates with the M68K debugger over the serial interface B. You will find the source code in the directory /opt/m68k-ada-1.7/m68k-coff/src/monitor/.

$ ls /opt/m68k-ada-1.7/m68k-coff/src/monitor/
CVS  Makefile  README  art1.S  install.sh  remcom.c  t1.c  t2.adb  t2.c
t6  t6.c  xgcmon.M  xgcmon.c  xgcmon.ld

The ready-to-load (S-Record) version is /opt/m68k-ada-1.7/m68k-coff/lib/xgcmon.

We assume the target board is fitted with a Motorola monitor.

In this guide we use the program tip to work as a terminal. This program is generally available on Solaris platforms, but is seldom seen on Linux or Windows. If you don't have tip then there are other programs (such as Kermit) that will do as well.

We configured tip to use the serial interface connected to the target at 19200 bps in the file dem32. On Solaris, the configuration statement is in the file /etc/remote. The following example shows the configuration line used to generate the rest of this text. Note there is no entry for the output EOF string. This is not required.

The configuration line we use is as follows:

Example 2-15. Remote Configuration File

$ cat /etc/remote
...
dem32:\
        :dv=/dev/term/b:br#19200:el=^C^S^Q^U^D:ie=%$:
...

The debug monitor is called xgcmon. This file is formatted in Motorola S-Records ready for down-loading in response to the load command, as shown in the following example.

Example 2-16. Output from the Monitor

tbd

The monitor is now running and ready to communicate over the other serial interface. To leave tip type ~..

2.7.2. Preparing a Program to Run under the Monitor

Because the debug monitor is a complete supervisor-mode application program it is not appropriate to down-load the programs we built in the previous section. We must rebuild the program using the start file art1.

The module art1 consists of the code from art0 to do with initializing the high-level language environment. It omits the trap vector and trap handling code. You can get the source from /opt/m68k-ada-1.7/m68k-coff/src/monitor/art1.S.

The following code shows how to compile the Ackermann benchmark program using a custom linker script and the file art1.

$ m68k-coff-gcc -O ackermann.c -o ackermann -T xgcmon.ld art1.o

The file xgcmon.ld may be found on the CD-ROM in the run-time source directory /opt/m68k-ada-1.7/m68k-coff/src/monitor.

The following example shows the Ackermann benchmark running under the control of the debugger. You should substitute your serial device name for ttyS0.

Example 2-17. Remote Debugging

$ m68k-coff-gdb ackermann
XGC m68k-ada Version 1.7b1 (debugger)
Copyright (c) 1996, 2002, XGC Software.
Based on gdb version 5.1.1
Copyright (c) 1998 Free Software Foundation...
(gdb) set remotebaud 19200
(gdb) tar rem /dev/ttyS0
Remote debugging using /dev/ttyS0
0x21f965c in ?? ()
(gdb) load
Loading section .text, size 0x1948 lma 0x2000000
Loading section .rdata, size 0x3d8 lma 0x2001948
Loading section .data, size 0x50 lma 0x2001d20
Start address 0x2000110
Transfer rate: 6698 bits/sec.
(gdb) run
Starting program: /hdb3/xgc/benchmarks/ackermann
,.,. ackermann GTS Version 0.1
---- ackermann Function call benchmark, A (3, 6).
   - ackermann time taken = 1.130e+00 Seconds.
**** ackermann  PASSED ============================.
Program exited normally.
(gdb) quit
$