Program: 149862
Project: 149862
Buggy source:
/** 
 * Write method address map for use with dbx debugger.
 * @param fileName name of file to write the map to
 */
private static void writeAddressMap(String mapFileName) throws IOException {
  if (verbose >= 1)   say("String_Node_Str",mapFileName);
  VM_Statics.bootImageReportGeneration(staticsJunk);
  FileOutputStream fos=new FileOutputStream(mapFileName);
  BufferedOutputStream bos=new BufferedOutputStream(fos,128);
  PrintStream out=new PrintStream(bos,false);
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str" + Integer.toHexString(BOOT_IMAGE_DATA_START.toInt()) + "String_Node_Str"+ Integer.toHexString(BOOT_IMAGE_DATA_START.toInt() + bootImage.getDataSize()));
  out.println("String_Node_Str" + Integer.toHexString(BOOT_IMAGE_CODE_START.toInt()) + "String_Node_Str"+ Integer.toHexString(BOOT_IMAGE_CODE_START.toInt() + bootImage.getCodeSize()));
  out.println("String_Node_Str" + Integer.toHexString(BOOT_IMAGE_RMAP_START.toInt()) + "String_Node_Str"+ Integer.toHexString(BOOT_IMAGE_RMAP_START.toInt() + bootImage.getRMapSize()));
  out.println();
  out.println("String_Node_Str");
  out.println();
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  String pad="String_Node_Str";
  for (int jtocSlot=VM_Statics.getLowestInUseSlot(); jtocSlot < VM_Statics.middleOfTable; jtocSlot++) {
    Offset jtocOff=VM_Statics.slotAsOffset(jtocSlot);
    String category;
    String contents;
    String details;
    VM_Field field=getRvmStaticField(jtocOff);
    VM_Field field2=getRvmStaticField(jtocOff.plus(4));
    boolean couldBeLongLiteral=VM_Statics.isLongSizeLiteral(jtocSlot);
    boolean couldBeIntLiteral=VM_Statics.isIntSizeLiteral(jtocSlot);
    if (couldBeLongLiteral && ((field == null) || (field2 == null))) {
      if ((field == null) && (field2 == null)) {
        category="String_Node_Str";
        long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
        contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
        details=lval + "String_Node_Str";
      }
 else       if ((field == null) && (field2 != null)) {
        category="String_Node_Str";
        long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
        contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
        details=lval + "String_Node_Str" + field2.toString();
      }
 else       if ((field != null) && (field2 == null)) {
        category="String_Node_Str";
        long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
        contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
        details=lval + "String_Node_Str" + field.toString();
      }
 else {
        throw new Error("String_Node_Str");
      }
      jtocSlot++;
    }
 else     if (couldBeIntLiteral) {
      if (field != null) {
        category="String_Node_Str";
        int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
        contents=VM.intAsHexString(ival) + pad;
        details=Integer.toString(ival) + "String_Node_Str" + field.toString();
      }
 else {
        category="String_Node_Str";
        int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
        contents=VM.intAsHexString(ival) + pad;
        details=Integer.toString(ival);
      }
    }
 else {
      if (field != null) {
        category="String_Node_Str";
        details=field.toString();
        VM_TypeReference type=field.getType();
        if (type.isIntLikeType()) {
          int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
          contents=VM.intAsHexString(ival) + pad;
        }
 else         if (type.isLongType()) {
          long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
          contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
          jtocSlot++;
        }
 else         if (type.isFloatType()) {
          int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
          contents=Float.toString(Float.intBitsToFloat(ival)) + pad;
        }
 else         if (type.isDoubleType()) {
          long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
          contents=Double.toString(Double.longBitsToDouble(lval)) + pad;
          jtocSlot++;
        }
 else         if (type.isWordType()) {
          if (VM.BuildFor32Addr) {
            int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
            contents=VM.intAsHexString(ival) + pad;
          }
 else {
            long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
            contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
            jtocSlot++;
          }
        }
 else {
          int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
          category="String_Node_Str";
          details="String_Node_Str" + field.toString() + "String_Node_Str";
          contents=VM.intAsHexString(ival) + pad;
        }
      }
 else {
        int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
        category="String_Node_Str";
        details="String_Node_Str";
        contents=VM.intAsHexString(ival) + pad;
      }
    }
    out.println((jtocSlot + "String_Node_Str").substring(0,6) + VM.addressAsHexString(jtocOff.toWord().toAddress()) + "String_Node_Str"+ category+ "String_Node_Str"+ contents+ "String_Node_Str"+ details);
  }
  for (int jtocSlot=VM_Statics.middleOfTable, n=VM_Statics.getHighestInUseSlot(); jtocSlot <= n; jtocSlot+=VM_Statics.getReferenceSlotSize()) {
    Offset jtocOff=VM_Statics.slotAsOffset(jtocSlot);
    Object obj=BootImageMap.getObject(getIVal(jtocOff));
    String category;
    String details;
    String contents=VM.addressAsHexString(getReferenceAddr(jtocOff,false)) + pad;
    VM_Field field=getRvmStaticField(jtocOff);
    if (VM_Statics.isReferenceLiteral(jtocSlot)) {
      if (field != null) {
        category="String_Node_Str";
      }
 else {
        category="String_Node_Str";
      }
      if (obj == null) {
        details="String_Node_Str";
      }
 else       if (obj instanceof String) {
        details="String_Node_Str" + obj + "String_Node_Str";
      }
 else       if (obj instanceof Class) {
        details="String_Node_Str" + obj;
      }
 else       if (obj instanceof VM_TIB) {
        category="String_Node_Str";
        VM_Type type=VM_Statics.findTypeOfTIBSlot(jtocOff);
        details=(type == null) ? "String_Node_Str" : type.toString();
      }
 else {
        details="String_Node_Str" + obj.getClass();
      }
      if (field != null) {
        details+="String_Node_Str" + field.toString();
      }
    }
 else {
      if (field != null) {
        category="String_Node_Str";
        details=field.toString();
      }
 else {
        VM_CompiledMethod m=findMethodOfCode(obj);
        if (m != null) {
          category="String_Node_Str";
          details=m.getMethod().toString();
        }
 else {
          category="String_Node_Str";
          details="String_Node_Str";
        }
      }
    }
    out.println((jtocSlot + "String_Node_Str").substring(0,6) + VM.addressAsHexString(jtocOff.toWord().toAddress()) + "String_Node_Str"+ category+ "String_Node_Str"+ contents+ "String_Node_Str"+ details);
  }
  out.println();
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println();
  VM_CompiledMethod[] compiledMethods=VM_CompiledMethods.getCompiledMethods();
  for (int i=0; i < VM_CompiledMethods.numCompiledMethods(); ++i) {
    VM_CompiledMethod compiledMethod=compiledMethods[i];
    if (compiledMethod != null) {
      VM_Method m=compiledMethod.getMethod();
      if (m != null && compiledMethod.isCompiled()) {
        VM_CodeArray instructions=compiledMethod.getEntryCodeArray();
        Address code=BootImageMap.getImageAddress(instructions.getBacking(),true);
        out.println("String_Node_Str" + VM.addressAsHexString(code) + "String_Node_Str"+ compiledMethod.getMethod());
      }
    }
  }
  if (false) {
    out.println();
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    out.println();
    SortedSet<BootImageMap.Entry> set=new TreeSet<BootImageMap.Entry>(new Comparator<BootImageMap.Entry>(){
      public int compare(      BootImageMap.Entry a,      BootImageMap.Entry b){
        return Integer.valueOf(a.imageAddress.toInt()).compareTo(b.imageAddress.toInt());
      }
      public boolean equals(){
        throw new Error("String_Node_Str");
      }
    }
);
    for (Enumeration<BootImageMap.Entry> e=BootImageMap.elements(); e.hasMoreElements(); ) {
      BootImageMap.Entry entry=e.nextElement();
      set.add(entry);
    }
    for (Iterator<BootImageMap.Entry> i=set.iterator(); i.hasNext(); ) {
      BootImageMap.Entry entry=i.next();
      Address data=entry.imageAddress;
      out.println("String_Node_Str" + VM.addressAsHexString(data) + "String_Node_Str"+ entry.jdkObject.getClass());
    }
  }
  out.println();
  out.println("String_Node_Str");
  out.flush();
  out.close();
}

Fixed version (ground truth):
/** 
 * Write method address map for use with dbx debugger.
 * @param fileName name of file to write the map to
 */
private static void writeAddressMap(String mapFileName) throws IOException {
  if (verbose >= 1)   say("String_Node_Str",mapFileName);
  VM_Statics.bootImageReportGeneration(staticsJunk);
  FileOutputStream fos=new FileOutputStream(mapFileName);
  BufferedOutputStream bos=new BufferedOutputStream(fos,128);
  PrintStream out=new PrintStream(bos,false);
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str" + Integer.toHexString(BOOT_IMAGE_DATA_START.toInt()) + "String_Node_Str"+ Integer.toHexString(BOOT_IMAGE_DATA_START.toInt() + bootImage.getDataSize()));
  out.println("String_Node_Str" + Integer.toHexString(BOOT_IMAGE_CODE_START.toInt()) + "String_Node_Str"+ Integer.toHexString(BOOT_IMAGE_CODE_START.toInt() + bootImage.getCodeSize()));
  out.println("String_Node_Str" + Integer.toHexString(BOOT_IMAGE_RMAP_START.toInt()) + "String_Node_Str"+ Integer.toHexString(BOOT_IMAGE_RMAP_START.toInt() + bootImage.getRMapSize()));
  out.println();
  out.println("String_Node_Str");
  out.println();
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  String pad="String_Node_Str";
  for (int jtocSlot=VM_Statics.getLowestInUseSlot(); jtocSlot < VM_Statics.middleOfTable; jtocSlot++) {
    Offset jtocOff=VM_Statics.slotAsOffset(jtocSlot);
    String category;
    String contents;
    String details;
    VM_Field field=getRvmStaticField(jtocOff);
    VM_Field field2=getRvmStaticField(jtocOff.plus(4));
    boolean couldBeLongLiteral=VM_Statics.isLongSizeLiteral(jtocSlot);
    boolean couldBeIntLiteral=VM_Statics.isIntSizeLiteral(jtocSlot);
    if (couldBeLongLiteral && ((field == null) || (field2 == null))) {
      if ((field == null) && (field2 == null)) {
        category="String_Node_Str";
        long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
        contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
        details=lval + "String_Node_Str";
      }
 else       if ((field == null) && (field2 != null)) {
        category="String_Node_Str";
        long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
        contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
        details=lval + "String_Node_Str" + field2.toString();
      }
 else       if ((field != null) && (field2 == null)) {
        category="String_Node_Str";
        long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
        contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
        details=lval + "String_Node_Str" + field.toString();
      }
 else {
        throw new Error("String_Node_Str");
      }
      jtocSlot++;
    }
 else     if (couldBeIntLiteral) {
      if (field != null) {
        category="String_Node_Str";
        int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
        contents=VM.intAsHexString(ival) + pad;
        details=Integer.toString(ival) + "String_Node_Str" + field.toString();
      }
 else {
        category="String_Node_Str";
        int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
        contents=VM.intAsHexString(ival) + pad;
        details=Integer.toString(ival);
      }
    }
 else {
      if (field != null) {
        category="String_Node_Str";
        details=field.toString();
        VM_TypeReference type=field.getType();
        if (type.isIntLikeType()) {
          int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
          contents=VM.intAsHexString(ival) + pad;
        }
 else         if (type.isLongType()) {
          long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
          contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
          jtocSlot++;
        }
 else         if (type.isFloatType()) {
          int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
          contents=Float.toString(Float.intBitsToFloat(ival)) + pad;
        }
 else         if (type.isDoubleType()) {
          long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
          contents=Double.toString(Double.longBitsToDouble(lval)) + pad;
          jtocSlot++;
        }
 else         if (type.isWordType()) {
          if (VM.BuildFor32Addr) {
            int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
            contents=VM.intAsHexString(ival) + pad;
          }
 else {
            long lval=VM_Statics.getSlotContentsAsLong(jtocOff);
            contents=VM.intAsHexString((int)(lval >> 32)) + VM.intAsHexString((int)(lval & 0xffffffffL)).substring(2);
            jtocSlot++;
          }
        }
 else {
          int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
          category="String_Node_Str";
          details="String_Node_Str" + field.toString() + "String_Node_Str";
          contents=VM.intAsHexString(ival) + pad;
        }
      }
 else {
        int ival=VM_Statics.getSlotContentsAsInt(jtocOff);
        category="String_Node_Str";
        details="String_Node_Str";
        contents=VM.intAsHexString(ival) + pad;
      }
    }
    out.println((jtocSlot + "String_Node_Str").substring(0,6) + VM.addressAsHexString(jtocOff.toWord().toAddress()) + "String_Node_Str"+ category+ "String_Node_Str"+ contents+ "String_Node_Str"+ details);
  }
  for (int jtocSlot=VM_Statics.middleOfTable, n=VM_Statics.getHighestInUseSlot(); jtocSlot <= n; jtocSlot+=VM_Statics.getReferenceSlotSize()) {
    Offset jtocOff=VM_Statics.slotAsOffset(jtocSlot);
    Object obj=BootImageMap.getObject(getIVal(jtocOff));
    String category;
    String details;
    String contents=VM.addressAsHexString(getReferenceAddr(jtocOff,false)) + pad;
    VM_Field field=getRvmStaticField(jtocOff);
    if (VM_Statics.isReferenceLiteral(jtocSlot)) {
      if (field != null) {
        category="String_Node_Str";
      }
 else {
        category="String_Node_Str";
      }
      if (obj == null) {
        details="String_Node_Str";
      }
 else       if (obj instanceof String) {
        details="String_Node_Str" + obj + "String_Node_Str";
      }
 else       if (obj instanceof Class) {
        details="String_Node_Str" + obj;
      }
 else       if (obj instanceof VM_TIB) {
        category="String_Node_Str";
        VM_Type type=VM_Statics.findTypeOfTIBSlot(jtocOff);
        details=(type == null) ? "String_Node_Str" : type.toString();
      }
 else {
        details="String_Node_Str" + obj.getClass();
      }
      if (field != null) {
        details+="String_Node_Str" + field.toString();
      }
    }
 else {
      if (field != null) {
        category="String_Node_Str";
        details=field.toString();
      }
 else       if (obj instanceof VM_TIB) {
        category="String_Node_Str";
        VM_Type type=VM_Statics.findTypeOfTIBSlot(jtocOff);
        details=(type == null) ? "String_Node_Str" : type.toString();
      }
 else {
        VM_CompiledMethod m=findMethodOfCode(obj);
        if (m != null) {
          category="String_Node_Str";
          details=m.getMethod().toString();
        }
 else {
          category="String_Node_Str";
          details="String_Node_Str";
        }
      }
    }
    out.println((jtocSlot + "String_Node_Str").substring(0,6) + VM.addressAsHexString(jtocOff.toWord().toAddress()) + "String_Node_Str"+ category+ "String_Node_Str"+ contents+ "String_Node_Str"+ details);
  }
  out.println();
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println("String_Node_Str");
  out.println();
  VM_CompiledMethod[] compiledMethods=VM_CompiledMethods.getCompiledMethods();
  for (int i=0; i < VM_CompiledMethods.numCompiledMethods(); ++i) {
    VM_CompiledMethod compiledMethod=compiledMethods[i];
    if (compiledMethod != null) {
      VM_Method m=compiledMethod.getMethod();
      if (m != null && compiledMethod.isCompiled()) {
        VM_CodeArray instructions=compiledMethod.getEntryCodeArray();
        Address code=BootImageMap.getImageAddress(instructions.getBacking(),true);
        out.println("String_Node_Str" + VM.addressAsHexString(code) + "String_Node_Str"+ compiledMethod.getMethod());
      }
    }
  }
  if (false) {
    out.println();
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    out.println();
    SortedSet<BootImageMap.Entry> set=new TreeSet<BootImageMap.Entry>(new Comparator<BootImageMap.Entry>(){
      public int compare(      BootImageMap.Entry a,      BootImageMap.Entry b){
        return Integer.valueOf(a.imageAddress.toInt()).compareTo(b.imageAddress.toInt());
      }
      public boolean equals(){
        throw new Error("String_Node_Str");
      }
    }
);
    for (Enumeration<BootImageMap.Entry> e=BootImageMap.elements(); e.hasMoreElements(); ) {
      BootImageMap.Entry entry=e.nextElement();
      set.add(entry);
    }
    for (Iterator<BootImageMap.Entry> i=set.iterator(); i.hasNext(); ) {
      BootImageMap.Entry entry=i.next();
      Address data=entry.imageAddress;
      out.println("String_Node_Str" + VM.addressAsHexString(data) + "String_Node_Str"+ entry.jdkObject.getClass());
    }
  }
  out.println();
  out.println("String_Node_Str");
  out.flush();
  out.close();
}