#include "src/trace_processor/perfetto_sql/intrinsics/table_functions/flamegraph_construction_algorithms.h"
#include <algorithm>
#include <cstdint>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <unordered_set>
#include <utility>
#include <vector>
#include "perfetto/base/logging.h"
#include "perfetto/ext/base/string_splitter.h"
#include "perfetto/ext/base/string_utils.h"
#include "perfetto/ext/base/string_view.h"
#include "perfetto/trace_processor/basic_types.h"
#include "src/trace_processor/containers/row_map.h"
#include "src/trace_processor/db/column/types.h"
#include "src/trace_processor/db/table.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/tables/metadata_tables_py.h"
#include "src/trace_processor/tables/profiler_tables_py.h"
namespace perfetto::trace_processor {
namespace {
struct MergedCallsite { … };
struct FlamegraphTableAndMergedCallsites { … };
std::vector<MergedCallsite> GetMergedCallsites(TraceStorage* storage,
uint32_t callstack_row) { … }
}
static FlamegraphTableAndMergedCallsites BuildFlamegraphTableTreeStructure(
TraceStorage* storage,
std::optional<UniquePid> upid,
std::optional<std::string> upid_group,
int64_t default_timestamp,
StringId profile_type) { … }
static std::unique_ptr<tables::ExperimentalFlamegraphTable>
BuildFlamegraphTableHeapSizeAndCount(
std::unique_ptr<tables::ExperimentalFlamegraphTable> tbl,
const std::vector<uint32_t>& callsite_to_merged_callsite,
tables::HeapProfileAllocationTable::ConstIterator it) { … }
static std::unique_ptr<tables::ExperimentalFlamegraphTable>
BuildFlamegraphTableCallstackSizeAndCount(
const tables::PerfSampleTable& table,
std::unique_ptr<tables::ExperimentalFlamegraphTable> tbl,
const std::vector<uint32_t>& callsite_to_merged_callsite,
std::vector<Constraint> constraints,
const std::unordered_set<uint32_t>& utids) { … }
std::unique_ptr<tables::ExperimentalFlamegraphTable> BuildHeapProfileFlamegraph(
TraceStorage* storage,
UniquePid upid,
int64_t timestamp) { … }
std::unique_ptr<tables::ExperimentalFlamegraphTable>
BuildNativeCallStackSamplingFlamegraph(
TraceStorage* storage,
std::optional<UniquePid> upid,
std::optional<std::string> upid_group,
const std::vector<TimeConstraints>& time_constraints) { … }
}