Adrian Prantl 0642cd768b
[lldb] Turn lldb_private::Status into a value type. (#106163)
This patch removes all of the Set.* methods from Status.

This cleanup is part of a series of patches that make it harder use the
anti-pattern of keeping a long-lives Status object around and updating
it while dropping any errors it contains on the floor.

This patch is largely NFC, the more interesting next steps this enables
is to:
1. remove Status.Clear()
2. assert that Status::operator=() never overwrites an error
3. remove Status::operator=()

Note that step (2) will bring 90% of the benefits for users, and step
(3) will dramatically clean up the error handling code in various
places. In the end my goal is to convert all APIs that are of the form

`    ResultTy DoFoo(Status& error)
`
to

`    llvm::Expected<ResultTy> DoFoo()
`
How to read this patch?

The interesting changes are in Status.h and Status.cpp, all other
changes are mostly

` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git
grep -l SetErrorString lldb/source)
`
plus the occasional manual cleanup.
2024-08-27 10:59:31 -07:00

82 lines
2.7 KiB
C++

//===-- PlatformQemuUser.h ------------------------------------------------===//
//
// 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 LLDB_SOURCE_PLUGINS_PLATFORM_QEMUUSER_PLATFORMQEMUUSER_H
#define LLDB_SOURCE_PLUGINS_PLATFORM_QEMUUSER_PLATFORMQEMUUSER_H
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Platform.h"
namespace lldb_private {
class PlatformQemuUser : public Platform {
public:
static void Initialize();
static void Terminate();
static llvm::StringRef GetPluginNameStatic() { return "qemu-user"; }
static llvm::StringRef GetPluginDescriptionStatic();
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
llvm::StringRef GetDescription() override {
return GetPluginDescriptionStatic();
}
UserIDResolver &GetUserIDResolver() override {
return HostInfo::GetUserIDResolver();
}
std::vector<ArchSpec>
GetSupportedArchitectures(const ArchSpec &process_host_arch) override;
lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
Debugger &debugger, Target &target,
Status &error) override;
lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
Target *target, Status &status) override {
status = Status::FromErrorString("Not supported");
return nullptr;
}
uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
ProcessInstanceInfoList &proc_infos) override {
return 0;
}
bool GetProcessInfo(lldb::pid_t pid,
ProcessInstanceInfo &proc_info) override {
return false;
}
bool IsConnected() const override { return true; }
void CalculateTrapHandlerSymbolNames() override {}
Environment GetEnvironment() override;
MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr,
lldb::addr_t length, unsigned prot,
unsigned flags, lldb::addr_t fd,
lldb::addr_t offset) override {
return Platform::GetHostPlatform()->GetMmapArgumentList(
arch, addr, length, prot, flags, fd, offset);
}
private:
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
static void DebuggerInitialize(Debugger &debugger);
PlatformQemuUser() : Platform(/*is_host=*/true) {}
};
} // namespace lldb_private
#endif // LLDB_SOURCE_PLUGINS_PLATFORM_QEMUUSER_PLATFORMQEMUUSER_H