[Previous] [Next] [Contents] [Index]


    SDT C Compiler Driver (SCCD)

The SDT C Compiler Driver (SCCD) is a utility intended to simplify C level debugging of code generated by SDT and handwritten code. It can be invoked from the makefiles used by SDT or stand-alone from the OS command line.

Table of Contents 

Introduction

The SDT C Compiler Driver (SCCD) is intended to simplify C level debugging by generating an intermediate C file placed in a user defined directory. This C file has all its macros expanded and is optionally "beautified" (pretty-printed). For ease of use SCCD is used as a C compiler driver called from the SDT generated or handwritten makefiles. SCCD may also be used as a command line option when compiling C code.

The simplest way to introduce this facility for use in the standard SDT environment is to modify the makeoptions or make.opt file associated with the predefined run-time library to be used. To enable this feature in a modified SDT run-time library, the directory and file structure must be similar to the pre-defined one.

The makeoptions or make.opt file is found in the $sdtdir/SCT[Kernel name] directory together with the sctworld.o file (the pre-compiled and pre-linked run-time library). The only modification required is to change the line

to

SCCD must of course be visible in your path.

To customize the behavior of SCCD, modify the configuration file sccd_<your_compiler_type>.cfg variables described in the following sections.

Syntax for Invoking

The following syntax can be used to invoke SCCD:

To execute SCCD:

To print the values of the variables in the configuration file sccd.cfg:

To print the variables with extra help information:

Return Codes

0: Success.

1: After printing "help".

2: No .c file.

3: Could not open InFile.c.

4: Could not open InFile.i for write.

5: sccdMOVE or sccdOUTFILEREDIR needs to be defined.

6: Could not open InFile.i for read.

7: Could not open/create TmpDir/InFile.c.

Actions Performed by SCCD

  1. Execute an optional first-user defined command (sccdUSER_CMD1).
  2. Create a sub-directory for temporary files and the pre-processed .c files.
  3. Execute an optional second user-defined command (sccdUSER_CMD2).
  4. Run a C pre-processor pass to expand all macros.
  5. Execute an optional third user-defined command (sccdUSER_CMD3).
  6. Pretty print the file.
  7. Optional clean-up of the sub-directory.
  8. Optionally copy .hs files to the sub-directory.
  9. Execute an optional fourth user-defined command (sccdUSER_CMD4). You should use this command if you wish to invoke the "indent" utility from SCCD (see C Beautifier for more information).
  10. Optionally compile, i.e. run the original command line.
  11. Optional clean-up of the sub-directory, but leave the pre-processed .c file(s) for debugging purposes.

Configuration File

The behavior of SCCD is defined using a number of variables, each starting with "sccd". The variables are defined in a configuration file, sccd_<your_compiler_type>.cfg. Select the configuration file that corresponds to your C compiler and copy this file as sccd.cfg. If run from SDT, SCCD uses $sctdir/sccd.cfg as the configuration file; otherwise SCCD searches for sccd.cfg in the current directory, $SCCD, and (on UNIX) $HOME.

Note: 

If sccd.cfg is not found, hard-coded defaults suitable for the Gnu C compiler (gcc) are used.

Below are the variables that control the behavior of SCCD. Note that all characters in variable values are significant, including white spaces.

To include `#' in sccdUSER_CMDx and sccdTMPDIR, enter \#
To include `"' in sccdUSER_CMDx and sccdTMPDIR, enter \"
To include `\' in sccdUSER_CMDx and sccdTMPDIR, enter \\

C Beautifier

If you need a C beautifier to further format the C code from SDT, do as follows.

Try the indent utility (courtesy of Joseph Arcaneaux). The .zip file contains source code and an executable compiled as a win32 application; the .tar file contains the original indent-1.9.1 source code for UNIX. The UNIX version must be compiled for the appropriate platform but this work is normally simplified if you read the documentation in the .tar file and use the enclosed make file.

The indent executable must be placed in your path.

In order to easily invoke indent from SCCD, insert the following statement in sccdUSER_CMD4 in the appropriate sccd.cfg file(s), assuming no other changes have been made to the sccd.cfg file(s):

For UNIX compiler environments:

For "DOS"-like compiler environments:

This setup gives a .c source file formatted according to rules very like the ones used in the Kernighan & Richie "C" book. It will also try to force lines to be shorter than 70 characters and will use 2 positions indentation in if/while/... statements.

A slightly more elaborate example:


[Previous] [Next] [Contents] [Index]