SmartLog icon indicating copy to clipboard operation
SmartLog copied to clipboard

Error-Log Statement Placement by Deep Understanding of Log Intention

SmartLog

Place Error Log Statement by Deep Understanding of Log Intention.


Introduction

SmartLog is a log automation tool. Existing log automation tools define log placement rules by extracting syntax features or summarizing code patterns. These approaches are limited since the log placements are far beyond those rules but are according to the intention of software code. We design SmartLog, an accurate log automation tool that places error-log statements by deep understanding of log intention.

Usage

Compile
  • Change directory to Clang tools directory.
cd path/to/llvm-source-tree/tools/clang/tools
  • Download source code.
git clone https://github.com/ZhouyangJia/SmartLog.git
  • Add add_subdirectory(SmartLog) to CMakeList.txt.
echo "add_subdirectory(SmartLog)" >> CMakeLists.txt
ls path/to/llvm-build/Release/bin/clang-smartlog
Run
cd test/
tar zxvf bftpd-3.2.tar
cd bftpd/
./configure
bear make
  • Generate compiled_files.def, This file has all names of compiled source files.
../../script/extract_command.pl compile_commands.json
  • Build LLVM IR.
./build_ir.sh
  • Generate call dependence before running SmartLog (Compile CallDependence tool first).
../../script/call_dependence.sh
  • Generate logging_statement.out, logging_behavior.out, normalizes_behavior.out and logging_rules.out.
cat compiled_files.def | xargs clang-smartlog -find-logging-behavior > logging_rules.out

logging_statement.out. The logging statements, including function name and call location.

logging_behavior.out. The logging behavior, including error-prone function name, function call expression, function call location, argument index, log type (SA for sensitive argement, RV for return value and PA for pointer argument), check condition, check location, logging statement, log approach (LL for local log, RL for remote log and NL for no log), log location.

normalizes_behavior.out. The normalized behavior, including error-prone function name, argument index, log type, normalized check condition, log approach.

  • Generate patches.
python ../../script/patch.py > patch.out