mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
[trace] Migrate uses of operator<<(raw_ostream &OS, const Optional<T> &O) to std::optional
This commit is contained in:
@@ -627,7 +627,7 @@ public:
|
||||
/// \return \b true if the session transcript was successfully written to
|
||||
/// disk, \b false otherwise.
|
||||
bool SaveTranscript(CommandReturnObject &result,
|
||||
llvm::Optional<std::string> output_file = std::nullopt);
|
||||
std::optional<std::string> output_file = std::nullopt);
|
||||
|
||||
FileSpec GetCurrentSourceDir();
|
||||
|
||||
|
||||
@@ -3191,7 +3191,7 @@ bool CommandInterpreter::IOHandlerInterrupt(IOHandler &io_handler) {
|
||||
}
|
||||
|
||||
bool CommandInterpreter::SaveTranscript(
|
||||
CommandReturnObject &result, llvm::Optional<std::string> output_file) {
|
||||
CommandReturnObject &result, std::optional<std::string> output_file) {
|
||||
if (output_file == std::nullopt || output_file->empty()) {
|
||||
std::string now = llvm::to_string(std::chrono::system_clock::now());
|
||||
std::replace(now.begin(), now.end(), ' ', '_');
|
||||
|
||||
@@ -65,8 +65,8 @@ Error IntelPTCollector::TraceStop(const TraceStopRequest &request) {
|
||||
/// \return
|
||||
/// some file descriptor in /sys/fs/ associated with the cgroup of the given
|
||||
/// pid, or \a std::nullopt if the pid is not part of a cgroup.
|
||||
static Optional<int> GetCGroupFileDescriptor(lldb::pid_t pid) {
|
||||
static Optional<int> fd;
|
||||
static std::optional<int> GetCGroupFileDescriptor(lldb::pid_t pid) {
|
||||
static std::optional<int> fd;
|
||||
if (fd)
|
||||
return fd;
|
||||
|
||||
@@ -119,7 +119,7 @@ Error IntelPTCollector::TraceStart(const TraceIntelPTStartRequest &request) {
|
||||
effective_request.enable_tsc = true;
|
||||
|
||||
// We try to use cgroup filtering whenever possible
|
||||
Optional<int> cgroup_fd;
|
||||
std::optional<int> cgroup_fd;
|
||||
if (!request.disable_cgroup_filtering.value_or(false))
|
||||
cgroup_fd = GetCGroupFileDescriptor(m_process.GetID());
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ static Error IncludePerfEventParanoidMessageInError(Error &&error) {
|
||||
Expected<std::unique_ptr<IntelPTMultiCoreTrace>>
|
||||
IntelPTMultiCoreTrace::StartOnAllCores(const TraceIntelPTStartRequest &request,
|
||||
NativeProcessProtocol &process,
|
||||
Optional<int> cgroup_fd) {
|
||||
std::optional<int> cgroup_fd) {
|
||||
Expected<ArrayRef<cpu_id_t>> cpu_ids = GetAvailableLogicalCoreIDs();
|
||||
if (!cpu_ids)
|
||||
return cpu_ids.takeError();
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
static llvm::Expected<std::unique_ptr<IntelPTMultiCoreTrace>>
|
||||
StartOnAllCores(const TraceIntelPTStartRequest &request,
|
||||
NativeProcessProtocol &process,
|
||||
llvm::Optional<int> cgroup_fd = std::nullopt);
|
||||
std::optional<int> cgroup_fd = std::nullopt);
|
||||
|
||||
/// Execute the provided callback on each core that is being traced.
|
||||
///
|
||||
|
||||
@@ -228,9 +228,11 @@ Expected<std::vector<uint8_t>> IntelPTSingleBufferTrace::GetIptTrace() {
|
||||
return m_perf_event.GetReadOnlyAuxBuffer();
|
||||
}
|
||||
|
||||
Expected<IntelPTSingleBufferTrace> IntelPTSingleBufferTrace::Start(
|
||||
const TraceIntelPTStartRequest &request, Optional<lldb::tid_t> tid,
|
||||
Optional<cpu_id_t> cpu_id, bool disabled, Optional<int> cgroup_fd) {
|
||||
Expected<IntelPTSingleBufferTrace>
|
||||
IntelPTSingleBufferTrace::Start(const TraceIntelPTStartRequest &request,
|
||||
std::optional<lldb::tid_t> tid,
|
||||
std::optional<cpu_id_t> cpu_id, bool disabled,
|
||||
std::optional<int> cgroup_fd) {
|
||||
#ifndef PERF_ATTR_SIZE_VER5
|
||||
return createStringError(inconvertibleErrorCode(),
|
||||
"Intel PT Linux perf event not supported");
|
||||
|
||||
@@ -50,10 +50,9 @@ public:
|
||||
/// A \a IntelPTSingleBufferTrace instance if tracing was successful, or
|
||||
/// an \a llvm::Error otherwise.
|
||||
static llvm::Expected<IntelPTSingleBufferTrace>
|
||||
Start(const TraceIntelPTStartRequest &request,
|
||||
llvm::Optional<lldb::tid_t> tid,
|
||||
llvm::Optional<lldb::cpu_id_t> cpu_id = std::nullopt,
|
||||
bool disabled = false, llvm::Optional<int> cgroup_fd = std::nullopt);
|
||||
Start(const TraceIntelPTStartRequest &request, std::optional<lldb::tid_t> tid,
|
||||
std::optional<lldb::cpu_id_t> cpu_id = std::nullopt,
|
||||
bool disabled = false, std::optional<int> cgroup_fd = std::nullopt);
|
||||
|
||||
/// \return
|
||||
/// The bytes requested by a jLLDBTraceGetBinaryData packet that was routed
|
||||
|
||||
@@ -76,9 +76,9 @@ void resource_handle::FileDescriptorDeleter::operator()(long *ptr) {
|
||||
}
|
||||
|
||||
llvm::Expected<PerfEvent> PerfEvent::Init(perf_event_attr &attr,
|
||||
Optional<lldb::pid_t> pid,
|
||||
Optional<lldb::cpu_id_t> cpu,
|
||||
Optional<long> group_fd,
|
||||
std::optional<lldb::pid_t> pid,
|
||||
std::optional<lldb::cpu_id_t> cpu,
|
||||
std::optional<long> group_fd,
|
||||
unsigned long flags) {
|
||||
errno = 0;
|
||||
long fd = syscall(SYS_perf_event_open, &attr, pid.value_or(-1),
|
||||
@@ -92,8 +92,8 @@ llvm::Expected<PerfEvent> PerfEvent::Init(perf_event_attr &attr,
|
||||
}
|
||||
|
||||
llvm::Expected<PerfEvent> PerfEvent::Init(perf_event_attr &attr,
|
||||
Optional<lldb::pid_t> pid,
|
||||
Optional<lldb::cpu_id_t> cpu) {
|
||||
std::optional<lldb::pid_t> pid,
|
||||
std::optional<lldb::cpu_id_t> cpu) {
|
||||
return Init(attr, pid, cpu, -1, 0);
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ lldb_private::process_linux::CreateContextSwitchTracePerfEvent(
|
||||
LLDB_LOG(log, "Will create context switch trace buffer of size {0}",
|
||||
data_buffer_size);
|
||||
|
||||
Optional<long> group_fd;
|
||||
std::optional<long> group_fd;
|
||||
if (parent_perf_event)
|
||||
group_fd = parent_perf_event->GetFd();
|
||||
|
||||
|
||||
@@ -107,9 +107,9 @@ public:
|
||||
/// If the perf_event_open syscall was successful, a minimal \a PerfEvent
|
||||
/// instance, or an \a llvm::Error otherwise.
|
||||
static llvm::Expected<PerfEvent> Init(perf_event_attr &attr,
|
||||
llvm::Optional<lldb::pid_t> pid,
|
||||
llvm::Optional<lldb::cpu_id_t> cpu,
|
||||
llvm::Optional<long> group_fd,
|
||||
std::optional<lldb::pid_t> pid,
|
||||
std::optional<lldb::cpu_id_t> cpu,
|
||||
std::optional<long> group_fd,
|
||||
unsigned long flags);
|
||||
|
||||
/// Create a new performance monitoring event via the perf_event_open syscall
|
||||
@@ -125,8 +125,8 @@ public:
|
||||
/// The process or thread to be monitored by the event. If \b None, then
|
||||
/// all threads and processes are monitored.
|
||||
static llvm::Expected<PerfEvent>
|
||||
Init(perf_event_attr &attr, llvm::Optional<lldb::pid_t> pid,
|
||||
llvm::Optional<lldb::cpu_id_t> core = std::nullopt);
|
||||
Init(perf_event_attr &attr, std::optional<lldb::pid_t> pid,
|
||||
std::optional<lldb::cpu_id_t> core = std::nullopt);
|
||||
|
||||
/// Mmap the metadata page and the data and aux buffers of the perf event and
|
||||
/// expose them through \a PerfEvent::GetMetadataPage() , \a
|
||||
|
||||
Reference in New Issue
Block a user