lab2 增加 lab1 变更
This commit is contained in:
parent
1c15a8b9d9
commit
fd018168a9
2
lab2/.gitignore
vendored
2
lab2/.gitignore
vendored
@ -14,3 +14,5 @@ build
|
|||||||
*.out
|
*.out
|
||||||
*.pyc
|
*.pyc
|
||||||
chcore.out
|
chcore.out
|
||||||
|
|
||||||
|
.idea
|
@ -119,7 +119,25 @@ static int printk_write_num(char **out, long long i, int base, int sign,
|
|||||||
// store the digitals in the buffer `print_buf`:
|
// store the digitals in the buffer `print_buf`:
|
||||||
// 1. the last postion of this buffer must be '\0'
|
// 1. the last postion of this buffer must be '\0'
|
||||||
// 2. the format is only decided by `base` and `letbase` here
|
// 2. the format is only decided by `base` and `letbase` here
|
||||||
|
int len = 0;
|
||||||
|
s = print_buf + 1;
|
||||||
|
while (u > 0) {
|
||||||
|
t = u % base;
|
||||||
|
u /= base;
|
||||||
|
if (t <= 9)
|
||||||
|
s[len++] = t + '0';
|
||||||
|
else
|
||||||
|
s[len++] = t - 10 + (letbase ? 'a': 'A');
|
||||||
|
}
|
||||||
|
s[len] = '\0';
|
||||||
|
// swap print_buf
|
||||||
|
char ch;
|
||||||
|
for (int i = 0; i < len / 2; i++) {
|
||||||
|
ch = s[i];
|
||||||
|
s[i] = s[len - 1 - i];
|
||||||
|
s[len - 1 - i] = ch;
|
||||||
|
}
|
||||||
|
|
||||||
if (neg) {
|
if (neg) {
|
||||||
if (width && (flags & PAD_ZERO)) {
|
if (width && (flags & PAD_ZERO)) {
|
||||||
simple_outputchar(out, '-');
|
simple_outputchar(out, '-');
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
#include <common/printk.h>
|
#include <common/printk.h>
|
||||||
#include <common/types.h>
|
#include <common/types.h>
|
||||||
|
#include <common/machine.h>
|
||||||
|
|
||||||
|
extern char kernel_stack[PLAT_CPU_NUM][KERNEL_STACK_SIZE];
|
||||||
|
|
||||||
static inline __attribute__ ((always_inline))
|
static inline __attribute__ ((always_inline))
|
||||||
u64 read_fp()
|
u64 read_fp()
|
||||||
@ -30,6 +33,21 @@ int stack_backtrace()
|
|||||||
printk("Stack backtrace:\n");
|
printk("Stack backtrace:\n");
|
||||||
|
|
||||||
// Your code here.
|
// Your code here.
|
||||||
|
u64 *fp, *preFp;
|
||||||
|
fp = read_fp();
|
||||||
|
// until stack end
|
||||||
|
while (true) {
|
||||||
|
preFp = *fp;
|
||||||
|
// entry frame
|
||||||
|
if (preFp == 0)
|
||||||
|
break;
|
||||||
|
printk("LR %lx FP %lx Args", *(preFp + 1), preFp);
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
printk(" %lx", *(fp + 2 + i));
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
fp = preFp;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user