2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
6 #include "Breakpoint.h"
9 // #pragma mark - BreakpointClient
12 BreakpointClient::~BreakpointClient()
17 // #pragma mark - Breakpoint
20 Breakpoint::Breakpoint(Image
* image
, target_addr_t address
)
29 Breakpoint::~Breakpoint()
35 Breakpoint::SetInstalled(bool installed
)
37 fInstalled
= installed
;
42 Breakpoint::ShouldBeInstalled() const
44 if (!fClients
.IsEmpty())
47 return !fClients
.IsEmpty() || HasEnabledUserBreakpoint();
52 Breakpoint::IsUnused() const
54 return fClients
.IsEmpty() && fUserBreakpoints
.IsEmpty();
59 Breakpoint::HasEnabledUserBreakpoint() const
61 for (UserBreakpointInstanceList::ConstIterator it
62 = fUserBreakpoints
.GetIterator();
63 UserBreakpointInstance
* instance
= it
.Next();) {
64 if (instance
->GetUserBreakpoint()->IsEnabled())
73 Breakpoint::AddUserBreakpoint(UserBreakpointInstance
* instance
)
75 fUserBreakpoints
.Add(instance
);
80 Breakpoint::RemoveUserBreakpoint(UserBreakpointInstance
* instance
)
82 fUserBreakpoints
.Remove(instance
);
87 Breakpoint::AddClient(BreakpointClient
* client
)
89 return fClients
.AddItem(client
);
94 Breakpoint::RemoveClient(BreakpointClient
* client
)
96 fClients
.RemoveItem(client
);
101 Breakpoint::CompareBreakpoints(const Breakpoint
* a
, const Breakpoint
* b
)
103 if (a
->Address() < b
->Address())
105 return a
->Address() == b
->Address() ? 0 : 1;
110 Breakpoint::CompareAddressBreakpoint(const target_addr_t
* address
,
111 const Breakpoint
* breakpoint
)
113 if (*address
< breakpoint
->Address())
115 return *address
== breakpoint
->Address() ? 0 : 1;