The goal of this refactor is to enable ProcessMinidump to take into account the loaded modules and their sections when computing the permissions of various ranges of memory, as discussed in D66638. This patch moves some of the responsibility for computing the ranges from MinidumpParser into ProcessMinidump. MinidumpParser still does the parsing, but ProcessMinidump becomes responsible for answering the actual queries about memory ranges. This will enable it (in a follow-up patch) to augment the information obtained from the parser with data obtained from actual object files. The changes in the actual code are fairly straight-forward and just involve moving code around. MinidumpParser::GetMemoryRegions is renamed to BuildMemoryRegions to emphasize that it does no caching. The only new thing is the additional bool flag returned from this function. This indicates whether the returned regions describe all memory mapped into the target process. Data obtained from /proc/maps and the MemoryInfoList stream is considered to be exhaustive. Data obtained from Memory(64)List is not. This will be used to determine whether we need to augment the data or not. This reshuffle means that it is no longer possible/easy to test some of this code via unit tests, as constructing a ProcessMinidump instance is hard. Instead, I update the unit tests to only test the parsing of the actual data, and test the answering of queries through a lit test using the "memory region" command. The patch also includes some tweaks to the MemoryRegion class to make the unit tests easier to write. Reviewers: amccarth, clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D69035
123 lines
3.3 KiB
C++
123 lines
3.3 KiB
C++
//===-- ProcessMinidump.h ---------------------------------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef liblldb_ProcessMinidump_h_
|
|
#define liblldb_ProcessMinidump_h_
|
|
|
|
#include "MinidumpParser.h"
|
|
#include "MinidumpTypes.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
#include "lldb/Target/StopInfo.h"
|
|
#include "lldb/Target/Target.h"
|
|
#include "lldb/Utility/ConstString.h"
|
|
#include "lldb/Utility/Status.h"
|
|
|
|
#include "llvm/Support/Format.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace minidump {
|
|
|
|
class ProcessMinidump : public Process {
|
|
public:
|
|
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
|
|
lldb::ListenerSP listener_sp,
|
|
const FileSpec *crash_file_path);
|
|
|
|
static void Initialize();
|
|
|
|
static void Terminate();
|
|
|
|
static ConstString GetPluginNameStatic();
|
|
|
|
static const char *GetPluginDescriptionStatic();
|
|
|
|
ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
|
|
const FileSpec &core_file, lldb::DataBufferSP code_data);
|
|
|
|
~ProcessMinidump() override;
|
|
|
|
bool CanDebug(lldb::TargetSP target_sp,
|
|
bool plugin_specified_by_name) override;
|
|
|
|
CommandObject *GetPluginCommandObject() override;
|
|
|
|
Status DoLoadCore() override;
|
|
|
|
DynamicLoader *GetDynamicLoader() override { return nullptr; }
|
|
|
|
ConstString GetPluginName() override;
|
|
|
|
uint32_t GetPluginVersion() override;
|
|
|
|
SystemRuntime *GetSystemRuntime() override { return nullptr; }
|
|
|
|
Status DoDestroy() override;
|
|
|
|
void RefreshStateAfterStop() override;
|
|
|
|
bool IsAlive() override;
|
|
|
|
bool WarnBeforeDetach() const override;
|
|
|
|
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
|
|
Status &error) override;
|
|
|
|
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
|
|
Status &error) override;
|
|
|
|
ArchSpec GetArchitecture();
|
|
|
|
Status GetMemoryRegionInfo(lldb::addr_t load_addr,
|
|
MemoryRegionInfo &range_info) override;
|
|
|
|
Status GetMemoryRegions(
|
|
lldb_private::MemoryRegionInfos ®ion_list) override;
|
|
|
|
bool GetProcessInfo(ProcessInstanceInfo &info) override;
|
|
|
|
Status WillResume() override {
|
|
Status error;
|
|
error.SetErrorStringWithFormat(
|
|
"error: %s does not support resuming processes",
|
|
GetPluginName().GetCString());
|
|
return error;
|
|
}
|
|
|
|
llvm::Optional<MinidumpParser> m_minidump_parser;
|
|
|
|
protected:
|
|
void Clear();
|
|
|
|
bool UpdateThreadList(ThreadList &old_thread_list,
|
|
ThreadList &new_thread_list) override;
|
|
|
|
void ReadModuleList();
|
|
|
|
JITLoaderList &GetJITLoaders() override;
|
|
|
|
private:
|
|
FileSpec m_core_file;
|
|
lldb::DataBufferSP m_core_data;
|
|
llvm::ArrayRef<minidump::Thread> m_thread_list;
|
|
const minidump::ExceptionStream *m_active_exception;
|
|
lldb::CommandObjectSP m_command_sp;
|
|
bool m_is_wow64;
|
|
llvm::Optional<MemoryRegionInfos> m_memory_regions;
|
|
|
|
void BuildMemoryRegions();
|
|
};
|
|
|
|
} // namespace minidump
|
|
} // namespace lldb_private
|
|
|
|
#endif // liblldb_ProcessMinidump_h_
|