@@ -460,17 +460,13 @@ void Breakpoint::ResolveBreakpointInModules(ModuleList &module_list,
460
460
// If this is not an internal breakpoint, set up to record the new
461
461
// locations, then dispatch an event with the new locations.
462
462
if (!IsInternal () && send_event) {
463
- BreakpointEventData * new_locations_event = new BreakpointEventData (
464
- eBreakpointEventTypeLocationsAdded, shared_from_this ());
465
-
463
+ std::shared_ptr< BreakpointEventData> new_locations_event =
464
+ std::make_shared<BreakpointEventData>(
465
+ eBreakpointEventTypeLocationsAdded, shared_from_this ());
466
466
ResolveBreakpointInModules (
467
467
module_list, new_locations_event->GetBreakpointLocationCollection ());
468
-
469
- if (new_locations_event->GetBreakpointLocationCollection ().GetSize () !=
470
- 0 ) {
468
+ if (new_locations_event->GetBreakpointLocationCollection ().GetSize () != 0 )
471
469
SendBreakpointChangedEvent (new_locations_event);
472
- } else
473
- delete new_locations_event;
474
470
} else {
475
471
ElapsedTime elapsed (m_resolve_time);
476
472
m_resolver_sp->ResolveBreakpointInModules (*m_filter_sp, module_list);
@@ -565,12 +561,10 @@ void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
565
561
// the module list, then remove their breakpoint sites, and their locations
566
562
// if asked to.
567
563
568
- BreakpointEventData * removed_locations_event;
564
+ std::shared_ptr< BreakpointEventData> removed_locations_event;
569
565
if (!IsInternal ())
570
- removed_locations_event = new BreakpointEventData (
566
+ removed_locations_event = std::make_shared< BreakpointEventData> (
571
567
eBreakpointEventTypeLocationsRemoved, shared_from_this ());
572
- else
573
- removed_locations_event = nullptr ;
574
568
575
569
for (ModuleSP module_sp : module_list.Modules ()) {
576
570
if (m_filter_sp->ModulePasses (module_sp)) {
@@ -795,31 +789,30 @@ void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
795
789
// about telling the world about removing a location we didn't tell them
796
790
// about adding.
797
791
798
- BreakpointEventData *locations_event ;
792
+ std::shared_ptr< BreakpointEventData> removed_locations_event ;
799
793
if (!IsInternal ())
800
- locations_event = new BreakpointEventData (
794
+ removed_locations_event = std::make_shared< BreakpointEventData> (
801
795
eBreakpointEventTypeLocationsRemoved, shared_from_this ());
802
- else
803
- locations_event = nullptr ;
804
796
805
797
for (BreakpointLocationSP loc_sp :
806
798
locations_to_remove.BreakpointLocations ()) {
807
799
m_locations.RemoveLocation (loc_sp);
808
- if (locations_event )
809
- locations_event ->GetBreakpointLocationCollection ().Add (loc_sp);
800
+ if (removed_locations_event )
801
+ removed_locations_event ->GetBreakpointLocationCollection ().Add (loc_sp);
810
802
}
811
- SendBreakpointChangedEvent (locations_event );
803
+ SendBreakpointChangedEvent (removed_locations_event );
812
804
813
805
// And announce the new ones.
814
806
815
807
if (!IsInternal ()) {
816
- locations_event = new BreakpointEventData (
817
- eBreakpointEventTypeLocationsAdded, shared_from_this ());
808
+ std::shared_ptr<BreakpointEventData> added_locations_event =
809
+ std::make_shared<BreakpointEventData>(
810
+ eBreakpointEventTypeLocationsAdded, shared_from_this ());
818
811
for (BreakpointLocationSP loc_sp :
819
812
locations_to_announce.BreakpointLocations ())
820
- locations_event ->GetBreakpointLocationCollection ().Add (loc_sp);
813
+ added_locations_event ->GetBreakpointLocationCollection ().Add (loc_sp);
821
814
822
- SendBreakpointChangedEvent (locations_event );
815
+ SendBreakpointChangedEvent (added_locations_event );
823
816
}
824
817
m_locations.Compact ();
825
818
}
@@ -989,22 +982,22 @@ void Breakpoint::SendBreakpointChangedEvent(
989
982
if (!m_being_created && !IsInternal () &&
990
983
GetTarget ().EventTypeHasListeners (
991
984
Target::eBroadcastBitBreakpointChanged)) {
992
- BreakpointEventData * data =
993
- new Breakpoint:: BreakpointEventData (eventKind, shared_from_this ());
985
+ std::shared_ptr< BreakpointEventData> data =
986
+ std::make_shared< BreakpointEventData> (eventKind, shared_from_this ());
994
987
995
988
GetTarget ().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
996
989
}
997
990
}
998
991
999
- void Breakpoint::SendBreakpointChangedEvent (BreakpointEventData *data) {
1000
- if (data == nullptr )
992
+ void Breakpoint::SendBreakpointChangedEvent (
993
+ const lldb::EventDataSP &breakpoint_data_sp) {
994
+ if (!breakpoint_data_sp)
1001
995
return ;
1002
996
1003
997
if (!m_being_created && !IsInternal () &&
1004
998
GetTarget ().EventTypeHasListeners (Target::eBroadcastBitBreakpointChanged))
1005
- GetTarget ().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
1006
- else
1007
- delete data;
999
+ GetTarget ().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
1000
+ breakpoint_data_sp);
1008
1001
}
1009
1002
1010
1003
const char *Breakpoint::BreakpointEventTypeAsCString (BreakpointEventType type) {
0 commit comments