| Directory: | ./ |
|---|---|
| File: | src/debug/debug.cpp |
| Date: | 2025-05-13 12:28:21 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 6 | 9 | 66.7% |
| Branches: | 2 | 12 | 16.7% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright 2010, | ||
| 3 | * François Bleibel, | ||
| 4 | * Olivier Stasse, | ||
| 5 | * | ||
| 6 | * CNRS/AIST | ||
| 7 | * | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include <fstream> | ||
| 11 | #include <ios> | ||
| 12 | #include <sot/core/debug.hh> | ||
| 13 | |||
| 14 | using namespace dynamicgraph::sot; | ||
| 15 | |||
| 16 | namespace dynamicgraph { | ||
| 17 | namespace sot { | ||
| 18 | #ifdef WIN32 | ||
| 19 | const char *DebugTrace::DEBUG_FILENAME_DEFAULT = "c:/tmp/sot-core-traces.txt"; | ||
| 20 | #else // WIN32 | ||
| 21 | const char *DebugTrace::DEBUG_FILENAME_DEFAULT = "/tmp/sot-core-traces.txt"; | ||
| 22 | #endif // WIN32 | ||
| 23 | |||
| 24 | #ifdef VP_DEBUG | ||
| 25 | #ifdef WIN32 | ||
| 26 | std::ofstream debugfile("C:/tmp/sot-core-traces.txt", | ||
| 27 | std::ios::trunc &std::ios::out); | ||
| 28 | #else // WIN32 | ||
| 29 | std::ofstream debugfile("/tmp/sot-core-traces.txt", | ||
| 30 | std::ios::trunc &std::ios::out); | ||
| 31 | #endif // WIN32 | ||
| 32 | #else // VP_DEBUG | ||
| 33 | |||
| 34 | std::ofstream debugfile; | ||
| 35 | |||
| 36 | class __sotDebug_init { | ||
| 37 | public: | ||
| 38 | 23 | __sotDebug_init() { debugfile.setstate(std::ios::failbit); } | |
| 39 | }; | ||
| 40 | __sotDebug_init __sotDebug_initialisator; | ||
| 41 | |||
| 42 | #endif // VP_DEBUG | ||
| 43 | |||
| 44 | } /* namespace sot */ | ||
| 45 | } /* namespace dynamicgraph */ | ||
| 46 | |||
| 47 | 2 | void DebugTrace::openFile(const char *filename) { | |
| 48 |
2/6✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
|
2 | if (debugfile.good() && debugfile.is_open()) debugfile.close(); |
| 49 | 2 | debugfile.clear(); | |
| 50 | 2 | debugfile.open(filename, std::ios::trunc & std::ios::out); | |
| 51 | 2 | } | |
| 52 | |||
| 53 | ✗ | void DebugTrace::closeFile(const char *) { | |
| 54 | ✗ | if (debugfile.good() && debugfile.is_open()) debugfile.close(); | |
| 55 | ✗ | debugfile.setstate(std::ios::failbit); | |
| 56 | } | ||
| 57 | |||
| 58 | namespace dynamicgraph { | ||
| 59 | namespace sot { | ||
| 60 | DebugTrace sotDEBUGFLOW(debugfile); | ||
| 61 | DebugTrace sotERRORFLOW(debugfile); | ||
| 62 | } // namespace sot. | ||
| 63 | } // namespace dynamicgraph | ||
| 64 |