28 #include "defines.hpp" 34 #define PRINTER_CASTER(Target) \ 35 TR_BOOL_t localCastOK = TR_TRUE; \ 37 castOK = &localCastOK; \ 39 TR_BOOL_t &cOK = *castOK; \ 42 Target *printer = nullptr; \ 44 printer = dynamic_cast<Target *>(p->obj.get()); \ 59 if (!outStr || cOK != TR_TRUE)
64 string str = printer->genStringPreFrame(frameNum);
66 *outStr =
reinterpret_cast<char *
>(malloc(
sizeof(
char) * (str.length() + 1)));
67 strncpy(*outStr, str.c_str(), str.length() + 1);
75 if (!outStr || cOK != TR_TRUE)
80 string str = printer->genStringForFrame(frameNum);
82 *outStr =
reinterpret_cast<char *
>(malloc(
sizeof(
char) * (str.length() + 1)));
83 strncpy(*outStr, str.c_str(), str.length() + 1);
91 if (!outStr || cOK != TR_TRUE)
96 string str = printer->genStringPostFrame(frameNum);
98 *outStr =
reinterpret_cast<char *
>(malloc(
sizeof(
char) * (str.length() + 1)));
99 strncpy(*outStr, str.c_str(), str.length() + 1);
107 if (!outStr || cOK != TR_TRUE)
112 string str = printer->generateString();
114 *outStr =
reinterpret_cast<char *
>(malloc(
sizeof(
char) * (str.length() + 1)));
115 strncpy(*outStr, str.c_str(), str.length() + 1);
123 if (!file || cOK != TR_TRUE)
126 printer->printToFile(file, append == TR_TRUE);
136 printer->printToStdOut();
146 printer->printToStdErr();
157 printer->enableColor();
167 printer->disableColor();
174 if (!t || cOK != TR_TRUE)
177 printer->setTrace(t->
tPTR);
184 memset(&cfg, 0,
sizeof(cfg));
191 auto pCFG = printer->getConfig();
193 strncpy(cfg.
prefix, pCFG.prefix.c_str(), 64);
194 strncpy(cfg.
seper1, pCFG.seper1.c_str(), 64);
195 strncpy(cfg.
seper2, pCFG.seper2.c_str(), 64);
196 strncpy(cfg.
seper3, pCFG.seper3.c_str(), 64);
197 strncpy(cfg.
suffix, pCFG.suffix.c_str(), 64);
200 strncpy(cfg.
colorAddress, pCFG.colorAddress.c_str(), 64);
203 strncpy(cfg.
colorModule, pCFG.colorModule.c_str(), 64);
205 cfg.
shortenFiles = pCFG.shortenFiles ? TR_TRUE : TR_FALSE;
236 printer->setConfig(pCFG);
246 printer->setSignum(signum);
253 if (cOK != TR_TRUE || !name || !value)
256 printer->addSystemEntry({name, value});
std::string colorNotFound
ANSI escape sequence for the "Not Found" color.
void tr_Printer__genStringPostFrame(tr_Printer_t *p, size_t frameNum, char **outStr, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::genStringPostFrame.
void tr_Printer__printToStdErr(tr_Printer_t *p, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::printToStdErr.
void tr_Printer__genStringForFrame(tr_Printer_t *p, size_t frameNum, char **outStr, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::genStringForFrame.
void tr_Printer__printToStdOut(tr_Printer_t *p, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::printToStdOut.
std::string seper1
1st seperator
char colorLineInfo[64]
ANSI escape sequence for the Line information color.
std::string colorFrameNum
ANSI escape sequence for the Frame number color.
tr_DefaultPrinter_Config_t tr_Printer__getConfig(tr_Printer_t *p, TR_BOOL_t *castOK)
Wrapper for tracer::DefaultPrinter::getConfig.
User configuration structure.
Gnerates strings from the frame structure.
char colorAddress[64]
ANSI escape sequence for the Address color.
Internal C wrapper structure.
void tr_Printer__setConfig(tr_Printer_t *p, tr_DefaultPrinter_Config_t cfg, TR_BOOL_t *castOK)
Wrapper for tracer::DefaultPrinter::setConfig.
void tr_Printer__setSignum(tr_Printer_t *p, int signum, TR_BOOL_t *castOK)
Wrapper for tracer::SystemInfoPrinter::setSignum.
char colorFuncName[64]
ANSI escape sequence for the Function Name color.
char seper2[64]
2nd seperator
std::string seper3
3rd seperator
TR_BOOL_t shortenFiles
The source file path.
void tr_Printer__generateString(tr_Printer_t *p, char **outStr, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::generateString.
std::string colorAddress
ANSI escape sequence for the Address color.
TR_BOOL_t canonicalizePaths
Fixes path names if they contain "/../" or are relative.
void tr_Printer__genStringPreFrame(tr_Printer_t *p, size_t frameNum, char **outStr, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::genStringPreFrame.
char prefix[64]
Perefix (prefix [functionName])
char colorNotFound[64]
ANSI escape sequence for the "Not Found" color.
Internal C wrapper structure.
bool canonicalizePaths
Fixes path names if they contain "/../" or are relative.
void tr_Printer__printToFile(tr_Printer_t *p, const char *file, TR_BOOL_t append, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::printToFile.
char colorFrameNum[64]
ANSI escape sequence for the Frame number color.
#define PRINTER_CASTER(Target)
Makes sure that the printer can be casted and sets cOK.
TR_BOOL_t shortenModules
The executable module (.so/.dll/.exe)
Basic class for all printers.
char seper1[64]
1st seperator
void tr_Printer__disableColor(tr_Printer_t *p, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::disableColor.
enum TR_BOOL TR_BOOL_t
Define some our own boolean values.
void tr_Printer__addSystemEntry(tr_Printer_t *p, const char *name, const char *value, TR_BOOL_t *castOK)
Wrapper for tracer::SystemInfoPrinter::addSystemEntry.
void tr_Printer__enableColor(tr_Printer_t *p, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::enableColor.
bool shortenModules
The executable module (.so/.dll/.exe)
Prints additional information before the first stack frame.
bool shortenFiles
The source file path.
char seper3[64]
3rd seperator
User configuration structure.
std::string colorFuncName
ANSI escape sequence for the Function Name color.
std::string colorLineInfo
ANSI escape sequence for the Line information color.
void tr_Printer__setTrace(tr_Printer_t *p, tr_Tracer_t *t, TR_BOOL_t *castOK)
Wrapper for tracer::AbstractPrinter::setTrace.
tracer::Tracer * tPTR
Pointer to the tracer object to use.
std::string seper2
2nd seperator
std::string prefix
Perefix (prefix [functionName])
std::string colorModule
ANSI escape sequence for the Frame number color.
char colorModule[64]
ANSI escape sequence for the Frame number color.