Commit 9a09a855 authored by Robert Sprowson's avatar Robert Sprowson

dis2 and testbed improvements

Test/testbed.c: Remove the special case for MAR/MRA now that Debugger supports these. Don't leak raw on exit, found by cppcheck static analysis.
main.c: Don't leak prog on exit, found by cppcheck static analysis.
The apparent memory leaks are slightly academic since these are both applications and would be reclaimed on exit.

Tested with all 256M 'EQ' and 256M 'NV' condition codes, only expected differences remain such as use of hex.v.dec for small constants.
Tagged as Debugger-2_02-1 since Debugger itself is unchanged.
parent 6eee6524
......@@ -25,7 +25,6 @@
void xsystem(const char *cmd)
{
// printf("*%s\n",cmd);
if (system(cmd))
{
fprintf(stderr,"'%s' failed!\n",cmd);
......@@ -405,8 +404,6 @@ int diff_debugger(char *folder,char *one,char *two,char *out)
if(strstr(c2,"Unallocated"))
continue;
/* Skip LDC/STC/etc. - might be caused by VFP/NEON handling differences */
if(strstr(c2,"MAR") || strstr(c2,"MRA"))
continue;
if((strstr(c1,"LDC") || strstr(c1,"STC") || strstr(c1,"MCR") || strstr(c1,"MRC") || strstr(c1,"MRRC") || strstr(c1,"CDP")) && strstr(c2,"Undefined"))
continue;
if((strstr(c2,"LDC") || strstr(c2,"STC") || strstr(c2,"MCR") || strstr(c2,"MRC") || strstr(c2,"MRRC") || strstr(c2,"CDP")) && strstr(c1,"Undefined"))
......@@ -557,6 +554,7 @@ int main(int argc,char **argv)
fread(raw,count<<2,1,f);
fclose(f);
process(rawfile,folder,raw,count);
free(raw);
}
else
{
......
......@@ -87,21 +87,6 @@ int main(int argc,char **argv)
fprintf(stderr,"Usage: dis2 <file> <addr> [-debugger|-decaof|-decaofual]\n");
exit(EXIT_FAILURE);
}
FILE *f = fopen(argv[1],"rb");
if(!f)
{
fprintf(stderr,"Couldn't open '%s'\n",argv[1]);
exit(EXIT_FAILURE);
}
fseek(f,0,SEEK_END);
uint32_t len = ((uint32_t) ftell(f)) & ~3;
uint32_t *prog = (uint32_t *) malloc(len);
fseek(f,0,SEEK_SET);
fread(prog,len,1,f);
fclose(f);
uint32_t addr;
if(sscanf(argv[2],"0x%x",&addr) != 1)
addr = atoi(argv[2]);
bool debugger = false;
dis_options *opt;
if(!strcmp(argv[3],"-debugger"))
......@@ -122,6 +107,28 @@ int main(int argc,char **argv)
fprintf(stderr,"Unknown disassembly format '%s'\n",argv[3]);
exit(EXIT_FAILURE);
}
FILE *f = fopen(argv[1],"rb");
if(!f)
{
fprintf(stderr,"Couldn't open '%s'\n",argv[1]);
exit(EXIT_FAILURE);
}
fseek(f,0,SEEK_END);
uint32_t len = ((uint32_t) ftell(f)) & ~3;
uint32_t *progstore, *prog;
progstore = prog = (uint32_t *) malloc(len);
if(!progstore)
{
fprintf(stderr,"Out of memory allocating %u\n",len);
fclose(f);
exit(EXIT_FAILURE);
}
fseek(f,0,SEEK_SET);
fread(prog,len,1,f);
fclose(f);
uint32_t addr;
if(sscanf(argv[2],"0x%x",&addr) != 1)
addr = atoi(argv[2]);
while(len)
{
char buf[1024];
......@@ -135,5 +142,6 @@ int main(int argc,char **argv)
addr+=4;
len-=4;
}
free(progstore);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment