mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
Everywhere: Core dump => Coredump
We all know what a coredump is, and it feels more natural to refer to it as a coredump (most code already does), so let's be consistent.
This commit is contained in:
parent
a930877f31
commit
bcd2025311
21 changed files with 73 additions and 72 deletions
|
@ -48,7 +48,7 @@ set(KERNEL_SOURCES
|
|||
CMOS.cpp
|
||||
CommandLine.cpp
|
||||
ConsoleDevice.cpp
|
||||
CoreDump.cpp
|
||||
Coredump.cpp
|
||||
Devices/AsyncDeviceRequest.cpp
|
||||
Devices/BlockDevice.cpp
|
||||
Devices/CharacterDevice.cpp
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/JsonObjectSerializer.h>
|
||||
#include <Kernel/CoreDump.h>
|
||||
#include <Kernel/Coredump.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
|
@ -19,41 +19,41 @@
|
|||
#include <Kernel/Process.h>
|
||||
#include <Kernel/RTC.h>
|
||||
#include <LibC/elf.h>
|
||||
#include <LibELF/CoreDump.h>
|
||||
#include <LibELF/Core.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
OwnPtr<CoreDump> CoreDump::create(NonnullRefPtr<Process> process, const String& output_path)
|
||||
OwnPtr<Coredump> Coredump::create(NonnullRefPtr<Process> process, const String& output_path)
|
||||
{
|
||||
if (!process->is_dumpable()) {
|
||||
dbgln("Refusing to generate CoreDump for non-dumpable process {}", process->pid().value());
|
||||
dbgln("Refusing to generate coredump for non-dumpable process {}", process->pid().value());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto fd = create_target_file(process, output_path);
|
||||
if (!fd)
|
||||
return {};
|
||||
return adopt_own_if_nonnull(new (nothrow) CoreDump(move(process), fd.release_nonnull()));
|
||||
return adopt_own_if_nonnull(new (nothrow) Coredump(move(process), fd.release_nonnull()));
|
||||
}
|
||||
|
||||
CoreDump::CoreDump(NonnullRefPtr<Process> process, NonnullRefPtr<FileDescription>&& fd)
|
||||
Coredump::Coredump(NonnullRefPtr<Process> process, NonnullRefPtr<FileDescription>&& fd)
|
||||
: m_process(move(process))
|
||||
, m_fd(move(fd))
|
||||
, m_num_program_headers(m_process->address_space().region_count() + 1) // +1 for NOTE segment
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<FileDescription> CoreDump::create_target_file(const Process& process, const String& output_path)
|
||||
RefPtr<FileDescription> Coredump::create_target_file(const Process& process, const String& output_path)
|
||||
{
|
||||
auto output_directory = KLexicalPath::dirname(output_path);
|
||||
auto dump_directory = VirtualFileSystem::the().open_directory(output_directory, VirtualFileSystem::the().root_custody());
|
||||
if (dump_directory.is_error()) {
|
||||
dbgln("Can't find directory '{}' for core dump", output_directory);
|
||||
dbgln("Can't find directory '{}' for coredump", output_directory);
|
||||
return nullptr;
|
||||
}
|
||||
auto dump_directory_metadata = dump_directory.value()->inode().metadata();
|
||||
if (dump_directory_metadata.uid != 0 || dump_directory_metadata.gid != 0 || dump_directory_metadata.mode != 040777) {
|
||||
dbgln("Refusing to put core dump in sketchy directory '{}'", output_directory);
|
||||
dbgln("Refusing to put coredump in sketchy directory '{}'", output_directory);
|
||||
return nullptr;
|
||||
}
|
||||
auto fd_or_error = VirtualFileSystem::the().open(
|
||||
|
@ -64,14 +64,14 @@ RefPtr<FileDescription> CoreDump::create_target_file(const Process& process, con
|
|||
UidAndGid { process.uid(), process.gid() });
|
||||
|
||||
if (fd_or_error.is_error()) {
|
||||
dbgln("Failed to open core dump '{}' for writing", output_path);
|
||||
dbgln("Failed to open coredump '{}' for writing", output_path);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fd_or_error.value();
|
||||
}
|
||||
|
||||
KResult CoreDump::write_elf_header()
|
||||
KResult Coredump::write_elf_header()
|
||||
{
|
||||
ElfW(Ehdr) elf_file_header;
|
||||
elf_file_header.e_ident[EI_MAG0] = 0x7f;
|
||||
|
@ -117,7 +117,7 @@ KResult CoreDump::write_elf_header()
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult CoreDump::write_program_headers(size_t notes_size)
|
||||
KResult Coredump::write_program_headers(size_t notes_size)
|
||||
{
|
||||
size_t offset = sizeof(ElfW(Ehdr)) + m_num_program_headers * sizeof(ElfW(Phdr));
|
||||
for (auto& region : m_process->address_space().regions()) {
|
||||
|
@ -159,7 +159,7 @@ KResult CoreDump::write_program_headers(size_t notes_size)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult CoreDump::write_regions()
|
||||
KResult Coredump::write_regions()
|
||||
{
|
||||
for (auto& region : m_process->address_space().regions()) {
|
||||
if (region->is_kernel())
|
||||
|
@ -190,7 +190,7 @@ KResult CoreDump::write_regions()
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult CoreDump::write_notes_segment(ByteBuffer& notes_segment)
|
||||
KResult Coredump::write_notes_segment(ByteBuffer& notes_segment)
|
||||
{
|
||||
auto result = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(notes_segment.data()), notes_segment.size());
|
||||
if (result.is_error())
|
||||
|
@ -198,7 +198,7 @@ KResult CoreDump::write_notes_segment(ByteBuffer& notes_segment)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
ByteBuffer CoreDump::create_notes_process_data() const
|
||||
ByteBuffer Coredump::create_notes_process_data() const
|
||||
{
|
||||
ByteBuffer process_data;
|
||||
|
||||
|
@ -232,7 +232,7 @@ ByteBuffer CoreDump::create_notes_process_data() const
|
|||
return process_data;
|
||||
}
|
||||
|
||||
ByteBuffer CoreDump::create_notes_threads_data() const
|
||||
ByteBuffer Coredump::create_notes_threads_data() const
|
||||
{
|
||||
ByteBuffer threads_data;
|
||||
|
||||
|
@ -253,7 +253,7 @@ ByteBuffer CoreDump::create_notes_threads_data() const
|
|||
return threads_data;
|
||||
}
|
||||
|
||||
ByteBuffer CoreDump::create_notes_regions_data() const
|
||||
ByteBuffer Coredump::create_notes_regions_data() const
|
||||
{
|
||||
ByteBuffer regions_data;
|
||||
size_t region_index = 0;
|
||||
|
@ -282,7 +282,7 @@ ByteBuffer CoreDump::create_notes_regions_data() const
|
|||
return regions_data;
|
||||
}
|
||||
|
||||
ByteBuffer CoreDump::create_notes_metadata_data() const
|
||||
ByteBuffer Coredump::create_notes_metadata_data() const
|
||||
{
|
||||
ByteBuffer metadata_data;
|
||||
|
||||
|
@ -303,7 +303,7 @@ ByteBuffer CoreDump::create_notes_metadata_data() const
|
|||
return metadata_data;
|
||||
}
|
||||
|
||||
ByteBuffer CoreDump::create_notes_segment_data() const
|
||||
ByteBuffer Coredump::create_notes_segment_data() const
|
||||
{
|
||||
ByteBuffer notes_buffer;
|
||||
|
||||
|
@ -319,7 +319,7 @@ ByteBuffer CoreDump::create_notes_segment_data() const
|
|||
return notes_buffer;
|
||||
}
|
||||
|
||||
KResult CoreDump::write()
|
||||
KResult Coredump::write()
|
||||
{
|
||||
SpinlockLocker lock(m_process->address_space().get_lock());
|
||||
ProcessPagingScope scope(m_process);
|
|
@ -13,15 +13,15 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
class CoreDump {
|
||||
class Coredump {
|
||||
public:
|
||||
static OwnPtr<CoreDump> create(NonnullRefPtr<Process>, const String& output_path);
|
||||
static OwnPtr<Coredump> create(NonnullRefPtr<Process>, const String& output_path);
|
||||
|
||||
~CoreDump() = default;
|
||||
~Coredump() = default;
|
||||
[[nodiscard]] KResult write();
|
||||
|
||||
private:
|
||||
CoreDump(NonnullRefPtr<Process>, NonnullRefPtr<FileDescription>&&);
|
||||
Coredump(NonnullRefPtr<Process>, NonnullRefPtr<FileDescription>&&);
|
||||
static RefPtr<FileDescription> create_target_file(const Process&, const String& output_path);
|
||||
|
||||
[[nodiscard]] KResult write_elf_header();
|
|
@ -12,7 +12,7 @@ namespace Kernel {
|
|||
|
||||
class BlockDevice;
|
||||
class CharacterDevice;
|
||||
class CoreDump;
|
||||
class Coredump;
|
||||
class Custody;
|
||||
class DevFSDeviceInode;
|
||||
class DevFSDirectoryInode;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <AK/Types.h>
|
||||
#include <Kernel/API/Syscall.h>
|
||||
#include <Kernel/Arch/x86/InterruptDisabler.h>
|
||||
#include <Kernel/CoreDump.h>
|
||||
#include <Kernel/Coredump.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#ifdef ENABLE_KERNEL_COVERAGE_COLLECTION
|
||||
# include <Kernel/Devices/KCOVDevice.h>
|
||||
|
@ -406,7 +406,7 @@ void Process::crash(int signal, FlatPtr ip, bool out_of_memory)
|
|||
ProtectedDataMutationScope scope { *this };
|
||||
m_protected_values.termination_signal = signal;
|
||||
}
|
||||
set_dump_core(!out_of_memory);
|
||||
set_should_generate_coredump(!out_of_memory);
|
||||
address_space().dump_regions();
|
||||
VERIFY(is_user_process());
|
||||
die();
|
||||
|
@ -561,10 +561,10 @@ KResultOr<NonnullOwnPtr<KString>> Process::get_syscall_path_argument(Syscall::St
|
|||
bool Process::dump_core()
|
||||
{
|
||||
VERIFY(is_dumpable());
|
||||
VERIFY(should_core_dump());
|
||||
VERIFY(should_generate_coredump());
|
||||
dbgln("Generating coredump for pid: {}", pid().value());
|
||||
auto coredump_path = String::formatted("/tmp/coredump/{}_{}_{}", name(), pid().value(), kgettimeofday().to_truncated_seconds());
|
||||
auto coredump = CoreDump::create(*this, coredump_path);
|
||||
auto coredump = Coredump::create(*this, coredump_path);
|
||||
if (!coredump)
|
||||
return false;
|
||||
return !coredump->write().is_error();
|
||||
|
@ -615,7 +615,7 @@ void Process::finalize()
|
|||
dbgln_if(PROCESS_DEBUG, "Finalizing process {}", *this);
|
||||
|
||||
if (is_dumpable()) {
|
||||
if (m_should_dump_core)
|
||||
if (m_should_generate_coredump)
|
||||
dump_core();
|
||||
if (m_perf_event_buffer) {
|
||||
dump_perfcore();
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
MAKE_ALIGNED_ALLOCATED(Process, PAGE_SIZE);
|
||||
|
||||
friend class Thread;
|
||||
friend class CoreDump;
|
||||
friend class Coredump;
|
||||
friend class ProcFSProcessFileDescriptions;
|
||||
|
||||
// Helper class to temporarily unprotect a process's protected data so you can write to it.
|
||||
|
@ -190,8 +190,9 @@ public:
|
|||
|
||||
bool is_profiling() const { return m_profiling; }
|
||||
void set_profiling(bool profiling) { m_profiling = profiling; }
|
||||
bool should_core_dump() const { return m_should_dump_core; }
|
||||
void set_dump_core(bool dump_core) { m_should_dump_core = dump_core; }
|
||||
|
||||
bool should_generate_coredump() const { return m_should_generate_coredump; }
|
||||
void set_should_generate_coredump(bool b) { m_should_generate_coredump = b; }
|
||||
|
||||
bool is_dying() const { return m_state.load(AK::MemoryOrder::memory_order_acquire) != State::Running; }
|
||||
bool is_dead() const { return m_state.load(AK::MemoryOrder::memory_order_acquire) == State::Dead; }
|
||||
|
@ -498,7 +499,7 @@ public:
|
|||
KResult set_coredump_property(NonnullOwnPtr<KString> key, NonnullOwnPtr<KString> value);
|
||||
KResult try_set_coredump_property(StringView key, StringView value);
|
||||
|
||||
const NonnullRefPtrVector<Thread>& threads_for_coredump(Badge<CoreDump>) const { return m_threads_for_coredump; }
|
||||
const NonnullRefPtrVector<Thread>& threads_for_coredump(Badge<Coredump>) const { return m_threads_for_coredump; }
|
||||
|
||||
PerformanceEventBuffer* perf_events() { return m_perf_event_buffer; }
|
||||
|
||||
|
@ -754,7 +755,7 @@ private:
|
|||
Atomic<State> m_state { State::Running };
|
||||
bool m_profiling { false };
|
||||
Atomic<bool, AK::MemoryOrder::memory_order_relaxed> m_is_stopped { false };
|
||||
bool m_should_dump_core { false };
|
||||
bool m_should_generate_coredump { false };
|
||||
|
||||
RefPtr<Custody> m_executable;
|
||||
RefPtr<Custody> m_cwd;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/CoreDump.h>
|
||||
#include <Kernel/Coredump.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/PerformanceManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
|
|
@ -890,7 +890,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
|
|||
set_state(Stopped, signal);
|
||||
return DispatchSignalResult::Yield;
|
||||
case DefaultSignalAction::DumpCore:
|
||||
process.set_dump_core(true);
|
||||
process.set_should_generate_coredump(true);
|
||||
process.for_each_thread([](auto& thread) {
|
||||
thread.set_dump_backtrace_on_finalization();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue