Revert "only mainthread can call table pairs and histogram"

Sometime we have to call histogram or pairs in timer context,
so allow non-mainthread to do that.

This is still a temp solution, because using pairs and histogram
in non-mainthread have a little unsafe, find a more safe way
to fix it.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
update comments of perf overflow callback

make comments to be more accurate.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
kill unused function event_regstr

register dump functionality in ktap should be implemented
by some kind of FFI support(implement in future), don't dump
the register vaule one by one manually.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
add skip and max_entries option arguments into print_backtrace()/backtrace()

Normally skip and max_entries both set to 10 when dump stack,
but sometimes stack entries exceed 10, or skip 10 entries is
not enough, so allow user dump stack with specific skip and
max_entries.

print_backtrace (skip, max_entries)
backtrace (skip, max_entries)

If user don't add skip or max_entries arguments, use 10 defaultly.

Note the max number of max_entries is 100.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
skip 12 stack entries in dumpstack() for stack_profile.kp

Skip 12 stack entries to hide some timer interrupt function,
make stack dump more accurate.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
fix error handling in kp_lib_printf function

add missed preempt_enable_notrace.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
make kp_init_state a little faster

Use memset to init all stack value to nil, instead of
for-loop many times, memset would be more efficient.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
disallow stack growing in ktap

Set a stack size limit for ktap, if thread exceed the limit,
ktapvm will report "stack overflow".

The default stack size is 120, enlarge this value if script
need more stack.

Make this value to be configurable in future.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
add test/stack_overflow.kp

This testcase is purpose for stack overflow checking.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
support dump more instructions

Below instructions can be dump now by "ktap -b *.kp"
1. SETTABUP
2. NEWTABLE
3. GETUPVAL
4. MOVE

Signed-off-by: Qingping Hou <qingping.hou@gmail.com>
Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
change printk to kp_error

The error info should be printed by kp_error, not printk.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
add memory and events statistics into ktapvm

Support memory allocated/free and events hits/missed stats,
statistics is stored in percpu data.

The statistics data will report after execute script finished.

Usage:

	#./ktap -v scripts/tracepoints/eventcount.kp
	...
	[verbose] ktap stats:
	[verbose] memory allocated size: 473157
	[verbose] memory allocate num: 11039
	[verbose] memory free num: 11039
	[verbose] events_hits: 376981
	[verbose] events_missed: 0

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
kill unused kp_newuserdata function and ktap_udata strucutre

There have no user for kp_newuserdata and ktap_udata, so kill it.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
create synth_tbl in kp_aggrtable_new

This will avoid create synth_tbl multiple times when
using histogram or pairs of aggregation table.

Further more, we only allow create table in mainthread.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
cleanup some comments associated with lua

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
rename ktap_aggrtable to ktap_ptable

Use a more simple name to represent parallel table.

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