2.7. Working with the Target

M1750 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.

Note: Note that the monitor is written for a specific target computer and will require customization to work with other target computers.

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 M1750 Ada debug monitor. This is a small program that resides in upper RAM, and communicates with the debugger over a serial interface. You will find the source code in the directory /opt/m1750-ada-1.7/m1750-coff/src/monitor/.

$ ls /opt/m1750-ada-1.7/m1750-coff/src/monitor/
art1.S      Makefile  remcom.c  xgcmon.c   xgcmon.M
install.sh  README    t1.c      xgcmon.ld

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-7. 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.

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/m1750-ada-1.7/m1750-coff/src/monitor/art1.S.

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

$ m1750-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.

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-8. Remote Debugging

$ m1750-coff-gdb ackermann
m1750-ada Version 1.7 (debugger)
Copyright (c) 1996, 2001 XGC.Com Software.
Based on gdb version 4.17.gnat.3.11
Copyright (c) 1998 Free Software Foundation.
(gdb) set remote speed 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