/* * Copyright (C) 2023 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_processor/perfetto_sql/intrinsics/functions/stack_functions.h" #include <stdlib.h> #include <cstdint> #include <cstring> #include <deque> #include <iterator> #include <optional> #include <type_traits> #include <vector> #include "perfetto/base/logging.h" #include "perfetto/base/status.h" #include "perfetto/protozero/scattered_heap_buffer.h" #include "perfetto/trace_processor/basic_types.h" #include "perfetto/trace_processor/status.h" #include "protos/perfetto/trace_processor/stack.pbzero.h" #include "src/trace_processor/perfetto_sql/engine/perfetto_sql_engine.h" #include "src/trace_processor/perfetto_sql/intrinsics/functions/sql_function.h" #include "src/trace_processor/sqlite/sqlite_utils.h" #include "src/trace_processor/storage/trace_storage.h" #include "src/trace_processor/types/trace_processor_context.h" #include "src/trace_processor/util/status_macros.h" namespace perfetto { namespace trace_processor { namespace { Stack; util::Status SetBytesOutputValue(const std::vector<uint8_t>& src, SqlValue& out, SqlFunction::Destructors& destructors) { … } // CAT_STACKS(root BLOB/STRING, level_1 BLOB/STRING, …, leaf BLOB/STRING) // Creates a Stack by concatenating other Stacks. Also accepts strings for which // it generates a fake Frame struct CatStacksFunction : public SqlFunction { … }; // STACK_FROM_STACK_PROFILE_CALLSITE(callsite_id LONG, [annotate BOOLEAN]) // Creates a stack by taking a callsite_id (reference to the // stack_profile_callsite table) and generating a list of frames (by walking the // stack_profile_callsite table) // Optionally annotates frames (annotate param has a default value of false) // // Important: Annotations might interfere with certain aggregations, as we // will could have a frame that is annotated with different annotations. That // will lead to multiple functions being generated (same name, line etc, but // different annotation). struct StackFromStackProfileCallsiteFunction : public SqlFunction { … }; // STACK_FROM_STACK_PROFILE_FRAME(frame_id LONG) // Creates a stack with just the frame referenced by frame_id (reference to the // stack_profile_frame table) struct StackFromStackProfileFrameFunction : public SqlFunction { … }; } // namespace base::Status RegisterStackFunctions(PerfettoSqlEngine* engine, TraceProcessorContext* context) { … } } // namespace trace_processor } // namespace perfetto