backtrace task finished
This commit is contained in:
2
Makefile
2
Makefile
@ -343,7 +343,7 @@ grade:
|
|||||||
@echo $(MAKE) clean
|
@echo $(MAKE) clean
|
||||||
@$(MAKE) clean || \
|
@$(MAKE) clean || \
|
||||||
(echo "'make clean' failed. HINT: Do you have another running instance of xv6?" && exit 1)
|
(echo "'make clean' failed. HINT: Do you have another running instance of xv6?" && exit 1)
|
||||||
./grade-lab-$(LAB) $(GRADEFLAGS)
|
python3.12 ./grade-lab-$(LAB) $(GRADEFLAGS)
|
||||||
|
|
||||||
##
|
##
|
||||||
## FOR submissions
|
## FOR submissions
|
||||||
|
|||||||
@ -80,6 +80,7 @@ int pipewrite(struct pipe*, uint64, int);
|
|||||||
int printf(char*, ...) __attribute__ ((format (printf, 1, 2)));
|
int printf(char*, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
void panic(char*) __attribute__((noreturn));
|
void panic(char*) __attribute__((noreturn));
|
||||||
void printfinit(void);
|
void printfinit(void);
|
||||||
|
void backtrace(void);
|
||||||
|
|
||||||
// proc.c
|
// proc.c
|
||||||
int cpuid(void);
|
int cpuid(void);
|
||||||
|
|||||||
@ -176,3 +176,22 @@ printfinit(void)
|
|||||||
initlock(&pr.lock, "pr");
|
initlock(&pr.lock, "pr");
|
||||||
pr.locking = 1;
|
pr.locking = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace(void)
|
||||||
|
{
|
||||||
|
printf("barcktrace:\n");
|
||||||
|
|
||||||
|
uint64 ra,fp = r_fp();//frame pointer -> address
|
||||||
|
uint64 pre_fp = *((uint64*)(fp - 16));
|
||||||
|
|
||||||
|
while(PGROUNDDOWN(fp)==PGROUNDDOWN(pre_fp)){
|
||||||
|
ra = *(uint64 *)(fp - 8);
|
||||||
|
printf("%p\n", (void*)ra);
|
||||||
|
fp = pre_fp;
|
||||||
|
pre_fp = *((uint64*)(fp - 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
ra = *(uint64 *)(fp - 8);
|
||||||
|
printf("%p\n",(void*)ra);
|
||||||
|
}
|
||||||
@ -338,6 +338,14 @@ r_ra()
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint64
|
||||||
|
r_fp()
|
||||||
|
{
|
||||||
|
uint64 x;
|
||||||
|
asm volatile("mv %0, s0" : "=r" (x) );
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
// flush the TLB.
|
// flush the TLB.
|
||||||
static inline void
|
static inline void
|
||||||
sfence_vma()
|
sfence_vma()
|
||||||
|
|||||||
@ -54,6 +54,8 @@ sys_sleep(void)
|
|||||||
int n;
|
int n;
|
||||||
uint ticks0;
|
uint ticks0;
|
||||||
|
|
||||||
|
backtrace();
|
||||||
|
|
||||||
argint(0, &n);
|
argint(0, &n);
|
||||||
if(n < 0)
|
if(n < 0)
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user