| 320 | /// @b Complexity: O(N) |
| 321 | template <class Char, class Trait> |
| 322 | static basic_stacktrace from_dump(std::basic_istream<Char, Trait>& in, const allocator_type& a = allocator_type()) { |
| 323 | typedef typename std::basic_istream<Char, Trait>::pos_type pos_type; |
| 324 | basic_stacktrace ret(0, 0, a); |
| 325 | |
| 326 | // reserving space |
| 327 | const pos_type pos = in.tellg(); |
| 328 | in.seekg(0, in.end); |
| 329 | const std::size_t frames_count = frames_count_from_buffer_size(static_cast<std::size_t>(in.tellg())); |
| 330 | in.seekg(pos); |
| 331 | |
| 332 | if (!frames_count) { |
| 333 | return ret; |
| 334 | } |
| 335 | |
| 336 | native_frame_ptr_t ptr = 0; |
| 337 | ret.impl_.reserve(frames_count); |
| 338 | while (in.read(reinterpret_cast<Char*>(&ptr), sizeof(ptr))) { |
| 339 | if (!ptr) { |
| 340 | break; |
| 341 | } |
| 342 | |
| 343 | ret.impl_.push_back(frame(ptr)); |
| 344 | } |
| 345 | |
| 346 | return ret; |
| 347 | } |
| 348 | |
| 349 | /// Constructs stacktrace from raw memory dump. Terminating zero frame is discarded. |
| 350 | /// |