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 "BreakpointSetting.h"
12 #include "ArchivingUtils.h"
13 #include "FunctionID.h"
14 #include "LocatableFile.h"
15 #include "UserBreakpoint.h"
18 BreakpointSetting::BreakpointSetting()
26 fConditionExpression()
31 BreakpointSetting::BreakpointSetting(const BreakpointSetting
& other
)
33 fFunctionID(other
.fFunctionID
),
34 fSourceFile(other
.fSourceFile
),
35 fSourceLocation(other
.fSourceLocation
),
36 fRelativeAddress(other
.fRelativeAddress
),
37 fEnabled(other
.fEnabled
),
38 fHidden(other
.fHidden
),
39 fConditionExpression(other
.fConditionExpression
)
41 if (fFunctionID
!= NULL
)
42 fFunctionID
->AcquireReference();
46 BreakpointSetting::~BreakpointSetting()
53 BreakpointSetting::SetTo(const UserBreakpointLocation
& location
, bool enabled
,
54 bool hidden
, const BString
& conditionExpression
)
58 fFunctionID
= location
.GetFunctionID();
59 if (fFunctionID
!= NULL
)
60 fFunctionID
->AcquireReference();
62 if (LocatableFile
* file
= location
.SourceFile())
63 file
->GetPath(fSourceFile
);
65 fSourceLocation
= location
.GetSourceLocation();
66 fRelativeAddress
= location
.RelativeAddress();
69 fConditionExpression
= conditionExpression
;
76 BreakpointSetting::SetTo(const BMessage
& archive
)
80 fFunctionID
= ArchivingUtils::UnarchiveChild
<FunctionID
>(archive
,
82 if (fFunctionID
== NULL
)
85 archive
.FindString("sourceFile", &fSourceFile
);
88 if (archive
.FindInt32("line", &line
) != B_OK
)
92 if (archive
.FindInt32("column", &column
) != B_OK
)
95 fSourceLocation
= SourceLocation(line
, column
);
97 if (archive
.FindUInt64("relativeAddress", &fRelativeAddress
) != B_OK
)
100 if (archive
.FindBool("enabled", &fEnabled
) != B_OK
)
103 if (archive
.FindBool("hidden", &fHidden
) != B_OK
)
106 if (archive
.FindString("condition", &fConditionExpression
) != B_OK
)
107 fConditionExpression
.Truncate(0);
114 BreakpointSetting::WriteTo(BMessage
& archive
) const
116 if (fFunctionID
== NULL
)
122 if ((error
= ArchivingUtils::ArchiveChild(fFunctionID
, archive
, "function"))
124 || (error
= archive
.AddString("sourceFile", fSourceFile
)) != B_OK
125 || (error
= archive
.AddInt32("line", fSourceLocation
.Line())) != B_OK
126 || (error
= archive
.AddInt32("column", fSourceLocation
.Column()))
128 || (error
= archive
.AddUInt64("relativeAddress", fRelativeAddress
))
130 || (error
= archive
.AddBool("enabled", fEnabled
)) != B_OK
131 || (error
= archive
.AddBool("hidden", fHidden
)) != B_OK
132 || (error
= archive
.AddString("condition", fConditionExpression
))
142 BreakpointSetting::operator=(const BreakpointSetting
& other
)
149 fFunctionID
= other
.fFunctionID
;
150 if (fFunctionID
!= NULL
)
151 fFunctionID
->AcquireReference();
153 fSourceFile
= other
.fSourceFile
;
154 fSourceLocation
= other
.fSourceLocation
;
155 fRelativeAddress
= other
.fRelativeAddress
;
156 fEnabled
= other
.fEnabled
;
157 fHidden
= other
.fHidden
;
158 fConditionExpression
= other
.fConditionExpression
;
165 BreakpointSetting::_Unset()
167 if (fFunctionID
!= NULL
) {
168 fFunctionID
->ReleaseReference();
172 fSourceFile
.Truncate(0);
173 fSourceLocation
= SourceLocation();
174 fRelativeAddress
= 0;
176 fConditionExpression
.Truncate(0);