Use CPPTRACE_PATH_MAX more consistently, and another small refactor
This commit is contained in:
parent
87cd24438b
commit
0ee29d0855
@ -22,9 +22,9 @@
|
||||
namespace cpptrace {
|
||||
namespace detail {
|
||||
inline void get_safe_object_frame(frame_ptr address, safe_object_frame* out) {
|
||||
out->raw_address = address;
|
||||
dl_find_object result;
|
||||
if(_dl_find_object(reinterpret_cast<void*>(address), &result) == 0) {
|
||||
out->raw_address = address;
|
||||
out->address_relative_to_object_start = address - reinterpret_cast<frame_ptr>(result.dlfo_map_start);
|
||||
if(result.dlfo_link_map->l_name != nullptr && result.dlfo_link_map->l_name[0] != 0) {
|
||||
std::size_t path_length = std::strlen(result.dlfo_link_map->l_name);
|
||||
@ -35,8 +35,8 @@ namespace detail {
|
||||
);
|
||||
} else {
|
||||
// empty l_name, this means it's the currently running executable
|
||||
memset(out->object_path, 0, PATH_MAX + 1);
|
||||
auto res = readlink("/proc/self/exe", out->object_path, PATH_MAX);
|
||||
memset(out->object_path, 0, CPPTRACE_PATH_MAX + 1);
|
||||
auto res = readlink("/proc/self/exe", out->object_path, CPPTRACE_PATH_MAX);
|
||||
if(res == -1) {
|
||||
// error handling?
|
||||
}
|
||||
@ -44,7 +44,6 @@ namespace detail {
|
||||
}
|
||||
} else {
|
||||
// std::cout<<"error"<<std::endl;
|
||||
out->raw_address = address;
|
||||
out->address_relative_to_object_start = 0;
|
||||
out->object_path[0] = 0;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace detail {
|
||||
#include <mach-o/dyld.h>
|
||||
#include <sys/syslimits.h>
|
||||
|
||||
#define CPPTRACE_MAX_PATH PATH_MAX
|
||||
#define CPPTRACE_MAX_PATH CPPTRACE_PATH_MAX
|
||||
|
||||
namespace cpptrace {
|
||||
namespace detail {
|
||||
@ -49,7 +49,7 @@ namespace detail {
|
||||
static bool valid = false;
|
||||
if(!did_init) {
|
||||
did_init = true;
|
||||
std::uint32_t bufferSize = PATH_MAX + 1;
|
||||
std::uint32_t bufferSize = CPPTRACE_PATH_MAX + 1;
|
||||
char buffer[bufferSize];
|
||||
if(_NSGetExecutablePath(buffer, &bufferSize) == 0) {
|
||||
name.assign(buffer, bufferSize);
|
||||
@ -67,7 +67,7 @@ namespace detail {
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define CPPTRACE_MAX_PATH PATH_MAX
|
||||
#define CPPTRACE_MAX_PATH CPPTRACE_PATH_MAX
|
||||
|
||||
namespace cpptrace {
|
||||
namespace detail {
|
||||
@ -79,8 +79,8 @@ namespace detail {
|
||||
static bool valid = false;
|
||||
if(!did_init) {
|
||||
did_init = true;
|
||||
char buffer[PATH_MAX + 1];
|
||||
const ssize_t size = readlink("/proc/self/exe", buffer, PATH_MAX);
|
||||
char buffer[CPPTRACE_PATH_MAX + 1];
|
||||
const ssize_t size = readlink("/proc/self/exe", buffer, CPPTRACE_PATH_MAX);
|
||||
if(size == -1) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user