Skip to content

Development Guideline

Xiangyan Sun edited this page Sep 10, 2015 · 1 revision

Compilation

Make sure you have Visual Studio 2015. Open flinux.sln and you should be able to compile the flinux.exe and flog.exe executables. The resulting files will be located at Release/ or Debug/ folder, as per default.

Source tree structure

binfmt/: ELF format definitions
common/: Linux kernel headers (a bit reorganized)
dbt/: Dynamic binary translator
lib/: Core data structures and library functions
fs/: Virtual file system handlers
syscall/: Implementation of most system calls

Logging and the flog tool

flinux comes with a very fast interprocess logging viewer: flog. It is simple to use: open it first, any flinux sessions created after will automatically attach it and start logging.

There are currently some rules regarding logging:

  • log_error() is used for unimplemented functions, or critical bugs which has effects on system call semantics
  • log_warning() is used for "normal" error conditions, like opening a non-existent file. It could be a flinux bug, or just an ordinary program condition.
  • log_info() is used for logging normal messages.
  • log_debug() is used for temporary debugging sessions. Add this to output temporary debug messages. Then you can easily find and remove all these after you fix the issues.

Development tricks

  • You can add code and use the __debugbreak() function to implement a conditional breakpoint. This is very useful in debugging an issue consisting of multiple processes. Since in this case it is almost impossible to set breakpoints.
  • Enable the output logging at console_write() to help you identify which write() call writes the program error message.