F
F
floppa3222021-12-02 22:45:35
C++ / C#
floppa322, 2021-12-02 22:45:35

Is it a good practice to use Stack Trace libraries in a debug build?

Hello everyone

Is it good practice to use tools like Backward-cpp during application development ? And are there any unobvious pitfalls? (it is clear that compilation with the optimization flag turned off)

Also, in particular, Backward-cpp can hang callbacks on various system signals such as an unhandled exception or segfault.

Using the assert macro as an example:

// smartAssert.h

void smartAssert(bool expression)
{
    if (expression)
        return;

    using namespace backward;

    StackTrace stackTrace;
    stackTrace.load_here(32);

    Printer printer;
    printer.object = true;
    printer.color_mode = ColorMode::always;
    printer.address = true;

    printer.print(stackTrace, stdout);
}


// config.h
#ifdef DEBUG
#   include "external/backward/backward.cpp"
#endif

#ifdef DEBUG
#   include "SmartAssert.h"
#   define SMART_ASSERT(expression) do { smartAssert(expression); } while (0)
#else
#  define SMART_ASSERT(expression) do {} while (0)
#endif

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-12-02
@Lite_stream

This is normal practice. For example, your browser most likely uses just such a tool (if it is based on Chromium).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question