ClickHouse/src/Functions/addressToLine.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
1.8 KiB
C++
Raw Normal View History

#if defined(__ELF__) && !defined(OS_FREEBSD)
2019-08-21 00:48:34 +00:00
#include <Common/Dwarf.h>
#include <Columns/ColumnString.h>
#include <DataTypes/DataTypeString.h>
#include <Functions/FunctionFactory.h>
#include <IO/WriteBufferFromArena.h>
#include <IO/WriteHelpers.h>
#include <Access/Common/AccessFlags.h>
#include <Functions/addressToLine.h>
namespace DB
{
2020-09-07 18:00:37 +00:00
namespace
{
class FunctionAddressToLine: public FunctionAddressToLineBase<StringRef, Dwarf::LocationInfoMode::FAST>
{
public:
static constexpr auto name = "addressToLine";
2022-01-25 16:30:27 +00:00
String getName() const override { return name; }
2021-06-01 12:20:52 +00:00
static FunctionPtr create(ContextPtr context)
{
context->checkAccess(AccessType::addressToLine);
return std::make_shared<FunctionAddressToLine>();
}
protected:
DataTypePtr getDataType() const override
{
return std::make_shared<DataTypeString>();
}
ColumnPtr getResultColumn(const typename ColumnVector<UInt64>::Container & data, size_t input_rows_count) const override
{
auto result_column = ColumnString::create();
for (size_t i = 0; i < input_rows_count; ++i)
{
StringRef res_str = implCached(data[i]);
result_column->insertData(res_str.data, res_str.size);
}
2020-10-17 15:22:42 +00:00
return result_column;
}
void setResult(StringRef & result, const Dwarf::LocationInfo & location, const std::vector<Dwarf::SymbolizedFrame> &) const override
{
const char * arena_begin = nullptr;
WriteBufferFromArena out(cache.arena, arena_begin);
writeString(location.file.toString(), out);
writeChar(':', out);
writeIntText(location.line, out);
result = out.complete();
}
};
2020-09-07 18:00:37 +00:00
}
REGISTER_FUNCTION(AddressToLine)
{
factory.registerFunction<FunctionAddressToLine>();
}
}
2019-08-21 00:48:34 +00:00
#endif