cow lab initialized

This commit is contained in:
2025-06-28 09:57:36 +08:00
parent 7c42fbed17
commit c6fa25504f
25 changed files with 351 additions and 617 deletions

View File

@@ -176,24 +176,3 @@ printfinit(void)
initlock(&pr.lock, "pr");
pr.locking = 1;
}
// 打印当前调用栈的返回地址,实现简单的函数回溯,用于调试。
void
backtrace(void)
{
printf("barcktrace:\n");
uint64 ra,fp = r_fp();//frame pointer -> address
uint64 pre_fp = *((uint64*)(fp - 16));
// 只要当前fp和上一个fp在同一页内就继续回溯
while(PGROUNDDOWN(fp)==PGROUNDDOWN(pre_fp)){
ra = *(uint64 *)(fp - 8); // 取出返回地址
printf("%p\n", (void*)ra); // 打印返回地址
fp = pre_fp; // 更新fp为上一个fp
pre_fp = *((uint64*)(fp - 16)); // 获取新的上一个fp
}
ra = *(uint64 *)(fp - 8);
printf("%p\n",(void*)ra);
}