@@ -1591,26 +1591,6 @@ class CommandObjectProcessHandle : public CommandObjectParsed {
1591
1591
1592
1592
Options *GetOptions () override { return &m_options; }
1593
1593
1594
- std::optional<bool > VerifyCommandOptionValue (const std::string &option) {
1595
- if (option.empty ())
1596
- return std::nullopt;
1597
-
1598
- bool success = false ;
1599
- bool tmp_value = OptionArgParser::ToBoolean (option, false , &success);
1600
- if (success)
1601
- return tmp_value;
1602
-
1603
- int parsed_value = -1 ;
1604
- if (llvm::to_integer (option, parsed_value)) {
1605
- if (parsed_value != 0 && parsed_value != 1 )
1606
- return std::nullopt;
1607
-
1608
- return parsed_value == 0 ? false : true ;
1609
- }
1610
-
1611
- return std::nullopt;
1612
- }
1613
-
1614
1594
void PrintSignalHeader (Stream &str) {
1615
1595
str.Printf (" NAME PASS STOP NOTIFY\n " );
1616
1596
str.Printf (" =========== ===== ===== ======\n " );
@@ -1666,27 +1646,48 @@ class CommandObjectProcessHandle : public CommandObjectParsed {
1666
1646
// the user's options.
1667
1647
ProcessSP process_sp = target.GetProcessSP ();
1668
1648
1669
- std::optional<bool > stop_action = VerifyCommandOptionValue (m_options.stop );
1670
- std::optional<bool > pass_action = VerifyCommandOptionValue (m_options.pass );
1671
- std::optional<bool > notify_action =
1672
- VerifyCommandOptionValue (m_options.notify );
1649
+ std::optional<bool > stop_action = {};
1650
+ std::optional<bool > pass_action = {};
1651
+ std::optional<bool > notify_action = {};
1673
1652
1674
- if (!m_options.stop .empty () && !stop_action.has_value ()) {
1675
- result.AppendError (" Invalid argument for command option --stop; must be "
1676
- " true or false.\n " );
1677
- return ;
1653
+ if (!m_options.stop .empty ()) {
1654
+ bool success = false ;
1655
+ bool value = OptionArgParser::ToBoolean (m_options.stop , false , &success);
1656
+ if (!success) {
1657
+ result.AppendError (
1658
+ " Invalid argument for command option --stop; must be "
1659
+ " true or false.\n " );
1660
+ return ;
1661
+ }
1662
+
1663
+ stop_action = value;
1678
1664
}
1679
1665
1680
- if (!m_options.pass .empty () && !pass_action.has_value ()) {
1681
- result.AppendError (" Invalid argument for command option --pass; must be "
1682
- " true or false.\n " );
1683
- return ;
1666
+ if (!m_options.pass .empty ()) {
1667
+ bool success = false ;
1668
+ bool value = OptionArgParser::ToBoolean (m_options.pass , false , &success);
1669
+ if (!success) {
1670
+ result.AppendError (
1671
+ " Invalid argument for command option --pass; must be "
1672
+ " true or false.\n " );
1673
+ return ;
1674
+ }
1675
+ pass_action = value;
1676
+ }
1677
+
1678
+ if (!m_options.notify .empty ()) {
1679
+ bool success = false ;
1680
+ bool value =
1681
+ OptionArgParser::ToBoolean (m_options.notify , false , &success);
1682
+ if (!success) {
1683
+ result.AppendError (" Invalid argument for command option --notify; must "
1684
+ " be true or false.\n " );
1685
+ return ;
1686
+ }
1687
+ notify_action = value;
1684
1688
}
1685
1689
1686
1690
if (!m_options.notify .empty () && !notify_action.has_value ()) {
1687
- result.AppendError (" Invalid argument for command option --notify; must "
1688
- " be true or false.\n " );
1689
- return ;
1690
1691
}
1691
1692
1692
1693
bool no_actions = (!stop_action.has_value () && !pass_action.has_value () &&
@@ -1728,8 +1729,6 @@ class CommandObjectProcessHandle : public CommandObjectParsed {
1728
1729
if (signals_sp) {
1729
1730
int32_t signo = signals_sp->GetSignalNumberFromName (arg.c_str ());
1730
1731
if (signo != LLDB_INVALID_SIGNAL_NUMBER) {
1731
- // Casting the actions as bools here should be okay, because
1732
- // VerifyCommandOptionValue guarantees the value is either 0 or 1.
1733
1732
if (stop_action.has_value ())
1734
1733
signals_sp->SetShouldStop (signo, *stop_action);
1735
1734
if (pass_action.has_value ()) {
0 commit comments