Skip to content

Commit

Permalink
Improve a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
gleocadie committed Nov 27, 2024
1 parent 7d236d0 commit 969b9e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

extern "C"
{
#include "datadog/blazesym.h"
#include "datadog/common.h"
#include "datadog/crashtracker.h"
#include "datadog/profiling.h"
Expand Down Expand Up @@ -133,9 +132,7 @@ std::vector<ModuleInfo> CrashReportingLinux::GetModules()
moduleBaseAddresses[path] = baseAddress;
}

std::size_t len = 0;
auto* buffer = blaze_read_elf_build_id(path.data(), &len);
modules.push_back(ModuleInfo{ start, end, baseAddress, std::move(path), ElfBuildId(buffer, len)});
modules.push_back(ModuleInfo{ start, end, baseAddress, std::move(path), ElfBuildId(path.data())});
}

return modules;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

extern "C"
{
#include "datadog/blazesym.h"
#include "datadog/common.h"
#include "datadog/profiling.h"
}
Expand All @@ -38,8 +39,13 @@ class ElfBuildId
{
private:
struct ElfBuildIdImpl {
ElfBuildIdImpl() : ElfBuildIdImpl(nullptr, 0) {}
ElfBuildIdImpl(std::uint8_t* ptr, std::size_t size) : _ptr{ptr}, _size{size} {};
ElfBuildIdImpl() : ElfBuildIdImpl(nullptr) {}
ElfBuildIdImpl(const char* path) : _ptr{nullptr}, _size{0} {
if (path != nullptr)
{
_ptr = blaze_read_elf_build_id(path, &_size);
}
};
~ElfBuildIdImpl()
{
auto* ptr = std::exchange(_ptr, nullptr);
Expand All @@ -59,9 +65,9 @@ class ElfBuildId
std::size_t _size;
};
public:
ElfBuildId() : ElfBuildId(nullptr, 0) {}
ElfBuildId(std::uint8_t* ptr, std::size_t size)
: _impl{std::make_shared<ElfBuildIdImpl>(ptr, size)} {}
ElfBuildId() : ElfBuildId(nullptr) {}
ElfBuildId(const char* path)
: _impl{std::make_shared<ElfBuildIdImpl>(path)} {}

shared::span<std::uint8_t> AsSpan() const
{
Expand Down

0 comments on commit 969b9e1

Please sign in to comment.