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