xtd 0.2.0
debug

Definition

All needed for debugging and tracing.

Collaboration diagram for debug:

Classes

class  xtd::diagnostics::console_trace_listener
 Directs tracing or debugging output to either the standard output or the standard error stream. More...
 
class  xtd::diagnostics::debug
 Provides a set of methods and properties that help you debug the execution of your code. This class cannot be inherited. More...
 
class  xtd::diagnostics::debugger
 Enables communication with a debugger. This class cannot be inherited. More...
 
class  xtd::diagnostics::default_trace_listener
 Provides the default output methods and behavior for tracing. More...
 
class  xtd::diagnostics::ostream_trace_listener
 Directs tracing or debugging output to a std::ostream, such as std::fstream, std::stream... More...
 
class  xtd::diagnostics::stack_frame
 Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the call stack for the current thread. More...
 
class  xtd::diagnostics::stack_trace
 Represents a stack trace, which is an ordered collection of one or more stack frames. More...
 
class  xtd::diagnostics::trace
 Provides a set of methods and properties that help you debug the execution of your code. This class cannot be inherited. More...
 
class  xtd::forms::control_trace_listener
 Directs tracing or debugging output to a icontrol_trace object. More...
 
class  xtd::forms::debug_form
 Represents a form that displays debug form. This class cannot be inherited. More...
 
class  xtd::forms::debug_message_box
 Displays a dialog box and write debug. More...
 
class  xtd::forms::debug_message_dialog
 Displays a message window and write debug, which presents a debug message to the user. More...
 
class  xtd::forms::enable_debug
 Represent enable debug class. More...
 
class  xtd::forms::trace_form
 Represents a form that displays trace form. This class cannot be inherited. More...
 
class  xtd::forms::trace_form_base
 Represents a base form for debug_form and trace_form forms. This class cannot be instantiated. More...
 
class  xtd::forms::trace_message_box
 Displays a dialog box and write trace. More...
 
class  xtd::forms::trace_message_dialog
 Displays a message window and write debug, which presents a debug message to the user. More...
 

Macros

#define assert_(...)   if (xtd::diagnostics::debug::add_last_arg_to_command_(__should_aborted__, (csf_), __VA_ARGS__)) debug_break_()
 Checks for a condition; if the condition is false, displays a message box that shows the call stack. More...
 
#define cassert_(...)   add_last_arg_to_command_(cassert, (csf_), __VA_ARGS__)
 Checks for a condition; if the condition is false, displays a message box that shows the call stack. More...
 
#define debug_break_()   if (xtd::diagnostics::debugger::launch()) __std_abort()
 Signals a breakpoint to an attached debugger. More...
 

Macro Definition Documentation

◆ assert_

#define assert_ (   ...)    if (xtd::diagnostics::debug::add_last_arg_to_command_(__should_aborted__, (csf_), __VA_ARGS__)) debug_break_()

#include <xtd.core/include/xtd/diagnostics/assert.h>

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Header
#include <xtd/diagnostics/assert>
Library
xtd.core
Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
message(optional) The message to send to the xtd::diagnostics::debug::listeners collection.
Examples
The following example shows how to use assert_ macro.
#include <xtd/xtd>
using namespace xtd;
int main() {
// Uncomment following line to remove assert dialog
//diagnostics::debug::show_assert_dialog(false);
auto index = 0;
console::write_line("Start application");
assert_(index > 0);
console::write_line("End application");
}
// This code produces the following output :
//
// > If user clicks assert dialog 'Abort' button:
// Start application
//
// > If user clicks assert dialog 'Retry' button:
// Start application
// > Break the debugger on file assert_.cpp line 11.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application
Examples
The following example shows how to use assert_ macro with message.
#include <xtd/xtd>
using namespace xtd;
int main() {
// Uncomment following line to remove assert dialog
//diagnostics::debug::show_assert_dialog(false);
auto index = 0;
console::write_line("Start application");
assert_(index > 0, "index must be greater than 0");
console::write_line("End application");
}
// This code produces the following output :
//
// > If user clicks assert dialog 'Abort' button:
// Start application
//
// > If user clicks assert dialog 'Retry' button:
// Start application
// > Break the debugger on file assert_with_message.cpp line 11.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application
Examples:
application_and_assert.cpp, assert_.cpp, and assert_with_message.cpp.

◆ cassert_

#define cassert_ (   ...)    add_last_arg_to_command_(cassert, (csf_), __VA_ARGS__)

#include <xtd.core/include/xtd/diagnostics/debug.h>

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Inheritance
xtd::static_objectxtd::diagnostics::debug
Header
#include <xtd/diagnostics/debug>
Library
xtd.core
Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
message(optional) The message to send to the xtd::diagnostics::debug::listeners collection.
Usage
This assert can only call by xtd::diagnostics::debug and xtd::diagnostics::trace like this :
  • xtd::diagnostics::debug::cassert_();
  • xtd::diagnostics:trace::cassert_();
Examples
The following example shows how to use xtd::diagnostics::debug::cassert_ method.
#include <xtd/diagnostics/debug>
#include <xtd/console>
using namespace xtd;
using namespace xtd::diagnostics;
auto main()->int {
// Uncomment following line to remove assert dialog
//diagnostics::debug::show_assert_dialog(false);
auto index = 0;
console::write_line("Start application");
debug::cassert_(index > 0);
console::write_line("End application");
}
// This code produces the following output :
//
// > If user clicks assert dialog 'Abort' button:
// Start application
//
// > If user clicks assert dialog 'Retry' button:
// Start application
// > Break the debugger on file debug_cassert.cpp line 12.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application
Examples
The following example shows how to use xtd::diagnostics::trace::cassert_ method.
#define TRACE
#include <xtd/diagnostics/trace>
#include <xtd/console>
using namespace xtd;
using namespace xtd::diagnostics;
auto main()->int {
// Uncomment following line to remove assert dialog
//diagnostics::debug::show_assert_dialog(false);
auto index = 0;
console::write_line("Start application");
trace::cassert_(index > 0, "index must be greater than 0");
console::write_line("End application");
}
// This code produces the following output :
//
// > If user clicks assert dialog 'Abort' button:
// Start application
//
// > If user clicks assert dialog 'Retry' button:
// Start application
// > Break the debugger on file tace_cassert.cpp line 13.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application
Examples:
application_and_assert.cpp, debug_cassert.cpp, and trace_cassert.cpp.

◆ debug_break_

#define debug_break_ ( )    if (xtd::diagnostics::debugger::launch()) __std_abort()

#include <xtd.core/include/xtd/diagnostics/debug_break.h>

Signals a breakpoint to an attached debugger.

Header
#include <xtd/diagnostics/debug_break>
Library
xtd.core
Examples
The following code example demonstrates how to stop the debugger at the call to write_line.
console::write_line("Hello, world.");
Examples:
application_and_assert.cpp, assert_box.cpp, and assert_dialog.cpp.