@@ -1423,7 +1423,8 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
1423
1423
1424
1424
class CommandOptions : public Options {
1425
1425
public:
1426
- CommandOptions () : Options(), m_use_dummy(false ), m_force(false ) {}
1426
+ CommandOptions () : Options(), m_use_dummy(false ), m_force(false ),
1427
+ m_delete_disabled (false ) {}
1427
1428
1428
1429
~CommandOptions () override = default ;
1429
1430
@@ -1440,6 +1441,10 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
1440
1441
case ' D' :
1441
1442
m_use_dummy = true ;
1442
1443
break ;
1444
+
1445
+ case ' d' :
1446
+ m_delete_disabled = true ;
1447
+ break ;
1443
1448
1444
1449
default :
1445
1450
llvm_unreachable (" Unimplemented option" );
@@ -1451,6 +1456,7 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
1451
1456
void OptionParsingStarting (ExecutionContext *execution_context) override {
1452
1457
m_use_dummy = false ;
1453
1458
m_force = false ;
1459
+ m_delete_disabled = false ;
1454
1460
}
1455
1461
1456
1462
llvm::ArrayRef<OptionDefinition> GetDefinitions () override {
@@ -1460,16 +1466,18 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
1460
1466
// Instance variables to hold the values for command options.
1461
1467
bool m_use_dummy;
1462
1468
bool m_force;
1469
+ bool m_delete_disabled;
1463
1470
};
1464
1471
1465
1472
protected:
1466
1473
bool DoExecute (Args &command, CommandReturnObject &result) override {
1467
1474
Target &target = GetSelectedOrDummyTarget (m_options.m_use_dummy );
1468
-
1475
+ result.Clear ();
1476
+
1469
1477
std::unique_lock<std::recursive_mutex> lock;
1470
1478
target.GetBreakpointList ().GetListMutex (lock);
1471
1479
1472
- const BreakpointList &breakpoints = target.GetBreakpointList ();
1480
+ BreakpointList &breakpoints = target.GetBreakpointList ();
1473
1481
1474
1482
size_t num_breakpoints = breakpoints.GetSize ();
1475
1483
@@ -1479,7 +1487,7 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
1479
1487
return false ;
1480
1488
}
1481
1489
1482
- if (command.empty ()) {
1490
+ if (command.empty () && !m_options. m_delete_disabled ) {
1483
1491
if (!m_options.m_force &&
1484
1492
!m_interpreter.Confirm (
1485
1493
" About to delete all breakpoints, do you want to do that?" ,
@@ -1495,10 +1503,34 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
1495
1503
} else {
1496
1504
// Particular breakpoint selected; disable that breakpoint.
1497
1505
BreakpointIDList valid_bp_ids;
1498
- CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (
1499
- command, &target, result, &valid_bp_ids,
1500
- BreakpointName::Permissions::PermissionKinds::deletePerm) ;
1506
+
1507
+ if (m_options. m_delete_disabled ) {
1508
+ BreakpointIDList excluded_bp_ids ;
1501
1509
1510
+ if (!command.empty ()) {
1511
+ CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (
1512
+ command, &target, result, &excluded_bp_ids,
1513
+ BreakpointName::Permissions::PermissionKinds::deletePerm);
1514
+ }
1515
+ for (auto breakpoint_sp : breakpoints.Breakpoints ()) {
1516
+ if (!breakpoint_sp->IsEnabled () && breakpoint_sp->AllowDelete ()) {
1517
+ BreakpointID bp_id (breakpoint_sp->GetID ());
1518
+ size_t pos = 0 ;
1519
+ if (!excluded_bp_ids.FindBreakpointID (bp_id, &pos))
1520
+ valid_bp_ids.AddBreakpointID (breakpoint_sp->GetID ());
1521
+ }
1522
+ }
1523
+ if (valid_bp_ids.GetSize () == 0 ) {
1524
+ result.AppendError (" No disabled breakpoints." );
1525
+ result.SetStatus (eReturnStatusFailed);
1526
+ return false ;
1527
+ }
1528
+ } else {
1529
+ CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (
1530
+ command, &target, result, &valid_bp_ids,
1531
+ BreakpointName::Permissions::PermissionKinds::deletePerm);
1532
+ }
1533
+
1502
1534
if (result.Succeeded ()) {
1503
1535
int delete_count = 0 ;
1504
1536
int disable_count = 0 ;
0 commit comments