Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cc_defaults {
name: "btfparse-defaults",

cppflags: [
"-fexceptions",
"-Wall",
"-Wconversion",
"-Wunused",
"-Wshadow",
"-fvisibility=hidden",
"-Werror",
"-Wno-deprecated-declarations",
"-O2",
"-DNDEBUG",
"-g0"
]
}
32 changes: 32 additions & 0 deletions btfparse/btfparse/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cc_library {
name: "btfparse",

host_supported: true,

defaults: [
"btfparse-defaults"
],

srcs: [
"src/ibtf.cpp",
"src/ibtfheadergenerator.cpp",
"src/btf.cpp",
"src/btfheadergenerator.cpp"
],

local_include_dirs: [
"include"
],

export_include_dirs: [
"include"
],

header_libs: [
"btfparse-utils"
],

static_libs: [
"btfparse-filereader"
]
}
4 changes: 2 additions & 2 deletions btfparse/btfparse/src/btf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ BTF::parseDataSecData(const BTFFileList &btf_file_list,
}

Result<std::string, BTFError> BTF::parseString(const BTFFileList &btf_file_list,
std::uint64_t offset) noexcept {
std::size_t offset) noexcept {
std::uint32_t start_offset{};

for (const auto &btf_file : btf_file_list) {
Expand Down Expand Up @@ -996,7 +996,7 @@ Result<std::string, BTFError> BTF::parseString(const BTFFileList &btf_file_list,
}

Result<std::string, BTFError> BTF::parseString(IFileReader &file_reader,
std::uint64_t offset) noexcept {
std::size_t offset) noexcept {

Result<std::string, BTFError> output;

Expand Down
4 changes: 2 additions & 2 deletions btfparse/btfparse/src/btf.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ class BTF final : public IBTF {
IFileReader &file_reader) noexcept;

static Result<std::string, BTFError>
parseString(const BTFFileList &btf_file_list, std::uint64_t offset) noexcept;
parseString(const BTFFileList &btf_file_list, std::size_t offset) noexcept;

static Result<std::string, BTFError>
parseString(IFileReader &file_reader, std::uint64_t offset) noexcept;
parseString(IFileReader &file_reader, std::size_t offset) noexcept;

friend class IBTF;
};
Expand Down
7 changes: 5 additions & 2 deletions btfparse/btfparse/src/btfheadergenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ bool BTFHeaderGenerator::materializePadding(Context &context) {
}

bool BTFHeaderGenerator::materializeStructPadding(
Context &context, std::uint32_t id, StructBTFType &struct_btf_type) {
Context &context, [[maybe_unused]] std::uint32_t id, StructBTFType &struct_btf_type) {
auto member_list = std::move(struct_btf_type.member_list);
struct_btf_type.member_list.clear();

Expand Down Expand Up @@ -807,6 +807,8 @@ bool BTFHeaderGenerator::setTypeName(Context &context, std::uint32_t id,
case BTFKind::Fwd: {
auto &fwd_btf_type = getTypeAsMutable<FwdBTFType>(btf_type);
fwd_btf_type.name = name;

return true;
}

default:
Expand Down Expand Up @@ -1571,7 +1573,8 @@ bool BTFHeaderGenerator::generateType(Context &context,

bool BTFHeaderGenerator::generateType(
Context &context, std::stringstream &buffer, std::uint32_t id,
const FuncProtoBTFType &func_proto_btf_type, bool as_type_definition) {
const FuncProtoBTFType &func_proto_btf_type,
[[maybe_unused]] bool as_type_definition) {

filterFuncProtoModifiers(context);
generateTypeHeader(context, buffer, id);
Expand Down
27 changes: 27 additions & 0 deletions btfparse/filereader/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cc_library {
name: "btfparse-filereader",

host_supported: true,

defaults: [
"btfparse-defaults"
],

srcs: [
"src/ifilereader.cpp",
"src/filereader.cpp",
"src/memoryfileadapter.cpp"
],

local_include_dirs: [
"include"
],

export_include_dirs: [
"include"
],

header_libs: [
"btfparse-utils"
]
}
6 changes: 3 additions & 3 deletions btfparse/filereader/include/btfparse/ifilereader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct FileReaderErrorInformation final {
};

struct ReadOperation final {
std::uint64_t offset{};
std::size_t offset{};
std::size_t size{};
};

Expand Down Expand Up @@ -90,8 +90,8 @@ class IFileReader {

virtual void setEndianness(bool little_endian) = 0;

virtual void seek(std::uint64_t offset) = 0;
virtual std::uint64_t offset() const = 0;
virtual void seek(std::size_t offset) = 0;
virtual std::size_t offset() const = 0;

virtual void read(std::uint8_t *buffer, std::size_t size) = 0;
virtual std::uint8_t u8() = 0;
Expand Down
4 changes: 2 additions & 2 deletions btfparse/filereader/include/btfparse/istream.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class IStream {
IStream() = default;
virtual ~IStream() = default;

virtual bool seek(std::uint64_t offset) = 0;
virtual std::uint64_t offset() const = 0;
virtual bool seek(std::size_t offset) = 0;
virtual std::size_t offset() const = 0;

virtual bool read(std::uint8_t *buffer, std::size_t size) = 0;

Expand Down
8 changes: 4 additions & 4 deletions btfparse/filereader/src/filereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void FileReader::setEndianness(bool little_endian) {
setEndianness(d->context, little_endian);
}

void FileReader::seek(std::uint64_t offset) { seek(d->context, offset); }
void FileReader::seek(std::size_t offset) { seek(d->context, offset); }

std::uint64_t FileReader::offset() const { return offset(d->context); }
std::size_t FileReader::offset() const { return offset(d->context); }

void FileReader::read(std::uint8_t *buffer, std::size_t size) {
read(d->context, buffer, size);
Expand All @@ -63,15 +63,15 @@ void FileReader::setEndianness(Context &context, bool little_endian) {
context.little_endian = little_endian;
}

void FileReader::seek(Context &context, std::uint64_t offset) {
void FileReader::seek(Context &context, std::size_t offset) {
if (!context.stream->seek(offset)) {
throw FileReaderError(
{FileReaderErrorInformation::Code::IOError,
FileReaderErrorInformation::ReadOperation{offset, 0}});
}
}

std::uint64_t FileReader::offset(Context &context) {
std::size_t FileReader::offset(Context &context) {
return context.stream->offset();
}

Expand Down
8 changes: 4 additions & 4 deletions btfparse/filereader/src/filereader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class FileReader final : public IFileReader {

virtual void setEndianness(bool little_endian) override;

virtual void seek(std::uint64_t offset) override;
virtual std::uint64_t offset() const override;
virtual void seek(std::size_t offset) override;
virtual std::size_t offset() const override;

virtual void read(std::uint8_t *buffer, std::size_t size) override;
virtual std::uint8_t u8() override;
Expand All @@ -44,8 +44,8 @@ class FileReader final : public IFileReader {

static void setEndianness(Context &context, bool little_endian);

static void seek(Context &context, std::uint64_t offset);
static std::uint64_t offset(Context &context);
static void seek(Context &context, std::size_t offset);
static std::size_t offset(Context &context);

static void read(Context &context, std::uint8_t *buffer, std::size_t size);
static std::uint8_t u8(Context &context);
Expand Down
8 changes: 4 additions & 4 deletions btfparse/filereader/src/memoryfileadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ IStream::Ptr MemoryFileAdapter::create(const std::filesystem::path &path) {
std::size_t pos = 0;

do {
auto read_size = std::min(file_size - pos, 4096UL);
auto read_size = std::min(file_size - pos, static_cast<size_t>(4096));

read_res = ::read(fd, &file_buffer[pos], read_size);

Expand All @@ -78,7 +78,7 @@ IStream::Ptr MemoryFileAdapter::create(const std::filesystem::path &path) {
}
}

bool MemoryFileAdapter::seek(std::uint64_t offset) {
bool MemoryFileAdapter::seek(std::size_t offset) {
if (offset >= file_buffer_size) {
return false;
}
Expand All @@ -88,8 +88,8 @@ bool MemoryFileAdapter::seek(std::uint64_t offset) {
return true;
}

std::uint64_t MemoryFileAdapter::offset() const {
return static_cast<std::uint64_t>(file_pos);
std::size_t MemoryFileAdapter::offset() const {
return file_pos;
}

bool MemoryFileAdapter::read(std::uint8_t *buffer, std::size_t size) {
Expand Down
4 changes: 2 additions & 2 deletions btfparse/filereader/src/memoryfileadapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class MemoryFileAdapter final : public IStream {
static Ptr create(const std::filesystem::path &path);
virtual ~MemoryFileAdapter() override;

virtual bool seek(std::uint64_t offset) override;
virtual std::uint64_t offset() const override;
virtual bool seek(std::size_t offset) override;
virtual std::size_t offset() const override;
virtual bool read(std::uint8_t *buffer, std::size_t size) override;

private:
Expand Down
9 changes: 9 additions & 0 deletions btfparse/utils/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cc_library_headers {
name: "btfparse-utils",

host_supported: true,

export_include_dirs: [
"include"
]
}
21 changes: 21 additions & 0 deletions tools/dump-btf/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cc_binary {
name: "dump-btf",

defaults: [
"btfparse-defaults"
],

srcs: [
"src/main.cpp",
"src/utils.cpp"
],

header_libs: [
"btfparse-utils"
],

static_libs: [
"btfparse-filereader",
"btfparse"
]
}
20 changes: 20 additions & 0 deletions tools/include-gen/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cc_binary {
name: "include-gen",

defaults: [
"btfparse-defaults"
],

srcs: [
"src/main.cpp"
],

header_libs: [
"btfparse-utils"
],

static_libs: [
"btfparse-filereader",
"btfparse"
]
}