OSEck系统中的各种hook函数

There are several possibilities for debugging an OSEck System. For low-level debugging the sysinfo system calls can be utilized for writing debug hooks and error handlers, performing traces, memory profiling, and crash analysis.

hook是一段应用程序,将该应用程序注册到系统,使该应用程序可以在系统级访问在正常情况下无法访问的一些资源,处理一些消息等。hook是debug系统的一种手段。

OSEck guide中对hook的定义:

It is sometimes desirable to write customized routines to change the behavior of, or add functionality to, some of the OSE system calls. This is realized through a number of pre-defined system events (which often but not always map 1:1 to a single system call) for which user defined handlers, so called hooks, can be configured, as described in the OSEck Kernel Reference Manual. Any number of hook functions can be configured for each event, and will be called in the order that they are entered in the configuration file. Hooks exist mainly for debugging and logging purposes,and are not portable from one CPU, or kernel, to another.

OSEck支持应用应用注册以下hook:

alloc_hook,create_pool_hook,create_process_hook,error_hook,debug_hook,kill_pool_hook,kill_proc_hook,receive_hook,reset_pool_hook,restore_hook,send_hook,swap_hook

上述hook将会注册到OSEck的系统级全局变量odo_config(CPU级别的)中,进而提供给系统。

例如,较为常用的swap_hook, 它会在进程切换时被调用,我们可以记录一些进程切换信息,如from,to的进程ID,以及timestamp。这样我们就可以知道不同的进程的切换背景以及进程的执行时间。如果某个进程陷入死循环的话,记录下的该进程的执行时间会很长,这样就有助于我们调查问题了。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值