更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_stackinfo_pri.h 文件参考

浏览源代码.

结构体

struct  StackInfo
 

函数

VOID OsExcStackInfo (VOID)
 打印栈的信息 把每个CPU的栈信息打印出来 更多...
 
VOID OsExcStackInfoReg (const StackInfo *stackInfo, UINT32 stackNum)
 注册栈信息 更多...
 
VOID OsStackInit (VOID *stacktop, UINT32 stacksize)
 task栈的初始化,设置固定的值. 0xcccccccc 和 0xcacacaca 更多...
 
UINT32 OsStackWaterLineGet (const UINTPTR *stackBottom, const UINTPTR *stackTop, UINT32 *peakUsed)
 Get stack waterline. 更多...
 

函数说明

◆ OsExcStackInfo()

VOID OsExcStackInfo ( VOID  )

打印栈的信息 把每个CPU的栈信息打印出来

在文件 los_stackinfo.c109 行定义.

110{
111 UINT32 index;
112 UINT32 cpuid;
113 UINT32 size;
114 UINTPTR *stackTop = NULL;
115 UINTPTR *stack = NULL;
116
117 if (g_stackInfo == NULL) {
118 return;
119 }
120
121 PrintExcInfo("\n stack name cpu id stack addr total size used size\n"
122 " ---------- ------ --------- -------- --------\n");
123 for (index = 0; index < g_stackNum; index++) {
124 for (cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {//可以看出 各个CPU的栈是紧挨的的
125 stackTop = (UINTPTR *)((UINTPTR)g_stackInfo[index].stackTop + cpuid * g_stackInfo[index].stackSize);
126 stack = (UINTPTR *)((UINTPTR)stackTop + g_stackInfo[index].stackSize);
127 (VOID)OsStackWaterLineGet(stack, stackTop, &size);//获取吃水线, 鸿蒙用WaterLine 这个词用的很妙
128
129 PrintExcInfo("%11s %-5d %-10p 0x%-8x 0x%-4x\n", g_stackInfo[index].stackName,
130 LOSCFG_KERNEL_CORE_NUM - 1 - cpuid, stackTop, g_stackInfo[index].stackSize, size);
131 }
132 }
133
134 OsExcStackCheck();//发生异常时栈检查
135}
macro EXC_SP_SET stackSize
Definition: asm.h:50
UINT32 OsStackWaterLineGet(const UINTPTR *stackBottom, const UINTPTR *stackTop, UINT32 *peakUsed)
获取栈的吃水线
Definition: los_stackinfo.c:70
VOID PrintExcInfo(const CHAR *fmt,...)
打印异常信息
Definition: los_printf.c:263
const StackInfo * g_stackInfo
CPU所有工作模式的栈信息
Definition: los_stackinfo.c:67
VOID OsExcStackCheck(VOID)
异常情况下的栈检查,主要就是检查栈顶值有没有被改写
Definition: los_stackinfo.c:88
UINT32 g_stackNum
Definition: los_stackinfo.c:68
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
UINT32 stackSize
栈大小
VOID * stackTop
栈顶
函数调用图:
这是这个函数的调用关系图:

◆ OsExcStackInfoReg()

VOID OsExcStackInfoReg ( const StackInfo stackInfo,
UINT32  stackNum 
)

注册栈信息

在文件 los_stackinfo.c138 行定义.

139{
140 g_stackInfo = stackInfo; //全局变量指向g_excStack
141 g_stackNum = stackNum;
142}
这是这个函数的调用关系图:

◆ OsStackInit()

VOID OsStackInit ( VOID *  stacktop,
UINT32  stacksize 
)

task栈的初始化,设置固定的值. 0xcccccccc 和 0xcacacaca

在文件 los_stackinfo.c145 行定义.

146{
147 /* initialize the task stack, write magic num to stack top */
148 errno_t ret = memset_s(stacktop, stacksize, (INT32)OS_STACK_INIT, stacksize);//清一色填 0xCACACACA
149 if (ret == EOK) {
150 *((UINTPTR *)stacktop) = OS_STACK_MAGIC_WORD;//0xCCCCCCCCC 中文就是"烫烫烫烫" 这几个字懂点计算机的人都不会陌生了.
151 }
152}
signed int INT32
Definition: los_typedef.h:60
这是这个函数的调用关系图: