LLVM 22.0.0git
|
Go to the source code of this file.
Classes | |
class | llvm::impl::raw_ldbg_ostream |
A raw_ostream that tracks \n and print the prefix after each newline. More... | |
class | llvm::impl::RAIINewLineStream |
A raw_ostream that prints a newline on destruction, useful for LDBG() More... |
Namespaces | |
namespace | llvm |
This is an optimization pass for GlobalISel generic memory operations. | |
namespace | llvm::impl |
Macros | |
#define | LDBG(...) |
LDBG() is a macro that can be used as a raw_ostream for debugging. | |
#define | LDBG_OS(...) |
LDBG_OS() is a macro that behaves like LDBG() but instead of directly using it to stream the output, it takes a callback function that will be called with a raw_ostream. | |
#define | __LLVM_FILE_NAME__ ::llvm::impl::getShortFileName(__FILE__) |
#define | LDBG_STREAM ::llvm::dbgs() |
This macro expands to the stream to use for output, we use a macro to allow unit-testing to override. | |
#define | LDBG_FUNC_CHOOSER(_f1, _f2, _f3, ...) |
#define | LDBG_FUNC_RECOMPOSER(argsWithParentheses) |
#define | LDBG_CHOOSE_FROM_ARG_COUNT(...) |
#define | LDBG_NO_ARG_EXPANDER() |
#define | _GET_LDBG_MACRO(...) |
#define | LDBG_STREAM_LEVEL_TYPE_FILE_AND_LINE(STREAM, LEVEL_OR_TYPE, TYPE_OR_LEVEL, FILE, LINE) |
This macro is the core of the LDBG() implementation. | |
#define | LDBG_STREAM_LEVEL_TYPE_AND_FILE(STREAM, LEVEL_OR_TYPE, TYPE_OR_LEVEL, FILE) |
These macros are helpers to implement LDBG() with an increasing amount of optional arguments made explicit. | |
#define | LDGB_STREAM_LEVEL_AND_TYPE(STREAM, LEVEL_OR_TYPE, TYPE_OR_LEVEL) |
#define | LDBG_TYPE_AND_LEVEL(TYPE, LEVEL) |
This macro is a helper when LDBG() is called with 2 arguments. | |
#define | LDBG_LEVEL_OR_TYPE(LEVEL_OR_TYPE) |
When a single argument is provided. | |
#define | LDBG_NO_ARG() |
#define | LDBG_OS_FUNC_CHOOSER(_f1, _f2, _f3, _f4, ...) |
#define | LDBG_OS_FUNC_RECOMPOSER(argsWithParentheses) |
#define | LDBG_OS_CHOOSE_FROM_ARG_COUNT(...) |
#define | LDBG_OS_NO_ARG_EXPANDER() |
#define | _GET_LDBG_OS_MACRO(...) |
#define | LDBG_OS_IMPL(TYPE_OR_LEVEL, LEVEL_OR_TYPE, CALLBACK, STREAM, FILE, LINE) |
This macro is the core of the LDBG_OS() macros. | |
#define | LDBG_OS_TYPE_AND_LEVEL_AND_CALLBACK(TYPE, LEVEL, CALLBACK) |
#define | LDBG_OS_LEVEL_OR_TYPE_AND_CALLBACK(LEVEL_OR_TYPE, CALLBACK) |
#define | LDBG_OS_CALLBACK(CALLBACK) |
#define | LDBG_GET_DEFAULT_TYPE_OR_LEVEL(LEVEL_OR_TYPE) |
Helper to provide the default level (=1) or type (=DEBUG_TYPE). | |
#define | LDBG_GET_DEBUG_TYPE_STR__(X) |
Helpers to get DEBUG_TYPE as a StringRef, even when DEBUG_TYPE is not defined (in which case it expands to "DEBUG_TYPE") | |
#define | LDBG_GET_DEBUG_TYPE_STR_(X) |
#define | LDBG_GET_DEBUG_TYPE_STR() |
Functions | |
constexpr ::llvm::StringRef | llvm::impl::strip_quotes (const char *Str) |
Return the stringified macro as a StringRef. | |
static LLVM_ATTRIBUTE_UNUSED bool | llvm::impl::ldbgIsCurrentDebugType (StringRef Type, int Level) |
Helper to call isCurrentDebugType with a StringRef. | |
static LLVM_ATTRIBUTE_UNUSED bool | llvm::impl::ldbgIsCurrentDebugType (int Level, StringRef Type) |
static LLVM_ATTRIBUTE_UNUSED constexpr const char * | llvm::impl::getShortFileName (const char *path) |
Remove the path prefix from the file name. | |
static LLVM_ATTRIBUTE_UNUSED std::string | llvm::impl::computePrefix (StringRef DebugType, const char *File, int Line, int Level) |
Compute the prefix for the debug log in the form of: "[DebugType] File:Line " Where the File is the file name without the path prefix. | |
static LLVM_ATTRIBUTE_UNUSED std::string | llvm::impl::computePrefix (int Level, const char *File, int Line, StringRef DebugType) |
Overload allowing to swap the order of the DebugType and Level arguments. |
#define __LLVM_FILE_NAME__ ::llvm::impl::getShortFileName(__FILE__) |
Definition at line 79 of file DebugLog.h.
#define _GET_LDBG_MACRO | ( | ... | ) |
Definition at line 101 of file DebugLog.h.
#define _GET_LDBG_OS_MACRO | ( | ... | ) |
Definition at line 157 of file DebugLog.h.
#define LDBG | ( | ... | ) |
LDBG() is a macro that can be used as a raw_ostream for debugging.
It will stream the output to the dbgs() stream, with a prefix of the debug type and the file and line number. A trailing newline is added to the output automatically. If the streamed content contains a newline, the prefix is added to each beginning of a new line. Nothing is printed if the debug output is not enabled or the debug type does not match.
E.g., LDBG() << "Bitset contains: " << Bitset; is equivalent to LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] " << FILE << ":" << LINE << " " << "Bitset contains: " << Bitset << "\n"); output. The default level is 1, and is in increasing level of verbosity.
The level argument can be a literal integer, or a macro that evaluates to an integer.
An optional type argument can be provided to control the debug type. The default type is DEBUG_TYPE. The type argument can be a literal string, or a macro that evaluates to a string.
E.g., LDBG(2) << "Bitset contains: " << Bitset; LDBG("debug_type") << "Bitset contains: " << Bitset; LDBG("debug_type", 2) << "Bitset contains: " << Bitset;
Definition at line 50 of file DebugLog.h.
Referenced by llvm::mca::RISCVInstrumentManager::createInstrument(), llvm::mca::RISCVInstrumentManager::createInstruments(), and llvm::mca::RISCVInstrumentManager::getSchedClassID().
#define LDBG_CHOOSE_FROM_ARG_COUNT | ( | ... | ) |
Definition at line 98 of file DebugLog.h.
#define LDBG_FUNC_CHOOSER | ( | _f1, | |
_f2, | |||
_f3, | |||
... ) |
Definition at line 95 of file DebugLog.h.
#define LDBG_FUNC_RECOMPOSER | ( | argsWithParentheses | ) |
Definition at line 96 of file DebugLog.h.
#define LDBG_GET_DEBUG_TYPE_STR | ( | ) |
Definition at line 221 of file DebugLog.h.
#define LDBG_GET_DEBUG_TYPE_STR_ | ( | X | ) |
Definition at line 220 of file DebugLog.h.
#define LDBG_GET_DEBUG_TYPE_STR__ | ( | X | ) |
Helpers to get DEBUG_TYPE as a StringRef, even when DEBUG_TYPE is not defined (in which case it expands to "DEBUG_TYPE")
Definition at line 219 of file DebugLog.h.
#define LDBG_GET_DEFAULT_TYPE_OR_LEVEL | ( | LEVEL_OR_TYPE | ) |
Helper to provide the default level (=1) or type (=DEBUG_TYPE).
This is used when a single argument is passed to LDBG() (or LDBG_OS()), if it is an integer we return DEBUG_TYPE and if it is a string we return 1. When DEBUG_TYPE is not defined, we return the current file name instead.
Definition at line 203 of file DebugLog.h.
#define LDBG_LEVEL_OR_TYPE | ( | LEVEL_OR_TYPE | ) |
When a single argument is provided.
This can be either a level or the debug type. If a level is provided, we default the debug type to DEBUG_TYPE, if a string is provided, we default the level to 1.
Definition at line 138 of file DebugLog.h.
#define LDBG_NO_ARG | ( | ) |
Definition at line 141 of file DebugLog.h.
#define LDBG_NO_ARG_EXPANDER | ( | ) |
Definition at line 100 of file DebugLog.h.
#define LDBG_OS | ( | ... | ) |
LDBG_OS() is a macro that behaves like LDBG() but instead of directly using it to stream the output, it takes a callback function that will be called with a raw_ostream.
This is useful when you need to pass a raw_ostream to a helper function to be able to print (when the << operator is not available).
E.g., LDBG_OS([&] (raw_ostream &Os) { Os << "Pass Manager contains: "; pm.printAsTextual(Os); });
Just like LDBG(), it optionally accepts a level and type arguments. E.g., LDBG_OS(2, [&] (raw_ostream &Os) { ... }); LDBG_OS("debug_type", [&] (raw_ostream &Os) { ... }); LDBG_OS("debug_type", 2, [&] (raw_ostream &Os) { ... });
Definition at line 70 of file DebugLog.h.
#define LDBG_OS_CALLBACK | ( | CALLBACK | ) |
Definition at line 179 of file DebugLog.h.
#define LDBG_OS_CHOOSE_FROM_ARG_COUNT | ( | ... | ) |
Definition at line 152 of file DebugLog.h.
#define LDBG_OS_FUNC_CHOOSER | ( | _f1, | |
_f2, | |||
_f3, | |||
_f4, | |||
... ) |
Definition at line 149 of file DebugLog.h.
#define LDBG_OS_FUNC_RECOMPOSER | ( | argsWithParentheses | ) |
Definition at line 150 of file DebugLog.h.
#define LDBG_OS_IMPL | ( | TYPE_OR_LEVEL, | |
LEVEL_OR_TYPE, | |||
CALLBACK, | |||
STREAM, | |||
FILE, | |||
LINE ) |
This macro is the core of the LDBG_OS() macros.
It is used to print the debug output with the given stream, level, type, file, and line number.
Definition at line 162 of file DebugLog.h.
#define LDBG_OS_LEVEL_OR_TYPE_AND_CALLBACK | ( | LEVEL_OR_TYPE, | |
CALLBACK ) |
Definition at line 176 of file DebugLog.h.
#define LDBG_OS_NO_ARG_EXPANDER | ( | ) |
Definition at line 156 of file DebugLog.h.
#define LDBG_OS_TYPE_AND_LEVEL_AND_CALLBACK | ( | TYPE, | |
LEVEL, | |||
CALLBACK ) |
Definition at line 173 of file DebugLog.h.
#define LDBG_STREAM ::llvm::dbgs() |
This macro expands to the stream to use for output, we use a macro to allow unit-testing to override.
Definition at line 87 of file DebugLog.h.
#define LDBG_STREAM_LEVEL_TYPE_AND_FILE | ( | STREAM, | |
LEVEL_OR_TYPE, | |||
TYPE_OR_LEVEL, | |||
FILE ) |
These macros are helpers to implement LDBG() with an increasing amount of optional arguments made explicit.
Definition at line 119 of file DebugLog.h.
#define LDBG_STREAM_LEVEL_TYPE_FILE_AND_LINE | ( | STREAM, | |
LEVEL_OR_TYPE, | |||
TYPE_OR_LEVEL, | |||
FILE, | |||
LINE ) |
This macro is the core of the LDBG() implementation.
It is used to print the debug output with the given stream, level, type, file, and line number.
Definition at line 106 of file DebugLog.h.
#define LDBG_TYPE_AND_LEVEL | ( | TYPE, | |
LEVEL ) |
This macro is a helper when LDBG() is called with 2 arguments.
In this case we want to force the first argument to be the type for consistency in the codebase. We trick this by casting the first argument to a (const char *) which won't compile with an int.
Definition at line 131 of file DebugLog.h.
#define LDGB_STREAM_LEVEL_AND_TYPE | ( | STREAM, | |
LEVEL_OR_TYPE, | |||
TYPE_OR_LEVEL ) |
Definition at line 123 of file DebugLog.h.