save process name for debugging
This commit is contained in:
parent
7e89fb90bd
commit
7366e042d9
3 changed files with 12 additions and 5 deletions
1
proc.h
1
proc.h
|
@ -40,6 +40,7 @@ struct proc {
|
||||||
struct inode *cwd; // Current directory
|
struct inode *cwd; // Current directory
|
||||||
struct jmpbuf jmpbuf; // Jump here to run process
|
struct jmpbuf jmpbuf; // Jump here to run process
|
||||||
struct trapframe *tf; // Trap frame for current interrupt
|
struct trapframe *tf; // Trap frame for current interrupt
|
||||||
|
char name[16]; // Process name (debugging)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process memory is laid out contiguously:
|
// Process memory is laid out contiguously:
|
||||||
|
|
|
@ -322,7 +322,7 @@ sys_exec(void)
|
||||||
struct elfhdr elf;
|
struct elfhdr elf;
|
||||||
struct proghdr ph;
|
struct proghdr ph;
|
||||||
char *mem = 0;
|
char *mem = 0;
|
||||||
char *path, *s;
|
char *path, *s, *last;
|
||||||
uint argv;
|
uint argv;
|
||||||
|
|
||||||
if(argstr(0, &path) < 0 || argint(1, (int*)&argv) < 0)
|
if(argstr(0, &path) < 0 || argint(1, (int*)&argv) < 0)
|
||||||
|
@ -399,6 +399,12 @@ sys_exec(void)
|
||||||
}
|
}
|
||||||
*(uint*)(mem + p1) = 0;
|
*(uint*)(mem + p1) = 0;
|
||||||
|
|
||||||
|
// Save name for debugging.
|
||||||
|
for(last=s=path; *s; s++)
|
||||||
|
if(*s == '/')
|
||||||
|
last = s+1;
|
||||||
|
safestrcpy(cp->name, last, sizeof cp->name);
|
||||||
|
|
||||||
// commit to the new image.
|
// commit to the new image.
|
||||||
kfree(cp->mem, cp->sz);
|
kfree(cp->mem, cp->sz);
|
||||||
cp->sz = sz;
|
cp->sz = sz;
|
||||||
|
|
6
trap.c
6
trap.c
|
@ -80,10 +80,10 @@ trap(struct trapframe *tf)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(curproc[cpu()]) {
|
if(cp) {
|
||||||
// Assume process divided by zero or dereferenced null, etc.
|
// Assume process divided by zero or dereferenced null, etc.
|
||||||
cprintf("pid %d: unhandled trap %d on cpu %d eip %x -- kill proc\n",
|
cprintf("pid %d %s: unhandled trap %d on cpu %d eip %x -- kill proc\n",
|
||||||
curproc[cpu()]->pid, v, cpu(), tf->eip);
|
cp->pid, cp->name, v, cpu(), tf->eip);
|
||||||
proc_exit();
|
proc_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue