Trace function entry and return with caller function name and
visualize nested function calls in single shoot:
#define _trace_enter_exit_() char _caller[200];
lookup_symbol_name((unsigned
long)__builtin_return_address(0),_caller); \
char __attribute__ ((cleanup(printk))) _ret_msg[100];
sprintf(_ret_msg, "%s < %s }\n", _caller, __func__); \
printk("%s > %s { @ %s:%d\n", _caller, __func__, __FILE__, __LINE__);
For demonstration purpose add define _trace_enter_exit_ ONCE to
beginning of functions: rest_init, start_kernel, do_basic_setup,
run_init_process, kernel_init, kernel_init_freeable. Compile and run
kernel. Run dmesg and see results:
# dmesg | grep "[{}]"
[ 0.000000] > start_kernel { @ init/main.c:471
[ 0.071838] start_kernel > rest_init { @ init/main.c:363
[ 0.072387] ret_from_fork > kernel_init { @ init/main.c:810
[ 0.072418] ret_from_fork > kernel_init_freeable { @ init/main.c:856
[ 0.143615] ret_from_fork > do_basic_setup { @ init/main.c:780
[ 0.151397] ret_from_fork > do_initcalls { @ init/main.c:765
[ 1.902526] ret_from_fork < do_initcalls }
[ 1.906860] ret_from_fork < do_basic_setup }
[ 6.504058] ret_from_fork < kernel_init_freeable }
[ 6.513244] kernel_init > run_init_process { @ init/main.c:802
[ 6.554626] kernel_init < run_init_process }
[ 6.559112] ret_from_fork < kernel_init }
Bonus: You can highlight or jump between corresponding entry "{" and
return "}" in smart editor if nested braces are synchronized. For
example you jump or highlight entry "{" and return "}" of kernel_init.
--
Constantine Shulyupin
http://www.MakeLinux.com/
Embedded Linux Systems,
Device Drivers, TI DaVinci
_______________________________________________
Celinux-dev mailing list
[email protected]
https://lists.celinuxforum.org/mailman/listinfo/celinux-dev