Skip to content

Commit a710aa1

Browse files
committed
Remove debug std::cout code. Run git-clang-format
1 parent e8d1f3a commit a710aa1

File tree

7 files changed

+49
-43
lines changed

7 files changed

+49
-43
lines changed

lldb/source/Plugins/Process/minidump/MinidumpParser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ std::vector<const minidump::Module *> MinidumpParser::GetFilteredModuleList() {
408408
continue;
409409
}
410410
// This module has been seen. Modules are sometimes mentioned multiple
411-
// times when they are mapped discontiguously, so find the module with
411+
// times when they are mapped discontiguously, so find the module with
412412
// the lowest "base_of_image" and use that as the filtered module.
413413
if (module.BaseOfImage < dup_module->BaseOfImage)
414414
filtered_modules[iter->second] = &module;
@@ -417,7 +417,8 @@ std::vector<const minidump::Module *> MinidumpParser::GetFilteredModuleList() {
417417
return filtered_modules;
418418
}
419419

420-
const std::vector<minidump::ExceptionStream> MinidumpParser::GetExceptionStreams() {
420+
const std::vector<minidump::ExceptionStream>
421+
MinidumpParser::GetExceptionStreams() {
421422
auto ExpectedStream = GetMinidumpFile().getExceptionStreams();
422423
if (ExpectedStream)
423424
return ExpectedStream.get();

lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
#include <memory>
4141
#include <optional>
42-
#include <iostream>
4342

4443
using namespace lldb;
4544
using namespace lldb_private;
@@ -158,8 +157,7 @@ ProcessMinidump::ProcessMinidump(lldb::TargetSP target_sp,
158157
const FileSpec &core_file,
159158
DataBufferSP core_data)
160159
: PostMortemProcess(target_sp, listener_sp, core_file),
161-
m_core_data(std::move(core_data)),
162-
m_is_wow64(false) {}
160+
m_core_data(std::move(core_data)), m_is_wow64(false) {}
163161

164162
ProcessMinidump::~ProcessMinidump() {
165163
Clear();
@@ -210,18 +208,19 @@ Status ProcessMinidump::DoLoadCore() {
210208
GetTarget().SetArchitecture(arch, true /*set_platform*/);
211209

212210
m_thread_list = m_minidump_parser->GetThreads();
213-
std::vector<minidump::ExceptionStream> exception_streams = m_minidump_parser->GetExceptionStreams();
211+
std::vector<minidump::ExceptionStream> exception_streams =
212+
m_minidump_parser->GetExceptionStreams();
214213
for (const auto &exception_stream : exception_streams) {
215-
if (m_exceptions_by_tid.count(exception_stream.ThreadId) > 0) {
216-
// We only cast to avoid the warning around converting little endian in printf.
217-
error.SetErrorStringWithFormat("duplicate exception stream for tid %" PRIu32, (uint32_t)exception_stream.ThreadId);
214+
if (!m_exceptions_by_tid
215+
.try_emplace(exception_stream.ThreadId, exception_stream)
216+
.second) {
217+
// We only cast to avoid the warning around converting little endian in
218+
// printf.
219+
error.SetErrorStringWithFormat(
220+
"duplicate exception stream for tid %" PRIu32,
221+
(uint32_t)exception_stream.ThreadId);
218222
return error;
219-
} else
220-
m_exceptions_by_tid[exception_stream.ThreadId] = exception_stream;
221-
222-
223-
std::cout << "Adding Exception Stream # " << (uint32_t)exception_stream.ThreadId << std::endl;
224-
std::cout << "Added index " << (uint32_t)m_exceptions_by_tid[exception_stream.ThreadId].ExceptionRecord.ExceptionCode << std::endl;
223+
}
225224
}
226225

227226
SetUnixSignals(UnixSignals::Create(GetArchitecture()));
@@ -270,14 +269,12 @@ void ProcessMinidump::RefreshStateAfterStop() {
270269

271270
if (arch.GetTriple().getOS() == llvm::Triple::Linux) {
272271
uint32_t signo = exception_stream.ExceptionRecord.ExceptionCode;
273-
std::cout << "Thread Id : " << exception_stream.ThreadId << " has signal " << signo << std::endl;
274272
if (signo == 0) {
275273
// No stop.
276274
return;
277275
}
278276

279-
stop_info = StopInfo::CreateStopReasonWithSignal(
280-
*stop_thread, signo);
277+
stop_info = StopInfo::CreateStopReasonWithSignal(*stop_thread, signo);
281278
} else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) {
282279
stop_info = StopInfoMachException::CreateStopReasonWithMachException(
283280
*stop_thread, exception_stream.ExceptionRecord.ExceptionCode, 2,
@@ -288,10 +285,10 @@ void ProcessMinidump::RefreshStateAfterStop() {
288285
llvm::raw_string_ostream desc_stream(desc);
289286
desc_stream << "Exception "
290287
<< llvm::format_hex(
291-
exception_stream.ExceptionRecord.ExceptionCode, 8)
288+
exception_stream.ExceptionRecord.ExceptionCode, 8)
292289
<< " encountered at address "
293290
<< llvm::format_hex(
294-
exception_stream.ExceptionRecord.ExceptionAddress, 8);
291+
exception_stream.ExceptionRecord.ExceptionAddress, 8);
295292
stop_info = StopInfo::CreateStopReasonWithException(
296293
*stop_thread, desc_stream.str().c_str());
297294
}
@@ -405,14 +402,14 @@ bool ProcessMinidump::DoUpdateThreadList(ThreadList &old_thread_list,
405402
exception = m_exceptions_by_tid[thread.ThreadId].ExceptionRecord;
406403
}
407404

408-
409405
llvm::ArrayRef<uint8_t> context;
410406
if (!m_is_wow64)
411407
context = m_minidump_parser->GetThreadContext(context_location);
412408
else
413409
context = m_minidump_parser->GetThreadContextWow64(thread);
414410

415-
lldb::ThreadSP thread_sp(new ThreadMinidump(*this, thread, context, exception));
411+
lldb::ThreadSP thread_sp(
412+
new ThreadMinidump(*this, thread, context, exception));
416413
new_thread_list.AddThread(thread_sp);
417414
}
418415
return new_thread_list.GetSize(false) > 0;

lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ using namespace lldb_private;
3434
using namespace minidump;
3535

3636
ThreadMinidump::ThreadMinidump(Process &process, const minidump::Thread &td,
37-
llvm::ArrayRef<uint8_t> gpregset_data, std::optional<minidump::Exception> exception)
37+
llvm::ArrayRef<uint8_t> gpregset_data,
38+
std::optional<minidump::Exception> exception)
3839
: Thread(process, td.ThreadId), m_thread_reg_ctx_sp(),
3940
m_gpregset_data(gpregset_data), m_exception(exception) {}
4041

@@ -115,12 +116,15 @@ ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) {
115116
return reg_ctx_sp;
116117
}
117118

119+
// This method doesn't end up getting called for minidump
120+
// because the stopinfo is set in `ProcessMinidump::RefreshStateAfterStop`
118121
bool ThreadMinidump::CalculateStopInfo() {
119122
if (!m_exception)
120123
return false;
121124

122125
minidump::Exception thread_exception = m_exception.value();
123126
SetStopInfo(StopInfo::CreateStopReasonWithSignal(
124-
*this, thread_exception.ExceptionCode, /*description=*/nullptr, thread_exception.ExceptionCode));
127+
*this, thread_exception.ExceptionCode, /*description=*/nullptr,
128+
thread_exception.ExceptionCode));
125129
return true;
126130
}

lldb/source/Plugins/Process/minidump/ThreadMinidump.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ namespace minidump {
2121
class ThreadMinidump : public Thread {
2222
public:
2323
ThreadMinidump(Process &process, const minidump::Thread &td,
24-
llvm::ArrayRef<uint8_t> gpregset_data, std::optional<minidump::Exception> exception);
24+
llvm::ArrayRef<uint8_t> gpregset_data,
25+
std::optional<minidump::Exception> exception);
2526

2627
~ThreadMinidump() override;
2728

lldb/unittests/Process/minidump/MinidumpParserTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ TEST_F(MinidumpParserTest, GetExceptionStream) {
253253
SetUpData("linux-x86_64.dmp");
254254
llvm::Expected<std::vector<ExceptionStream>> exception_stream =
255255
parser->GetExceptionStreams();
256-
// LLVM::Expected has an explicit bool operator that determines if
256+
// LLVM::Expected has an explicit bool operator that determines if
257257
// the expected value is an error or not.
258258
ASSERT_TRUE((bool)exception_stream);
259259
ASSERT_EQ(1UL, exception_stream->size());

llvm/include/llvm/Object/Minidump.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ class MinidumpFile : public Binary {
8282
return getListStream<minidump::Thread>(minidump::StreamType::ThreadList);
8383
}
8484

85-
/// Returns the contents of the Exception stream. An error is returned if the
86-
/// associated stream is smaller than the size of the ExceptionStream structure.
87-
/// Or the directory supplied is not of kind exception stream.
88-
Expected<minidump::ExceptionStream> getExceptionStream(minidump::Directory Directory) const {
85+
/// Returns the contents of the Exception stream. An error is returned if the
86+
/// associated stream is smaller than the size of the ExceptionStream
87+
/// structure. Or the directory supplied is not of kind exception stream.
88+
Expected<minidump::ExceptionStream>
89+
getExceptionStream(minidump::Directory Directory) const {
8990
if (Directory.Type != minidump::StreamType::Exception) {
9091
return createError("Not an exception stream");
9192
}
@@ -94,8 +95,9 @@ class MinidumpFile : public Binary {
9495
}
9596

9697
/// Returns the contents of the Exception streams. An error is returned if
97-
/// any of the streams are smaller than the size of the ExceptionStream structure.
98-
/// The internal consistency of the stream is not checked in any way.
98+
/// any of the streams are smaller than the size of the ExceptionStream
99+
/// structure. The internal consistency of the stream is not checked in any
100+
/// way.
99101
Expected<std::vector<minidump::ExceptionStream>> getExceptionStreams() const;
100102

101103
/// Returns the list of descriptors embedded in the MemoryList stream. The
@@ -182,7 +184,8 @@ class MinidumpFile : public Binary {
182184
/// Return the stream of the given type, cast to the appropriate type. Checks
183185
/// that the stream is large enough to hold an object of this type.
184186
template <typename T>
185-
Expected<const T &> getStreamFromDirectory(minidump::Directory Directory) const;
187+
Expected<const T &>
188+
getStreamFromDirectory(minidump::Directory Directory) const;
186189

187190
/// Return the stream of the given type, cast to the appropriate type. Checks
188191
/// that the stream is large enough to hold an object of this type.
@@ -200,7 +203,8 @@ class MinidumpFile : public Binary {
200203
};
201204

202205
template <typename T>
203-
Expected<const T &> MinidumpFile::getStreamFromDirectory(minidump::Directory Directory) const {
206+
Expected<const T &>
207+
MinidumpFile::getStreamFromDirectory(minidump::Directory Directory) const {
204208
ArrayRef<uint8_t> Stream = getRawStream(Directory);
205209
if (Stream.size() >= sizeof(T))
206210
return *reinterpret_cast<const T *>(Stream.data());

llvm/lib/Object/Minidump.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ Expected<std::string> MinidumpFile::getString(size_t Offset) const {
5454
return Result;
5555
}
5656

57-
Expected<std::vector<minidump::ExceptionStream>> MinidumpFile::getExceptionStreams() const {
57+
Expected<std::vector<minidump::ExceptionStream>>
58+
MinidumpFile::getExceptionStreams() const {
5859
// Scan the directories for exceptions first
5960
std::vector<Directory> exceptionStreams;
6061
for (const auto &directory : Streams) {
@@ -67,15 +68,12 @@ Expected<std::vector<minidump::ExceptionStream>> MinidumpFile::getExceptionStrea
6768

6869
std::vector<minidump::ExceptionStream> exceptionStreamList;
6970
for (const auto &exceptionStream : exceptionStreams) {
70-
llvm::Expected<minidump::ExceptionStream> ExpectedStream = getStreamFromDirectory<minidump::ExceptionStream>(exceptionStream);
71+
llvm::Expected<minidump::ExceptionStream> ExpectedStream =
72+
getStreamFromDirectory<minidump::ExceptionStream>(exceptionStream);
7173
if (!ExpectedStream)
7274
return ExpectedStream.takeError();
7375

74-
std::cout << "Adding Exception Stream # " << exceptionStreamList.size() << std::endl;
75-
std::cout << "Thread Id : " << ExpectedStream->ThreadId << std::endl;
76-
std::cout << "Exception Code : " << ExpectedStream.get().ExceptionRecord.ExceptionCode << std::endl;
7776
exceptionStreamList.push_back(ExpectedStream.get());
78-
assert(exceptionStreamList.back().ThreadId == ExpectedStream->ThreadId);
7977
}
8078

8179
return exceptionStreamList;
@@ -172,9 +170,10 @@ MinidumpFile::create(MemoryBufferRef Source) {
172170
}
173171

174172
// We treat exceptions differently here because the LLDB minidump
175-
// makes some assumptions about uniqueness, all the streams other than exceptions
176-
// are lists. But exceptions are not a list, they are single streams that point back to their thread
177-
// So we will omit them here, and will find them when needed in the MinidumpFile.
173+
// makes some assumptions about uniqueness, all the streams other than
174+
// exceptions are lists. But exceptions are not a list, they are single
175+
// streams that point back to their thread So we will omit them here, and
176+
// will find them when needed in the MinidumpFile.
178177
if (Type == StreamType::Exception) {
179178
continue;
180179
}

0 commit comments

Comments
 (0)