Skip to content

Commit fea7cd2

Browse files
author
git apple-llvm automerger
committed
Merge commit 'd094d97d0223' from llvm.org/master into apple/master
2 parents 360b8b9 + d094d97 commit fea7cd2

File tree

7 files changed

+34
-63
lines changed

7 files changed

+34
-63
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,15 @@ std::vector<const minidump::Module *> MinidumpParser::GetFilteredModuleList() {
314314
return filtered_modules;
315315
}
316316

317-
const MinidumpExceptionStream *MinidumpParser::GetExceptionStream() {
318-
llvm::ArrayRef<uint8_t> data = GetStream(StreamType::Exception);
319-
320-
if (data.size() == 0)
321-
return nullptr;
322-
323-
return MinidumpExceptionStream::Parse(data);
317+
const minidump::ExceptionStream *MinidumpParser::GetExceptionStream() {
318+
auto ExpectedStream = GetMinidumpFile().getExceptionStream();
319+
if (ExpectedStream)
320+
return &*ExpectedStream;
321+
322+
LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS),
323+
ExpectedStream.takeError(),
324+
"Failed to read minidump exception stream: {0}");
325+
return nullptr;
324326
}
325327

326328
llvm::Optional<minidump::Range>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class MinidumpParser {
8282
// have the same name, it keeps the copy with the lowest load address.
8383
std::vector<const minidump::Module *> GetFilteredModuleList();
8484

85-
const MinidumpExceptionStream *GetExceptionStream();
85+
const llvm::minidump::ExceptionStream *GetExceptionStream();
8686

8787
llvm::Optional<Range> FindMemoryRange(lldb::addr_t addr);
8888

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,6 @@ LinuxProcStatus::Parse(llvm::ArrayRef<uint8_t> &data) {
5757

5858
lldb::pid_t LinuxProcStatus::GetPid() const { return pid; }
5959

60-
// Exception stuff
61-
const MinidumpExceptionStream *
62-
MinidumpExceptionStream::Parse(llvm::ArrayRef<uint8_t> &data) {
63-
const MinidumpExceptionStream *exception_stream = nullptr;
64-
Status error = consumeObject(data, exception_stream);
65-
if (error.Fail())
66-
return nullptr;
67-
68-
return exception_stream;
69-
}
70-
7160
std::pair<llvm::ArrayRef<MinidumpMemoryDescriptor64>, uint64_t>
7261
MinidumpMemoryDescriptor64::ParseMemory64List(llvm::ArrayRef<uint8_t> &data) {
7362
const llvm::support::ulittle64_t *mem_ranges_count;

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,35 +118,6 @@ class LinuxProcStatus {
118118
LinuxProcStatus() = default;
119119
};
120120

121-
// Exception stuff
122-
struct MinidumpException {
123-
enum : unsigned {
124-
ExceptonInfoMaxParams = 15,
125-
DumpRequested = 0xFFFFFFFF,
126-
};
127-
128-
llvm::support::ulittle32_t exception_code;
129-
llvm::support::ulittle32_t exception_flags;
130-
llvm::support::ulittle64_t exception_record;
131-
llvm::support::ulittle64_t exception_address;
132-
llvm::support::ulittle32_t number_parameters;
133-
llvm::support::ulittle32_t unused_alignment;
134-
llvm::support::ulittle64_t exception_information[ExceptonInfoMaxParams];
135-
};
136-
static_assert(sizeof(MinidumpException) == 152,
137-
"sizeof MinidumpException is not correct!");
138-
139-
struct MinidumpExceptionStream {
140-
llvm::support::ulittle32_t thread_id;
141-
llvm::support::ulittle32_t alignment;
142-
MinidumpException exception_record;
143-
LocationDescriptor thread_context;
144-
145-
static const MinidumpExceptionStream *Parse(llvm::ArrayRef<uint8_t> &data);
146-
};
147-
static_assert(sizeof(MinidumpExceptionStream) == 168,
148-
"sizeof MinidumpExceptionStream is not correct!");
149-
150121
} // namespace minidump
151122
} // namespace lldb_private
152123
#endif // liblldb_MinidumpTypes_h_

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,36 +241,45 @@ void ProcessMinidump::RefreshStateAfterStop() {
241241
if (!m_active_exception)
242242
return;
243243

244-
if (m_active_exception->exception_record.exception_code ==
245-
MinidumpException::DumpRequested) {
244+
constexpr uint32_t BreakpadDumpRequested = 0xFFFFFFFF;
245+
if (m_active_exception->ExceptionRecord.ExceptionCode ==
246+
BreakpadDumpRequested) {
247+
// This "ExceptionCode" value is a sentinel that is sometimes used
248+
// when generating a dump for a process that hasn't crashed.
249+
250+
// TODO: The definition and use of this "dump requested" constant
251+
// in Breakpad are actually Linux-specific, and for similar use
252+
// cases on Mac/Windows it defines differnt constants, referring
253+
// to them as "simulated" exceptions; consider moving this check
254+
// down to the OS-specific paths and checking each OS for its own
255+
// constant.
246256
return;
247257
}
248258

249259
lldb::StopInfoSP stop_info;
250260
lldb::ThreadSP stop_thread;
251261

252-
Process::m_thread_list.SetSelectedThreadByID(m_active_exception->thread_id);
262+
Process::m_thread_list.SetSelectedThreadByID(m_active_exception->ThreadId);
253263
stop_thread = Process::m_thread_list.GetSelectedThread();
254264
ArchSpec arch = GetArchitecture();
255265

256266
if (arch.GetTriple().getOS() == llvm::Triple::Linux) {
257267
stop_info = StopInfo::CreateStopReasonWithSignal(
258-
*stop_thread, m_active_exception->exception_record.exception_code);
268+
*stop_thread, m_active_exception->ExceptionRecord.ExceptionCode);
259269
} else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) {
260270
stop_info = StopInfoMachException::CreateStopReasonWithMachException(
261-
*stop_thread, m_active_exception->exception_record.exception_code, 2,
262-
m_active_exception->exception_record.exception_flags,
263-
m_active_exception->exception_record.exception_address, 0);
271+
*stop_thread, m_active_exception->ExceptionRecord.ExceptionCode, 2,
272+
m_active_exception->ExceptionRecord.ExceptionFlags,
273+
m_active_exception->ExceptionRecord.ExceptionAddress, 0);
264274
} else {
265275
std::string desc;
266276
llvm::raw_string_ostream desc_stream(desc);
267277
desc_stream << "Exception "
268278
<< llvm::format_hex(
269-
m_active_exception->exception_record.exception_code, 8)
279+
m_active_exception->ExceptionRecord.ExceptionCode, 8)
270280
<< " encountered at address "
271281
<< llvm::format_hex(
272-
m_active_exception->exception_record.exception_address,
273-
8);
282+
m_active_exception->ExceptionRecord.ExceptionAddress, 8);
274283
stop_info = StopInfo::CreateStopReasonWithException(
275284
*stop_thread, desc_stream.str().c_str());
276285
}
@@ -335,8 +344,8 @@ bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
335344

336345
// If the minidump contains an exception context, use it
337346
if (m_active_exception != nullptr &&
338-
m_active_exception->thread_id == thread.ThreadId) {
339-
context_location = m_active_exception->thread_context;
347+
m_active_exception->ThreadId == thread.ThreadId) {
348+
context_location = m_active_exception->ThreadContext;
340349
}
341350

342351
llvm::ArrayRef<uint8_t> context;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class ProcessMinidump : public Process {
108108
FileSpec m_core_file;
109109
lldb::DataBufferSP m_core_data;
110110
llvm::ArrayRef<minidump::Thread> m_thread_list;
111-
const MinidumpExceptionStream *m_active_exception;
111+
const minidump::ExceptionStream *m_active_exception;
112112
lldb::CommandObjectSP m_command_sp;
113113
bool m_is_wow64;
114114
};

lldb/unittests/Process/minidump/MinidumpParserTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ TEST_F(MinidumpParserTest, GetFilteredModuleList) {
252252

253253
TEST_F(MinidumpParserTest, GetExceptionStream) {
254254
SetUpData("linux-x86_64.dmp");
255-
const MinidumpExceptionStream *exception_stream =
255+
const llvm::minidump::ExceptionStream *exception_stream =
256256
parser->GetExceptionStream();
257257
ASSERT_NE(nullptr, exception_stream);
258-
ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
258+
ASSERT_EQ(11UL, exception_stream->ExceptionRecord.ExceptionCode);
259259
}
260260

261261
void check_mem_range_exists(MinidumpParser &parser, const uint64_t range_start,

0 commit comments

Comments
 (0)