Browse Source

Version 0.90

tags/REL_0_90
Marc Wäckerlin 15 years ago
parent
commit
93696ef645

+ 9
- 9
COPYING View File

@@ -57,7 +57,7 @@ modified by someone else and passed on, the recipients should know
57 57
 that what they have is not the original version, so that the original
58 58
 author's reputation will not be affected by problems that might be
59 59
 introduced by others.
60
-^L
60
+
61 61
   Finally, software patents pose a constant threat to the existence of
62 62
 any free program.  We wish to make sure that a company cannot
63 63
 effectively restrict the users of a free program by obtaining a
@@ -113,7 +113,7 @@ modification follow.  Pay close attention to the difference between a
113 113
 "work based on the library" and a "work that uses the library".  The
114 114
 former contains code derived from the library, whereas the latter must
115 115
 be combined with the library in order to run.
116
-^L
116
+
117 117
                   GNU LESSER GENERAL PUBLIC LICENSE
118 118
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
119 119
 
@@ -160,7 +160,7 @@ Library.
160 160
   You may charge a fee for the physical act of transferring a copy,
161 161
 and you may at your option offer warranty protection in exchange for a
162 162
 fee.
163
-
163
+
164 164
   2. You may modify your copy or copies of the Library or any portion
165 165
 of it, thus forming a work based on the Library, and copy and
166 166
 distribute such modifications or work under the terms of Section 1
@@ -218,7 +218,7 @@ instead of to this License.  (If a newer version than version 2 of the
218 218
 ordinary GNU General Public License has appeared, then you can specify
219 219
 that version instead if you wish.)  Do not make any other change in
220 220
 these notices.
221
-^L
221
+
222 222
   Once this change is made in a given copy, it is irreversible for
223 223
 that copy, so the ordinary GNU General Public License applies to all
224 224
 subsequent copies and derivative works made from that copy.
@@ -269,7 +269,7 @@ Library will still fall under Section 6.)
269 269
 distribute the object code for the work under the terms of Section 6.
270 270
 Any executables containing that work also fall under Section 6,
271 271
 whether or not they are linked directly with the Library itself.
272
-^L
272
+
273 273
   6. As an exception to the Sections above, you may also combine or
274 274
 link a "work that uses the Library" with the Library to produce a
275 275
 work containing portions of the Library, and distribute that work
@@ -331,7 +331,7 @@ restrictions of other proprietary libraries that do not normally
331 331
 accompany the operating system.  Such a contradiction means you cannot
332 332
 use both them and the Library together in an executable that you
333 333
 distribute.
334
-^L
334
+
335 335
   7. You may place library facilities that are a work based on the
336 336
 Library side-by-side in a single library together with other library
337 337
 facilities not covered by this License, and distribute such a combined
@@ -372,7 +372,7 @@ subject to these terms and conditions.  You may not impose any further
372 372
 restrictions on the recipients' exercise of the rights granted herein.
373 373
 You are not responsible for enforcing compliance by third parties with
374 374
 this License.
375
-^L
375
+
376 376
   11. If, as a consequence of a court judgment or allegation of patent
377 377
 infringement or for any other reason (not limited to patent issues),
378 378
 conditions are imposed on you (whether by court order, agreement or
@@ -425,7 +425,7 @@ conditions either of that version or of any later version published by
425 425
 the Free Software Foundation.  If the Library does not specify a
426 426
 license version number, you may choose any version ever published by
427 427
 the Free Software Foundation.
428
-^L
428
+
429 429
   14. If you wish to incorporate parts of the Library into other free
430 430
 programs whose distribution conditions are incompatible with these,
431 431
 write to the author to ask for permission.  For software which is
@@ -459,7 +459,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
459 459
 DAMAGES.
460 460
 
461 461
                      END OF TERMS AND CONDITIONS
462
-^L
462
+
463 463
            How to Apply These Terms to Your New Libraries
464 464
 
465 465
   If you develop a new library, and you want it to be of the greatest

+ 7
- 0
ChangeLog View File

@@ -0,0 +1,7 @@
1
+* Fri Apr 24 2004 Marc Wäckerlin <marc@waeckerlin.org> - mrw-c++-0.90 (mrw)
2
+	- initial rpm with two spec files
3
+	- test cases for libmrwexcstderr and libmrwexclog4cxx
4
+* Thu Apr 23 2004 Marc Wäckerlin <marc@waeckerlin.org> - mrw-c++-0.11 (mrw)
5
+	- better support for solaris, but not yet tested
6
+	- more and better documentation and a pdf file
7
+	- new submodule "Automated Unexpected Handler with Stack Trace"

+ 5
- 0
NEWS View File

@@ -0,0 +1,5 @@
1
+This is a preliminary release. Especially tests, configure
2
+environment, packages and documentation are not yet finished. It
3
+should already work, even though it may be not yet perfect.
4
+
5
+It is know not to link on Solaris.

+ 6
- 9
README View File

@@ -1,9 +1,6 @@
1
-Please read:
2
- - from the .tar.gz package:
3
-     mrw/doc/html/index.html
4
- - from the .tar.gz installation:
5
-     /usr/local/share/mrw-c++/doc/html/index.html
6
- - from the rpm installation:
7
-     /usr/share/doc/packages/mrw-c++/doc/html/index.html
8
- - the webpage at:
9
-     http://marc.waeckerlin.org/mrw-c++/index.html
1
+C++ Library for automated C-Library resource management, UNIX
2
+Pipes, simple and secure UNIX system command execution, runtime
3
+stack trace and automated unexpected exception handling.
4
+
5
+HTML and PDF documentation is include in the installation (built with
6
+Doxygen).

+ 4
- 0
bootstrap.sh View File

@@ -0,0 +1,4 @@
1
+#! /bin/sh
2
+
3
+make distclean
4
+aclocal && libtoolize --force && automake && autoconf

+ 24
- 7
configure.in View File

@@ -1,9 +1,16 @@
1
-AC_INIT([mrw/stacktrace.hpp])
1
+# init
2
+AC_INIT([mrw/mrw.hpp.in])
2 3
 PACKAGENAME=mrw-c++
3 4
 MAJOR=0
4
-MINOR=10
5
-SUPPORT=alfa
6
-AM_INIT_AUTOMAKE(@PACKAGENAME@, @MAJOR@.@MINOR@)
5
+MINOR=90
6
+SUPPORT=beta
7
+AM_INIT_AUTOMAKE(@PACKAGENAME@, @MAJOR@.@MINOR@, [marc@waeckerlin.org])
8
+
9
+# macros
10
+README=README
11
+AC_SUBST_FILE(README)
12
+CHANGE_LOG=ChangeLog
13
+AC_SUBST_FILE(CHANGE_LOG)
7 14
 
8 15
 # languages
9 16
 AC_LANG(C++)
@@ -18,9 +25,18 @@ AC_PROG_LIBTOOL
18 25
 AC_CHECK_PROG(have_doxygen, doxygen, yes, no)
19 26
 AC_CHECK_PROG(have_dot, dot, yes, no)
20 27
 
28
+# solaris?
29
+AC_CHECK_HEADER(sys/old_procfs.h, [AM_CPPFLAGS=-D__solaris__])
30
+
21 31
 # libraries
22
-AC_SEARCH_LIBS(cplus_demangle, iberty)
23
-AC_SEARCH_LIBS(bfd_get_symbol_leading_char, bfd)
32
+AC_SEARCH_LIBS(cplus_demangle, iberty, [AC_MSG_RESULT([OK])],
33
+               [AC_MSG_ERROR([Library iberty is required!])])
34
+AC_SEARCH_LIBS(bfd_arch_list, bfd, [AC_MSG_RESULT([OK])],
35
+               [
36
+               AC_SEARCH_LIBS(bfd_arch_list, bfd, [AC_MSG_RESULT([OK])],
37
+                              [AC_MSG_ERROR([BFD library libbfd is required])],
38
+                              [-lintl])
39
+               ])
24 40
 
25 41
 # Arguments
26 42
 AM_MAINTAINER_MODE
@@ -37,7 +53,8 @@ AC_SUBST(SUPPORT)
37 53
 AC_SUBST(PACKAGENAME)
38 54
 
39 55
 # create output
40
-AC_CONFIG_FILES([makefile mrw/makefile mrw/doxyfile mrw/mrw.hpp])
56
+AC_CONFIG_FILES([makefile mrw-c++.spec mrw-c++-devel.spec
57
+                 mrw/makefile mrw/doxyfile mrw/mrw.hpp])
41 58
 AC_OUTPUT
42 59
 
43 60
 # infos and warnings

+ 18
- 5
makefile.am View File

@@ -1,11 +1,24 @@
1 1
 SUBDIRS = mrw
2 2
 
3
-include_HEADERS = mrw/auto.hpp mrw/unistd.hpp \
3
+nobase_include_HEADERS = mrw/auto.hpp mrw/unistd.hpp \
4 4
                   mrw/stacktrace.hpp mrw/exception.hpp \
5 5
 		  mrw/exec.hpp
6
-data_DATA = AUTHORS NEWS README COPYING INSTALL ChangeLog
6
+infosdir = ${pkgdatadir}
7
+infos_DATA = AUTHORS NEWS README COPYING INSTALL ChangeLog \
8
+             @PACKAGENAME@.spec @PACKAGENAME@-devel.spec
7 9
 
8
-webserver: all check doc dist
10
+RPMS = /usr/src/packages/RPMS/i586/@PACKAGENAME@-@MAJOR@.@MINOR@-1.i586.rpm \
11
+     /usr/src/packages/RPMS/i586/@PACKAGENAME@-devel-@MAJOR@.@MINOR@-1.i586.rpm
12
+
13
+rpm: dist
14
+	cp @PACKAGENAME@-@MAJOR@.@MINOR@.tar.gz /usr/src/packages/SOURCES/
15
+	rpmbuild -bb --clean @PACKAGENAME@.spec
16
+	rpmbuild -bb --clean @PACKAGENAME@-devel.spec
17
+
18
+webserver: all check dist ${RPMS}
9 19
 	ssh root@waeckerlin.org mkdir -p /home/marc/mrw-c++
10
-	scp mrw/doc/html/* root@waeckerlin.org:/home/marc/mrw-c++/
11
-	scp @PACKAGENAME@-@MAJOR@.@MINOR@.tar.gz root@waeckerlin.org:/home/marc/mrw-c++/
20
+	scp mrw/doc/html/* \
21
+	    mrw/doc/latex/@PACKAGENAME@-@MAJOR@.@MINOR@.pdf \
22
+	    @PACKAGENAME@-@MAJOR@.@MINOR@.tar.gz \
23
+	    ${RPMS} \
24
+	    root@waeckerlin.org:/home/marc/mrw-c++/

+ 42
- 0
mrw-c++-devel.spec.in View File

@@ -0,0 +1,42 @@
1
+# rpmbuild -bb --clean @PACKAGENAME@.spec
2
+Summary: MRW's C++ Class Library, facilities for ease and quality
3
+Name: @PACKAGENAME@-devel
4
+Version: @MAJOR@.@MINOR@
5
+Release: 1
6
+License: LGPL
7
+Group: Development/Libraries/C++
8
+URL: http://marc.waeckerlin.org/mrw-c++/index.html
9
+Source0: @PACKAGENAME@-@MAJOR@.@MINOR@.tar.gz
10
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
11
+
12
+Prefix: /usr
13
+
14
+Requires: gcc-c++ >= 3.0
15
+Requires: binutils
16
+Requires: @PACKAGENAME@ = @MAJOR@.@MINOR@
17
+
18
+%description
19
+@README@
20
+
21
+This Package contains all files required for developement.
22
+
23
+%prep
24
+%setup -q -n @PACKAGENAME@-@MAJOR@.@MINOR@
25
+./configure --prefix=$RPM_BUILD_ROOT/usr
26
+
27
+%build
28
+make check
29
+
30
+%install
31
+make install
32
+rm -rf $RPM_BUILD_ROOT/usr/lib/libmrw*.so*
33
+
34
+%clean
35
+rm -rf $RPM_BUILD_ROOT
36
+
37
+%files
38
+%defattr(-,root,root,-)
39
+/usr
40
+
41
+%changelog
42
+@CHANGE_LOG@

+ 46
- 0
mrw-c++.spec.in View File

@@ -0,0 +1,46 @@
1
+# rpmbuild -bb --clean @PACKAGENAME@.spec
2
+Summary: MRW's C++ Class Library, facilities for ease and quality
3
+Name: @PACKAGENAME@
4
+Version: @MAJOR@.@MINOR@
5
+Release: 1
6
+License: LGPL
7
+Group: Development/Libraries/C++
8
+URL: http://marc.waeckerlin.org/mrw-c++/index.html
9
+Source0: %{name}-%{version}.tar.gz
10
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
11
+
12
+Prefix: /usr
13
+
14
+Requires: gcc-c++ >= 3.0
15
+Requires: binutils
16
+
17
+%description
18
+@README@
19
+
20
+This package contains only the shared libraries required at runtime.
21
+
22
+%prep
23
+%setup -q
24
+./configure --prefix=$RPM_BUILD_ROOT/usr
25
+
26
+%build
27
+make check
28
+
29
+%install
30
+make install
31
+rm -rf $RPM_BUILD_ROOT/usr/share/mrw-c++
32
+rm -rf $RPM_BUILD_ROOT/usr/include/mrw
33
+rm -rf $RPM_BUILD_ROOT/usr/lib/libmrw*.la
34
+rm -rf $RPM_BUILD_ROOT/usr/lib/libmrw*.a
35
+rmdir $RPM_BUILD_ROOT/usr/include
36
+rmdir $RPM_BUILD_ROOT/usr/share
37
+
38
+%clean
39
+rm -rf $RPM_BUILD_ROOT
40
+
41
+%files
42
+%defattr(-,root,root,-)
43
+/usr
44
+
45
+%changelog
46
+@CHANGE_LOG@

+ 4
- 0
mrw/auto.hpp View File

@@ -19,6 +19,7 @@ namespace mrw {
19 19
   //@{
20 20
   
21 21
   /** @brief Automatically closes a file when destructed.
22
+      @pre #include <mrw/auto.hpp>
22 23
 
23 24
       AutoFile works exactly like std::auto_ptr, but not for files
24 25
       instead of pointers. Whenever the context of AutoFile is left,
@@ -59,6 +60,7 @@ namespace mrw {
59 60
   };
60 61
 
61 62
   /** @brief Automatically call @c munmap for mmaped files on destruction.
63
+      @pre #include <mrw/auto.hpp>
62 64
       
63 65
       It's the same as std::auto_ptr, but for @c mmap instead of @c
64 66
       new.  When the context of @c AutoMapper is left, @c munmap is
@@ -89,6 +91,7 @@ namespace mrw {
89 91
   };
90 92
 
91 93
   /** @brief Automatically call @c bfd_close for @c bfd*.
94
+      @pre #include <mrw/auto.hpp>
92 95
       
93 96
       It acts like a @c std::auto_ptr, but for @c bfd*, that means it
94 97
       calls @c bfd_close whenever the context is left.
@@ -111,6 +114,7 @@ namespace mrw {
111 114
   };
112 115
 
113 116
   /** @brief Automatically calls @c free for @c malloc allocated memory.
117
+      @pre #include <mrw/auto.hpp>
114 118
 
115 119
       It works like a @c std::auto_ptr, but for memory that was
116 120
       allocated with @c malloc, not @c new. Memory is freed, whenever

+ 91
- 0
mrw/autostacktracelog4cxx.cpp View File

@@ -0,0 +1,91 @@
1
+#include <mrw/stacktrace.hpp>
2
+#include <mrw/exception.hpp>
3
+#include <exception>
4
+#include <log4cxx/logger.h>
5
+
6
+namespace mrw {
7
+
8
+  /** @addtogroup StackTrace */
9
+  //@{
10
+
11
+  /** @addtogroup AutoTrace
12
+
13
+      @section trclog4cxx Trace using the log4cxx Library
14
+
15
+      If you link to the library @c libmrwexclog4cxx using a linker
16
+      option such as: @c -lmrwexclog4cxx, then an unexpected handler
17
+      is registered, that traces a fatal error using the log4cxx
18
+      library. You don't need to change a single line in your code!
19
+
20
+      The log4cxx library is located at:
21
+       - http://logging.apache.org/log4cxx
22
+
23
+      @note The configurator is not installed automatically. If you
24
+      want to trace e.g. on the console, you have to call @c
25
+      log4cxx::BasicConfigurator::configure(); as first statement in
26
+      your @c main().
27
+  */
28
+  //@{
29
+
30
+  /// The log4cxx logger where the trace is written to.
31
+  static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("libmrw"));
32
+  
33
+  /** @brief unexpected handler, that traces using log4cxx
34
+
35
+      The unexpected handler is installed automatically when you link
36
+      to @c -lmrwexclog4cxx. The implementation of this unexpected
37
+      handler is as follows:
38
+
39
+      @code
40
+  void unexpected_log4cxx() {
41
+    logger->fatal("Unexpected Exception", __FILE__, __LINE__);
42
+    try {
43
+      throw;
44
+    } catch (const mrw::exception& x) {
45
+      StackTrace::createSymtable();
46
+      logger->fatal(std::string("Reason:\n")+x.what()
47
+                   +"\nStack:+\n"+x.stacktrace());
48
+    } catch (const std::exception& x) {
49
+      logger->fatal(std::string("Reason:\n")+x.what()
50
+                   +"\nStack:  **** not available ****");
51
+    } catch (...) {
52
+      logger->fatal(std::string("Reason: **** not available ****\n")
53
+                   +"\nStack:  **** not available ****");
54
+    }
55
+    throw std::bad_exception();
56
+  }
57
+      @endcode
58
+
59
+  */
60
+  void unexpected_log4cxx() {
61
+    logger->fatal("Unexpected Exception", __FILE__, __LINE__);
62
+    try {
63
+      throw;
64
+    } catch (const mrw::exception& x) {
65
+      StackTrace::createSymtable();
66
+      logger->fatal(std::string("Reason:\n")+x.what()
67
+                   +"\nStack:+\n"+x.stacktrace());
68
+    } catch (const std::exception& x) {
69
+      logger->fatal(std::string("Reason:\n")+x.what()
70
+                   +"\nStack:  **** not available ****");
71
+    } catch (...) {
72
+      logger->fatal(std::string("Reason: **** not available ****\n")
73
+                   +"\nStack:  **** not available ****");
74
+    }
75
+    throw std::bad_exception();
76
+  }
77
+
78
+  //@}
79
+  //@}
80
+
81
+  class AutoStackTrace {
82
+    public:
83
+    AutoStackTrace() {
84
+      std::set_unexpected(&mrw::unexpected_log4cxx);
85
+    }
86
+  };
87
+
88
+  // initialize stack traces (load symbols)
89
+  static AutoStackTrace _autoStackTrace;
90
+
91
+}

+ 67
- 3
mrw/autostacktracestderr.cpp View File

@@ -5,8 +5,69 @@
5 5
 
6 6
 namespace mrw {
7 7
 
8
-  /// @todo integrate it into the distribution and document it
9
-  void unexpected() {
8
+  /** @addtogroup StackTrace */
9
+  //@{
10
+
11
+  /** @defgroup AutoTrace Automated Unexpected Handler with Stack Trace
12
+
13
+      @brief Don't care about the unexpected handler, let the library
14
+      do all the repetitive work for you.
15
+
16
+      For all your programs it is recommended to implement an identical
17
+      unexpected handler, that rethrows, catches the @c
18
+      mrw::exception, @c std::exception and all unknown exceptions,
19
+      traces them and finally quits with a throw of a @c
20
+      atd::bad_exception. The only thing that may be different from
21
+      project to project is, how tracing is done. The MRW C++ Class
22
+      Library provides you with additional libraries you can link
23
+      to. By linking to the library, you get an unexpected handler for
24
+      free: You don't need to add a single line of code, just link to
25
+      one more library! The libraries differ in how tracing is done.
26
+
27
+      The Implementation is done with a static instance of a class that
28
+      sets the unexpected handler in the constructor.
29
+
30
+      @section trcstderr Trace using std::cerr
31
+
32
+      If you link to the library @c libmrwexcstderr using a linker
33
+      option such as: @c -lmrwexcstderr, then an unexpected handler is
34
+      registered, that traces to the standard error stream @c
35
+      std::cerr. You don't need to change a single line in your code!
36
+  */
37
+  //@{
38
+  
39
+  /** @brief unexpected handler, that traces to @c std::cerr
40
+
41
+      The unexpected handler is installed automatically when you link
42
+      to @c -lmrwexcstderr. The implementation of this unexpected
43
+      handler is as follows:
44
+
45
+      @code
46
+  void unexpected_stderr() {
47
+    std::cerr<<"UNEXPECTED EXCEPTION: ----------------------------"<<std::endl;
48
+    try {
49
+      throw;
50
+    } catch (const mrw::exception& x) {
51
+      StackTrace::createSymtable();
52
+      std::cerr<<"---------- Reason:"<<std::endl
53
+               <<x.what()<<std::endl
54
+               <<"---------- Stack:"<<std::endl
55
+               <<x.stacktrace()<<std::endl;
56
+    } catch (const std::exception& x) {
57
+      std::cerr<<"---------- Reason:"<<std::endl
58
+               <<x.what()<<std::endl
59
+               <<"---------- Stack:  **** not available ****"<<std::endl;
60
+    } catch (...) {
61
+      std::cerr<<"---------- Reason: **** not available ****"<<std::endl
62
+               <<"---------- Stack:  **** not available ****"<<std::endl;
63
+    }
64
+    std::cerr<<"-------------------------------------------------"<<std::endl;
65
+    throw std::bad_exception();
66
+  }
67
+      @endcode
68
+
69
+  */
70
+  void unexpected_stderr() {
10 71
     std::cerr<<"UNEXPECTED EXCEPTION: ----------------------------"<<std::endl;
11 72
     try {
12 73
       throw;
@@ -28,10 +89,13 @@ namespace mrw {
28 89
     throw std::bad_exception();
29 90
   }
30 91
 
92
+  //@}
93
+  //@}
94
+
31 95
   class AutoStackTrace {
32 96
     public:
33 97
     AutoStackTrace() {
34
-      std::set_unexpected(&mrw::unexpected);
98
+      std::set_unexpected(&mrw::unexpected_stderr);
35 99
     }
36 100
   };
37 101
 

+ 15
- 15
mrw/doxyfile.in View File

@@ -117,7 +117,7 @@ BRIEF_MEMBER_DESC      = YES
117 117
 # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
118 118
 # brief descriptions will be completely suppressed.
119 119
 
120
-REPEAT_BRIEF           = YES
120
+REPEAT_BRIEF           = NO
121 121
 
122 122
 # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
123 123
 # Doxygen will generate a detailed section even if there is only a brief 
@@ -143,7 +143,7 @@ FULL_PATH_NAMES        = YES
143 143
 # only done if one of the specified strings matches the left-hand part of 
144 144
 # the path. It is allowed to use relative paths in the argument list.
145 145
 
146
-STRIP_FROM_PATH        = ../
146
+STRIP_FROM_PATH        = ..
147 147
 
148 148
 # The INTERNAL_DOCS tag determines if documentation 
149 149
 # that is typed after a \internal command is included. If the tag is set 
@@ -176,7 +176,7 @@ HIDE_SCOPE_NAMES       = NO
176 176
 # will put a list of the files that are included by a file in the documentation 
177 177
 # of that file.
178 178
 
179
-SHOW_INCLUDE_FILES     = YES
179
+SHOW_INCLUDE_FILES     = NO
180 180
 
181 181
 # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
182 182
 # will interpret the first line (until the first dot) of a JavaDoc-style 
@@ -297,7 +297,7 @@ OPTIMIZE_OUTPUT_JAVA   = NO
297 297
 # at the bottom of the documentation of classes and structs. If set to YES the 
298 298
 # list will mention the files that were used to generate the documentation.
299 299
 
300
-SHOW_USED_FILES        = YES
300
+SHOW_USED_FILES        = NO
301 301
 
302 302
 #---------------------------------------------------------------------------
303 303
 # configuration options related to warning and progress messages
@@ -381,13 +381,13 @@ EXCLUDE_SYMLINKS       = NO
381 381
 # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
382 382
 # certain files from those directories.
383 383
 
384
-EXCLUDE_PATTERNS       = 
384
+EXCLUDE_PATTERNS       = *_test.cpp
385 385
 
386 386
 # The EXAMPLE_PATH tag can be used to specify one or more files or 
387 387
 # directories that contain example code fragments that are included (see 
388 388
 # the \include command).
389 389
 
390
-EXAMPLE_PATH           = examples ..
390
+EXAMPLE_PATH           = .. examples
391 391
 
392 392
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the 
393 393
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
@@ -602,7 +602,7 @@ TREEVIEW_WIDTH         = 250
602 602
 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
603 603
 # generate Latex output.
604 604
 
605
-GENERATE_LATEX         = NO
605
+GENERATE_LATEX         = YES
606 606
 
607 607
 # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
608 608
 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 
@@ -625,7 +625,7 @@ MAKEINDEX_CMD_NAME     = makeindex
625 625
 # LaTeX documents. This may be useful for small projects and may help to 
626 626
 # save some trees in general.
627 627
 
628
-COMPACT_LATEX          = NO
628
+COMPACT_LATEX          = YES
629 629
 
630 630
 # The PAPER_TYPE tag can be used to set the paper type that is used 
631 631
 # by the printer. Possible values are: a4, a4wide, letter, legal and 
@@ -650,26 +650,26 @@ LATEX_HEADER           =
650 650
 # contain links (just like the HTML output) instead of page references 
651 651
 # This makes the output suitable for online browsing using a pdf viewer.
652 652
 
653
-PDF_HYPERLINKS         = NO
653
+PDF_HYPERLINKS         = YES
654 654
 
655 655
 # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
656 656
 # plain latex in the generated Makefile. Set this option to YES to get a 
657 657
 # higher quality PDF documentation.
658 658
 
659
-USE_PDFLATEX           = NO
659
+USE_PDFLATEX           = YES
660 660
 
661 661
 # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
662 662
 # command to the generated LaTeX files. This will instruct LaTeX to keep 
663 663
 # running if errors occur, instead of asking the user for help. 
664 664
 # This option is also used when generating formulas in HTML.
665 665
 
666
-LATEX_BATCHMODE        = NO
666
+LATEX_BATCHMODE        = YES
667 667
 
668 668
 # If LATEX_HIDE_INDICES is set to YES then doxygen will not 
669 669
 # include the index chapters (such as File Index, Compound Index, etc.) 
670 670
 # in the output.
671 671
 
672
-LATEX_HIDE_INDICES     = NO
672
+LATEX_HIDE_INDICES     = YES
673 673
 
674 674
 #---------------------------------------------------------------------------
675 675
 # configuration options related to the RTF output
@@ -691,7 +691,7 @@ RTF_OUTPUT             = rtf
691 691
 # RTF documents. This may be useful for small projects and may help to 
692 692
 # save some trees in general.
693 693
 
694
-COMPACT_RTF            = NO
694
+COMPACT_RTF            = YES
695 695
 
696 696
 # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
697 697
 # will contain hyperlink fields. The RTF file will 
@@ -700,7 +700,7 @@ COMPACT_RTF            = NO
700 700
 # programs which support those fields. 
701 701
 # Note: wordpad (write) and others do not support links.
702 702
 
703
-RTF_HYPERLINKS         = NO
703
+RTF_HYPERLINKS         = YES
704 704
 
705 705
 # Load stylesheet definitions from file. Syntax is similar to doxygen's 
706 706
 # config file, i.e. a series of assigments. You only have to provide 
@@ -739,7 +739,7 @@ MAN_EXTENSION          = .3
739 739
 # only source the real man page, but without them the man command 
740 740
 # would be unable to find the correct page. The default is NO.
741 741
 
742
-MAN_LINKS              = NO
742
+MAN_LINKS              = YES
743 743
 
744 744
 #---------------------------------------------------------------------------
745 745
 # configuration options related to the XML output

+ 55
- 0
mrw/examples/exceptionhandling.cpp View File

@@ -0,0 +1,55 @@
1
+#include <mrw/exception.hpp>
2
+#include <mrw/stacktrace.hpp>
3
+#include <exception>
4
+#include <iostream>
5
+
6
+void unexpectedHandler() {
7
+  try {
8
+    throw;
9
+  } catch (mrw::exception& x) {
10
+    mrw::StackTrace::createSymtable();
11
+    std::cerr<<"UNEXPECTED:"<<x.what()<<std::endl
12
+             <<"---------------------------Stack:"<<std::endl
13
+             <<x.stacktrace()
14
+             <<"---------------------------------"<<std::endl;
15
+  } catch (std::exception& x) {
16
+    std::cerr<<"UNEXPECTED:"<<x.what()<<std::endl;
17
+  } catch (...) {
18
+    std::cerr<<"UNKNOWN UNEXPECTED"<<std::endl;
19
+  }
20
+  throw std::bad_exception(); // try to recover
21
+}
22
+
23
+void fn2() throw(std::bad_exception) {
24
+  std::cout<<"enter fn2"<<std::endl;
25
+  throw mrw::exception(); // that's wrong, no exception excpected
26
+  std::cout<<"leave fn2"<<std::endl;
27
+}
28
+
29
+void fn1() throw(std::bad_exception) {
30
+  std::cout<<"enter fn1"<<std::endl;
31
+  fn2();
32
+  std::cout<<"leave fn1"<<std::endl;
33
+}
34
+
35
+void fn0() throw(std::bad_exception) {
36
+  std::cout<<"enter fn0"<<std::endl;
37
+  try {
38
+    fn1();
39
+  }  catch (std::exception& x) {
40
+    std::cerr<<"EXCEPTION caught in fn0:"<<x.what()<<std::endl;
41
+  }
42
+  std::cout<<"leave fn0"<<std::endl;
43
+}
44
+
45
+int main() {
46
+  std::set_unexpected(&unexpectedHandler);
47
+  try {
48
+    std::cout<<"call fn0"<<std::endl;
49
+    fn0();
50
+    std::cout<<"call of fn0 successful"<<std::endl;
51
+  } catch (...) {
52
+    std::cerr<<"OOOPS!!!"<<std::endl;
53
+  }
54
+  return 0;
55
+}

+ 10
- 2
mrw/exception.hpp View File

@@ -53,7 +53,8 @@ namespace mrw {
53 53
           - if any exception is thrown, specify @c throw(mrw::exception)
54 54
           - if no exception is thrown, specify @c throw(std::bad_exception)
55 55
        -# document the exact exception thrown with Doxygen's \@throw tag
56
-       -# write an unexpected handler as follows:
56
+       -# write an unexpected handler as follows
57
+          (or link to a @ref AutoTrace "library"):
57 58
 
58 59
       @code
59 60
         void unexpectedHandler() {
@@ -83,6 +84,9 @@ namespace mrw {
83 84
 
84 85
        For a proof of concept refer to
85 86
        @ref exceptionhandling.cpp "the example exceptionhandling.cpp".
87
+
88
+       The unexpected handler is implemented ready to use in @ref
89
+       AutoTrace "a separate library".
86 90
   */
87 91
   //@{
88 92
 
@@ -114,12 +118,16 @@ leave fn0
114 118
 call of fn0 successful
115 119
       @endverbatim
116 120
 
117
-      Please note, that without the exception concept and without the
121
+      The unexpected handler is implemented ready to use in @ref
122
+      AutoTrace "a separate library".
123
+
124
+       Please note, that without the exception concept and without the
118 125
       unexpected handler, the program would abort in function fn2 on
119 126
       line 25. The output was produced by the following code:
120 127
   */
121 128
         
122 129
   /** @brief replacement for @c std::exception, that collects a stack trace
130
+      @pre #include <mrw/exception.hpp>
123 131
 
124 132
       This exception class behaves exactely like @c std::exception,
125 133
       but it collects a stack trace in the constructor and offers a

+ 12
- 12
mrw/exec.cpp View File

@@ -85,26 +85,26 @@ mrw::Exec& mrw::Exec::operator=(const mrw::Exec& e) throw(std::bad_exception) {
85 85
 
86 86
 mrw::Exec& mrw::Exec::execute(bool throwExc) throw(mrw::exception) {
87 87
   /** This method calls @c fork, sets up a pipe connection to pass @c
88
-      stdot and @c stderr from the child process to the parent process
88
+      stdout and @c stderr from the child process to the parent process
89 89
       using mrw::pipe and calls @c execvp to execute the program. */
90 90
   _success = false;
91 91
   _res = _err = "";
92
-  mrw::pipe stdout, stderr;
93
-  if (!stdout || !stderr)
92
+  mrw::pipe stdOut, stdErr;
93
+  if (!stdOut || !stdErr)
94 94
     throw mrw::ExecutionFailedExc("cannot create pipe", *_cmd);
95 95
   pid_t pid(fork());
96 96
   if (pid<0)
97 97
     throw ExecutionFailedExc("cannot fork", *_cmd);
98 98
   if (pid) { // parent
99
-    stdout.close_out();
100
-    stderr.close_out();
101
-    if (!stdout || !stderr)
99
+    stdOut.close_out();
100
+    stdErr.close_out();
101
+    if (!stdOut || !stdErr)
102 102
       throw ExecutionFailedExc("cannot close pipe", *_cmd);
103 103
     int num1(0), num2(0);
104 104
     for (char buf1[4096], buf2[4096];
105
-         (num1=read(stdout.istream(), buf1, sizeof(buf1)))>0 ||
105
+         (num1=read(stdOut.istream(), buf1, sizeof(buf1)))>0 ||
106 106
            num1==-1 && errno==EINTR ||
107
-           (num2=read(stderr.istream(), buf2, sizeof(buf2)))>0 ||
107
+           (num2=read(stdErr.istream(), buf2, sizeof(buf2)))>0 ||
108 108
            num2==-1 && errno==EINTR;
109 109
          _res += std::string(buf1, num1), _err += std::string(buf2, num2));
110 110
     if (num1==-1 || num2==-1)
@@ -120,10 +120,10 @@ mrw::Exec& mrw::Exec::execute(bool throwExc) throw(mrw::exception) {
120 120
       }
121 121
     }
122 122
   } else { // child
123
-    stdout.close_in();
124
-    stderr.close_in();
125
-    stdout.connect_cout();
126
-    stderr.connect_cerr();
123
+    stdOut.close_in();
124
+    stdErr.close_in();
125
+    stdOut.connect_cout();
126
+    stdErr.connect_cerr();
127 127
     execvp(_cmd->path(), _cmd->args());
128 128
     exit(1); // execute failed
129 129
   }

+ 5
- 2
mrw/exec.hpp View File

@@ -45,6 +45,7 @@ namespace mrw {
45 45
   class Cmd;
46 46
   
47 47
   /** @brief Exception: Execution of command failed.
48
+      @pre #include <mrw/exec.hpp>
48 49
 
49 50
       This exception is thrown, if the exection of a command in
50 51
       mrw::Exec is failed. That means, it was not possible to fork or
@@ -64,10 +65,11 @@ namespace mrw {
64 65
   };
65 66
 
66 67
   /** @brief Execute a command in a new process.
68
+      @pre #include <mrw/exec.hpp>
67 69
 
68 70
       This class handles the execution of a command in a new process
69
-      and returns the two streams @c cout and @cerr, also known as @c
70
-      stderr and @stdout.
71
+      and returns the two streams @c cout and @c cerr, also known as @c
72
+      stderr and @c stdout.
71 73
 
72 74
       There are different ways of usage for this class. A simple way,
73 75
       one line of code, to get only the resulting stream (no error)
@@ -188,6 +190,7 @@ namespace mrw {
188 190
   };
189 191
 
190 192
   /** @brief A system command to be executed
193
+      @pre #include <mrw/exec.hpp>
191 194
 
192 195
       This class is used in conjunction with mrw::Exec. It mus be
193 196
       initialized with the command name, then the command parameters

+ 22
- 7
mrw/makefile.am View File

@@ -1,26 +1,31 @@
1
-CLEANFILES = doxygen.error
2 1
 AM_CPPFLAGS = -I..
3 2
 
3
+CLEANFILES = doxygen.error
4 4
 examplesdir = ${pkgdatadir}/examples
5 5
 examples_DATA = examples/*
6 6
 htmldir = ${pkgdatadir}/doc/html
7 7
 html_DATA = doc/html/*
8
-EXTRA_DIST = test.dat ${examples_DATA} ${html_DATA}
8
+pdfdir =  ${pkgdatadir}/doc/pdf
9
+pdf_DATA = doc/latex/@PACKAGENAME@-@MAJOR@.@MINOR@.pdf
10
+EXTRA_DIST = test.dat ${examples_DATA} ${html_DATA} ${pdf_DATA}
9 11
 
10
-lib_LTLIBRARIES = libmrw.la libmrwexcstderr.la
12
+lib_LTLIBRARIES = libmrw.la libmrwexcstderr.la libmrwexclog4cxx.la
11 13
 
12 14
 libmrw_la_SOURCES = mrw.hpp \
13 15
                     auto.hpp auto.cpp unistd.hpp \
14 16
 		    stacktrace.hpp stacktrace.cpp exception.hpp exception.cpp \
15 17
 		    exec.hpp exec.cpp
16 18
 libmrw_la_LDFLAGS = -version-info @MAJOR@:@MINOR@
17
-libmrw_la_LIBADD = -liberty -lbfd
18 19
 
19 20
 libmrwexcstderr_la_SOURCES = autostacktracestderr.cpp
20 21
 libmrwexcstderr_la_LDFLAGS = -version-info @MAJOR@:@MINOR@
21 22
 libmrwexcstderr_la_LIBADD = -lmrw
22 23
 
23
-check_PROGRAMS = auto_test exec_test stacktrace_test
24
+libmrwexclog4cxx_la_SOURCES = autostacktracelog4cxx.cpp
25
+libmrwexclog4cxx_la_LDFLAGS = -version-info @MAJOR@:@MINOR@
26
+libmrwexclog4cxx_la_LIBADD = -lmrw
27
+
28
+check_PROGRAMS = auto_test exec_test stacktrace_test mrwexcstderr_test mrwexclog4cxx_test
24 29
 auto_test_SOURCES = auto_test.cpp
25 30
 auto_test_CPPFLAGS = -I.. -g3
26 31
 auto_test_LDADD = -lmrw -lcppunit
@@ -30,8 +35,18 @@ exec_test_LDADD = -lmrw -lcppunit
30 35
 stacktrace_test_SOURCES = stacktrace_test.cpp
31 36
 stacktrace_test_CPPFLAGS = -I.. -g3
32 37
 stacktrace_test_LDADD = -lmrw -lcppunit
38
+mrwexcstderr_test_SOURCES = mrwexcstderr_test.cpp
39
+mrwexcstderr_test_CPPFLAGS = -I.. -g3
40
+mrwexcstderr_test_LDADD = -lmrwexcstderr -lcppunit
41
+mrwexclog4cxx_test_SOURCES = mrwexclog4cxx_test.cpp
42
+mrwexclog4cxx_test_CPPFLAGS = -I.. -g3
43
+mrwexclog4cxx_test_LDADD = -lmrwexclog4cxx -lcppunit -llog4cxx
33 44
 TESTS = ${check_PROGRAMS}
34 45
 
35
-doc: doc/html/index.html
36
-doc/html/index.html: doxyfile *.[ch]pp
46
+deps = ../COPYING ../README ../INSTALL ../NEWS ../ChangeLog
47
+doc: doc/html/index.html doc/latex/@PACKAGENAME@-@MAJOR@.@MINOR@.pdf
48
+doc/html/index.html: doxyfile *.[ch]pp ${deps}
37 49
 	doxygen doxyfile
50
+doc/latex/@PACKAGENAME@-@MAJOR@.@MINOR@.pdf: doxyfile *.[ch]pp ${deps}
51
+	cd doc/latex && make && \
52
+	mv refman.pdf @PACKAGENAME@-@MAJOR@.@MINOR@.pdf

+ 39
- 34
mrw/mrw.hpp.in View File

@@ -1,50 +1,52 @@
1 1
 /** @mainpage
2 2
 
3
-    @section license License and Copyright
4
-
5
-     - All files are under GNU LGPL license.
6
-     - All files are copyrighted by Marc Wäckerlin.
7
-     - There is no warranty.
8
-     - For details, read the file LICENSE in your distribution.
9
-
10 3
     @section intro Introduction
11 4
 
12
-    This library cares a about:
13
-     - resource management
14
-     - execution of UNIX sub processes
15
-     - stack trace
16
-     - exception handling
17
-
18
-    For details, see the modules page.
19
-
20
-    @section link Compile and Link Options
21
-
22
-    To be able to get the source file name&nbsp;/ line number
23
-    information in stack trace, you need the debug information compile
24
-    option @c -g. For compilation on Solaris, you may need the option
25
-    @c -D__solaris__. You must link to the MRW C++ Library. For this
26
-    you need the link option @c -lmrw.
5
+    @verbinclude README
6
+    
7
+    For details, see the <a href="modules.html">"Modules"</a> page.
27 8
 
28
-    @section download Download and Installation
9
+    @section download Download
29 10
 
30 11
     Download this version from here:
31
-     - http://marc.waeckerlin.org/mrw-c++/mrw-c++-@MAJOR@.@MINOR@.tar.gz
32
-    
33
-    Not yet available:
34
-     - http://marc.waeckerlin.org/mrw-c++/mrw-c++-@MAJOR@.@MINOR@.rpm
35
-     - http://marc.waeckerlin.org/mrw-c++/mrw-c++-devel-@MAJOR@.@MINOR@.rpm
12
+     - Source TAR-Ball (<code>./configure && make all install</code>):
13
+        - http://marc.waeckerlin.org/mrw-c++/mrw-c++-@MAJOR@.@MINOR@.tar.gz
14
+     - RPM Packages (built on i586/SuSE):
15
+        - http://marc.waeckerlin.org/mrw-c++/mrw-c++-@MAJOR@.@MINOR@-1.i586.rpm
16
+        - http://marc.waeckerlin.org/mrw-c++/mrw-c++-devel-@MAJOR@.@MINOR@-1.i586.rpm
36 17
 
18
+    Download this documentation in PDF:
19
+     - http://marc.waeckerlin.org/mrw-c++/mrw-c++-@MAJOR@.@MINOR@.pdf
20
+    
37 21
     The homepage is on:
38 22
      - http://marc.waeckerlin.org/mrw-c++/index.html
39 23
 
40
-    Install it with:
41
-    
24
+    @section usage Usage of the Library
25
+
26
+    Include the headers you need with prefix @c mrw, e.g.:
27
+
28
+    @verbatim
29
+    #include <mrw/stacktrace.hpp>
30
+    @endverbatim
31
+
32
+    Compile with debug information enabled, thats option @c -g and
33
+    link to the library with option @c -lmrw, e.g.;
34
+
42 35
     @verbatim
43
-    tar xzvf mrw-c++-@MAJOR@.@MINOR@.tar.gz
44
-    cd mrw-c++-@MAJOR@.@MINOR@
45
-    ./configure
46
-    make all check install
36
+    g++ -g -o myprogram myprogram.cpp -lmrw
47 37
     @endverbatim
38
+
39
+    For the @ref AutoTools "unexpected handler" you need to link with
40
+    @c -lmrwexcstderr or @c -lmrwexclog4cxx.
41
+
42
+    @section moreinfo Additional Information
43
+
44
+    See the <a href="pages.html">"Related Pages"</a>.
45
+    
46
+     - @ref license "License Information (LGPL)"
47
+     - @ref install "Compilation and Installation Information"
48
+     - @ref news "Breaking News"
49
+     - @ref changes "Change Log"
48 50
 */
49 51
 
50 52
 /** @page license License
@@ -53,6 +55,9 @@
53 55
 /** @page readme Readme
54 56
     @verbinclude README */
55 57
 
58
+/** @page install Installation
59
+    @verbinclude INSTALL */
60
+
56 61
 /** @page news News
57 62
     @verbinclude NEWS */
58 63
 

+ 68
- 0
mrw/mrwexclog4cxx_test.cpp View File

@@ -0,0 +1,68 @@
1
+#include <mrw/exception.hpp>
2
+#include <log4cxx/basicconfigurator.h>
3
+#include <cppunit/TestFixture.h>
4
+#include <cppunit/ui/text/TestRunner.h>
5
+#include <cppunit/extensions/HelperMacros.h>
6
+#include <cppunit/extensions/TestFactoryRegistry.h>
7
+
8
+namespace mrw {
9
+  class AutoExcLog4CxxTest: public CppUnit::TestFixture {
10
+  private:
11
+    bool enter_unexpectedThrow;
12
+    bool exit_unexpectedThrow;
13
+    bool enter_passUnexpected;
14
+    bool exit_passUnexpected;
15
+    bool enter_catchUnexpected;
16
+    bool exit_catchUnexpected;
17
+  public:
18
+    void setUp() {
19
+      enter_unexpectedThrow = false;
20
+      exit_unexpectedThrow = false;
21
+      enter_passUnexpected = false;
22
+      exit_passUnexpected = false;
23
+      enter_catchUnexpected = false;
24
+      exit_catchUnexpected = false;
25
+    }
26
+    void unexpectedThrow() throw(std::bad_exception) {
27
+      enter_unexpectedThrow = true;
28
+      throw mrw::exception();
29
+      exit_unexpectedThrow = true;
30
+    }
31
+    void passUnexpected() throw(std::bad_exception) {
32
+      enter_passUnexpected = true;
33
+      unexpectedThrow();
34
+      exit_passUnexpected = true;
35
+    }
36
+    void catchUnexpected() throw() {
37
+      enter_catchUnexpected = true;
38
+      bool caught(false);
39
+      try {
40
+        passUnexpected();
41
+      } catch (std::bad_exception&) {
42
+        caught = true;
43
+      }
44
+      CPPUNIT_ASSERT(caught);
45
+      exit_catchUnexpected = true;
46
+    }
47
+    void testcase() {
48
+      catchUnexpected();
49
+      CPPUNIT_ASSERT(enter_catchUnexpected &&
50
+                     enter_passUnexpected &&
51
+                     enter_unexpectedThrow &&
52
+                     exit_catchUnexpected &&
53
+                     !exit_passUnexpected &&
54
+                     !exit_unexpectedThrow);
55
+    }
56
+    CPPUNIT_TEST_SUITE(AutoExcLog4CxxTest);
57
+    CPPUNIT_TEST(testcase);
58
+    CPPUNIT_TEST_SUITE_END();
59
+  };
60
+  CPPUNIT_TEST_SUITE_REGISTRATION(AutoExcLog4CxxTest);
61
+}
62
+
63
+int main() {
64
+  log4cxx::BasicConfigurator::configure();
65
+  CppUnit::TextUi::TestRunner runner;
66
+  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
67
+  return runner.run() ? 0 : 1;
68
+}

+ 66
- 0
mrw/mrwexcstderr_test.cpp View File

@@ -0,0 +1,66 @@
1
+#include <mrw/exception.hpp>
2
+#include <cppunit/TestFixture.h>
3
+#include <cppunit/ui/text/TestRunner.h>
4
+#include <cppunit/extensions/HelperMacros.h>
5
+#include <cppunit/extensions/TestFactoryRegistry.h>
6
+
7
+namespace mrw {
8
+  class AutoExcStderrTest: public CppUnit::TestFixture {
9
+  private:
10
+    bool enter_unexpectedThrow;
11
+    bool exit_unexpectedThrow;
12
+    bool enter_passUnexpected;
13
+    bool exit_passUnexpected;
14
+    bool enter_catchUnexpected;
15
+    bool exit_catchUnexpected;
16
+  public:
17
+    void setUp() {
18
+      enter_unexpectedThrow = false;
19
+      exit_unexpectedThrow = false;
20
+      enter_passUnexpected = false;
21
+      exit_passUnexpected = false;
22
+      enter_catchUnexpected = false;
23
+      exit_catchUnexpected = false;
24
+    }
25
+    void unexpectedThrow() throw(std::bad_exception) {
26
+      enter_unexpectedThrow = true;
27
+      throw mrw::exception();
28
+      exit_unexpectedThrow = true;
29
+    }
30
+    void passUnexpected() throw(std::bad_exception) {
31
+      enter_passUnexpected = true;
32
+      unexpectedThrow();
33
+      exit_passUnexpected = true;
34
+    }
35
+    void catchUnexpected() throw() {
36
+      enter_catchUnexpected = true;
37
+      bool caught(false);
38
+      try {
39
+        passUnexpected();
40
+      } catch (std::bad_exception&) {
41
+        caught = true;
42
+      }
43
+      CPPUNIT_ASSERT(caught);
44
+      exit_catchUnexpected = true;
45
+    }
46
+    void testcase() {
47
+      catchUnexpected();
48
+      CPPUNIT_ASSERT(enter_catchUnexpected &&
49
+                     enter_passUnexpected &&
50
+                     enter_unexpectedThrow &&
51
+                     exit_catchUnexpected &&
52
+                     !exit_passUnexpected &&
53
+                     !exit_unexpectedThrow);
54
+    }
55
+    CPPUNIT_TEST_SUITE(AutoExcStderrTest);
56
+    CPPUNIT_TEST(testcase);
57
+    CPPUNIT_TEST_SUITE_END();
58
+  };
59
+  CPPUNIT_TEST_SUITE_REGISTRATION(AutoExcStderrTest);
60
+}
61
+
62
+int main() {
63
+  CppUnit::TextUi::TestRunner runner;
64
+  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
65
+  return runner.run() ? 0 : 1;
66
+}

+ 38
- 0
mrw/stacktrace.hpp View File

@@ -53,10 +53,48 @@ namespace mrw {
53 53
        - a system with ELF binaries (LINUX, Solaris, ...)
54 54
        - debug information, compile option @c -g
55 55
        - it must be linked with @c -libery and @c -lbfd
56
+
57
+      @subsection sttech Technology
58
+
59
+      On GNU glibc based systems (Linux), the stack trace is collected
60
+      with GNU glibc's function @c backtrace(). On other systems
61
+      (Solaris) it is collected using the GNU gcc's internal function @c
62
+      __builtin_return_address(). With both functions, at most 50 steps
63
+      back are collected.
64
+
65
+      The evaluation is not done with the glibc library function @c
66
+      backtrace_symbols(), because this function is unable to print
67
+      the source file name and line number information. Instead of
68
+      this, the executable binary is loaded into the memory and
69
+      evaluated using the bdf library functions. For this the stack
70
+      tracer needs to know how to find out which executable is
71
+      running. It is possible to get this information automatically on
72
+      Linux and Solaris. On other systems, I don't have this
73
+      information, but you can either tell me, and I integrate support
74
+      for your system (when I have time to do it), or provide the
75
+      executable file name as an argument to @c
76
+      mrw::StackTrace::createSymtable().
77
+
78
+      @subsection stdrawbacks Draw Backs
79
+
80
+      Unfortunately it is not possible to extract the source file name
81
+      and line number information if the executable was not compiled
82
+      with debug option @c -g. But what's worse, it is not possible to
83
+      ger symbolic information from libraries linked to the
84
+      executable. Perhaps it could be possible, if I'd add a
85
+      possibility to read and evaluate these libraries, but that's for
86
+      a future release.
87
+
88
+      @todo Add support to read debugging information from libraries
89
+      that are linked to the executable.
90
+
91
+      @todo Add support for alternative symbol evaluation using @c
92
+      backtrace_symbols.
56 93
   */
57 94
   //@{
58 95
 
59 96
   /** @brief store and print a stack trace of the actual position in code
97
+      @pre #include <mrw/stacktrace.hpp>
60 98
 
61 99
       In the constructor, a stack trace is stored, but not yet
62 100
       evaluated. Therefore storing a stack trace is relatively

+ 4
- 2
mrw/unistd.hpp View File

@@ -8,8 +8,10 @@ namespace mrw {
8 8
   /** @addtogroup AutoTools */
9 9
   //@{
10 10
   
11
-  /// class that implements an unnamed UNIX pipe
12
-  /** Implements a UNIX pipe that is automatically closed in
11
+  /** @brief class that implements an unnamed UNIX pipe
12
+      @pre #include <mrw/unistd.hpp>
13
+
14
+      Implements a UNIX pipe that is automatically closed in
13 15
       destructor and offers some facilities. */
14 16
   class pipe {
15 17
   private:

Loading…
Cancel
Save