Commit Diff


commit - 2709e6e3689c2f7957758de452ee740136e5eec0
commit + 2a931b7266c8a6550aca5f75b2ce3bf8655aa45b
blob - 7d8657aa4314c7ef71c0aef9a8a3ec0ce55a2d06
blob + 9759873ef06780b5766ea9435710f7c0f177c056
--- acid/port
+++ acid/port
@@ -32,11 +32,6 @@ notelstk(addr)
 	pfl(pc);
 	_stk({"PC", pc, "SP", sp, linkreg(addr)}, 1);
 }
-
-// defn labstk(l)				// trace from a label
-// {
-// 	_stk({"PC", *(l+4), "SP", *l, linkreg(0)}, 0);
-// }
 
 defn params(param)
 {
@@ -119,7 +114,6 @@ defn _stk(regs, dolocals)
 		if callerpc == 0 then
 			done=1;
 	}
-
 	if callerpc && !done then {
 		print(stkprefix, fmt(callerpc, 'a'), " ");
 		pfl(callerpc);
blob - /dev/null
blob + 90d8768604a32e6ba33ab49c2bede777bfb0b618 (mode 644)
--- /dev/null
+++ acid/pthread-linux-386
@@ -0,0 +1,53 @@
+// Linux NPTL 2.3.2
+complex list_head {
+	'X'	0	next;
+	'X'	4	prev;
+};
+complex nptl_pthread {
+	'X'	0	loopback;
+	'X'	0x48	tid;
+};
+
+// cannot be done at load time -- need shared library symbols
+defn guessnptl() {
+	if var("nptl_version") then {
+		pthreadlibrary = "nptl";
+		isnptl = 1;
+	} else {
+		pthreadlibrary = "linuxclone";
+		isnptl = 0;
+	}
+}
+
+defn pthread2tid(p) {
+	guessnptl();
+	if p == 0 then
+		return 0;
+	if isnptl then {
+		complex nptl_pthread p;
+		if p.loopback != p then
+			error("bad pthread "+itoa(p, "%x"));
+		return p.tid;
+	}else {
+		return p\X;
+	}
+}
+
+defn pthreadlist() {
+	local all, p, n, l;
+
+	if isnptl then {
+		all = {};
+		l = (list_head)stack_used;
+		l = (list_head)l.next;
+		while l != stack_used do {
+			p = l - *_thread_db_pthread_list;
+			all = append all, p;
+			l = (list_head)l.next;
+		}
+	} else {
+		all = {};
+	}
+	return all;
+}
+		
blob - 4ec0b47a82a478c612cb52cc0d02ee783f544ffa
blob + a2fd46c5e933e3d54a4fa4e098a2f53ab0967455
--- acid/thread
+++ acid/thread
@@ -3,63 +3,8 @@
 // avoid complicated libthread_db interface
 //
 
-// Linux NPTL 2.3.2
-complex list_head {
-	'X'	0	next;
-	'X'	4	prev;
-};
-complex nptl_pthread {
-	'X'	0	loopback;
-	'X'	0x48	tid;
-};
-defn isnptl() {
-	return var("nptl_version") != {};
-}
-defn nptl2tid(p) {
-	complex nptl_pthread p;
-	if p.loopback != p then 
-		error("bad pthread "+itoa(p, "%x"));
-	return p.tid;
-}
-defn nptlpthreadlist() {
-	local all, p, n, l;
-
-	all = {};
-	l = (list_head)stack_used;
-	l = (list_head)l.next;
-	while l != stack_used do {
-		p = l - *_thread_db_pthread_list;
-		all = append all, p;
-		l = (list_head)l.next;
-	}
-	return all;
-}
-
-// 
-// Generic dispatch
-// 
-defn pthreadlibrary() {
-	if var("_pthreadlibrary") == {} then {
-		if isnptl() then
-			_pthreadlibrary = "nptl";
-		else
-			_pthreadlibrary = "unknown";
-	}
-	return _pthreadlibrary;
-}
+include("pthread-"+systype+"-"+objtype);
 
-defn id2tid(id) {
-	if pthreadlibrary() == "nptl" then
-		return nptl2tid(id);
-	error("unknown pthread library: "+pthreadlibrary);
-}
-
-defn pthreadlist() {
-	if pthreadlibrary() == "nptl" then
-		return nptlpthreadlist(id);
-	error("unknown pthread library: "+pthreadlibrary);
-}
-
 // pick apart system mcontext_t structures
 defn mcontext(m)
 {
@@ -98,7 +43,7 @@ defn altfmt(A){
 	complex Alt A;
 
 	s = "alt(";
-	s = s + "tag(*" + itoa(A.tag, "%x") + "=" + itoa(*A.tag, "%x") + ") ";
+	s = s + "tag(*" + itoa(A.tag, "%#x") + "=" + itoa(*A.tag, "%#x") + ") ";
 	i = 0;
 	yes = 0;
 	while A.op != CHANEND && A.op != CHANNOBLK do{
@@ -109,7 +54,7 @@ defn altfmt(A){
 			if A.op == CHANSND then s = s + "send";
 			if A.op == CHANRCV then s = s + "recv";
 			s = s + "(channel(";
-			s = s + itoa(A.c, "%x");
+			s = s + itoa(A.c, "%#x");
 			s = s + "))";
 			yes = 1;
 		}
@@ -184,7 +129,7 @@ defn fnname(a){
 			return sym[0];
 		s = tail s;
 	}
-	return itoa(a, "%x");
+	return itoa(a, "%#x");
 }
 
 stkignorelist = {};
@@ -199,7 +144,7 @@ defn threadstkline(T){
 	P = (Proc)T.proc;
 	if P.thread == T then {
 		mainpid = pid;
-		setproc(id2tid(P.osprocid));
+		setproc(pthread2tid(P.osprocid));
 		stk = strace({});
 		setproc(mainpid);
 	} else
@@ -230,7 +175,7 @@ defn threadfmt(T){
 	local P, s, name;
 
 	P = (Proc)T.proc;
-	s = "t=(_Thread)"+itoa(T, "%-10x")+" // ";
+	s = "t=(_Thread)"+itoa(T, "%#-10x")+" // ";
 
 	if P.thread == T then
 		s = s + "Running    ";
@@ -296,12 +241,10 @@ defn threadstks(P){
 	complex Proc P;
 	local T,  mainpid, pref, ign;
 
-	// mainpid = pid;
 	pref = stkprefix;
 	stkprefix = pref+"\t\t";
 	ign = stkignore;
 	stkignore = threadstkignore;
-	// setproc(P.pid);
 	T = (_Thread)P.allthreads.$head;
 	while T != 0 do{
 		print("\t");
@@ -310,7 +253,6 @@ defn threadstks(P){
 		T = (_Thread)T.allnext;
 		print("\n");
 	}
-	// setproc(mainpid);
 	stkprefix = pref;
 	stkignore = ign;
 }
@@ -318,7 +260,7 @@ defn threadstks(P){
 defn proc(P){
 	complex Proc P;
 
-	print("p=(Proc)", itoa(P, "%-10x"), "  // pthread ", P.osprocid\X, " pid ", id2tid(P.osprocid)\D, " ");
+	print("p=(Proc)", itoa(P, "%#-10x"), "  // pthread ", P.osprocid\X, " pid ", pthread2tid(P.osprocid)\D, " ");
 	if P.thread==0 then
 		print(" Sched");
 	else
@@ -332,7 +274,7 @@ defn threadlstk(T){
 
 	P = (Proc)T.proc;
 	mainpid = pid;
-	setproc(id2tid(P.osprocid));
+	setproc(pthread2tid(P.osprocid));
 
 	if P.thread == T then
 		lstk();
@@ -347,7 +289,7 @@ defn threadstk(T){
 
 	P = (Proc)T.proc;
 	mainpid = pid;
-	setproc(id2tid(P.osprocid));
+	setproc(pthread2tid(P.osprocid));
 
 	if P.thread == T then
 		stk();