Program: 5691
Project: 5691
Buggy source:
public void setupCommands(ComponentRegistry registry,CommandHandler ch){
  this.registry=registry;
  final MSP430 cpu=(MSP430)registry.getComponent(MSP430.class);
  final ELF elf=(ELF)registry.getComponent(ELF.class);
  final GenericNode node=(GenericNode)registry.getComponent("String_Node_Str");
  if (cpu != null) {
    ch.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
      int address=0;
      public int executeCommand(      final CommandContext context){
        int baddr=context.getArgumentAsAddress(0);
        cpu.setBreakPoint(address=baddr,new CPUMonitor(){
          public void cpuAction(          int type,          int adr,          int data){
            context.out.println("String_Node_Str" + adr);
          }
        }
);
        context.out.println("String_Node_Str" + baddr);
        return 0;
      }
      public void stopCommand(      CommandContext context){
        cpu.clearBreakPoint(address);
      }
    }
);
    ch.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
      int mode=0;
      int address=0;
      public int executeCommand(      final CommandContext context){
        int baddr=context.getArgumentAsAddress(0);
        if (baddr == -1) {
          context.out.println("String_Node_Str" + context.getArgument(0));
          return -1;
        }
        if (context.getArgumentCount() > 1) {
          String modeStr=context.getArgument(1);
          if ("String_Node_Str".equals(modeStr)) {
            mode=1;
          }
 else           if ("String_Node_Str".equals(modeStr)) {
            mode=2;
          }
        }
        cpu.setBreakPoint(address=baddr,new CPUMonitor(){
          public void cpuAction(          int type,          int adr,          int data){
            if (mode == 0 || mode == 2) {
              int pc=cpu.readRegister(0);
              String adrStr=getSymOrAddr(context,adr);
              String pcStr=getSymOrAddrELF(elf,pc);
              String op="String_Node_Str";
              if (type == MEMORY_READ) {
                op="String_Node_Str";
              }
 else               if (type == MEMORY_WRITE) {
                op="String_Node_Str";
              }
              context.out.println("String_Node_Str" + op + "String_Node_Str"+ pcStr+ "String_Node_Str"+ adrStr+ "String_Node_Str"+ data);
              if (mode == 2) {
                cpu.stop();
              }
            }
 else {
              context.out.print((char)data);
            }
          }
        }
);
        context.out.println("String_Node_Str" + baddr);
        return 0;
      }
      public void stopCommand(      CommandContext context){
        cpu.clearBreakPoint(address);
        context.exit(0);
      }
    }
);
    ch.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
      int mode=0;
      int register=0;
      public int executeCommand(      final CommandContext context){
        register=context.getArgumentAsRegister(0);
        if (register < 0) {
          return -1;
        }
        if (context.getArgumentCount() > 1) {
          String modeStr=context.getArgument(1);
          if ("String_Node_Str".equals(modeStr)) {
            mode=1;
          }
 else {
            context.err.println("String_Node_Str" + modeStr);
            return -1;
          }
        }
        cpu.setRegisterWriteMonitor(register,new CPUMonitor(){
          public void cpuAction(          int type,          int adr,          int data){
            if (mode == 0) {
              int pc=cpu.readRegister(0);
              String adrStr=getRegisterName(register);
              String pcStr=getSymOrAddrELF(elf,pc);
              context.out.println("String_Node_Str" + pcStr + "String_Node_Str"+ adrStr+ "String_Node_Str"+ data);
            }
 else {
              context.out.println(data);
            }
          }
        }
);
        context.out.println("String_Node_Str" + getRegisterName(register));
        return 0;
      }
      public void stopCommand(      CommandContext context){
        cpu.clearBreakPoint(register);
      }
    }
);
    ch.registerCommand("String_Node_Str",new Command(){
      public int executeCommand(      final CommandContext context){
        int baddr=context.getArgumentAsAddress(0);
        cpu.setBreakPoint(baddr,null);
        return 0;
      }
      public String getArgumentHelp(      String commandName){
        return "String_Node_Str";
      }
      public String getCommandHelp(      String commandName){
        return "String_Node_Str";
      }
    }
);
    ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
      public int executeCommand(      final CommandContext context){
        String regExp=context.getArgument(0);
        MapEntry[] entries=context.getMapTable().getEntries(regExp);
        for (int i=0; i < entries.length; i++) {
          MapEntry mapEntry=entries[i];
          context.out.println("String_Node_Str" + mapEntry.getName() + "String_Node_Str"+ Utils.hex16(mapEntry.getAddress()));
        }
        return 0;
      }
    }
);
    if (node != null) {
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          node.stop();
          context.out.println("String_Node_Str" + Utils.hex16(cpu.readRegister(0)));
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          node.start();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          int nr=context.getArgumentCount() > 0 ? context.getArgumentAsInt(0) : 1;
          long cyc=cpu.cycles;
          node.step(nr);
          context.out.println("String_Node_Str" + Utils.hex16(cpu.readRegister(0)) + "String_Node_Str"+ (cpu.cycles - cyc)+ "String_Node_Str"+ cpu.cycles+ "String_Node_Str");
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          int stackEnd=context.getMapTable().heapStartAddress;
          int stackStart=context.getMapTable().stackStartAddress;
          int current=cpu.readRegister(MSP430Constants.SP);
          context.out.println("String_Node_Str" + Utils.hex16(current) + "String_Node_Str"+ (stackStart - current)+ "String_Node_Str"+ (stackStart - stackEnd)+ ')');
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          int adr=context.getArgumentAsAddress(0);
          if (adr != -1) {
            context.out.println("String_Node_Str" + context.getArgument(0) + "String_Node_Str"+ Utils.hex16(cpu.read(adr,adr >= 0x100)));
          }
 else {
            context.out.println("String_Node_Str");
          }
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          int register=context.getArgumentAsRegister(0);
          if (register >= 0) {
            context.out.println(context.getArgument(0) + "String_Node_Str" + Utils.hex16(cpu.readRegister(register)));
            return 0;
          }
          return -1;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          cpu.reset();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          long time=((long)(cpu.getTimeMillis()));
          context.out.println("String_Node_Str" + time + "String_Node_Str"+ (time - lastCall)+ "String_Node_Str"+ "String_Node_Str"+ (System.currentTimeMillis() - lastWall)+ "String_Node_Str");
          lastCall=time;
          lastWall=System.currentTimeMillis();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        final CommandContext context){
          int start=context.getArgumentAsAddress(0);
          int count=context.getArgumentAsInt(1);
          int size=1;
          boolean signed=false;
          if (context.getArgumentCount() > 2) {
            String tS=context.getArgument(2);
            if ("String_Node_Str".equals(tS)) {
              signed=true;
            }
 else             if ("String_Node_Str".equals(tS)) {
              signed=true;
              size=2;
            }
 else             if ("String_Node_Str".equals(tS)) {
              size=2;
            }
          }
          for (int i=0; i < count; i++) {
            int data=0;
            data=cpu.memory[start++];
            if (size == 2) {
              data=data + (cpu.memory[start++] << 8);
            }
            context.out.print("String_Node_Str" + data);
          }
          context.out.println();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        final CommandContext context){
          int adr=context.getArgumentAsAddress(0);
          int val=context.getArgumentAsInt(1);
          boolean word=val > 0xff;
          cpu.write(adr,val,word);
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        final CommandContext context){
          Memory xmem=(Memory)DebugCommands.this.registry.getComponent("String_Node_Str");
          if (xmem == null) {
            context.err.println("String_Node_Str");
            return 0;
          }
          int start=context.getArgumentAsAddress(0);
          int count=context.getArgumentAsInt(1);
          int size=1;
          boolean signed=false;
          if (context.getArgumentCount() > 2) {
            String tS=context.getArgument(2);
            if ("String_Node_Str".equals(tS)) {
              signed=true;
            }
 else             if ("String_Node_Str".equals(tS)) {
              signed=true;
              size=2;
            }
 else             if ("String_Node_Str".equals(tS)) {
              size=2;
            }
          }
          for (int i=0; i < count; i++) {
            int data=0;
            data=xmem.readByte(start++);
            if (size == 2) {
              data=data + (xmem.readByte(start++) << 8);
            }
            context.out.print("String_Node_Str" + data);
          }
          context.out.println();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        final CommandContext context){
          Memory xmem=(Memory)DebugCommands.this.registry.getComponent("String_Node_Str");
          if (xmem == null) {
            context.err.println("String_Node_Str");
            return 0;
          }
          int adr=context.getArgumentAsAddress(0);
          int val=context.getArgumentAsInt(1);
          boolean word=val > 0xff;
          if (word) {
            xmem.writeByte(adr,val >> 8);
            val=val & 0xff;
            adr++;
          }
          xmem.writeByte(adr,val & 0xff);
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        @Override public int executeCommand(        CommandContext context){
          Chip[] chips=cpu.getChips();
          for (int i=0; i < chips.length; i++) {
            context.out.println(chips[i].getName());
          }
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
        Chip chip=null;
        @Override public int executeCommand(        CommandContext context){
          chip=cpu.getChip(context.getArgument(0));
          if (chip == null) {
            context.err.println("String_Node_Str" + context.getArgument(0));
          }
          chip.setLogStream(context.out);
          return 0;
        }
        public void stopCommand(        CommandContext context){
          chip.clearLogStream();
        }
      }
);
    }
  }
}

Fixed version (ground truth):
public void setupCommands(ComponentRegistry registry,CommandHandler ch){
  this.registry=registry;
  final MSP430 cpu=(MSP430)registry.getComponent(MSP430.class);
  final ELF elf=(ELF)registry.getComponent(ELF.class);
  final GenericNode node=(GenericNode)registry.getComponent("String_Node_Str");
  if (cpu != null) {
    ch.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
      int address=0;
      public int executeCommand(      final CommandContext context){
        int baddr=context.getArgumentAsAddress(0);
        cpu.setBreakPoint(address=baddr,new CPUMonitor(){
          public void cpuAction(          int type,          int adr,          int data){
            context.out.println("String_Node_Str" + adr);
          }
        }
);
        context.out.println("String_Node_Str" + baddr);
        return 0;
      }
      public void stopCommand(      CommandContext context){
        cpu.clearBreakPoint(address);
      }
    }
);
    ch.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
      int mode=0;
      int address=0;
      public int executeCommand(      final CommandContext context){
        int baddr=context.getArgumentAsAddress(0);
        if (baddr == -1) {
          context.out.println("String_Node_Str" + context.getArgument(0));
          return -1;
        }
        if (context.getArgumentCount() > 1) {
          String modeStr=context.getArgument(1);
          if ("String_Node_Str".equals(modeStr)) {
            mode=1;
          }
 else           if ("String_Node_Str".equals(modeStr)) {
            mode=2;
          }
        }
        cpu.setBreakPoint(address=baddr,new CPUMonitor(){
          public void cpuAction(          int type,          int adr,          int data){
            if (mode == 0 || mode == 2) {
              int pc=cpu.readRegister(0);
              String adrStr=getSymOrAddr(context,adr);
              String pcStr=getSymOrAddrELF(elf,pc);
              String op="String_Node_Str";
              if (type == MEMORY_READ) {
                op="String_Node_Str";
              }
 else               if (type == MEMORY_WRITE) {
                op="String_Node_Str";
              }
              context.out.println("String_Node_Str" + op + "String_Node_Str"+ pcStr+ "String_Node_Str"+ adrStr+ "String_Node_Str"+ data);
              if (mode == 2) {
                cpu.stop();
              }
            }
 else {
              context.out.print((char)data);
            }
          }
        }
);
        context.out.println("String_Node_Str" + baddr);
        return 0;
      }
      public void stopCommand(      CommandContext context){
        cpu.clearBreakPoint(address);
        context.exit(0);
      }
    }
);
    ch.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
      int mode=0;
      int register=0;
      public int executeCommand(      final CommandContext context){
        register=context.getArgumentAsRegister(0);
        if (register < 0) {
          return -1;
        }
        if (context.getArgumentCount() > 1) {
          String modeStr=context.getArgument(1);
          if ("String_Node_Str".equals(modeStr)) {
            mode=1;
          }
 else {
            context.err.println("String_Node_Str" + modeStr);
            return -1;
          }
        }
        cpu.setRegisterWriteMonitor(register,new CPUMonitor(){
          public void cpuAction(          int type,          int adr,          int data){
            if (mode == 0) {
              int pc=cpu.readRegister(0);
              String adrStr=getRegisterName(register);
              String pcStr=getSymOrAddrELF(elf,pc);
              context.out.println("String_Node_Str" + pcStr + "String_Node_Str"+ adrStr+ "String_Node_Str"+ data);
            }
 else {
              context.out.println(data);
            }
          }
        }
);
        context.out.println("String_Node_Str" + getRegisterName(register));
        return 0;
      }
      public void stopCommand(      CommandContext context){
        cpu.clearBreakPoint(register);
      }
    }
);
    ch.registerCommand("String_Node_Str",new Command(){
      public int executeCommand(      final CommandContext context){
        int baddr=context.getArgumentAsAddress(0);
        cpu.setBreakPoint(baddr,null);
        return 0;
      }
      public String getArgumentHelp(      String commandName){
        return "String_Node_Str";
      }
      public String getCommandHelp(      String commandName){
        return "String_Node_Str";
      }
    }
);
    ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
      public int executeCommand(      final CommandContext context){
        String regExp=context.getArgument(0);
        MapEntry[] entries=context.getMapTable().getEntries(regExp);
        for (int i=0; i < entries.length; i++) {
          MapEntry mapEntry=entries[i];
          int address=mapEntry.getAddress();
          context.out.println("String_Node_Str" + mapEntry.getName() + "String_Node_Str"+ Utils.hex16(address)+ "String_Node_Str"+ Utils.hex8(cpu.memory[address])+ "String_Node_Str"+ Utils.hex8(cpu.memory[address + 1])+ "String_Node_Str");
        }
        return 0;
      }
    }
);
    if (node != null) {
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          node.stop();
          context.out.println("String_Node_Str" + Utils.hex16(cpu.readRegister(0)));
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          node.start();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          int nr=context.getArgumentCount() > 0 ? context.getArgumentAsInt(0) : 1;
          long cyc=cpu.cycles;
          node.step(nr);
          context.out.println("String_Node_Str" + Utils.hex16(cpu.readRegister(0)) + "String_Node_Str"+ (cpu.cycles - cyc)+ "String_Node_Str"+ cpu.cycles+ "String_Node_Str");
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          int stackEnd=context.getMapTable().heapStartAddress;
          int stackStart=context.getMapTable().stackStartAddress;
          int current=cpu.readRegister(MSP430Constants.SP);
          context.out.println("String_Node_Str" + Utils.hex16(current) + "String_Node_Str"+ (stackStart - current)+ "String_Node_Str"+ (stackStart - stackEnd)+ ')');
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          int adr=context.getArgumentAsAddress(0);
          if (adr != -1) {
            context.out.println("String_Node_Str" + context.getArgument(0) + "String_Node_Str"+ Utils.hex16(cpu.read(adr,adr >= 0x100)));
          }
 else {
            context.out.println("String_Node_Str");
          }
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          int register=context.getArgumentAsRegister(0);
          if (register >= 0) {
            context.out.println(context.getArgument(0) + "String_Node_Str" + Utils.hex16(cpu.readRegister(register)));
            return 0;
          }
          return -1;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          cpu.reset();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        CommandContext context){
          long time=((long)(cpu.getTimeMillis()));
          context.out.println("String_Node_Str" + time + "String_Node_Str"+ (time - lastCall)+ "String_Node_Str"+ "String_Node_Str"+ (System.currentTimeMillis() - lastWall)+ "String_Node_Str");
          lastCall=time;
          lastWall=System.currentTimeMillis();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        final CommandContext context){
          int start=context.getArgumentAsAddress(0);
          int count=context.getArgumentAsInt(1);
          int size=1;
          boolean signed=false;
          if (context.getArgumentCount() > 2) {
            String tS=context.getArgument(2);
            if ("String_Node_Str".equals(tS)) {
              signed=true;
            }
 else             if ("String_Node_Str".equals(tS)) {
              signed=true;
              size=2;
            }
 else             if ("String_Node_Str".equals(tS)) {
              size=2;
            }
          }
          for (int i=0; i < count; i++) {
            int data=0;
            data=cpu.memory[start++];
            if (size == 2) {
              data=data + (cpu.memory[start++] << 8);
            }
            context.out.print("String_Node_Str" + data);
          }
          context.out.println();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        final CommandContext context){
          int adr=context.getArgumentAsAddress(0);
          int val=context.getArgumentAsInt(1);
          boolean word=val > 0xff;
          cpu.write(adr,val,word);
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        final CommandContext context){
          Memory xmem=(Memory)DebugCommands.this.registry.getComponent("String_Node_Str");
          if (xmem == null) {
            context.err.println("String_Node_Str");
            return 0;
          }
          int start=context.getArgumentAsAddress(0);
          int count=context.getArgumentAsInt(1);
          int size=1;
          boolean signed=false;
          if (context.getArgumentCount() > 2) {
            String tS=context.getArgument(2);
            if ("String_Node_Str".equals(tS)) {
              signed=true;
            }
 else             if ("String_Node_Str".equals(tS)) {
              signed=true;
              size=2;
            }
 else             if ("String_Node_Str".equals(tS)) {
              size=2;
            }
          }
          for (int i=0; i < count; i++) {
            int data=0;
            data=xmem.readByte(start++);
            if (size == 2) {
              data=data + (xmem.readByte(start++) << 8);
            }
            context.out.print("String_Node_Str" + data);
          }
          context.out.println();
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        public int executeCommand(        final CommandContext context){
          Memory xmem=(Memory)DebugCommands.this.registry.getComponent("String_Node_Str");
          if (xmem == null) {
            context.err.println("String_Node_Str");
            return 0;
          }
          int adr=context.getArgumentAsAddress(0);
          int val=context.getArgumentAsInt(1);
          boolean word=val > 0xff;
          if (word) {
            xmem.writeByte(adr,val >> 8);
            val=val & 0xff;
            adr++;
          }
          xmem.writeByte(adr,val & 0xff);
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
        @Override public int executeCommand(        CommandContext context){
          Chip[] chips=cpu.getChips();
          for (int i=0; i < chips.length; i++) {
            context.out.println(chips[i].getName());
          }
          return 0;
        }
      }
);
      ch.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
        Chip chip=null;
        @Override public int executeCommand(        CommandContext context){
          chip=cpu.getChip(context.getArgument(0));
          if (chip == null) {
            context.err.println("String_Node_Str" + context.getArgument(0));
          }
          chip.setLogStream(context.out);
          return 0;
        }
        public void stopCommand(        CommandContext context){
          chip.clearLogStream();
        }
      }
);
    }
  }
}