23 #ifdef HAVE_EXECINFO_H 31 #endif // HAVE_CXXABI_H 32 #endif // HAVE_EXECINFO_H 38 #if !defined(KALDI_VERSION) 55 program_name = basename;
67 const char *prev = path, *last = path;
68 while ((path = std::strpbrk(path,
"\\/")) !=
nullptr) {
82 *begin = std::string::npos;
83 for (
size_t i = 1;
i < trace_name.size();
i++) {
84 if (trace_name[
i] !=
'_') {
87 if (trace_name[
i - 1] ==
' ' || trace_name[
i - 1] ==
'(') {
92 if (*begin == std::string::npos) {
95 *end = trace_name.find_first_of(
" +", *begin);
96 return *end != std::string::npos;
100 #ifdef HAVE_EXECINFO_H 101 static std::string Demangle(std::string trace_name) {
102 #ifndef HAVE_CXXABI_H 104 #else // HAVE_CXXABI_H 120 std::string symbol = trace_name.substr(begin, end - begin);
122 char *demangled_name = abi::__cxa_demangle(symbol.c_str(), 0, 0, &status);
123 if (status == 0 && demangled_name !=
nullptr) {
124 symbol = demangled_name;
125 free(demangled_name);
127 return trace_name.substr(0, begin) + symbol +
128 trace_name.substr(end, std::string::npos);
129 #endif // HAVE_CXXABI_H 131 #endif // HAVE_EXECINFO_H 135 #ifdef HAVE_EXECINFO_H 136 const size_t KALDI_MAX_TRACE_SIZE = 50;
137 const size_t KALDI_MAX_TRACE_PRINT = 50;
139 void *trace[KALDI_MAX_TRACE_SIZE];
141 size_t size = backtrace(trace, KALDI_MAX_TRACE_SIZE);
143 char **trace_symbol = backtrace_symbols(trace, size);
144 if (trace_symbol == NULL)
148 ans +=
"[ Stack-Trace: ]\n";
149 if (size <= KALDI_MAX_TRACE_PRINT) {
150 for (
size_t i = 0;
i < size;
i++) {
151 ans += Demangle(trace_symbol[
i]) +
"\n";
154 for (
size_t i = 0;
i < KALDI_MAX_TRACE_PRINT / 2;
i++) {
155 ans += Demangle(trace_symbol[
i]) +
"\n";
158 for (
size_t i = size - KALDI_MAX_TRACE_PRINT / 2;
i < size;
i++) {
159 ans += Demangle(trace_symbol[
i]) +
"\n";
161 if (size == KALDI_MAX_TRACE_SIZE)
168 #endif // HAVE_EXECINFO_H 175 const char *func,
const char *file,
int32 line) {
177 envelope_.severity = severity;
178 envelope_.func = func;
180 envelope_.line = line;
185 if (log_handler != NULL) {
192 std::stringstream full_message;
194 full_message <<
"VLOG[" << envelope_.severity <<
"] (";
196 switch (envelope_.severity) {
198 full_message <<
"LOG (";
201 full_message <<
"WARNING (";
204 full_message <<
"ASSERTION_FAILED (";
208 full_message <<
"ERROR (";
213 full_message << program_name.c_str() <<
"[" KALDI_VERSION "]" <<
':' 214 << envelope_.func <<
"():" << envelope_.file <<
':' 215 << envelope_.line <<
") " << GetMessage().c_str();
220 if (!stack_trace.empty()) {
221 full_message <<
"\n\n" << stack_trace;
226 full_message <<
"\n";
227 std::cerr << full_message.str();
233 const char *cond_str) {
236 <<
"Assertion failed: (" << cond_str <<
")";
245 log_handler = handler;
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
MessageLogger(LogMessageEnvelope::Severity severity, const char *func, const char *file, int32 line)
The constructor stores the message's "envelope", a set of data which.
static std::string program_name
void SetProgramName(const char *basename)
Called by ParseOptions to set base name (no directory) of the executing program.
void KaldiAssertFailure_(const char *func, const char *file, int32 line, const char *cond_str)
static std::string KaldiGetStackTrace()
void(* LogHandler)(const LogMessageEnvelope &envelope, const char *message)
Type of third-party logging function.
static LogHandler log_handler
Severity
Message severity.
LogHandler SetLogHandler(LogHandler handler)
Set logging handler.
Fatal error. KaldiFatalError will be thrown.
int32 g_kaldi_verbose_level
This is set by util/parse-options.
static const char * GetShortFileName(const char *path)
Assertion failure. abort() will be called.
bool LocateSymbolRange(const std::string &trace_name, size_t *begin, size_t *end)
Indicates a recoverable but abnormal condition.