@@ -1458,6 +1458,7 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
1458
1458
return false ;
1459
1459
}
1460
1460
1461
+ // Handle the delete all breakpoints case:
1461
1462
if (command.empty () && !m_options.m_delete_disabled ) {
1462
1463
if (!m_options.m_force &&
1463
1464
!m_interpreter.Confirm (
@@ -1471,67 +1472,73 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
1471
1472
(uint64_t )num_breakpoints, num_breakpoints > 1 ? " s" : " " );
1472
1473
}
1473
1474
result.SetStatus (eReturnStatusSuccessFinishNoResult);
1474
- } else {
1475
- // Particular breakpoint selected; disable that breakpoint.
1476
- BreakpointIDList valid_bp_ids;
1477
-
1478
- if (m_options.m_delete_disabled ) {
1479
- BreakpointIDList excluded_bp_ids;
1475
+ return result.Succeeded ();
1476
+ }
1477
+
1478
+ // Either we have some kind of breakpoint specification(s),
1479
+ // or we are handling "break disable --deleted". Gather the list
1480
+ // of breakpoints to delete here, the we'll delete them below.
1481
+ BreakpointIDList valid_bp_ids;
1482
+
1483
+ if (m_options.m_delete_disabled ) {
1484
+ BreakpointIDList excluded_bp_ids;
1480
1485
1481
- if (!command.empty ()) {
1482
- CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (
1483
- command, &target, result, &excluded_bp_ids,
1484
- BreakpointName::Permissions::PermissionKinds::deletePerm);
1485
- }
1486
- for (auto breakpoint_sp : breakpoints.Breakpoints ()) {
1487
- if (!breakpoint_sp->IsEnabled () && breakpoint_sp->AllowDelete ()) {
1488
- BreakpointID bp_id (breakpoint_sp->GetID ());
1489
- size_t pos = 0 ;
1490
- if (!excluded_bp_ids.FindBreakpointID (bp_id, &pos))
1491
- valid_bp_ids.AddBreakpointID (breakpoint_sp->GetID ());
1492
- }
1493
- }
1494
- if (valid_bp_ids.GetSize () == 0 ) {
1495
- result.AppendError (" No disabled breakpoints." );
1496
- return false ;
1497
- }
1498
- } else {
1486
+ if (!command.empty ()) {
1499
1487
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (
1500
- command, &target, result, &valid_bp_ids ,
1488
+ command, &target, result, &excluded_bp_ids ,
1501
1489
BreakpointName::Permissions::PermissionKinds::deletePerm);
1490
+ if (!result.Succeeded ())
1491
+ return false ;
1502
1492
}
1503
-
1504
- if (result.Succeeded ()) {
1505
- int delete_count = 0 ;
1506
- int disable_count = 0 ;
1507
- const size_t count = valid_bp_ids.GetSize ();
1508
- for (size_t i = 0 ; i < count; ++i) {
1509
- BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1510
1493
1511
- if (cur_bp_id.GetBreakpointID () != LLDB_INVALID_BREAK_ID) {
1512
- if (cur_bp_id.GetLocationID () != LLDB_INVALID_BREAK_ID) {
1513
- Breakpoint *breakpoint =
1514
- target.GetBreakpointByID (cur_bp_id.GetBreakpointID ()).get ();
1515
- BreakpointLocation *location =
1516
- breakpoint->FindLocationByID (cur_bp_id.GetLocationID ()).get ();
1517
- // It makes no sense to try to delete individual locations, so we
1518
- // disable them instead.
1519
- if (location) {
1520
- location->SetEnabled (false );
1521
- ++disable_count;
1522
- }
1523
- } else {
1524
- target.RemoveBreakpointByID (cur_bp_id.GetBreakpointID ());
1525
- ++delete_count;
1526
- }
1494
+ for (auto breakpoint_sp : breakpoints.Breakpoints ()) {
1495
+ if (!breakpoint_sp->IsEnabled () && breakpoint_sp->AllowDelete ()) {
1496
+ BreakpointID bp_id (breakpoint_sp->GetID ());
1497
+ size_t pos = 0 ;
1498
+ if (!excluded_bp_ids.FindBreakpointID (bp_id, &pos))
1499
+ valid_bp_ids.AddBreakpointID (breakpoint_sp->GetID ());
1500
+ }
1501
+ }
1502
+ if (valid_bp_ids.GetSize () == 0 ) {
1503
+ result.AppendError (" No disabled breakpoints." );
1504
+ return false ;
1505
+ }
1506
+ } else {
1507
+ CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (
1508
+ command, &target, result, &valid_bp_ids,
1509
+ BreakpointName::Permissions::PermissionKinds::deletePerm);
1510
+ if (!result.Succeeded ())
1511
+ return false ;
1512
+ }
1513
+
1514
+ int delete_count = 0 ;
1515
+ int disable_count = 0 ;
1516
+ const size_t count = valid_bp_ids.GetSize ();
1517
+ for (size_t i = 0 ; i < count; ++i) {
1518
+ BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1519
+
1520
+ if (cur_bp_id.GetBreakpointID () != LLDB_INVALID_BREAK_ID) {
1521
+ if (cur_bp_id.GetLocationID () != LLDB_INVALID_BREAK_ID) {
1522
+ Breakpoint *breakpoint =
1523
+ target.GetBreakpointByID (cur_bp_id.GetBreakpointID ()).get ();
1524
+ BreakpointLocation *location =
1525
+ breakpoint->FindLocationByID (cur_bp_id.GetLocationID ()).get ();
1526
+ // It makes no sense to try to delete individual locations, so we
1527
+ // disable them instead.
1528
+ if (location) {
1529
+ location->SetEnabled (false );
1530
+ ++disable_count;
1527
1531
}
1532
+ } else {
1533
+ target.RemoveBreakpointByID (cur_bp_id.GetBreakpointID ());
1534
+ ++delete_count;
1528
1535
}
1529
- result.AppendMessageWithFormat (
1530
- " %d breakpoints deleted; %d breakpoint locations disabled.\n " ,
1531
- delete_count, disable_count);
1532
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
1533
1536
}
1534
1537
}
1538
+ result.AppendMessageWithFormat (
1539
+ " %d breakpoints deleted; %d breakpoint locations disabled.\n " ,
1540
+ delete_count, disable_count);
1541
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
1535
1542
return result.Succeeded ();
1536
1543
}
1537
1544
0 commit comments