From 692a5dbb9e705ef62a17d900365988e762d1a6e8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 19 Nov 2008 12:51:25 -0800 Subject: [PATCH] coverage tweaks * handle new 6g shift sequence * assume 6.out R=r DELTA=24 (20 added, 0 deleted, 4 changed) OCL=19593 CL=19596 --- src/cmd/cov/main.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/cmd/cov/main.c b/src/cmd/cov/main.c index dbd9d0daec2..4856adf493d 100644 --- a/src/cmd/cov/main.c +++ b/src/cmd/cov/main.c @@ -21,7 +21,7 @@ typedef struct Ureg Ureg; void usage(void) { - fprint(2, "usage: cov 6.out [-lv] [-g regexp] [args...]\n"); + fprint(2, "usage: cov [-lv] [-g regexp] [6.out args...]\n"); fprint(2, "-g specifies pattern of interesting functions or files\n"); exits("usage"); } @@ -162,7 +162,7 @@ missing(uvlong pc, uvlong epc) if(epc - pc == 2 || epc -pc == 3) { // check for XORL inside shift. - // (on x86 have to implement large shift with explicit zeroing). + // (on x86 have to implement large left or unsigned right shift with explicit zeroing). // f+90 0x00002c9f CMPL CX,$20 // f+93 0x00002ca2 JCS f+97(SB) // f+95 0x00002ca4 XORL AX,AX <<< @@ -183,6 +183,24 @@ missing(uvlong pc, uvlong epc) } } + if(epc - pc == 3) { + // check for SAR inside shift. + // (on x86 have to implement large signed right shift as >>31). + // f+36 0x00016216 CMPL CX,$20 + // f+39 0x00016219 JCS f+3e(SB) + // f+3b 0x0001621b SARL $1f,AX <<< + // f+3e 0x0001621e SARL CL,AX + // f+40 0x00016220 XORL CX,CX + // f+42 0x00016222 CMPL CX,AX + buf[0] = 0; + machdata->das(text, pc, 0, buf, sizeof buf); + if(strncmp(buf, "SAR", 3) == 0) { + machdata->das(text, epc, 0, buf, sizeof buf); + if(strncmp(buf, "SAR", 3) == 0) + return; + } + } + // show first instruction to make clear where we were. machdata->das(text, pc, 0, buf, sizeof buf); @@ -379,8 +397,10 @@ main(int argc, char **argv) getwd(cwd, sizeof cwd); ncwd = strlen(cwd); - if(argc < 1) - usage(); + if(argc == 0) { + *--argv = "6.out"; + argc++; + } fd = open(argv[0], OREAD); if(fd < 0) sysfatal("open %s: %r", argv[0]);