歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> uclinux-2008R1-RC8(bf561)到VDSP5的移植(15):WARN()

uclinux-2008R1-RC8(bf561)到VDSP5的移植(15):WARN()

日期:2017/3/3 16:43:42   编辑:關於Linux

Uclinux的內核中有許多函數並不是一開始就調用的,而只是做為一個函數指針來使用,為了避免一開始就產生過多的鏈接錯誤,在config.h中定義了一個宏:

#ifndef __ASSEMBLY__
#include <ccblkfn.h>
#include <stdio.h>
#endif

#define WARN()
do {fprintf(stderr, "code omited: %d @ %s/n", __LINE__, __FILE__); while(1) idle();} while(0)

當發生鏈接錯誤時,首先找出函數體,並在其後加上WARN();如下所示:

static void
default_handler(int var_segment, struct pt_regs *regp)
{
//   set_personality(0);
//
//   if (current_thread_info()->exec_domain->handler != default_handler)
//       current_thread_info()->exec_domain->handler(var_segment, regp);
//   else
//       send_sig(SIGSEGV, current, 1);
WARN();
}

這樣,當運行到此函數時,將輸出一個提示信息並停下,我們再去掉此函數體的注釋,嘿嘿…………..

Copyright © Linux教程網 All Rights Reserved