add ftrace tracing description into tutorial

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
Introduce ffi_type, csymbol and ktap_cdata

ffi type is the basic type used in ffi module, which has fixed size and
alignment.

csymbol means symbol for c type, which is designed to represent all
possible c types in its format. It doesn't contain any real value or
data.

ktap_cdata is the uniform cdata type in ktap. It is an instance of
csymbol, which binds a csymbol with the real data. It mainly exists in
the vm stack.

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
Cparser to parse C declareation

Cparser is able to interpret C declareation, including basic types,
aggregate types, type definition and so on.

C declareations are converted into csymbol type, which provides type
information for cdata in ktap vm.

Cparser is partially ported from LuaFFI's c parser.
Thanks for their great work!

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
Integrate cparser into ktap compiler

When ktapc finds a 'cdef' token, it passes the C code to cparser module,
which then generates c symbols accordingly.

This patch also handles how to dump c symbols into vm chunk.

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
Introduce ffi call module in vm

kp_ffi_call function calls into C functions according to arguments
passed in ktap vm stack.

Only support x86_64 platform now, but it is rather easy to add support
for new platforms.

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
Integrate ffi call module into vm

This patch adds following features to vm:
* load csymbols from vm chunk file
* call C functions using ffi call module
* ffi library with functions that are designed to meet
  general usage for ffi module.

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
update gitignore file for FFI related files

* dont ignore .s file
* ignore cparser_test binary

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
Modify makefile to build ffi module

This patch adds rule to build ffi module into ktap.
Also, it introduces FFI flag to enable/disable FFI funtionality.

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
Add ffi test cases and sample script

Test cases include:

* cparser ability
* C function call on user-defined kernel functions
* C function call on native kernel functions

FFI sample scripts include:
* sched_clock
* halt
* printk

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
add CONFIG_KTAP_FFI option to Kconfig

Signed-off-by: Yicheng Qin <qycqycqycqycqyc@gmail.com>
Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
[Jovi: fix the FFI dependence]
Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
add ffi printk example into README

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
delete samples/ffi/halt.kp

This ffi script is too dangerous, should not to be sample.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
rename interpreter directory to runtime

"interpreter" naming is not properly anymore, it make
people think it's a slow language interpreter, there also
have possibility ktap will use some JIT in future, and
that directory include more files not connected with
normal interpreter, so use "runtime" would be more properly.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
rename test/bench to test/benchmark

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
use vfprintf in usage()

Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
print ktap version on -V argument

Signed-off-by: Qingping Hou <qingping.hou@gmail.com>