MCPcopy Create free account
hub / github.com/boostorg/stacktrace / source_line

Function source_line

include/boost/stacktrace/detail/addr2line_impls.hpp:251–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251inline std::size_t source_line(const void* addr, bool position_independent) {
252 std::size_t line_num = 0;
253 uintptr_t addr_base = 0;
254 if(position_independent){
255 addr_base = boost::stacktrace::detail::get_own_proc_addr_base(addr);
256 }
257 const void* offset = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(addr) - addr_base);
258 std::string res = boost::stacktrace::detail::addr2line("-e", offset);
259 const std::size_t last = res.find_last_of(':');
260 if (last == std::string::npos) {
261 return 0;
262 }
263 res = res.substr(last + 1);
264
265 if (!boost::stacktrace::detail::try_dec_convert(res.c_str(), line_num)) {
266 return 0;
267 }
268
269 return line_num;
270}
271
272} // namespace detail
273

Callers 2

frameClass · 0.85
source_lineMethod · 0.85

Calls 3

addr2lineFunction · 0.85
try_dec_convertFunction · 0.85
get_own_proc_addr_baseFunction · 0.70

Tested by

no test coverage detected