OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [binutils/] [dwarf.c] - Diff between revs 163 and 166

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 163 Rev 166
Line 167... Line 167...
  snprintf (ret, sizeof (buf[0].place), fmt, value);
  snprintf (ret, sizeof (buf[0].place), fmt, value);
 
 
  return ret;
  return ret;
}
}
 
 
 
/* Format a 64-bit value, given as two 32-bit values, in hex.
 
   For reentrancy, this uses a buffer provided by the caller.  */
 
 
 
static const char *
 
dwarf_vmatoa64 (dwarf_vma hvalue, dwarf_vma lvalue, char *buf,
 
                unsigned int buf_len)
 
{
 
  int len = 0;
 
 
 
  if (hvalue == 0)
 
    snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", lvalue);
 
  else
 
    {
 
      len = snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", hvalue);
 
      snprintf (buf + len, buf_len - len,
 
                "%08" DWARF_VMA_FMT "x", lvalue);
 
    }
 
 
 
  return buf;
 
}
 
 
dwarf_vma
dwarf_vma
read_leb128 (unsigned char *data, unsigned int *length_return, int sign)
read_leb128 (unsigned char *data, unsigned int *length_return, int sign)
{
{
  dwarf_vma result = 0;
  dwarf_vma result = 0;
  unsigned int num_read = 0;
  unsigned int num_read = 0;
Line 245... Line 266...
  unsigned char op_code;
  unsigned char op_code;
  unsigned int bytes_read;
  unsigned int bytes_read;
  unsigned int len;
  unsigned int len;
  unsigned char *name;
  unsigned char *name;
  dwarf_vma adr;
  dwarf_vma adr;
 
  unsigned char *orig_data = data;
 
 
  len = read_leb128 (data, & bytes_read, 0);
  len = read_leb128 (data, & bytes_read, 0);
  data += bytes_read;
  data += bytes_read;
 
 
  if (len == 0)
  if (len == 0)
Line 286... Line 308...
      printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
      printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
      data += bytes_read;
      data += bytes_read;
      printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
      printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
      data += bytes_read;
      data += bytes_read;
      printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
      printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
      printf ("%s\n\n", name);
      data += bytes_read;
 
      printf ("%s", name);
 
      if ((unsigned int) (data - orig_data) != len)
 
        printf (_(" [Bad opcode length]"));
 
      printf ("\n\n");
      break;
      break;
 
 
    case DW_LNE_set_discriminator:
    case DW_LNE_set_discriminator:
      printf (_("set Discriminator to %s\n"),
      printf (_("set Discriminator to %s\n"),
              dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
              dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0)));
Line 1374... Line 1400...
 
 
    case DW_FORM_ref8:
    case DW_FORM_ref8:
    case DW_FORM_data8:
    case DW_FORM_data8:
      if (!do_loc)
      if (!do_loc)
        {
        {
          uvalue = byte_get (data, 4);
          dwarf_vma high_bits;
          printf (" 0x%s", dwarf_vmatoa ("x", uvalue));
          char buf[64];
          printf (" 0x%lx", (unsigned long) byte_get (data + 4, 4));
 
 
          byte_get_64 (data, &high_bits, &uvalue);
 
          printf (" 0x%s",
 
                  dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
        }
        }
      if ((do_loc || do_debug_loc || do_debug_ranges)
      if ((do_loc || do_debug_loc || do_debug_ranges)
          && num_debug_info_entries == 0)
          && num_debug_info_entries == 0)
        {
        {
          if (sizeof (uvalue) == 8)
          if (sizeof (uvalue) == 8)
Line 1446... Line 1475...
      break;
      break;
 
 
    case DW_FORM_ref_sig8:
    case DW_FORM_ref_sig8:
      if (!do_loc)
      if (!do_loc)
        {
        {
          int i;
          dwarf_vma high_bits;
          printf (" signature: ");
          char buf[64];
          for (i = 0; i < 8; i++)
 
            {
          byte_get_64 (data, &high_bits, &uvalue);
              printf ("%02x", (unsigned) byte_get (data, 1));
          printf (" signature: 0x%s",
              data += 1;
                  dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
            }
 
        }
        }
      else
 
        data += 8;
        data += 8;
      break;
      break;
 
 
    default:
    default:
      warn (_("Unrecognized form: %lu\n"), form);
      warn (_("Unrecognized form: %lu\n"), form);
Line 1597... Line 1624...
        case DW_LANG_ObjC_plus_plus:    printf ("(Objective C++)"); break;
        case DW_LANG_ObjC_plus_plus:    printf ("(Objective C++)"); break;
        case DW_LANG_UPC:               printf ("(Unified Parallel C)"); break;
        case DW_LANG_UPC:               printf ("(Unified Parallel C)"); break;
        case DW_LANG_D:                 printf ("(D)"); break;
        case DW_LANG_D:                 printf ("(D)"); break;
          /* DWARF 4 values.  */
          /* DWARF 4 values.  */
        case DW_LANG_Python:            printf ("(Python)"); break;
        case DW_LANG_Python:            printf ("(Python)"); break;
 
          /* DWARF 5 values.  */
 
        case DW_LANG_Go:                printf ("(Go)"); break;
          /* MIPS extension.  */
          /* MIPS extension.  */
        case DW_LANG_Mips_Assembler:    printf ("(MIPS assembler)"); break;
        case DW_LANG_Mips_Assembler:    printf ("(MIPS assembler)"); break;
          /* UPC extension.  */
          /* UPC extension.  */
        case DW_LANG_Upc:               printf ("(Unified Parallel C)"); break;
        case DW_LANG_Upc:               printf ("(Unified Parallel C)"); break;
        default:
        default:
Line 2104... Line 2133...
      unsigned char *tags;
      unsigned char *tags;
      int level, last_level, saved_level;
      int level, last_level, saved_level;
      dwarf_vma cu_offset;
      dwarf_vma cu_offset;
      int offset_size;
      int offset_size;
      int initial_length_size;
      int initial_length_size;
      unsigned char signature[8] = { 0 };
      dwarf_vma signature_high = 0;
 
      dwarf_vma signature_low = 0;
      dwarf_vma type_offset = 0;
      dwarf_vma type_offset = 0;
 
 
      hdrptr = start;
      hdrptr = start;
 
 
      compunit.cu_length = byte_get (hdrptr, 4);
      compunit.cu_length = byte_get (hdrptr, 4);
Line 2138... Line 2168...
      compunit.cu_pointer_size = byte_get (hdrptr, 1);
      compunit.cu_pointer_size = byte_get (hdrptr, 1);
      hdrptr += 1;
      hdrptr += 1;
 
 
      if (do_types)
      if (do_types)
        {
        {
          int i;
          byte_get_64 (hdrptr, &signature_high, &signature_low);
 
          hdrptr += 8;
          for (i = 0; i < 8; i++)
 
            {
 
              signature[i] = byte_get (hdrptr, 1);
 
              hdrptr += 1;
 
            }
 
 
 
          type_offset = byte_get (hdrptr, offset_size);
          type_offset = byte_get (hdrptr, offset_size);
          hdrptr += offset_size;
          hdrptr += offset_size;
        }
        }
 
 
      if ((do_loc || do_debug_loc || do_debug_ranges)
      if ((do_loc || do_debug_loc || do_debug_ranges)
Line 2182... Line 2206...
          printf (_("   Abbrev Offset: %s\n"),
          printf (_("   Abbrev Offset: %s\n"),
                  dwarf_vmatoa ("d", compunit.cu_abbrev_offset));
                  dwarf_vmatoa ("d", compunit.cu_abbrev_offset));
          printf (_("   Pointer Size:  %d\n"), compunit.cu_pointer_size);
          printf (_("   Pointer Size:  %d\n"), compunit.cu_pointer_size);
          if (do_types)
          if (do_types)
            {
            {
              int i;
              char buf[64];
              printf (_("   Signature:     "));
 
              for (i = 0; i < 8; i++)
              printf (_("   Signature:     0x%s\n"),
                printf ("%02x", signature[i]);
                      dwarf_vmatoa64 (signature_high, signature_low,
              printf ("\n");
                                      buf, sizeof (buf)));
             printf (_("   Type Offset:   0x%s\n"),
             printf (_("   Type Offset:   0x%s\n"),
                     dwarf_vmatoa ("x", type_offset));
                     dwarf_vmatoa ("x", type_offset));
            }
            }
        }
        }
 
 
Line 2796... Line 2820...
      unsigned char *hdrptr;
      unsigned char *hdrptr;
      int initial_length_size;
      int initial_length_size;
      int offset_size;
      int offset_size;
      int i;
      int i;
      File_Entry *file_table = NULL;
      File_Entry *file_table = NULL;
 
      unsigned int n_files = 0;
      unsigned char **directory_table = NULL;
      unsigned char **directory_table = NULL;
 
      unsigned int n_directories = 0;
 
 
      hdrptr = data;
      hdrptr = data;
 
 
      /* Extract information from the Line Number Program Header.
      /* Extract information from the Line Number Program Header.
        (section 6.2.4 in the Dwarf3 doc).  */
        (section 6.2.4 in the Dwarf3 doc).  */
Line 2881... Line 2907...
 
 
      /* Traverse the Directory table just to count entries.  */
      /* Traverse the Directory table just to count entries.  */
      data = standard_opcodes + linfo.li_opcode_base - 1;
      data = standard_opcodes + linfo.li_opcode_base - 1;
      if (*data != 0)
      if (*data != 0)
        {
        {
          unsigned int n_directories = 0;
 
          unsigned char *ptr_directory_table = data;
          unsigned char *ptr_directory_table = data;
 
 
          while (*data != 0)
          while (*data != 0)
            {
            {
              data += strlen ((char *) data) + 1;
              data += strlen ((char *) data) + 1;
Line 2908... Line 2933...
      data++;
      data++;
 
 
      /* Traverse the File Name table just to count the entries.  */
      /* Traverse the File Name table just to count the entries.  */
      if (*data != 0)
      if (*data != 0)
        {
        {
          unsigned int n_files = 0;
 
          unsigned char *ptr_file_name_table = data;
          unsigned char *ptr_file_name_table = data;
 
 
          while (*data != 0)
          while (*data != 0)
            {
            {
              unsigned int bytes_read;
              unsigned int bytes_read;
Line 3040... Line 3064...
                    byte_get (op_code_data, ext_op_code_len - bytes_read - 1);
                    byte_get (op_code_data, ext_op_code_len - bytes_read - 1);
                    state_machine_regs.op_index = 0;
                    state_machine_regs.op_index = 0;
                    break;
                    break;
                  case DW_LNE_define_file:
                  case DW_LNE_define_file:
                    {
                    {
                      unsigned int dir_index = 0;
                      file_table = (File_Entry *) xrealloc
 
                        (file_table, (n_files + 1) * sizeof (File_Entry));
 
 
                      ++state_machine_regs.last_file_entry;
                      ++state_machine_regs.last_file_entry;
 
                      /* Source file name.  */
 
                      file_table[n_files].name = op_code_data;
                      op_code_data += strlen ((char *) op_code_data) + 1;
                      op_code_data += strlen ((char *) op_code_data) + 1;
                      dir_index = read_leb128 (op_code_data, & bytes_read, 0);
                      /* Directory index.  */
 
                      file_table[n_files].directory_index =
 
                        read_leb128 (op_code_data, & bytes_read, 0);
                      op_code_data += bytes_read;
                      op_code_data += bytes_read;
 
                      /* Last modification time.  */
 
                      file_table[n_files].modification_date =
                      read_leb128 (op_code_data, & bytes_read, 0);
                      read_leb128 (op_code_data, & bytes_read, 0);
                      op_code_data += bytes_read;
                      op_code_data += bytes_read;
 
                      /* File length.  */
 
                      file_table[n_files].length =
                      read_leb128 (op_code_data, & bytes_read, 0);
                      read_leb128 (op_code_data, & bytes_read, 0);
 
 
                      printf ("%s:\n", directory_table[dir_index]);
                      n_files++;
                      break;
                      break;
                    }
                    }
 
                  case DW_LNE_set_discriminator:
 
                  case DW_LNE_HP_set_sequence:
 
                    /* Simply ignored.  */
 
                    break;
 
 
                  default:
                  default:
                    printf (_("UNKNOWN: length %d\n"), ext_op_code_len - bytes_read);
                    printf (_("UNKNOWN (%u): length %d\n"),
 
                            ext_op_code, ext_op_code_len - bytes_read);
                    break;
                    break;
                  }
                  }
                data += ext_op_code_len;
                data += ext_op_code_len;
                break;
                break;
              }
              }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.