llvm/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp

//===-- ProcessElfCore.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <cstdlib>

#include <memory>
#include <mutex>

#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"

#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Support/Threading.h"

#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
#include "ProcessElfCore.h"
#include "ThreadElfCore.h"

usingnamespacelldb_private;
ELF;

LLDB_PLUGIN_DEFINE()

llvm::StringRef ProcessElfCore::GetPluginDescriptionStatic() {}

void ProcessElfCore::Terminate() {}

lldb::ProcessSP ProcessElfCore::CreateInstance(lldb::TargetSP target_sp,
                                               lldb::ListenerSP listener_sp,
                                               const FileSpec *crash_file,
                                               bool can_connect) {}

bool ProcessElfCore::CanDebug(lldb::TargetSP target_sp,
                              bool plugin_specified_by_name) {}

// ProcessElfCore constructor
ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp,
                               lldb::ListenerSP listener_sp,
                               const FileSpec &core_file)
    :{}

// Destructor
ProcessElfCore::~ProcessElfCore() {}

lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment(
    const elf::ELFProgramHeader &header) {}

lldb::addr_t ProcessElfCore::AddAddressRangeFromMemoryTagSegment(
    const elf::ELFProgramHeader &header) {}

// Process Control
Status ProcessElfCore::DoLoadCore() {}

void ProcessElfCore::UpdateBuildIdForNTFileEntries() {}

lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {}

bool ProcessElfCore::DoUpdateThreadList(ThreadList &old_thread_list,
                                        ThreadList &new_thread_list) {}

void ProcessElfCore::RefreshStateAfterStop() {}

Status ProcessElfCore::DoDestroy() {}

// Process Queries

bool ProcessElfCore::IsAlive() {}

// Process Memory
size_t ProcessElfCore::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
                                  Status &error) {}

Status ProcessElfCore::DoGetMemoryRegionInfo(lldb::addr_t load_addr,
                                             MemoryRegionInfo &region_info) {}

size_t ProcessElfCore::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
                                    Status &error) {}

llvm::Expected<std::vector<lldb::addr_t>>
ProcessElfCore::ReadMemoryTags(lldb::addr_t addr, size_t len) {}

void ProcessElfCore::Clear() {}

void ProcessElfCore::Initialize() {}

lldb::addr_t ProcessElfCore::GetImageInfoAddress() {}

// Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
static void ParseFreeBSDPrStatus(ThreadData &thread_data,
                                 const DataExtractor &data,
                                 bool lp64) {}

// Parse a FreeBSD NT_PRPSINFO note - see FreeBSD sys/procfs.h for details.
static void ParseFreeBSDPrPsInfo(ProcessElfCore &process,
                                 const DataExtractor &data,
                                 bool lp64) {}

static llvm::Error ParseNetBSDProcInfo(const DataExtractor &data,
                                       uint32_t &cpi_nlwps,
                                       uint32_t &cpi_signo,
                                       uint32_t &cpi_siglwp,
                                       uint32_t &cpi_pid) {}

static void ParseOpenBSDProcInfo(ThreadData &thread_data,
                                 const DataExtractor &data) {}

llvm::Expected<std::vector<CoreNote>>
ProcessElfCore::parseSegment(const DataExtractor &segment) {}

llvm::Error ProcessElfCore::parseFreeBSDNotes(llvm::ArrayRef<CoreNote> notes) {}

/// NetBSD specific Thread context from PT_NOTE segment
///
/// NetBSD ELF core files use notes to provide information about
/// the process's state.  The note name is "NetBSD-CORE" for
/// information that is global to the process, and "NetBSD-CORE@nn",
/// where "nn" is the lwpid of the LWP that the information belongs
/// to (such as register state).
///
/// NetBSD uses the following note identifiers:
///
///      ELF_NOTE_NETBSD_CORE_PROCINFO (value 1)
///             Note is a "netbsd_elfcore_procinfo" structure.
///      ELF_NOTE_NETBSD_CORE_AUXV     (value 2; since NetBSD 8.0)
///             Note is an array of AuxInfo structures.
///
/// NetBSD also uses ptrace(2) request numbers (the ones that exist in
/// machine-dependent space) to identify register info notes.  The
/// info in such notes is in the same format that ptrace(2) would
/// export that information.
///
/// For more information see /usr/include/sys/exec_elf.h
///
llvm::Error ProcessElfCore::parseNetBSDNotes(llvm::ArrayRef<CoreNote> notes) {}

llvm::Error ProcessElfCore::parseOpenBSDNotes(llvm::ArrayRef<CoreNote> notes) {}

/// A description of a linux process usually contains the following NOTE
/// entries:
/// - NT_PRPSINFO - General process information like pid, uid, name, ...
/// - NT_SIGINFO - Information about the signal that terminated the process
/// - NT_AUXV - Process auxiliary vector
/// - NT_FILE - Files mapped into memory
/// 
/// Additionally, for each thread in the process the core file will contain at
/// least the NT_PRSTATUS note, containing the thread id and general purpose
/// registers. It may include additional notes for other register sets (floating
/// point and vector registers, ...). The tricky part here is that some of these
/// notes have "CORE" in their owner fields, while other set it to "LINUX".
llvm::Error ProcessElfCore::parseLinuxNotes(llvm::ArrayRef<CoreNote> notes) {}

/// Parse Thread context from PT_NOTE segment and store it in the thread list
/// A note segment consists of one or more NOTE entries, but their types and
/// meaning differ depending on the OS.
llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment(
    const elf::ELFProgramHeader &segment_header,
    const DataExtractor &segment_data) {}

UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {}

uint32_t ProcessElfCore::GetNumThreadContexts() {}

ArchSpec ProcessElfCore::GetArchitecture() {}

DataExtractor ProcessElfCore::GetAuxvData() {}

bool ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info) {}