move function header from include/ into interpreter/

Now file header will more easy to maintain.
Also this is prepare for userspace and interpreter separation.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
update testcase for running ktap concurrently

Since we can run ktap concurrently now, so update the testcase.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
add sdt example into README and tutorial.md

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@gmail.com>
symbol: replace find_symbol() by get_dso_symbols()

Old find_symbol() just find symbol by name, the new one
get_dso_symbols() will return all symbols/notes.

And user of this functions, will match name/pattern by itself.

For now get_dso_symbols() used like find_symbol(), this behaviour will
be changed in next patches.

Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
uprobes,sdt: add all events for all matched symbols/notes

Not only for first one.

As Jovi, noticed for example:
  mulitple probe location with same sdt name
    For example(in my x86-64 machine):
    #readelf -n /lib64/libc.so.6 | grep lll_futex_wake
      Name: lll_futex_wake
      Name: lll_futex_wake

After this patch events will be added for both sdt notes.

Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
uprobes: use strglobmatch() instead of just strcmp()

This will allow us to use pattern's instead of just symbol names

For example for C++ applications with it's function names convention, it
will be useful for functions with different number of arguments or
types.
Or all methods in class/object C++.

Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
symbol: fix segmentation fault at sdt_note_addr()

Because dst.d_buf must be 24 bytes long (on x86-64) while there is only
8 bytes (allocated on stack).

return address was at: 0x7fffffffdd88
dst.d_buf:             0x7fffffffdd78

And after elf64_xlatetom() executed, it called memmove() into dst.d_buf,
and overwrite return address for sdt_note_addr(), and after retq
executed it jumps to 0x0.

Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
symbol: use actor instead of dynamically allocate array of symbols.

Like Jovi suggested, replace dynamic allocatins, by callback/actor.

I've renamed get_dso_symbols() -> read_dso_symbols(), since it really do
this.
read_dso_symbols() will call actor for every symbol/sdt note that it will
found.
And replace usage of get_dso_symbols() by read_dso_symbols() inn
parse_events_resolve_symbol() (uprobes)

This patch also fix some memory leaks (on failures), and drop some exit()
inside parse_events_resolve_symbol()

Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Support uprobe/sdt symbol glob match completely

This patch changes as below:
- error handling. need to cleanup resouces for sdt probe.
- remove unneeded field in struct uprobe_base
- use return value parse_dso_symbol more properly
- add symbol name into uprobe_events debugfs file to better event output
- enlarge the global ids_str array size (make it not hardcoded in future)
  (this fix the coredump)

sdt example :
	trace sdt:/lib64/libc.so.6:* {
        	print(execname(), argevent)
	}

Result:
	[root@localhost ktap]# ./ktap sdt.kp
	bash    kp0_setjmp: (0x38c0235801)
	bash    kp0_setjmp: (0x38c0235801)
	bash    kp0_setjmp: (0x38c0235801)
	bash    kp0_setjmp: (0x38c0235801)
	bash    kp0_setjmp: (0x38c0235801)
	bash    kp0_setjmp: (0x38c0235801)

uprobe_events file also changed:

	[root@localhost ktap]# cat /sys/kernel/debug/tracing/uprobe_events
	p:uprobes/kp0_setjmp /lib64/libc.so.6:0x0000000000035801
	p:uprobes/kp1_longjmp /lib64/libc.so.6:0x00000000000358e3
	p:uprobes/kp2_longjmp_target /lib64/libc.so.6:0x00000000000358ff
	p:uprobes/kp3_lll_futex_wake /lib64/libc.so.6:0x00000000000bc9ad
	p:uprobes/kp4_lll_lock_wait_private /lib64/libc.so.6:0x0000000000102a94
	p:uprobes/kp5_longjmp /lib64/libc.so.6:0x000000000010c903
	p:uprobes/kp6_longjmp_target /lib64/libc.so.6:0x000000000010c91f
	p:uprobes/kp7_lll_futex_wake /lib64/libc.so.6:0x0000000000130164

We also can trace all functions in glibc using symbol glob.

	trace probe:/lib64/libc.so.6:* {
        	print(execname(), argevent)
	}

Result:
	...
	top     kp5147__IO_padn: (0x38c026d620)
	top     kp5147__IO_padn: (0x38c026d620)
	top     kp5147__IO_padn: (0x38c026d620)
	top     kp5147__IO_padn: (0x38c026d620)
	top     kp5147__IO_padn: (0x38c026d620)
	top     kp5147__IO_padn: (0x38c026d620)
	...

uprobe_events file is like this:

	p:uprobes/kp0_check_one_fd /lib64/libc.so.6:0x000000000001f410
	p:uprobes/kp1_init /lib64/libc.so.6:0x000000000001f485
	p:uprobes/kp2_free_derivation /lib64/libc.so.6:0x0000000000161d30
	p:uprobes/kp3_derivation_compare /lib64/libc.so.6:0x00000000000231e0
	p:uprobes/kp4_free_modules_db /lib64/libc.so.6:0x0000000000161df0
	p:uprobes/kp5_free_mem /lib64/libc.so.6:0x00000000001625e
	...
	p:uprobes/kp5162_pututxline /lib64/libc.so.6:0x000000000012f490
	p:uprobes/kp5163_dup3 /lib64/libc.so.6:0x00000000000e7070
	p:uprobes/kp5164_timespec_get /lib64/libc.so.6:0x00000000000b7b90

(There have 5165 glibc symbols can be trace in my system)

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