u-boot中debug的一些总结

时间:2023-12-30 23:42:44

研究u-boot,首要搞清楚的是代码的流程,运行流程是什么样子的呢?不知道,就看log。这就要把log信息

打开。研究u-boot的文件,发现里面是很多DEBUG宏定义的打印,这个打印着怎么打开呢?

其实很简单,只需要把文件include/common.h中加上这句话即可:

#define DEBUG //记得喔,这个语句要加载一行上面才行。

 #ifdef DEBUG
#define _DEBUG 1
#else
#define _DEBUG 0
#endif #ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif /*
* Output a debug text when condition "cond" is met. The "cond" should be
* computed by a preprocessor in the best case, allowing for the best
* optimization.
*/
#define debug_cond(cond, fmt, args...) \
do { \
if (cond) \
printf(pr_fmt(fmt), ##args); \
} while () #define debug(fmt, args...) \
debug_cond(_DEBUG, fmt, ##args)

  另外一个间接的查看谁被编译的方式:只需到该目录下,ls -al *.o,即可确认真正被调用的函数。

因为该函数被编译了,就会生成.o文件。