henesyinit from p9fce6d0435 years agoHistory
128 lines · 1.6 KB · Text
RawDownload
// Coverage library defn coverage(){	local lmap, lp, e, pc, n; 	new(); 	bblock = {}; 	// find the first location in the text	e = (map()[0][1])\i; 	while e < etext-4 do {		l = follow(e);		if tail l != {} then {			plant(l[0]);			plant(l[1]);		}		e++;	} 	while 1 do {		cont();		pc = *PC;		n = match(pc, bblock);		if n >= 0 then {			pc = fmt(pc, bpfmt);			*pc = @pc;			bblock = delete bblock, n;		}		else {			pstop(pid);			return {};		}	}} defn plant(addr){	if match(addr, bblock) < 0 then {		*fmt(addr, bpfmt) = bpinst;		bblock = append bblock, addr;	}} defn eblock(addr){	addr = addr\i; 	while addr < etext do {		if (tail follow(addr)) != {} then			return pcline(addr);		addr++;	}	return 0;} defn basic(stsrc, ensrc, file){	local src, text; 	if stsrc >= ensrc then		return {}; 	print(file, ":", stsrc, ",", ensrc, "\n");	src = match(file, srcfiles); 	if src >= 0 then		src = srctext[src];	else		src = findsrc(file); 	if src == {} then		print("no source for ", file, "\n");	else {		while stsrc <= ensrc do {			text = src[stsrc];			if text != {} then				print("\t", stsrc, ":", text, "\n");			stsrc = stsrc+1;		}	}} defn analyse(fnaddr){	local addr, l, tfn; 	new(); 	tfn = fnbound(fnaddr); 	l = bblock;	while l do {		addr = head l; 		if addr >= tfn[0] && addr < tfn[1] then			basic(pcline(addr), eblock(addr), pcfile(addr));				l = tail l;	}	kill(pid);} defn report(){	local addr, l; 	new(); 	l = bblock;	while l do {		addr = head l; 		basic(pcline(addr), eblock(addr), pcfile(addr));				l = tail l;	}	kill(pid);} defn stopped(pid){	return {};} print("/sys/lib/acid/coverage");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t