update introduction.txt: Thanks Lua
use DECLARE_PER_CPU to replace "extern DEFINE_PER_CPU"

There have compilation failure in x86_64 if using "extern DEFINE_PER_CPU"
Use DECLARE_PER_CPU instead.
add .gitignore file

copy Linux kernel's .gitignore file into here,
this is for make output "git status" more clean.
add ktap gitignore rule into .gitignore file
add CONFIG_* pre-checking when compiling

This will avoid user found some unreference struct field compiling error.
syscall tracing example is incomplete, so modify it.

Signed-off-by: Libin <huawei.libin@huawei.com>
kdebug: use for_each_online_cpu instead of for_each_possible_cpu

A bug found by Jonathan Corbet:

	unable create tracepoint event sys_enter_mmap on cpu 4, err: -19
	unable create tracepoint event sys_enter_mmap on cpu 5, err: -19
	unable create tracepoint event sys_enter_mmap on cpu 6, err: -19
	unable create tracepoint event sys_enter_mmap on cpu 7, err: -19
	[...]

This code is:
	for_each_possible_cpu(cpu)
		enable_tracepoint_on_cpu(cpu, &attr, call, arg, type);

The reason is we should use for_each_online_cpu, instead of for_each_possible_cpu

Thanks Corbet, he suggested this fix.

Reported-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
kdebug: fix some complation error in Linux 3.1

This issue is reported by googya in github.

console tracing is not available in Linux 3.1, use a macro guard.
(the ktap dumpstack part should rewrite in future)

Same as ftrace macro.

Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
kdebug: simple change on kp_probe_init

make code logic more simpler

Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
kdebug: support perf_event_enable/disable functions in kernel earlier than 3.3

for kernel earlier than 3.3, functions perf_event_enable and perf_event_disable
was not exported, so ktap solve this in a hacking way.

Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
make ktap only support kernel 3.1 or later(tested)

Currently ktap don't support kernel older than 3.1,
make this clear in documentation, and disallow user compile ktap
in those old kernel.

The reason of why ktap don't support kernel older than 3.1 is below commit:

    commit 4dc0da86967d5463708631d02a70cfed5b104884
    Author: Avi Kivity <avi@redhat.com>
    Date:   Wed Jun 29 18:42:35 2011 +0300

    perf: Add context field to perf_event

    The perf_event overflow handler does not receive any caller-derived
    argument, so many callers need to resort to looking up the perf_event
    in their local data structure.  This is ugly and doesn't scale if a
    single callback services many perf_events.

    Fix by adding a context parameter to perf_event_create_kernel_counter()
    (and derived hardware breakpoints APIs) and storing it in the perf_event.
    The field can be accessed from the callback as event->overflow_handler_conte
    All callers are updated.

ktap is based on overflow_handler_context field of struct perf_event,
in theory, ktap could rewrite to use without overflow_handler_context, but
it's not needed at all.
so just make a rule: don't support kernel older than 3.1

If user really want to use ktap in older kernel, patch kernel firstly.

Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
License: make clear on ktap license

ktap is licensed ad GPL, but since it's based on lua initially,
so here I give credit to lua.

lua relased as MIT, but that's not a problem, because MIT license
is compatible with GPL, so it's not violation with ktap's GPL license
(checked this with lua team)

See more info in doc/ktap_license.txt

Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
rename built-in function inplace_inc(tbl, key) to count(tbl, key)

count is a more descriptive name than inplace_inc.

Signed-off-by: zhangwe(Jovi) <jovi.zhangwei@gmail.com>
update TODO list

- benchmark for ktap
- ktap exit logic rewrite
add new test script for count syscall by process

Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
update README about license
Introduction: add more into pre-requirements

add CONFIG_RELAY and CONFIG_DEBUG_FS

Reported-by: Oded Gabbay <ogabbay@advaoptical.com>
Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
kdebug: cannot run interpreter if kp_probe_init return failure

Oded report a panic on powerpc machine:

...
> Instruction dump:
> 419e0024 88030000 2f800000 409e0148 88180000 2f800000 409e011c 3b200000
> 3b000000 3f40f1ec 3ac00000 813a93a0 <83c90000> 7f89f000 419e00c0 3b5a93a0
> ---[ end trace b87e7dec14e55ffe ]---
>
> cannot lookup ftrace_events in kallsyms
> Kernel panic - not syncing: Fatal exception
> Rebooting in 5 seconds..

Obviously there missed a return value check for kp_probe_init, fix it.

Reported-by: Oded Gabbay <ogabbay@advaoptical.com>
Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
include vmalloc.h for compilation

Reported-by: Oded Gabbay <ogabbay@advaoptical.com>
Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@gmail.com>
add new sample script: tracepoints_histogram2.kp

This sample is for count tracepoint events by process,
so you will know which process fired most tracepoints.

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