some documentation love

* Fixed a lot of English errors.
* Fixed a lot of Markdown formatting issues.
* ktap was invented in the year 2012, not 2002.
add more gettimeofday variants and other fixes

* added new ktap builtin functions gettimeofday_ns(), gettimeofday_ms(),
  and gettimeofday_s().
* changed the internal helper C function gettimeofday_us to
  gettimeofday_ns because we can directly call the kernel API function
  getnstimeofday.
* fixed an integer overflow in the time values in the C function
  ktap_main.

Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
Update tutorial.md
remove unused allocated field for cdata ptr

Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
rename ktap_cdata.u.st to ktap_cdata.u.rec

to keep it consistent with kp_cdata_new_record

Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
support ffi.new on non-array type

Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
update tests for non-array ffi.new

Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
tiny update on README.md

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
port all ktap testcases into prove test framework

This patch also fix a deadloop bug:
	tick-1s {
		exit()
	}

	while (1) {}

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
use spaces consistently in the perl code
test: add timeout protection mechanism

* now we require the IPC::Run module instead of IPC::Run3 because the
  former has built-in timeout mechanism.
* added "--- timeout" section for specifying the timeout (in seconds)
  for the spawned ktap process. default to 10 (sec). timeout errors
  are treated as test failures unless the "--- expect_timeout" section
  appears.
* added "--- expect_timeout" section.
* added a test case for deadline loops killed by the signal (from our
  timeout mechanism).

Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
used the "reindex" tool to re-format the test suite
test: renamed "--- option" to "--- opts"

We allow multiple options specified in this section, so it is
better to use the plural form. Also, "opts" is shorter and is
more consistent with the existing "args" section name.

Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
don't rmmod in 'make test'

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
fix use-after-free bug in fp_final_exit

percpu G(ks)->stats variable is freed in exit_stats,
but will use in kp_free(ks, ks), this will cause
memory corruption bug.

Based on nr_mem_free variable in G(ks)->stats don't
give too much debug info to user, so just kill it,
to fix this use-after-free bug in simply way.

This bug was found while running the test suite in parallel.
	prove -j4 test

Reported-by: Yichun Zhang <agentzh@gmail.com>
Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
run the test suite in parallel defaultly

Parallel running will reduce time, also could
find more bugs(like previous use-after-free bug).

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
change non-alphanumeric characters into '_' uprobe symbols

Just get rid of first non-alphanumeric character in uprobe
symbol to '\0' is not enough, Go program symbol name maybe like
'github.com/foo/bar.foobar', it will corrupt to 'github', it's
impossible to intepret.

There also will fire a warning on this name transform when compile script,
then user will know the original mapping name.

So now the rule is simple: all non-alphanumeric characters
change to '_'.

A another method to fix this problem is change kernel event
name convention, let kernel tracing infrastructure accept
these event names.

Reported-by: Daniel Morsing <daniel.morsing@gmail.com>
Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>

xx
Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
add shownum argument for histogram function

Calling histogram(tbl, 100) will output 100 record entriens.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
add reschedulre check point in some busy loop

This patch also add some time measure point for table histogram
and ptable synthesis.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
fix divid 0 error in case 0 event hited

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>