⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dump.c

📁 gdb是linux下的一个远程调试环境.能让你很方便地调试linux下的代码.
💻 C
📖 第 1 页 / 共 3 页
字号:
         fprintf(stderr, "  %s\n", ASCII_buffer);	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "  %s\n", ASCII_buffer);         ASCII_index = 0;         }      /* Print address in margin */      if (((address & address_mask) == address) &&          (address != last_print_address)) {         result = print_addr_29k(memory_space, address);         if (result != 0)            return (EMBADADDR);         }      /* Do leading and trailing spaces (if necessary) */      if ((address < start_address) ||          (address >= end_address)) {         fprintf(stderr, "            ");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "            ");         result = dump_ASCII(ASCII_buffer, ASCII_index,                             (BYTE *) NULL, sizeof(INT32));         ASCII_index = ASCII_index + sizeof(INT32);         address = address + 1;         }      /* Print out hex data */      if ((address >= start_address) &&          (address < end_address)) {         result = get_data((BYTE *)&data_word,                           &read_buffer[byte_count],                           sizeof(INT32));         if (result != 0)            return (EMBADADDR);	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "%02lx %02lx %02lx %02lx ",                ((data_word >> 24) & 0xff),                ((data_word >> 16) & 0xff),                ((data_word >> 8) & 0xff),                (data_word & 0xff));         fprintf(stderr, "%02lx %02lx %02lx %02lx ",                ((data_word >> 24) & 0xff),                ((data_word >> 16) & 0xff),                ((data_word >> 8) & 0xff),                (data_word & 0xff));         /* Build ASCII srting */         result = dump_ASCII(ASCII_buffer,                             ASCII_index,                             &read_buffer[byte_count],                             sizeof(INT32));          ASCII_index = ASCII_index + sizeof(INT32);         address = address + 1;         byte_count = byte_count + sizeof(INT32);         }  /* end if */      }  /* end while */   fprintf(stderr, "\n");   if (io_config.echo_mode == (INT32) TRUE)   fprintf(io_config.echo_file, "\n");   return (0);   }  /* end dump_reg_byte() *//*** This function is used to dump memory as floats.*/intdump_mem_float(memory_space, read_address, bytes_returned, read_buffer)   INT32  memory_space;   ADDR32 read_address;   INT32  bytes_returned;   BYTE   *read_buffer;   {   int      result;   ADDR32   address;   ADDR32   start_address;   ADDR32   end_address;   ADDR32   last_print_address;   ADDR32   address_mask;   INT32    byte_count;   float    data_float;   struct   addr_29k_t addr_29k;   byte_count = 0;   address_mask = 0xfffffff0;   start_address = read_address;   end_address = read_address + bytes_returned;   last_print_address = (end_address + 0xf) & address_mask;   address = start_address & address_mask;   /*   ** Loop while data available   */   while (address <= last_print_address) {      /* Exit if address not valid */      addr_29k.memory_space = memory_space;      addr_29k.address = address;      result = addr_29k_ok(&addr_29k);      if (result != 0) {         fprintf(stderr, "\n\n");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "\n\n");         return (0);         }      /* Print address in margin */      if (((address & address_mask) == address) &&          (address != last_print_address)) {         fprintf(stderr, "\n");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "\n");         result = print_addr_29k(memory_space, address);         if (result != 0)            return (EMBADADDR);         }      /* Do leading and trailing spaces (if necessary) */      if ((address < start_address) ||          (address >= end_address)) {         fprintf(stderr, "               ");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "               ");         address = address + sizeof(float);         }      /* Print out hex data */      if ((address >= start_address) &&          (address < end_address)) {         result = get_data((BYTE *)&data_float,                           &read_buffer[byte_count],                           sizeof(float));         if (result != 0)            return (EMBADADDR);         fprintf(stderr, "%+1.6e ", (double) data_float);	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "%+1.6e ", (double) data_float);         address = address + sizeof(float);         byte_count = byte_count + sizeof(float);         }  /* end if */      }  /* end while */   fprintf(stderr, "\n");   if (io_config.echo_mode == (INT32) TRUE)   fprintf(io_config.echo_file, "\n");   return (0);   }  /* end dump_mem_float() *//*** This function is used to dump registers as floats.*/intdump_reg_float(memory_space, read_address, bytes_returned, read_buffer)   INT32  memory_space;   ADDR32 read_address;   INT32  bytes_returned;   BYTE   *read_buffer;   {   int      result;   ADDR32   address;   ADDR32   start_address;   ADDR32   end_address;   ADDR32   last_print_address;   ADDR32   address_mask;   INT32    byte_count;   float    data_float;   struct   addr_29k_t addr_29k;   byte_count = 0;   address_mask = 0xfffffffc;   start_address = read_address;   end_address = read_address + (bytes_returned / 4);   last_print_address = (end_address + 0x3) & address_mask;   address = start_address & address_mask;   /*   ** Loop while data available   */   while (address <= last_print_address) {      /* Exit if address not valid */      addr_29k.memory_space = memory_space;      addr_29k.address = address;      result = addr_29k_ok(&addr_29k);      if (result != 0) {         fprintf(stderr, "\n\n");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "\n\n");         return (0);         }      /* Print address in margin */      if (((address & address_mask) == address) &&          (address != last_print_address)) {         fprintf(stderr, "\n");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "\n");         result = print_addr_29k(memory_space, address);         if (result != 0)            return (EMBADADDR);         }      /* Do leading and trailing spaces (if necessary) */      if ((address < start_address) ||          (address >= end_address)) {         fprintf(stderr, "               ");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "               ");         address = address + 1;         }      /* Print out hex data */      if ((address >= start_address) &&          (address < end_address)) {         result = get_data((BYTE *)&data_float,                           &read_buffer[byte_count],                           sizeof(float));         if (result != 0)            return (EMBADADDR);         fprintf(stderr, "%+1.6e ", (double) data_float);	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "%+1.6e ", (double) data_float);         address = address + 1;         byte_count = byte_count + sizeof(float);         }  /* end if */      }  /* end while */   fprintf(stderr, "\n");   if (io_config.echo_mode == (INT32) TRUE)   fprintf(io_config.echo_file, "\n");   return (0);   }  /* end dump_reg_float() *//*** This function is used to dump memory as doubles.*/intdump_mem_double(memory_space, read_address, bytes_returned, read_buffer)   INT32  memory_space;   ADDR32 read_address;   INT32  bytes_returned;   BYTE   *read_buffer;   {   int      result;   ADDR32   address;   ADDR32   start_address;   ADDR32   end_address;   ADDR32   last_print_address;   ADDR32   address_mask;   INT32    byte_count;   double   data_double;   struct   addr_29k_t addr_29k;   byte_count = 0;   address_mask = 0xfffffff0;   start_address = read_address;   end_address = read_address + bytes_returned;   last_print_address = (end_address + 0xf) & address_mask;   address = start_address & address_mask;   /*   ** Loop while data available   */   while (address <= last_print_address) {      /* Exit if address not valid */      addr_29k.memory_space = memory_space;      addr_29k.address = address;      result = addr_29k_ok(&addr_29k);      if (result != 0) {         fprintf(stderr, "\n\n");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "\n\n");         return (0);         }      /* Print address in margin */      if (((address & address_mask) == address) &&          (address != last_print_address)) {         fprintf(stderr, "\n");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "\n");         result = print_addr_29k(memory_space, address);         if (result != 0)            return (EMBADADDR);         }      /* Do leading and trailing spaces (if necessary) */      if ((address < start_address) ||          (address >= end_address)) {         fprintf(stderr, "                        ");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "                        ");         address = address + sizeof(double);         }      /* Print out hex data */      if ((address >= start_address) &&          (address < end_address)) {         result = get_data((BYTE *)&data_double,                           &read_buffer[byte_count],                           sizeof(double));         if (result != 0)            return (EMBADADDR);         fprintf(stderr, "%+1.15e ", data_double);	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "%+1.15e ", data_double);         address = address + sizeof(double);         byte_count = byte_count + sizeof(double);         }  /* end if */      }  /* end while */   fprintf(stderr, "\n");   if (io_config.echo_mode == (INT32) TRUE)   fprintf(io_config.echo_file, "\n");   return (0);   }  /* end dump_mem_double() *//*** This function is used to dump registers as doubles.*/intdump_reg_double(memory_space, read_address, bytes_returned, read_buffer)   INT32  memory_space;   ADDR32 read_address;   INT32  bytes_returned;   BYTE   *read_buffer;   {   int      result;   ADDR32   address;   ADDR32   start_address;   ADDR32   end_address;   ADDR32   last_print_address;   ADDR32   address_mask;   INT32    byte_count;   double   data_double;   struct   addr_29k_t addr_29k;   byte_count = 0;   address_mask = 0xfffffffc;   start_address = read_address;   end_address = read_address + (bytes_returned / 4);   last_print_address = (end_address + 0x3) & address_mask;   address = start_address & address_mask;   /*   ** Loop while data available   */   while (address <= last_print_address) {      /* Exit if address not valid */      addr_29k.memory_space = memory_space;      addr_29k.address = address;      result = addr_29k_ok(&addr_29k);      if (result != 0) {         fprintf(stderr, "\n\n");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "\n\n");         return (0);         }      /* Print address in margin */      if (((address & address_mask) == address) &&          (address != last_print_address)) {         fprintf(stderr, "\n");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "\n");         result = print_addr_29k(memory_space, address);         if (result != 0)            return (EMBADADDR);         }      /* Do leading and trailing spaces (if necessary) */      if ((address < start_address) ||          (address >= end_address)) {         fprintf(stderr, "                        ");	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "                        ");         address = address + 2;         }      /* Print out hex data */      if ((address >= start_address) &&          (address < end_address)) {         result = get_data((BYTE *)&data_double,                           &read_buffer[byte_count],                           sizeof(double));         if (result != 0)            return (EMBADADDR);         fprintf(stderr, "%+1.15e ", data_double);	 if (io_config.echo_mode == (INT32) TRUE)         fprintf(io_config.echo_file, "%+1.15e ", data_double);         address = address + (sizeof(double) / sizeof(INT32));         byte_count = byte_count + sizeof(double);         }  /* end if */      }  /* end while */   fprintf(stderr, "\n");   if (io_config.echo_mode == (INT32) TRUE)   fprintf(io_config.echo_file, "\n");   return (0);   }  /* end dump_reg_double() *//*** This function fills in a buffer with a character** representation of the dumped data.*/intdump_ASCII(buffer, index, data, size)   char    *buffer;   int      index;   BYTE    *data;   int      size;   {   INT32    i;   /* Do ASCII dump */   for (i=0; i<size; i=i+1)      if (data == NULL)         buffer[index+i] = ' ';      else         if (isprint(data[i]))            buffer[index+i] = data[i];            else               buffer[index+i] = '.';   buffer[index+i] = '\0';  /* Null terminate */   return (0);   }  /* end dump_ASCII() */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -