File tree Expand file tree Collapse file tree 4 files changed +18
-11
lines changed Expand file tree Collapse file tree 4 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -119,8 +119,8 @@ class LLDB_API SBSaveCoreOptions {
119
119
// / an empty collection will be returned.
120
120
SBThreadCollection GetThreadsToSave () const ;
121
121
122
- // / Get the current total number of bytes the core is expected to be but not
123
- // / including the overhead of the core file format. Requires a Process and
122
+ // / Get the current total number of bytes the core is expected to have
123
+ // / excluding the overhead of the core file format. Requires a Process and
124
124
// / Style to be specified.
125
125
// /
126
126
// / \note
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ class SaveCoreOptions {
49
49
50
50
lldb_private::ThreadCollection::collection GetThreadsToSave () const ;
51
51
52
- uint64_t GetCurrentSizeInBytes (Status &error );
52
+ llvm::Expected< uint64_t > GetCurrentSizeInBytes ();
53
53
54
54
void Clear ();
55
55
Original file line number Diff line number Diff line change @@ -116,7 +116,14 @@ void SBSaveCoreOptions::Clear() {
116
116
117
117
uint64_t SBSaveCoreOptions::GetCurrentSizeInBytes (SBError &error) {
118
118
LLDB_INSTRUMENT_VA (this , error);
119
- return m_opaque_up->GetCurrentSizeInBytes (error.ref ());
119
+ llvm::Expected<uint64_t > expected_bytes = m_opaque_up->GetCurrentSizeInBytes ();
120
+ if (!expected_bytes) {
121
+ error = SBError (lldb_private::Status::FromError (expected_bytes.takeError ()));
122
+ return 0 ;
123
+ }
124
+ // Clear the error, so if the clearer uses it we set it to success.
125
+ error.Clear ();
126
+ return *expected_bytes;
120
127
}
121
128
122
129
lldb_private::SaveCoreOptions &SBSaveCoreOptions::ref () const {
Original file line number Diff line number Diff line change @@ -145,20 +145,20 @@ SaveCoreOptions::GetThreadsToSave() const {
145
145
return thread_collection;
146
146
}
147
147
148
- uint64_t SaveCoreOptions::GetCurrentSizeInBytes (Status &error ) {
149
- if (!m_process_sp) {
150
- error = Status::FromErrorString ( " Requires a process to be set. " );
151
- return 0 ;
152
- }
148
+ llvm::Expected< uint64_t > SaveCoreOptions::GetCurrentSizeInBytes () {
149
+ Status error;
150
+ if (!m_process_sp)
151
+ return Status::FromErrorString ( " Requires a process to be set. " ). takeError () ;
152
+
153
153
154
154
error = EnsureValidConfiguration (m_process_sp);
155
155
if (error.Fail ())
156
- return 0 ;
156
+ return error. takeError () ;
157
157
158
158
CoreFileMemoryRanges ranges;
159
159
error = m_process_sp->CalculateCoreFileSaveRanges (*this , ranges);
160
160
if (error.Fail ())
161
- return 0 ;
161
+ return error. takeError () ;
162
162
163
163
uint64_t total_in_bytes = 0 ;
164
164
for (auto &core_range : ranges)
You can’t perform that action at this time.
0 commit comments