run.c
Go to the documentation of this file.00001
00002
00003
00004
00005 int cmd_run(int argc,char **argv)
00006 {
00007 unsigned long download_addr;
00008 struct stat statbuf;
00009 char *buf;
00010 int fd;
00011 unsigned long before=0,after=0;
00012 int context_reg[dMIPS32_NUM_DEBUG_REGISTERS];
00013 if(stat(argv[1],&statbuf)!=0)
00014 {
00015 printf("error read file %s\n",argv[1]);
00016 exit(-1);
00017 }
00018
00019 if(argc>2)before=strtoul(argv[2],0,0);
00020 if(argc>3)after=strtoul(argv[3],0,0);
00021
00022 printf("open file %s,size %d\n",argv[1],statbuf.st_size);
00023 buf=malloc(statbuf.st_size+before+after);
00024 if(!buf)printf("error allocate memory\n");
00025 fd=open(argv[1],O_RDONLY);
00026 read(fd,buf+before,statbuf.st_size);
00027 close(fd);
00028
00029 printf("before=%x,after=%x\n",before,after);
00030 fMIPS32_ExecuteDebugModule(buf+before,statbuf.st_size+after,4);
00031
00032 free(buf);
00033
00034 return 0;
00035 }
00036
00037 mycmd_init(run,cmd_run,"run","run filename");