Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pantheios.Extras.DiagUtil

Header-only C and C++ library in the Pantheios.Extras namespace that aids diagnostics — notably memory-leak tracing around main().

C C++ License GitHub release Last Commit CI

Table of Contents

Introduction

Pantheios.Extras.DiagUtil is a small header-only library under the Pantheios extras namespace. It wraps a main()-like entry point so that, when compiling with Microsoft Visual C++ in _DEBUG, CRT memory allocations leaked by that call are reported via _CrtMemDumpAllObjectsSince. On other toolchains (and non-debug MSVC) the invoke path is a transparent passthrough.

That keeps application main() free of #if/crtdbg.h boilerplate while remaining compatible with the usual Extras nesting — for example wrapping Pantheios.Extras.Main and/or command-line helpers so leak tracing runs while the diagnostic logging layer is still initialised.

Why main leak-trace

Hand-rolled CRT leak checkpoints in main() are noisy and easy to get wrong:

  • You must remember conditional includes and checkpoints around every return path;
  • Exception paths need an explicit dump before rethrow;
  • Future backends (other compilers or leak detectors) would force every client to change;

Pantheios.Extras.DiagUtil centralises that protocol behind one C function and one C++ invoke overload set.

Dependencies

Component Implemented in Use in Dependencies
Core library C / C++ headers C — pantheios/extras/diagutil.h; C++ — …/diagutil.hpp Pantheios, STLSoft
Examples C / C++ Pantheios, STLSoft
Tests C Pantheios, STLSoft, xTests

Installation

Detailed instructions — via CMake, via bundling — are provided in the accompanying INSTALL.md file.

Components

C API

#include <pantheios/extras/diagutil.h>

int
pantheios_extras_diagutil_main_leak_trace_invoke(
    int                 argc
,   char**              argv
,   int (STLSOFT_CDECL* pfnMain)(int, char*[])
);

C++ API

#include <pantheios/extras/diagutil.hpp>

namespace pantheios {
namespace extras {
namespace diagutil {
namespace main_leak_trace {

int invoke(int argc, char** argv, int (STLSOFT_CDECL* pfnMain)(int, char*[]));

} // namespace main_leak_trace
} // namespace diagutil
} // namespace extras
} // namespace pantheios

Examples

Examples are provided in the examples directory (example.c.main_leak_trace.1, example.cpp.main_leak_trace.1).

Project Information

Where to get help

GitHub Page

Contribution guidelines

Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/Pantheios.Extras.DiagUtil.

Dependencies

Development dependencies

Related projects

License

Pantheios.Extras.DiagUtil is released under the 3-clause BSD license. See LICENSE for details.

About

Extension to Pantheios logging library that provides diagnostic facilities, for C and C++

Topics

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages