Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/gammasoft71/xtd
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Oct 26, 2024
2 parents a5ef420 + c5b33f7 commit a8d696e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/xtd.core.native.macos/src/xtd/native/macos/stack_trace.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
using frame = tuple<string, size_t, size_t, string, size_t>;
using frame_collection = vector<frame>;

tuple<string, size_t> get_method_and_offset_from_address(address address) {
tuple<string, size_t> get_method_and_offset(address address) {
auto dl_info = Dl_info {};
if (!dladdr(address, &dl_info)) return make_tuple("", numeric_limits<size_t>::max());
return make_tuple(__xtd_abi_demangle(dl_info.dli_sname ? dl_info.dli_sname : ""), reinterpret_cast<size_t>(address) - reinterpret_cast<size_t>(dl_info.dli_saddr));
}

frame_collection get_frames_without_file_info_from_addresses(const address_collection& addresses) {
frame_collection get_frames_without_file_info(const address_collection& addresses) {
auto frames = ::frame_collection {};
for (const auto& address : addresses) {
auto [method, offset] = get_method_and_offset_from_address(address);
auto [method, offset] = get_method_and_offset(address);
frames.emplace_back("", size_t {}, size_t {}, method, offset);
}
return frames;
}

frame_collection get_frames_from_addresses(const address_collection& addresses) {
frame_collection get_frames(const address_collection& addresses) {
auto ss = stringstream {};
ss << "atos -p " << getpid() << " ";
for (const auto& address : addresses)
Expand All @@ -63,7 +63,7 @@ frame_collection get_frames_from_addresses(const address_collection& addresses)
} catch (...) {
}
}
auto [dummy, offset] = get_method_and_offset_from_address(addresses[index]);
auto [dummy, offset] = get_method_and_offset(addresses[index]);
frames.emplace_back(file_name, line, size_t {}, method, offset);
}
return frames;
Expand All @@ -81,7 +81,7 @@ frame_collection get_frames_from_addresses(const address_collection& addresses)
addresses.erase(addresses.begin(), addresses.begin() + skip_frames + get_native_offset());

auto frames = frame_collection {};
for (const auto& frame : need_file_info ? get_frames_from_addresses(addresses) : get_frames_without_file_info_from_addresses(addresses)) {
for (const auto& frame : need_file_info ? ::get_frames(addresses) : get_frames_without_file_info(addresses)) {
if (get<3>(frame) == "start") break;
frames.push_back(frame);
}
Expand Down

0 comments on commit a8d696e

Please sign in to comment.