Skip to content
Snippets Groups Projects
Commit 7366e042 authored by rsc's avatar rsc
Browse files

save process name for debugging

parent 7e89fb90
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@ struct proc {
struct inode *cwd; // Current directory
struct jmpbuf jmpbuf; // Jump here to run process
struct trapframe *tf; // Trap frame for current interrupt
char name[16]; // Process name (debugging)
};
// Process memory is laid out contiguously:
......
......@@ -322,7 +322,7 @@ sys_exec(void)
struct elfhdr elf;
struct proghdr ph;
char *mem = 0;
char *path, *s;
char *path, *s, *last;
uint argv;
if(argstr(0, &path) < 0 || argint(1, (int*)&argv) < 0)
......@@ -399,6 +399,12 @@ sys_exec(void)
}
*(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.
kfree(cp->mem, cp->sz);
cp->sz = sz;
......@@ -419,7 +425,7 @@ sys_exec(void)
}
iput(ip);
cp->tf->eip = elf.entry;
cp->tf->esp = sp;
setupsegs(cp);
......
......@@ -80,10 +80,10 @@ trap(struct trapframe *tf)
break;
default:
if(curproc[cpu()]) {
if(cp) {
// Assume process divided by zero or dereferenced null, etc.
cprintf("pid %d: unhandled trap %d on cpu %d eip %x -- kill proc\n",
curproc[cpu()]->pid, v, cpu(), tf->eip);
cprintf("pid %d %s: unhandled trap %d on cpu %d eip %x -- kill proc\n",
cp->pid, cp->name, v, cpu(), tf->eip);
proc_exit();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment