|
|
|||
File indexing completed on 2025-12-15 10:09:21
0001 // (C) Copyright Gennadiy Rozental 2001. 0002 // Distributed under the Boost Software License, Version 1.0. 0003 // (See accompanying file LICENSE_1_0.txt or copy at 0004 // http://www.boost.org/LICENSE_1_0.txt) 0005 0006 // See http://www.boost.org/libs/test for the library home page. 0007 // 0008 //! @file 0009 //! @brief defines portable debug interfaces 0010 //! 0011 //! Intended to standardize interface of programs with debuggers 0012 // *************************************************************************** 0013 0014 #ifndef BOOST_TEST_DEBUG_API_HPP_112006GER 0015 #define BOOST_TEST_DEBUG_API_HPP_112006GER 0016 0017 // Boost.Test 0018 #include <boost/test/detail/config.hpp> 0019 #include <boost/test/utils/basic_cstring/basic_cstring.hpp> 0020 0021 // Boost 0022 #include <boost/function/function1.hpp> 0023 0024 // STL 0025 #include <string> 0026 0027 #include <boost/test/detail/suppress_warnings.hpp> 0028 0029 //____________________________________________________________________________// 0030 0031 namespace boost { 0032 /// Contains debugger and debug C Runtime interfaces 0033 namespace debug { 0034 0035 /// @defgroup DebuggerInterface Debugger and debug C Runtime portable interfaces 0036 /// @{ 0037 /// These interfaces are intended to be used by application to: 0038 /// - check if we are running under debugger 0039 /// - attach the debugger to itself 0040 /// 0041 /// Unfortunately these actions differ widely between different debuggers available in a field. These interface present generalized standard form of 0042 /// performing these actions. Implementation depends a lot on the environment application is running in and thus there are several custom implementations 0043 /// supported by the Boost.Test 0044 /// 0045 /// In addition here you find interfaces for memory leaks detection and reporting. 0046 /// 0047 /// All these interfaces are defined in namespace boost::debug 0048 0049 // ************************************************************************** // 0050 /// Checks if programs runs under debugger 0051 0052 /// @returns true if current process is under debugger. False otherwise 0053 // ************************************************************************** // 0054 bool BOOST_TEST_DECL under_debugger(); 0055 0056 // ************************************************************************** // 0057 /// Cause program to break execution in debugger at call point 0058 // ************************************************************************** // 0059 0060 void BOOST_TEST_DECL debugger_break(); 0061 0062 // ************************************************************************** // 0063 /// Collection of data, which is used by debugger starter routine 0064 // ************************************************************************** // 0065 0066 struct dbg_startup_info { 0067 long pid; ///< pid of a program to attach to 0068 bool break_or_continue; ///< what to do after debugger is attached 0069 unit_test::const_string binary_path; ///< path to executable for current process 0070 unit_test::const_string display; ///< if debugger has a GUI, which display to use (on UNIX) 0071 unit_test::const_string init_done_lock; ///< path to a uniquely named lock file, which is used to pause current application while debugger is being initialized 0072 }; 0073 0074 /// Signature of debugger starter routine. Takes an instance of dbg_startup_into as only argument 0075 typedef boost::function<void (dbg_startup_info const&)> dbg_starter; 0076 0077 // ************************************************************************** // 0078 /// Specifies which debugger to use when attaching and optionally what routine to use to start that debugger 0079 0080 /// There are many different debuggers available for different platforms. Some of them also can be used in a different setups/configuratins. 0081 /// For example, gdb can be used in plain text mode, inside ddd, inside (x)emacs or in a separate xterm window. 0082 /// Boost.Test identifies each configuration with unique string. 0083 /// Also different debuggers configurations require different routines which is specifically tailored to start that debugger configuration. 0084 /// Boost.Test comes with set of predefined configuration names and corresponding routines for these configurations: 0085 /// - TODO 0086 /// 0087 /// You can use this routine to select which one of the predefined debugger configurations to use in which case you do not need to provide starter 0088 /// routine (the one provided by Boost.Test will be used). You can also use this routine to select your own debugger by providing unique configuration 0089 /// id and starter routine for this configuration. 0090 /// 0091 /// @param[in] dbg_id Unique id for debugger configuration (for example, gdb) 0092 /// @param[in] s Optional starter routine for selected configuration (use only you want to define your own configuration) 0093 /// @returns Id of previously selected debugger configuration 0094 std::string BOOST_TEST_DECL set_debugger( unit_test::const_string dbg_id, dbg_starter s = dbg_starter() ); 0095 0096 // ************************************************************************** // 0097 /// Attaches debugger to the current process 0098 0099 /// Using currently selected debugger, this routine attempts to attach the debugger to this process. 0100 /// @param[in] break_or_continue tells what we wan to do after the debugger is attached. If true - process execution breaks 0101 /// in the point in invocation of this function. Otherwise execution continues, but now it is 0102 /// under the debugger 0103 /// @returns true if debugger successfully attached. False otherwise 0104 // ************************************************************************** // 0105 0106 bool BOOST_TEST_DECL attach_debugger( bool break_or_continue = true ); 0107 0108 // ************************************************************************** // 0109 /// Switches on/off memory leaks detection 0110 0111 /// On platforms where memory leak detection is possible inside of running application (at the moment this is only Windows family) you can 0112 /// switch this feature on and off using this interface. In addition you can specify the name of the file to write a report into. Otherwise 0113 /// the report is going to be generated in standard error stream. 0114 /// @param[in] on_off boolean switch 0115 /// @param[in] report_file file, where the report should be directed to 0116 // ************************************************************************** // 0117 0118 void BOOST_TEST_DECL detect_memory_leaks( bool on_off, unit_test::const_string report_file = unit_test::const_string() ); 0119 0120 // ************************************************************************** // 0121 /// Causes program to break execution in debugger at specific allocation point 0122 0123 /// On some platforms/memory managers (at the moment only on Windows/Visual Studio) one can tell a C Runtime to break 0124 /// on specific memory allocation. This can be used in combination with memory leak detection (which reports leaked memory 0125 /// allocation number) to locate the place where leak initiated. 0126 /// @param[in] mem_alloc_order_num Specific memory allocation number 0127 // ************************************************************************** // 0128 0129 void BOOST_TEST_DECL break_memory_alloc( long mem_alloc_order_num ); 0130 0131 } // namespace debug 0132 /// @} 0133 0134 } // namespace boost 0135 0136 #include <boost/test/detail/enable_warnings.hpp> 0137 0138 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|