Commit 7d37bf4d authored by Jean-Tiare Le Bigot's avatar Jean-Tiare Le Bigot

add debug constants

parent b83ccf35
......@@ -688,7 +688,7 @@ BFrontendAction::BFrontendAction(llvm::raw_ostream &os, unsigned flags)
}
void BFrontendAction::EndSourceFileAction() {
if (flags_ & 0x4)
if (flags_ & DEBUG_PREPROCESSOR)
rewriter_->getEditBuffer(rewriter_->getSourceMgr().getMainFileID()).write(llvm::errs());
rewriter_->getEditBuffer(rewriter_->getSourceMgr().getMainFileID()).write(os_);
os_.flush();
......
......@@ -26,6 +26,8 @@
#include "table_desc.h"
#define DEBUG_PREPROCESSOR 0x4
namespace clang {
class ASTConsumer;
class ASTContext;
......
......@@ -155,7 +155,7 @@ int ClangLoader::parse(unique_ptr<llvm::Module> *mod, unique_ptr<vector<TableDes
// Initialize a compiler invocation object from the clang (-cc1) arguments.
const driver::ArgStringList &ccargs = cmd.getArguments();
if (flags_ & 0x4) {
if (flags_ & DEBUG_PREPROCESSOR) {
llvm::errs() << "clang";
for (auto arg : ccargs)
llvm::errs() << " " << arg;
......
......@@ -41,6 +41,10 @@ ksym_names = {}
ksym_loaded = 0
_kprobe_limit = 1000
DEBUG_LLVM_IR = 0x1
DEBUG_BPF = 0x2
DEBUG_PREPROCESSOR = 0x4
@atexit.register
def cleanup_kprobes():
for k, v in open_kprobes.items():
......@@ -132,8 +136,9 @@ class BPF(object):
hdr_file (Optional[str]): Path to a helper header file for the `src_file`
text (Optional[str]): Contents of a source file for the module
debug (Optional[int]): Flags used for debug prints, can be |'d together
0x1: print LLVM IR to stderr
0x2: print BPF bytecode to stderr
DEBUG_LLVM_IR: print LLVM IR to stderr
DEBUG_BPF: print BPF bytecode to stderr
DEBUG_PREPROCESSOR: print Preprocessed C file to stderr
"""
self._reader_cb_impl = _CB_TYPE(BPF._reader_cb)
......@@ -192,7 +197,7 @@ class BPF(object):
lib.bpf_module_kern_version(self.module),
log_buf, ct.sizeof(log_buf) if log_buf else 0)
if self.debug & 0x2:
if self.debug & DEBUG_BPF:
print(log_buf.value.decode(), file=sys.stderr)
if fd < 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment