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.
8 #include "UserBreakpoint.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
;
76 // #pragma mark - UserBreakpointInstance
79 UserBreakpointInstance::UserBreakpointInstance(UserBreakpoint
* userBreakpoint
,
80 target_addr_t address
)
83 fUserBreakpoint(userBreakpoint
),
90 UserBreakpointInstance::SetBreakpoint(Breakpoint
* breakpoint
)
92 fBreakpoint
= breakpoint
;
96 // #pragma mark - UserBreakpoint
99 UserBreakpoint::UserBreakpoint(const UserBreakpointLocation
& location
)
105 fConditionExpression()
110 UserBreakpoint::~UserBreakpoint()
112 for (int32 i
= 0; UserBreakpointInstance
* instance
= fInstances
.ItemAt(i
);
120 UserBreakpoint::CountInstances() const
122 return fInstances
.CountItems();
126 UserBreakpointInstance
*
127 UserBreakpoint::InstanceAt(int32 index
) const
129 return fInstances
.ItemAt(index
);
134 UserBreakpoint::AddInstance(UserBreakpointInstance
* instance
)
136 return fInstances
.AddItem(instance
);
141 UserBreakpoint::RemoveInstance(UserBreakpointInstance
* instance
)
143 fInstances
.RemoveItem(instance
);
147 UserBreakpointInstance
*
148 UserBreakpoint::RemoveInstanceAt(int32 index
)
150 return fInstances
.RemoveItemAt(index
);
155 UserBreakpoint::SetValid(bool valid
)
162 UserBreakpoint::SetEnabled(bool enabled
)
169 UserBreakpoint::SetHidden(bool hidden
)
176 UserBreakpoint::SetCondition(const BString
& conditionExpression
)
178 fConditionExpression
= conditionExpression
;