#include "src/trace_processor/sqlite/sql_source.h"
#include <sqlite3.h>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <limits>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "perfetto/base/logging.h"
#include "perfetto/ext/base/string_utils.h"
#if SQLITE_VERSION_NUMBER < 3041002
#error "SQLite version is too old."
#endif
namespace perfetto::trace_processor {
namespace {
std::pair<uint32_t, uint32_t> GetLineAndColumnForOffset(const std::string& sql,
uint32_t line,
uint32_t column,
uint32_t offset) { … }
std::pair<std::string, size_t> SqlContextAndCaretPos(const std::string& sql,
uint32_t offset) { … }
}
SqlSource::SqlSource() = default;
SqlSource::SqlSource(Node node) : … { … }
SqlSource::SqlSource(std::string sql,
std::string name,
bool include_traceback_header) { … }
SqlSource SqlSource::FromExecuteQuery(std::string sql) { … }
SqlSource SqlSource::FromMetric(std::string sql, const std::string& name) { … }
SqlSource SqlSource::FromMetricFile(std::string sql, const std::string& name) { … }
SqlSource SqlSource::FromModuleInclude(std::string sql,
const std::string& module) { … }
SqlSource SqlSource::FromTraceProcessorImplementation(std::string sql) { … }
std::string SqlSource::AsTraceback(uint32_t offset) const { … }
std::string SqlSource::AsTracebackForSqliteOffset(
std::optional<uint32_t> opt_offset) const { … }
SqlSource SqlSource::Substr(uint32_t offset, uint32_t len) const { … }
SqlSource SqlSource::RewriteAllIgnoreExisting(SqlSource source) const { … }
std::string SqlSource::ApplyRewrites(const std::string& original_sql,
const std::vector<Rewrite>& rewrites) { … }
std::string SqlSource::Node::AsTraceback(uint32_t rewritten_offset) const { … }
std::string SqlSource::Node::SelfTraceback(uint32_t rewritten_offset,
uint32_t original_offset) const { … }
SqlSource::Node SqlSource::Node::Substr(uint32_t offset, uint32_t len) const { … }
uint32_t SqlSource::Node::RewrittenOffsetToOriginalOffset(
uint32_t rewritten_offset) const { … }
std::optional<uint32_t> SqlSource::Node::RewriteForOriginalOffset(
uint32_t original_offset) const { … }
SqlSource::Rewriter::Rewriter(SqlSource source)
: … { … }
SqlSource::Rewriter::Rewriter(Node source) : … { … }
void SqlSource::Rewriter::Rewrite(uint32_t rewritten_start,
uint32_t rewritten_end,
SqlSource source) { … }
SqlSource SqlSource::Rewriter::Build() && { … }
}