Exemplo n.º 1
0
void dump_line_symbols(void)
{
  static int lst_line_number = 1;
  static int last_src_line = 0;
  char buf[256];
  int i,j,start_block,end_block;

  LineSymbol *ls;

  start_block = gp_getl16(&directory_block_data[COD_DIR_LSTTAB]);

  if(start_block) {

    end_block = gp_getl16(&directory_block_data[COD_DIR_LSTTAB+2]);

    printf("\n\nLine Number Information\n");
    printf(" LstLn  SrcLn  Addr   Flags         FileName\n");
    printf(" -----  -----  ----   -----------   ---------------------------------------\n");

    for(j=start_block; j<=end_block; j++) {

      read_block(temp, j);

      ls = (LineSymbol *) temp;

      for(i=0; i<84; i++) {

	if((ls[i].smod & 4) == 0) {
	  assert(ls[i].sfile < number_of_source_files);
	  printf(" %5d  %5d %06X   %2x %s   %-50s\n",
		 lst_line_number++,
		 ls[i].sline,
		 ls[i].sloc*addrsize,
		 ls[i].smod,
		 smod_flags(ls[i].smod),
		 source_file_names[ls[i].sfile]);
	}
	if(source_files[ls[i].sfile] && (ls[i].sline != last_src_line)) {
	  fgets(buf, 256, source_files[ls[i].sfile]);
	  printf("%s",buf);
	}
	last_src_line = ls[i].sline;
      }
    }
  } else
    printf("No line number info\n");
}
Exemplo n.º 2
0
void
dump_line_symbols(void)
{
  static int lst_line_number = 1;
  static int last_src_line = 0;
  char buf[2048];
  unsigned short i, j, start_block, end_block;
  DirBlockInfo *dbi = main_dir;
  gp_boolean has_line_num_info = false;
  int _64k_base;

  do {
    _64k_base = gp_getu16(&dbi->dir[COD_DIR_HIGHADDR]);

    start_block = gp_getu16(&dbi->dir[COD_DIR_LSTTAB]);

    if (start_block) {
      end_block = gp_getu16(&dbi->dir[COD_DIR_LSTTAB + 2]);

      if (!has_line_num_info) {
        has_line_num_info = true;

        printf("Line Number Information:\n"
               " LstLn  SrcLn  Addr    Flags        FileName\n"
               " -----  -----  ------  -----------  ---------------------------------------\n");
      }

      for (j = start_block; j <= end_block; j++) {
        read_block(temp, j);

        for (i = 0; i < 84; i++) {
          unsigned int offset = i * COD_LINE_SYM_SIZE;

          unsigned char sfile  = temp[offset + COD_LS_SFILE];
          unsigned char smod   = temp[offset + COD_LS_SMOD];
          unsigned short sline = gp_getl16(&temp[offset + COD_LS_SLINE]);
          unsigned short sloc  = gp_getl16(&temp[offset + COD_LS_SLOC]);

          if ((sfile != 0 || smod != 0 || sline != 0 || sloc != 0) &&
              (smod & 4) == 0) {
            char *source_file_name;

            if (sfile < number_of_source_files) {
              source_file_name = source_file_names[sfile];
            }
            else {
              char buf[128];

              snprintf(buf, sizeof(buf), "Bad source file index: %d", sfile);
              source_file_name = buf;
            }

            printf(" %5d  %5d  %06X  %2x %s  %-50s\n",
                   lst_line_number++,
                   sline,
                   (_64k_base << 16) | sloc,
                   smod,
                   smod_flags(smod),
                   source_file_name);

            if ((sfile < number_of_source_files) && (sline != last_src_line)) {
              if (source_files[sfile] != NULL) {
                /*fgets(buf, sizeof(buf), source_files[sfile]);*/
                fget_line(sline, buf, sizeof(buf), source_files[sfile]);
                printf("%s", buf);
              }
              else {
                printf("ERROR: Source file \"%s\" does not exist.\n", source_file_names[sfile]);
              }
            }
          }
          last_src_line = sline;
        }
      } /* for */
    } /* if */
    dbi = dbi->next;
  } while (dbi != NULL);

  if (!has_line_num_info) {
    printf("No line number info.\n");
  }

  putchar('\n');
}