1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:47:45 +00:00

LibCoreDump: Make for_each_thread_info() callback arg a reference

It's never nullptr, so it should be a reference.
This commit is contained in:
Linus Groh 2020-12-28 16:26:54 +01:00 committed by Andreas Kling
parent 87f1f69dd2
commit 21bc8cfe8f
2 changed files with 6 additions and 6 deletions

View file

@ -134,11 +134,11 @@ static void backtrace(const String& coredump_path)
{ {
size_t thread_index = 0; size_t thread_index = 0;
auto coredump = CoreDump::Reader::create(coredump_path); auto coredump = CoreDump::Reader::create(coredump_path);
coredump->for_each_thread_info([&thread_index, &coredump](const ELF::Core::ThreadInfo* thread_info) { coredump->for_each_thread_info([&thread_index, &coredump](const ELF::Core::ThreadInfo& thread_info) {
dbgln("Backtrace for thread #{}, tid={}", thread_index++, thread_info->tid); dbgln("Backtrace for thread #{}, tid={}", thread_index++, thread_info.tid);
uint32_t* ebp = (uint32_t*)thread_info->regs.ebp; uint32_t* ebp = (uint32_t*)thread_info.regs.ebp;
uint32_t* eip = (uint32_t*)thread_info->regs.eip; uint32_t* eip = (uint32_t*)thread_info.regs.eip;
while (ebp && eip) { while (ebp && eip) {
auto line = backtrace_line(*coredump, (FlatPtr)eip); auto line = backtrace_line(*coredump, (FlatPtr)eip);

View file

@ -94,8 +94,8 @@ void Reader::for_each_thread_info(Func func) const
for (NotesEntryIterator it((const u8*)m_coredump_image.program_header(m_notes_segment_index).raw_data()); !it.at_end(); it.next()) { for (NotesEntryIterator it((const u8*)m_coredump_image.program_header(m_notes_segment_index).raw_data()); !it.at_end(); it.next()) {
if (it.type() != ELF::Core::NotesEntryHeader::Type::ThreadInfo) if (it.type() != ELF::Core::NotesEntryHeader::Type::ThreadInfo)
continue; continue;
auto* region = (const ELF::Core::ThreadInfo*)(it.current()); auto& thread_info = reinterpret_cast<const ELF::Core::ThreadInfo&>(*it.current());
IterationDecision decision = func(region); IterationDecision decision = func(thread_info);
if (decision == IterationDecision::Break) if (decision == IterationDecision::Break)
return; return;
} }