| 425 | } |
| 426 | |
| 427 | void MemorySearchView::onSearchButtonClicked() |
| 428 | { |
| 429 | if (!cpu().isAlive()) |
| 430 | return; |
| 431 | |
| 432 | const SearchType searchType = getCurrentSearchType(); |
| 433 | const bool searchHex = m_ui.chkSearchHex->isChecked(); |
| 434 | |
| 435 | bool ok; |
| 436 | const u32 searchStart = m_ui.txtSearchStart->text().toUInt(&ok, 16); |
| 437 | |
| 438 | if (!ok) |
| 439 | { |
| 440 | AsyncDialogs::critical(this, tr("Debugger"), tr("Invalid start address")); |
| 441 | return; |
| 442 | } |
| 443 | |
| 444 | const u32 searchEnd = m_ui.txtSearchEnd->text().toUInt(&ok, 16); |
| 445 | |
| 446 | if (!ok) |
| 447 | { |
| 448 | AsyncDialogs::critical(this, tr("Debugger"), tr("Invalid end address")); |
| 449 | return; |
| 450 | } |
| 451 | |
| 452 | if (searchStart >= searchEnd) |
| 453 | { |
| 454 | AsyncDialogs::critical(this, tr("Debugger"), tr("Start address can't be equal to or greater than the end address")); |
| 455 | return; |
| 456 | } |
| 457 | |
| 458 | const QString searchValue = m_ui.txtSearchValue->text(); |
| 459 | const SearchComparison searchComparison = getCurrentSearchComparison(); |
| 460 | const bool isFilterSearch = sender() == m_ui.btnFilterSearch; |
| 461 | unsigned long long value; |
| 462 | |
| 463 | if (searchComparison != SearchComparison::UnknownValue) |
| 464 | { |
| 465 | if (doesSearchComparisonTakeInput(searchComparison)) |
| 466 | { |
| 467 | switch (searchType) |
| 468 | { |
| 469 | case SearchType::ByteType: |
| 470 | case SearchType::Int16Type: |
| 471 | case SearchType::Int32Type: |
| 472 | case SearchType::Int64Type: |
| 473 | value = searchValue.toULongLong(&ok, searchHex ? 16 : 10); |
| 474 | break; |
| 475 | case SearchType::FloatType: |
| 476 | case SearchType::DoubleType: |
| 477 | searchValue.toDouble(&ok); |
| 478 | break; |
| 479 | case SearchType::StringType: |
| 480 | ok = !searchValue.isEmpty(); |
| 481 | break; |
| 482 | case SearchType::ArrayType: |
| 483 | ok = !searchValue.trimmed().isEmpty(); |
| 484 | break; |