gdb backtraces: -ggdb, -fno-omit-frame-pointer, BSIZE=1024
This commit is contained in:
parent
8607051b5f
commit
91ba81110a
4
Makefile
4
Makefile
|
@ -50,7 +50,7 @@ OBJCOPY = $(TOOLPREFIX)objcopy
|
||||||
OBJDUMP = $(TOOLPREFIX)objdump
|
OBJDUMP = $(TOOLPREFIX)objdump
|
||||||
|
|
||||||
# CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O
|
# CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O
|
||||||
CFLAGS = -Wall -Werror -O
|
CFLAGS = -Wall -Werror -O -fno-omit-frame-pointer -ggdb
|
||||||
CFLAGS += -mcmodel=medany
|
CFLAGS += -mcmodel=medany
|
||||||
CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax
|
CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax
|
||||||
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
|
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
|
||||||
|
@ -153,7 +153,7 @@ QEMUGDB = $(shell if $(QEMU) -help | grep -q '^-gdb'; \
|
||||||
then echo "-gdb tcp::$(GDBPORT)"; \
|
then echo "-gdb tcp::$(GDBPORT)"; \
|
||||||
else echo "-s -p $(GDBPORT)"; fi)
|
else echo "-s -p $(GDBPORT)"; fi)
|
||||||
ifndef CPUS
|
ifndef CPUS
|
||||||
CPUS := 1
|
CPUS := 3
|
||||||
endif
|
endif
|
||||||
QEMUOPTS = -machine virt -kernel kernel -m 3G -smp $(CPUS) -nographic
|
QEMUOPTS = -machine virt -kernel kernel -m 3G -smp $(CPUS) -nographic
|
||||||
QEMUOPTS += -initrd fs.img
|
QEMUOPTS += -initrd fs.img
|
||||||
|
|
|
@ -219,9 +219,15 @@ consolewrite(struct inode *ip, int user_src, uint64 src, int n)
|
||||||
void
|
void
|
||||||
consoleintr(int c)
|
consoleintr(int c)
|
||||||
{
|
{
|
||||||
|
int doprocdump = 0;
|
||||||
|
|
||||||
acquire(&cons.lock);
|
acquire(&cons.lock);
|
||||||
|
|
||||||
switch(c){
|
switch(c){
|
||||||
|
case C('P'): // Process list.
|
||||||
|
// procdump() locks cons.lock indirectly; invoke later
|
||||||
|
doprocdump = 1;
|
||||||
|
break;
|
||||||
case C('U'): // Kill line.
|
case C('U'): // Kill line.
|
||||||
while(input.e != input.w &&
|
while(input.e != input.w &&
|
||||||
input.buf[(input.e-1) % INPUT_BUF] != '\n'){
|
input.buf[(input.e-1) % INPUT_BUF] != '\n'){
|
||||||
|
@ -249,6 +255,9 @@ consoleintr(int c)
|
||||||
}
|
}
|
||||||
|
|
||||||
release(&cons.lock);
|
release(&cons.lock);
|
||||||
|
|
||||||
|
if(doprocdump)
|
||||||
|
procdump();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
1
defs.h
1
defs.h
|
@ -124,6 +124,7 @@ void wakeup(void*);
|
||||||
void yield(void);
|
void yield(void);
|
||||||
int either_copyout(int user_dst, uint64 dst, void *src, uint64 len);
|
int either_copyout(int user_dst, uint64 dst, void *src, uint64 len);
|
||||||
int either_copyin(void *dst, int user_src, uint64 src, uint64 len);
|
int either_copyin(void *dst, int user_src, uint64 src, uint64 len);
|
||||||
|
void procdump(void);
|
||||||
|
|
||||||
// swtch.S
|
// swtch.S
|
||||||
void swtch(struct context*, struct context*);
|
void swtch(struct context*, struct context*);
|
||||||
|
|
6
fs.h
6
fs.h
|
@ -2,8 +2,8 @@
|
||||||
// Both the kernel and user programs use this header file.
|
// Both the kernel and user programs use this header file.
|
||||||
|
|
||||||
|
|
||||||
#define ROOTINO 1 // root i-number
|
#define ROOTINO 1 // root i-number
|
||||||
#define BSIZE 512 // block size
|
#define BSIZE 1024 // block size
|
||||||
|
|
||||||
// Disk layout:
|
// Disk layout:
|
||||||
// [ boot block | super block | log | inode blocks |
|
// [ boot block | super block | log | inode blocks |
|
||||||
|
@ -48,7 +48,7 @@ struct dinode {
|
||||||
#define BPB (BSIZE*8)
|
#define BPB (BSIZE*8)
|
||||||
|
|
||||||
// Block of free map containing bit for block b
|
// Block of free map containing bit for block b
|
||||||
#define BBLOCK(b, sb) (b/BPB + sb.bmapstart)
|
#define BBLOCK(b, sb) ((b)/BPB + sb.bmapstart)
|
||||||
|
|
||||||
// Directory is a file containing a sequence of dirent structures.
|
// Directory is a file containing a sequence of dirent structures.
|
||||||
#define DIRSIZ 14
|
#define DIRSIZ 14
|
||||||
|
|
29
proc.c
29
proc.c
|
@ -560,3 +560,32 @@ either_copyin(void *dst, int user_src, uint64 src, uint64 len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print a process listing to console. For debugging.
|
||||||
|
// Runs when user types ^P on console.
|
||||||
|
// No lock to avoid wedging a stuck machine further.
|
||||||
|
void
|
||||||
|
procdump(void)
|
||||||
|
{
|
||||||
|
static char *states[] = {
|
||||||
|
[UNUSED] "unused",
|
||||||
|
[EMBRYO] "embryo",
|
||||||
|
[SLEEPING] "sleep ",
|
||||||
|
[RUNNABLE] "runble",
|
||||||
|
[RUNNING] "run ",
|
||||||
|
[ZOMBIE] "zombie"
|
||||||
|
};
|
||||||
|
struct proc *p;
|
||||||
|
char *state;
|
||||||
|
|
||||||
|
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
|
||||||
|
if(p->state == UNUSED)
|
||||||
|
continue;
|
||||||
|
if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
|
||||||
|
state = states[p->state];
|
||||||
|
else
|
||||||
|
state = "???";
|
||||||
|
printf("%d %s %s", p->pid, state, p->name);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,13 @@ release(struct spinlock *lk)
|
||||||
// section are visible to other cores before the lock is released.
|
// section are visible to other cores before the lock is released.
|
||||||
// Both the C compiler and the hardware may re-order loads and
|
// Both the C compiler and the hardware may re-order loads and
|
||||||
// stores; __sync_synchronize() tells them both not to.
|
// stores; __sync_synchronize() tells them both not to.
|
||||||
|
// On RISC-V, this turns into a fence instruction.
|
||||||
__sync_synchronize();
|
__sync_synchronize();
|
||||||
|
|
||||||
// Release the lock, equivalent to lk->locked = 0.
|
// Release the lock, equivalent to lk->locked = 0.
|
||||||
// This code can't use a C assignment, since it might
|
// This code can't use a C assignment, since it might
|
||||||
// not be atomic. A real OS would use C atomics here.
|
// not be atomic. A real OS would use C atomics here.
|
||||||
|
// On RISC-V, use an amoswap instruction.
|
||||||
//asm volatile("movl $0, %0" : "+m" (lk->locked) : );
|
//asm volatile("movl $0, %0" : "+m" (lk->locked) : );
|
||||||
__sync_lock_release(&lk->locked);
|
__sync_lock_release(&lk->locked);
|
||||||
|
|
||||||
|
@ -73,7 +75,7 @@ holding(struct spinlock *lk)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
push_off();
|
push_off();
|
||||||
r = lk->locked && lk->cpu == mycpu();
|
r = (lk->locked && lk->cpu == mycpu());
|
||||||
pop_off();
|
pop_off();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue