Skip to content

Commit

Permalink
Logger log_instruction updated to the master version.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaskov committed Nov 24, 2023
1 parent c340bfd commit 2a52137
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions include/nil/blueprint/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,20 @@ namespace nil {
void debug(std::string_view debug_message) {
BOOST_LOG_TRIVIAL(debug) << debug_message;
}

void log_instruction(const llvm::Instruction *inst) {
if (inst->getFunction() != current_function) {
current_function = inst->getFunction();

BOOST_LOG_TRIVIAL(debug) << current_function->getName().str();
}
if (inst->getParent() != current_block) {
current_block = inst->getParent();

BOOST_LOG_TRIVIAL(debug) << current_block->getNameOrAsOperand();
}
std::string inst_name = inst->getNameOrAsOperand();
const char *opcode_name = inst->getOpcodeName();
if (inst_name == "<badref>") {
BOOST_LOG_TRIVIAL(debug) << "\t\t" << opcode_name;
} else {
BOOST_LOG_TRIVIAL(debug) << "\t\t" << opcode_name << " -> " << inst_name;
BOOST_LOG_TRIVIAL(debug) << "\t" << current_block->getNameOrAsOperand();
}
std::string str;
llvm::raw_string_ostream ss(str);
inst->print(ss);
BOOST_LOG_TRIVIAL(debug) << "\t\t" << str;
}
};
} // namespace blueprint
Expand Down

0 comments on commit 2a52137

Please sign in to comment.