aboutsummaryrefslogtreecommitdiff
path: root/acid/coverage
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-04-19 18:18:37 +0000
committerrsc <devnull@localhost>2004-04-19 18:18:37 +0000
commit0a61c07d591273b76da21fb8386b669989da3707 (patch)
tree1dd9832f7d646f12c0ff5cf7ff64d1fddc6bd361 /acid/coverage
parentc8af1ab17b72f500c27688598dbb893f09f62c53 (diff)
downloadplan9port-0a61c07d591273b76da21fb8386b669989da3707.tar.gz
plan9port-0a61c07d591273b76da21fb8386b669989da3707.tar.bz2
plan9port-0a61c07d591273b76da21fb8386b669989da3707.zip
acid files
Diffstat (limited to 'acid/coverage')
-rw-r--r--acid/coverage128
1 files changed, 128 insertions, 0 deletions
diff --git a/acid/coverage b/acid/coverage
new file mode 100644
index 00000000..3436bd1c
--- /dev/null
+++ b/acid/coverage
@@ -0,0 +1,128 @@
+// Coverage library
+
+defn coverage()
+{
+ local lmap, lp, e, pc, n, l;
+
+ 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 {
+ if match(l[0], bblock) < 0 then
+ bblock = append bblock, l[0];
+ if match(l[1], bblock) < 0 then
+ bblock = append bblock, l[1];
+ }
+ e++;
+ }
+
+ l = bblock;
+ while l != {} do {
+ *fmt(head l, bpfmt) = bpinst;
+ l = tail l;
+ }
+
+ 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 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(acidfile);