Commit Diff


commit - 88c6062214c07dabeb7e9625aaccb3d45ed5d71c
commit + 7468541674bc7bfe8c741a6ea997faab1b7b78ba
blob - 29842b655cb531f06f372235fff6ca00047d4b21
blob + e9b2f036bad6fb1b6565245fc0c5d910da728583
--- acid/386
+++ acid/386
@@ -67,17 +67,44 @@ defn mmregs()
 	print("MM6\t", *MM6, " MM7\t", *MM7, "\n");
 }
 
+defn pfixstop(pid)
+{
+	if *fmt(*PC-1, 'b') == 0xCC then {
+		// Linux stops us after the breakpoint, not at it
+		*PC = *PC-1;
+	}
+}
+
+
 defn pstop(pid)
 {
 	local l;
 	local pc;
+	local why;
 
 	pc = *PC;
 
-	print(pid,": ", reason(*TRAP), "\t");
-	print(fmt(pc, 'a'), "\t", *fmt(pc, 'i'), "\n");
+	// FIgure out why we stopped.
+	if *fmt(pc, 'b') == 0xCC then {
+		why = "breakpoint";
+		
+		// fix up instruction for print; will put back later
+		*pc = @pc;
+	} else if *(pc-2\x) == 0x80CD then {
+		pc = pc-2;
+		why = "system call";
+	} else
+		why = "stopped";
 
-	if notes then {
+	if printstopped then {
+		print(pid,": ", why, "\t");
+		print(fmt(pc, 'a'), "\t", *fmt(pc, 'i'), "\n");
+	}
+	
+	if why == "breakpoint" then
+		*fmt(pc, bpfmt) = bpinst;
+	
+	if printstopped && notes then {
 		if notes[0] != "sys: breakpoint" then {
 			print("Notes pending:\n");
 			l = notes;
blob - 9cd2f7606d29f6fdcb30905320d6f34457860037
blob + c6bf9056f18d881dae73e917894f198083c5ae91
--- acid/port
+++ acid/port
@@ -325,6 +325,16 @@ defn bptab()					// print a table of breakpoints
 defn bpdel(addr)				// delete a breakpoint
 {
 	local n, pc, nbplist;
+
+	if addr == 0 then {
+		while bplist do {
+			pc = head bplist;
+			pc = fmt(pc, bpfmt);
+			*pc = @pc;
+			bplist = tail bplist;
+		}
+		return {};
+	}
 
 	n = match(addr, bplist);
 	if n < 0  then {
@@ -360,6 +370,7 @@ defn cont()					// continue execution
 
 defn stopped(pid)		// called from acid when a process changes state
 {
+	pfixstop(pid);
 	pstop(pid);		// stub so this is easy to replace
 }
 
@@ -472,14 +483,22 @@ defn win2()
 	stopped(npid);
 }
 
+printstopped = 1;
 defn new()
 {
+	local a;
+	
 	bplist = {};
 	newproc(progargs);
-	// Dont miss the delay slot calls
-	bpset(follow(main)[0]);
-	cont();
-	bpdel(*PC);
+	a = var("p9main");
+	if a == {} then
+		a = var("main");
+	if a == {} then
+		return {};
+	bpset(a);
+	while *PC != a do
+		cont();
+	bpdel(a);
 }
 
 defn stmnt()			// step one statement
@@ -517,10 +536,14 @@ defn func()			// step until we leave the current funct
 
 defn next()
 {
-	local sp, bound;
+	local sp, bound, pc;
 
 	sp = *SP;
 	bound = fnbound(*PC);
+	if bound == {} then {
+		print("cannot locate text symbol\n");
+		return {};
+	}
 	stmnt();
 	pc = *PC;
 	if pc >= bound[0] && pc < bound[1] then