changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: acid/kernel: for stacktraces, try to use context from error stack when process is not sleeping

changeset 7386: c2b1522cb6c7
parent 7385: 6e69acb02881
child 7387: 27f7b5d5b78a
author: cinap_lenrek@felloff.net
date: Thu, 12 Sep 2019 15:28:04 +0200
files: sys/lib/acid/kernel
description: acid/kernel: for stacktraces, try to use context from error stack when process is not sleeping

when a process state has not been saved (Proc.mach != nil)
then the contents of Proc.sched should be considered invalid.

to approximate a stacktrace in this case, we use the error
stack and get a stacktrace from the last waserror() call.
     1.1--- a/sys/lib/acid/kernel
     1.2+++ b/sys/lib/acid/kernel
     1.3@@ -271,12 +271,23 @@ defn procstksize(p) {
     1.4 
     1.5 defn procstk(p) {
     1.6 	complex Proc p;
     1.7+	local l, n;
     1.8 
     1.9 	if p.state != 0 then {	// 0 is Dead
    1.10+		if p.mach == 0 then {
    1.11+			l = p.sched;
    1.12+		} else {
    1.13+			n = p.nerrlab;
    1.14+			if n == 0 then {
    1.15+				return 0;
    1.16+			}
    1.17+			l = p.errlab + (n-1)*sizeofLabel;
    1.18+		}
    1.19+		complex Label l;
    1.20 		if objtype=="386" || objtype=="amd64" then
    1.21-			_stk(gotolabel, p.sched.sp, linkreg(0), 0);
    1.22+			_stk(gotolabel, l.sp, linkreg(0), 0);
    1.23 		else
    1.24-			_stk(p.sched.pc, p.sched.sp, linkreg(0), 0);
    1.25+			_stk(l.pc, l.sp, linkreg(0), 0);
    1.26 	}
    1.27 }
    1.28