chromium/third_party/perfetto/src/trace_redaction/redact_sched_events.cc

/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "src/trace_redaction/redact_sched_events.h"

#include "perfetto/protozero/scattered_heap_buffer.h"
#include "src/trace_processor/util/status_macros.h"
#include "src/trace_redaction/proto_util.h"

#include "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h"
#include "protos/perfetto/trace/ftrace/ftrace_event_bundle.pbzero.h"
#include "protos/perfetto/trace/ftrace/sched.pbzero.h"

namespace perfetto::trace_redaction {

namespace {
bool IsTrue(bool value) {}

// Copy a field from 'decoder' to 'message' if the field can be found. Returns
// false if the field cannot be found.
bool Passthrough(protozero::ProtoDecoder& decoder,
                 uint32_t field_id,
                 protozero::Message* message) {}
}  // namespace

int64_t InternTable::Push(const char* data, size_t size) {}

std::string_view InternTable::Find(size_t index) const {}

// Redact sched switch trace events in an ftrace event bundle:
//
//  event {
//    timestamp: 6702093744772646
//    pid: 0
//    sched_switch {
//      prev_comm: "swapper/0"
//      prev_pid: 0
//      prev_prio: 120
//      prev_state: 0
//      next_comm: "writer"
//      next_pid: 23020
//      next_prio: 96
//    }
//  }
//
// In the above message, it should be noted that "event.pid" will always be
// equal to "event.sched_switch.prev_pid".
//
// "ftrace_event_bundle_message" is the ftrace event bundle (contains a
// collection of ftrace event messages) because data in a sched_switch message
// is needed in order to know if the event should be added to the bundle.

base::Status RedactSchedEvents::Transform(const Context& context,
                                          std::string* packet) const {}

base::Status RedactSchedEvents::OnFtraceEvents(
    const Context& context,
    protozero::Field ftrace_events,
    protos::pbzero::FtraceEventBundle* message) const {}

base::Status RedactSchedEvents::OnFtraceEvent(
    const Context& context,
    int32_t cpu,
    protozero::Field ftrace_event,
    protos::pbzero::FtraceEvent* message) const {}

base::Status RedactSchedEvents::OnFtraceEventSwitch(
    const Context& context,
    uint64_t ts,
    int32_t cpu,
    protos::pbzero::SchedSwitchFtraceEvent::Decoder& sched_switch,
    std::string* scratch_str,
    protos::pbzero::SchedSwitchFtraceEvent* message) const {}

// Redact sched waking trace events in a ftrace event bundle:
//
//  event {
//    timestamp: 6702093787823849
//    pid: 814                      <-- waker
//    sched_waking {
//      comm: "surfaceflinger"
//      pid: 756                    <-- target
//      prio: 97
//      success: 1
//      target_cpu: 2
//    }
//  }
base::Status RedactSchedEvents::OnFtraceEventWaking(
    const Context& context,
    uint64_t ts,
    int32_t cpu,
    protos::pbzero::SchedWakingFtraceEvent::Decoder& sched_waking,
    std::string* scratch_str,
    protos::pbzero::FtraceEvent* parent_message) const {}

base::Status RedactSchedEvents::OnCompSched(
    const Context& context,
    int32_t cpu,
    protos::pbzero::FtraceEventBundle::CompactSched::Decoder& comp_sched,
    protos::pbzero::FtraceEventBundle::CompactSched* message) const {}

base::Status RedactSchedEvents::OnCompSchedSwitch(
    const Context& context,
    int32_t cpu,
    protos::pbzero::FtraceEventBundle::CompactSched::Decoder& comp_sched,
    InternTable* intern_table,
    protos::pbzero::FtraceEventBundle::CompactSched* message) const {}

base::Status RedactSchedEvents::OnCompactSchedWaking(
    const Context& context,
    protos::pbzero::FtraceEventBundle::CompactSched::Decoder& compact_sched,
    InternTable* intern_table,
    protos::pbzero::FtraceEventBundle::CompactSched* compact_sched_message)
    const {}

}  // namespace perfetto::trace_redaction