Пример #1
0
        public bool Compare(Stream regStream, BreakpointType bpType, UInt32 bpAddress, USBGecko gecko)
        {
            if (regStream.Length != 0x120)
            {
                return(false);
            }

            int spos = PRegister * 4;

            UInt32 val = 0;

            if (spos == 0x120) //Value of address is supposed to be checked
            {
                switch (bpType)
                {
                case BreakpointType.Read:
                    val = gecko.peek(bpAddress);
                    break;

                case BreakpointType.ReadWrite:
                case BreakpointType.Write:
                    gecko.Step();
                    val = gecko.peek(bpAddress);
                    break;

                default:
                    return(true);
                }
            }
            else
            {
                regStream.Seek(spos, SeekOrigin.Begin);
                val = GlobalFunctions.ReadStream(regStream);
            }

            switch (PCondition)
            {
            case BreakpointComparison.Equal:
                return(val == PValue);

            case BreakpointComparison.NotEqual:
                return(val != PValue);

            case BreakpointComparison.Greater:
                return(val > PValue);

            case BreakpointComparison.GreaterEqual:
                return(val >= PValue);

            case BreakpointComparison.Lower:
                return(val < PValue);

            case BreakpointComparison.LowerEqual:
                return(val <= PValue);
            }

            return(true);
        }
Пример #2
0
        private void CellSelectionChange(object sender, EventArgs e)
        {
            UInt32 sAddress = cAddress & 0xFFFFFFF0;

            if (gView.SelectedCells.Count > 0)
            {
                int col = gView.SelectedCells[0].ColumnIndex;
                int row = gView.SelectedCells[0].RowIndex;
                if (col == 0)
                {
                    gView.Rows[oldRow].Cells[oldCol].Selected = true;
                }
                else
                {
                    oldCol = col;
                    oldRow = row;
                    UInt32 addr = (UInt32)(sAddress + row * 16 + (col - 1) * 4);

                    // Nothing to update if the address didn't change
                    if (selAddress == addr)
                    {
                        return;
                    }

                    selAddress       = addr;
                    pokeAddress.Text = GlobalFunctions.toHex(addr);
                    try
                    {
                        UInt32 locValue = 0;
                        if (gecko.connected)
                        {
                            locValue = gecko.peek(addr);
                        }
                        pokeValue.Text = GlobalFunctions.toHex(locValue);
                        fpValue.Text   = GlobalFunctions.UIntToSingle(locValue).ToString("G6");
                    }
                    catch (EUSBGeckoException exc)
                    {
                        exceptionHandling.HandleException(exc);
                    }
                }
            }
        }
Пример #3
0
        private void UpdateList()
        {
            try
            {
                int            i, j;
                UInt32[]       address;
                UInt32         peekAddress, actAddress, peekValue;
                WatchDataSize  dataSize;
                UInt32         dumpAnd;
                String         aOutput, vOutput;
                UInt32         add;
                bool           pointer, vPointer, vAddress;
                int            maxCount = Math.Min(addressWatchList.Count, watchOut.RowCount);
                DoubleString[] oUp      =
                    new DoubleString[maxCount];
                for (i = 0; i < maxCount; i++)
                {
                    // Skip over any rows that aren't displayed
                    if (!isRowDisplayed(watchOut, i))
                    {
                        continue;
                    }
                    address  = addressWatchList[i].address;
                    pointer  = address.Length > 1;
                    dataSize = addressWatchList[i].dataSize;
                    switch (dataSize)
                    {
                    case WatchDataSize.Bit8:
                        dumpAnd = 0xFFFFFFFF;
                        break;

                    case WatchDataSize.Bit16:
                        dumpAnd = 0xFFFFFFFE;
                        break;

                    default:
                        dumpAnd = 0xFFFFFFFC;
                        break;
                    }
                    vPointer    = true;
                    peekAddress = address[0];

                    for (j = 1; j < address.Length; j++)
                    {
                        if (ValidMemory.validAddress(peekAddress, enableDebug))
                        {
                            peekAddress &= 0xFFFFFFFC;
                            peekAddress  = gecko.peek(peekAddress);
                            peekAddress += address[j];
                        }
                        else
                        {
                            vPointer = false;
                            break;
                        }
                    }

                    vAddress = vPointer && ValidMemory.validAddress(peekAddress, enableDebug);
                    if (pointer)
                    {
                        aOutput = "P->";
                        if (vPointer)
                        {
                            aOutput += GlobalFunctions.toHex(peekAddress);
                        }
                        else
                        {
                            aOutput += "????????";
                        }
                    }
                    else
                    {
                        aOutput = GlobalFunctions.toHex(peekAddress);
                    }

                    if (vAddress)
                    {
                        actAddress   = peekAddress;
                        peekAddress &= 0xFFFFFFFC;
                        add          = actAddress - peekAddress;
                        add         &= dumpAnd;
                        peekValue    = gecko.peek(peekAddress);
                        vOutput      = ParseValue(peekValue, dataSize, add, addressWatchList[i]);

                        addressWatchList[i].addressAvail   = true;
                        addressWatchList[i].updatedAddress = peekAddress + add;
                    }
                    else
                    {
                        vOutput = "????????";
                        addressWatchList[i].addressAvail = false;
                    }
                    oUp[i].address = aOutput;
                    oUp[i].value   = vOutput;
                    watchOut.Invoke((MethodInvoker) delegate
                    {
                        watchOut.Rows[i].Cells[1].Value = oUp[i].address;
                        watchOut.Rows[i].Cells[3].Value = oUp[i].value;
                    });
                }

                //watchOut.Invoke((MethodInvoker)delegate
                // {
                //     for (i = 0; i < maxCount; i++)
                //     {
                //         watchOut.Rows[i].Cells[1].Value = oUp[i].address;
                //         watchOut.Rows[i].Cells[3].Value = oUp[i].value;
                //     }
                // });
            }
            catch (EUSBGeckoException e)
            {
                listEnabled = false;
                exceptionHandling.HandleException(e);
            }
            catch
            {
            }
        }
Пример #4
0
        public String GetStepLog()
        {
            String          DetailedInstruction = currentInstructionAndAddress;
            String          regDetails;
            MatchCollection getRegDetails;

            if (currentInstructionAndAddress == null)
            {
                return(String.Empty);
            }

            String[] Padding = DetailedInstruction.Split('\t');

            // this will help align things
            if (Padding.Length < 3)
            {
                DetailedInstruction += "        ";
            }
            else if (Padding[2].Length < 8)
            {
                for (int i = 8 - Padding[2].Length; i > 0; i--)
                {
                    DetailedInstruction += " ";
                }
            }

            // Get all the places where there's an LR
            getRegDetails = Regex.Matches(DetailedInstruction, "lr");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                regDetails = "LR = " + GlobalFunctions.toHex(GetRegisterValue(39));
                //DetailedInstruction = DetailedInstruction.Insert(getRegDetails[i].Index + getRegDetails[i].Length, regDetails);
                DetailedInstruction += "\t" + regDetails;
            }

            // Get all the places where there's an f0-f31
            // TODO: not 0-9 or a-f!
            // TODO: over matching?  switch to trying to find the 0x to determine when not a float reg?
            //getRegDetails = Regex.Matches(DetailedInstruction, "([^0-9]f[0-9][^0-9])|" +
            //                                                  "([^0-9]f1[0-9][^0-9])|" +
            //                                                  "([^0-9]f2[0-9][^0-9])|" +
            //                                                  "([^0-9]f3[01][^0-9])");

            if (!Regex.Match(DetailedInstruction, "0x").Success)
            {
                getRegDetails = Regex.Matches(DetailedInstruction, "f[0-9]+");

                for (int i = 0; i < getRegDetails.Count; i++)
                {
                    string floatReg = getRegDetails[i].Value;
                    int    index    = Int32.Parse(floatReg.Substring(1)) + 40;
                    Single floatVal = GetFloatRegisterValue(index);
                    regDetails = floatReg + " = " + floatVal.ToString("G6");
                    //DetailedInstruction = DetailedInstruction.Insert(getRegDetails[i].Index + getRegDetails[i].Length, regDetails);
                    DetailedInstruction += "\t" + regDetails;
                }
            }

            // Get all the places where there's an r0-r31
            getRegDetails = Regex.Matches(DetailedInstruction, "r[0-9]+");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                regDetails = getRegDetails[i].Value + " = " + GlobalFunctions.toHex(GetRegisterValue(Int32.Parse(getRegDetails[i].Value.Substring(1)) + 7));
                //DetailedInstruction = DetailedInstruction.Insert(getRegDetails[i].Index + getRegDetails[i].Length, regDetails);
                DetailedInstruction += "\t" + regDetails;
            }

            getRegDetails = Regex.Matches(DetailedInstruction, "\\(r[0-9]+\\)");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                if (ValidMemory.validAddress(MemoryAddress))
                {
                    regDetails = "[" + GlobalFunctions.toHex(MemoryAddress) + "] = " + GlobalFunctions.toHex(gecko.peek(MemoryAddress));
                    //DetailedInstruction = DetailedInstruction.Insert(getRegDetails[i].Index + getRegDetails[i].Length, regDetails);
                    if (Regex.Match(DetailedInstruction, "lfd|stfd").Success)
                    {
                        regDetails += GlobalFunctions.toHex(gecko.peek(MemoryAddress + 4));
                    }
                    DetailedInstruction += "\t" + regDetails;
                }
            }

            //if (IsTakenBranch())
            if ((isConditionalBranch(currentInstruction) && BranchTaken(currentInstruction)) || currentInstruction[0] == "b")
            {
                DetailedInstruction += "\r\n";
                for (int i = 0; i < logIndent; i++)
                {
                    DetailedInstruction += "|  ";
                }
                DetailedInstruction += "\t...\t...\t...\t...";
            }

            if (logIndent > 0)
            {
                for (int i = 0; i < logIndent; i++)
                {
                    DetailedInstruction = DetailedInstruction.Insert(0, "|  ");
                }
            }

            if (IsBL())
            {
                logIndent++;
            }

            if (logIndent > 0 && IsBLR())
            {
                logIndent--;
            }

            return(DetailedInstruction);
        }
Пример #5
0
        public bool Compare(Stream regStream, BreakpointType bpType, UInt32 bpAddress, USBGecko gecko)
        {
            if (regStream.Length != 0x120)
                return false;
            
            int spos = PRegister * 4;

            UInt32 val = 0;
            if (spos == 0x120) //Value of address is supposed to be checked
            {
                switch (bpType)
                {                    
                    case BreakpointType.Read:
                        val = gecko.peek(bpAddress);
                        break;
                    case BreakpointType.ReadWrite:
                    case BreakpointType.Write:
                        gecko.Step();
                        val = gecko.peek(bpAddress);
                        break;
                    default:
                        return true;
                }
            }
            else
            {
                regStream.Seek(spos, SeekOrigin.Begin);
                val = GlobalFunctions.ReadStream(regStream);
            }

            switch (PCondition)
            {
                case BreakpointComparison.Equal:
                    return (val == PValue);
                case BreakpointComparison.NotEqual:
                    return (val != PValue);
                case BreakpointComparison.Greater:
                    return (val > PValue);
                case BreakpointComparison.GreaterEqual:
                    return (val >= PValue);
                case BreakpointComparison.Lower:
                    return (val < PValue);
                case BreakpointComparison.LowerEqual:
                    return (val <= PValue);
            }

            return true;
        }