/* * Must come before the linux/compiler.h include, which defines several * macros (e.g. noinline) that conflict with compiler builtins used * by LLVM.
*/ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter"/* Needed for LLVM <= 15 */ #include <llvm/DebugInfo/Symbolize/Symbolize.h> #include <llvm/Support/TargetSelect.h> #pragma GCC diagnostic pop
extern"C" char *dso__demangle_sym(struct dso *dso, int kmodule, constchar *elf_name);
usingnamespace llvm; using llvm::symbolize::LLVMSymbolizer;
/* * Allocate a static LLVMSymbolizer, which will live to the end of the program. * Unlike the bfd paths, LLVMSymbolizer has its own cache, so we do not need * to store anything in the dso struct.
*/ static LLVMSymbolizer *get_symbolizer()
{ static LLVMSymbolizer *instance = nullptr; if (instance == nullptr) {
LLVMSymbolizer::Options opts; /* * LLVM sometimes demangles slightly different from the rest * of the code, and this mismatch can cause new_inline_sym() * to get confused and mark non-inline symbol as inlined * (since the name does not properly match up with base_sym). * Thus, disable the demangling and let the rest of the code * handle it.
*/
opts.Demangle = false;
instance = new LLVMSymbolizer(opts);
} return instance;
}
/* Returns 0 on error, 1 on success. */ staticint extract_file_and_line(const DILineInfo &line_info, char **file, unsignedint *line)
{ if (file) { if (line_info.FileName == "") { /* Match the convention of libbfd. */
*file = nullptr;
} else { /* The caller expects to get something it can free(). */
*file = strdup(line_info.FileName.c_str()); if (*file == nullptr) return 0;
}
} if (line)
*line = line_info.Line; return 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.