headers/bsd: Add sys/queue.h.
[haiku.git] / src / kits / debugger / model / Breakpoint.cpp
blobc7c49cb17ade743a069f35c5923f6bb3ac5d986a
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "Breakpoint.h"
9 // #pragma mark - BreakpointClient
12 BreakpointClient::~BreakpointClient()
17 // #pragma mark - Breakpoint
20 Breakpoint::Breakpoint(Image* image, target_addr_t address)
22 fAddress(address),
23 fImage(image),
24 fInstalled(false)
29 Breakpoint::~Breakpoint()
34 void
35 Breakpoint::SetInstalled(bool installed)
37 fInstalled = installed;
41 bool
42 Breakpoint::ShouldBeInstalled() const
44 if (!fClients.IsEmpty())
45 return true;
47 return !fClients.IsEmpty() || HasEnabledUserBreakpoint();
51 bool
52 Breakpoint::IsUnused() const
54 return fClients.IsEmpty() && fUserBreakpoints.IsEmpty();
58 bool
59 Breakpoint::HasEnabledUserBreakpoint() const
61 for (UserBreakpointInstanceList::ConstIterator it
62 = fUserBreakpoints.GetIterator();
63 UserBreakpointInstance* instance = it.Next();) {
64 if (instance->GetUserBreakpoint()->IsEnabled())
65 return true;
68 return false;
72 void
73 Breakpoint::AddUserBreakpoint(UserBreakpointInstance* instance)
75 fUserBreakpoints.Add(instance);
79 void
80 Breakpoint::RemoveUserBreakpoint(UserBreakpointInstance* instance)
82 fUserBreakpoints.Remove(instance);
86 bool
87 Breakpoint::AddClient(BreakpointClient* client)
89 return fClients.AddItem(client);
93 void
94 Breakpoint::RemoveClient(BreakpointClient* client)
96 fClients.RemoveItem(client);
100 /*static*/ int
101 Breakpoint::CompareBreakpoints(const Breakpoint* a, const Breakpoint* b)
103 if (a->Address() < b->Address())
104 return -1;
105 return a->Address() == b->Address() ? 0 : 1;
109 /*static*/ int
110 Breakpoint::CompareAddressBreakpoint(const target_addr_t* address,
111 const Breakpoint* breakpoint)
113 if (*address < breakpoint->Address())
114 return -1;
115 return *address == breakpoint->Address() ? 0 : 1;