From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4db,42269369cf44983d,start X-Google-Attributes: gid10d4db,public From: pjm@hakea.cs.ntu.edu.au (Phil Maker) Subject: nana-1.02: improved assertion and logging library Date: 1997/05/22 Message-ID: X-Deja-AN: 242999554 X-Server-Date: 22 May 1997 05:08:28 GMT Followup-To: poster Old-Date: 17 May 1997 23:58:09 GMT Summary: Free library Organization: Northern Territory University X-Auth: PGPMoose V1.1 PGP comp.os.linux.announce iQBVAwUBM4PUzDiesvPHtqnBAQG7JgH9EOhGXpKUUyzfWTOl0otJRCekYVmeum8E w/ER2b8lm/8KQVJUDcsG/G6M/ChBhXfUOomXGwE/Xn7gaY4zdVIbug== =B/Vb Newsgroups: comp.os.linux.announce -----BEGIN PGP SIGNED MESSAGE----- G'day, If your interested in programs working correctly you might be interested in nana. Its a free library supporting "Programming by Contract", Formal Methods, etc, etc. **************************************************************************** Nana: improved support for assertions and logging in C and C++ Phil Maker See for the original version of this document. Nana is a free library providing improved support for assertion checking and logging in C and C++. It provides some support for Formal Methods and Programming by Contract in C and C++. The library and documentation are available under a Berkeley style license. Who might be interested? * Programmers: particularly humble ones. * Software Engineers: particularly for embedded or hard real-time systems which are safety critical. * Academics teaching Formal Methods. * Test Engineers. What does it do? * Most of the features of the library are implemented using in-line C macros or by generating commands for the gdb(1) debugger. The gdb approach has the benefit that the time overhead for the checking and logging only occurs when you run the system under the debugger. It also minimises the space and time overhead since the checking and logging is done by the debugger rather than the program. * Features can be enabled and disabled at both compile and run-time via a standard mechanism. This can be used to implement different checking or logging levels in your system. * Logging messages can be sent to the terminal, files, programs or a circular buffer in core. The last option lets you answer the dreaded ``I wonder what it was doing before it went ballistic'' question without a large performance hit since you are not doing any output operations. * Forall, Exists, Exists1, etc of predicate calculus are provided. Support is also provided for C++ iterators as provided by the STL library. For example: /* All elements in a[][] are +ve and there exists a single */ /* object in the STL container object m which has a +ve key */ A(int i = 0, i != XMAX, i++, A(int j = 0, j != YMAX, j++, a[i][j] >= 0)) && E1O(i, m, (*i).first >= 0) * Before/After state: you can save the state of variables away and refer to the before state in the postcondition for an operation. * Messages can be automatically time stamped and assertions can be made about the real time behaviour of you system using system clocks or an instruction level simulator such as PSIM. Why use it? * Efficient: at least compared to assert.h. For example assert(i >= 0) assertion uses 53 bytes on an i386 whilst Nana uses 1 or 10 bytes depending on whether you use inline C code or the debugger. * Programming by Contract: the use of pre/post conditions makes the debugging of programs much much much faster. The sooner the error is detected the sooner you'll be able to find the error. * For automated testing: if you can't measure it it doesn't exist!. You can feed the logging output of nana to programs which automatically verify that the system is meeting its specification. This is particularly useful for non-determistic systems. If anyone is interested in this particular application please e-mail me. I've used the method in the past and its been fairly successful, particularly compared to other approaches. I'm also doing some playing around with a separate tool set for this which isn't ready for release yet. Why was it written? The author has grown tired of writing systems like this for each new project. Nana is an attempt to solve the problem once and for all (hope springs eternal). Earliers systems on which Nana is based where used for experiment control and embedded (inside people) systems. What other software is required to use it? Ideally you should be using recent versions of GNU C/C++ and GDB. The library is a normal GNU package with automatic configuration using an autoconf generated configure script. But will it work with Language L on Compiler X using Debugger Y? Currently the library only supports GNU C/C++ and GDB on *IX type platforms. If you are using pure ANSI C then some of the libraries will not work, e.g. support for Forall, Exists, etc requires the statement value extension and logging code uses the varargs mechanism. Ports to other environments are fairly easy and if anyone is interested please contact me. In the past we have ported it to Microsoft C using the Codeview debugger. Unfortunately these implementations were less than beautiful due to restrictions in the Codeview debugger. As for other languages support existed in earlier versions of Nana for the GNU Ada compiler. We may be adding support for Ada and FORTRAN in the near future if anyone is interested. For more information see: ftp://ftp.cs.ntu.edu.au/pub/nana http://www.cs.ntu.edu.au/homepages/pjm/nana-home - -- This article has been digitally signed by the moderator, using PGP. http://www.iki.fi/liw/lars-public-key.asc has PGP key for validating signature. Send submissions for comp.os.linux.announce to: linux-announce@news.ornl.gov PLEASE remember a short description of the software and the LOCATION. This group is archived at http://www.iki.fi/liw/linux/cola.html -----BEGIN PGP SIGNATURE----- Version: 2.6.3ia Charset: noconv iQCVAwUBM4PUyoQRll5MupLRAQHs6gP8C9An38A+Rdl3l3AMW9+PiXQ+6BnHHA/A eetROuVnpARZheP0g+rOTCyxSxGO43OokloUytw7ugPJauU+vhu+yTQTqmsTgdpF poIjwLQDCqV8odpE8LmKuks8n0Ivp+OkL6SYS5//WAAvv7rCjMtYeYkFClnwb/KQ 9ZxXZSRJNcA= =hjRF -----END PGP SIGNATURE-----