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>
quit ktap if register perf event failure

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
fix memory corruption when process "*:*" events

In function idmap_clear():
If the id is not set yet, it shouldn't clear idmap and decrement id_nr.

for example:
idmap_set 10, 11, 12
idmap_clear 1
id_nr=2
id_array[0]=i ok
id_array[1]=i ok
id_array[2]=i illegal

The bug can reporduce in 3.2 kernel, because ftrace:function
event is not available in 3.2 kernel.
fix run error in schedtime.kp

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
improve verbose message for event register

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
kill pevent field in struct ktap_event

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
read available_events debugfs file to get tracepoint event name

Now just read /sys/kernel/debug/tracing/available_events,
avoid read each event directory one by one.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
Rework ffi testcases by new prove test scaffold

Now all ffi testcases moved to test/ffi_test.t,
directory test/ffi_test/ contains cparser_test and
dummy kernel module used for test/ffi_test.t.

Compilation of ffi dummy kernel module and cparser_test.c
is triggered by test/ffi_test.t.

If no ffi compiled in, then test/ffi_test.t will be skipped.

Using skip feature for ffi test is suggested by Yichun (agentzh).

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
delete test/ffi_test/.gitignore

Because all temp files of test/ffi_test compilation
will be delete after execute test/ffi_test.t finish,
so there have no need to maintain .gitignore file any more.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
pre-allocate 2000 record entries in stack_profile.kp

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