headers/bsd: Add sys/queue.h.
[haiku.git] / src / kits / debugger / model / UserBreakpoint.cpp
blobc2c288e2be307585737d409b6adf225aaaab0a86
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2013-2014, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
8 #include "UserBreakpoint.h"
10 #include "Function.h"
11 #include "FunctionID.h"
12 #include "LocatableFile.h"
15 // #pragma mark - UserBreakpointLocation
18 UserBreakpointLocation::UserBreakpointLocation(FunctionID* functionID,
19 LocatableFile* sourceFile, const SourceLocation& sourceLocation,
20 target_addr_t relativeAddress)
22 fFunctionID(functionID),
23 fSourceFile(sourceFile),
24 fSourceLocation(sourceLocation),
25 fRelativeAddress(relativeAddress)
27 fFunctionID->AcquireReference();
28 if (fSourceFile != NULL)
29 fSourceFile->AcquireReference();
33 UserBreakpointLocation::UserBreakpointLocation(
34 const UserBreakpointLocation& other)
36 fFunctionID(other.fFunctionID),
37 fSourceFile(other.fSourceFile),
38 fSourceLocation(other.fSourceLocation),
39 fRelativeAddress(other.fRelativeAddress)
41 fFunctionID->AcquireReference();
42 if (fSourceFile != NULL)
43 fSourceFile->AcquireReference();
47 UserBreakpointLocation::~UserBreakpointLocation()
49 fFunctionID->ReleaseReference();
50 if (fSourceFile != NULL)
51 fSourceFile->ReleaseReference();
55 UserBreakpointLocation&
56 UserBreakpointLocation::operator=(
57 const UserBreakpointLocation& other)
59 other.fFunctionID->AcquireReference();
60 if (other.fSourceFile != NULL)
61 other.fSourceFile->AcquireReference();
63 fFunctionID->ReleaseReference();
64 if (fSourceFile != NULL)
65 fSourceFile->ReleaseReference();
67 fFunctionID = other.fFunctionID;
68 fSourceFile = other.fSourceFile;
69 fSourceLocation = other.fSourceLocation;
70 fRelativeAddress = other.fRelativeAddress;
72 return *this;
76 // #pragma mark - UserBreakpointInstance
79 UserBreakpointInstance::UserBreakpointInstance(UserBreakpoint* userBreakpoint,
80 target_addr_t address)
82 fAddress(address),
83 fUserBreakpoint(userBreakpoint),
84 fBreakpoint(NULL)
89 void
90 UserBreakpointInstance::SetBreakpoint(Breakpoint* breakpoint)
92 fBreakpoint = breakpoint;
96 // #pragma mark - UserBreakpoint
99 UserBreakpoint::UserBreakpoint(const UserBreakpointLocation& location)
101 fLocation(location),
102 fValid(false),
103 fEnabled(false),
104 fHidden(false),
105 fConditionExpression()
110 UserBreakpoint::~UserBreakpoint()
112 for (int32 i = 0; UserBreakpointInstance* instance = fInstances.ItemAt(i);
113 i++) {
114 delete instance;
119 int32
120 UserBreakpoint::CountInstances() const
122 return fInstances.CountItems();
126 UserBreakpointInstance*
127 UserBreakpoint::InstanceAt(int32 index) const
129 return fInstances.ItemAt(index);
133 bool
134 UserBreakpoint::AddInstance(UserBreakpointInstance* instance)
136 return fInstances.AddItem(instance);
140 void
141 UserBreakpoint::RemoveInstance(UserBreakpointInstance* instance)
143 fInstances.RemoveItem(instance);
147 UserBreakpointInstance*
148 UserBreakpoint::RemoveInstanceAt(int32 index)
150 return fInstances.RemoveItemAt(index);
154 void
155 UserBreakpoint::SetValid(bool valid)
157 fValid = valid;
161 void
162 UserBreakpoint::SetEnabled(bool enabled)
164 fEnabled = enabled;
168 void
169 UserBreakpoint::SetHidden(bool hidden)
171 fHidden = hidden;
175 void
176 UserBreakpoint::SetCondition(const BString& conditionExpression)
178 fConditionExpression = conditionExpression;