// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/profiler/chrome_unwind_info_android_32.h" #include "base/containers/buffer_iterator.h" namespace base { ChromeUnwindInfoAndroid32::ChromeUnwindInfoAndroid32( span unwind_instruction_table, span function_offset_table, span function_table, span page_table) : unwind_instruction_table(unwind_instruction_table), function_offset_table(function_offset_table), function_table(function_table), page_table(page_table) {} ChromeUnwindInfoAndroid32::~ChromeUnwindInfoAndroid32() = default; ChromeUnwindInfoAndroid32::ChromeUnwindInfoAndroid32( const ChromeUnwindInfoAndroid32& other) = default; ChromeUnwindInfoAndroid32& ChromeUnwindInfoAndroid32::operator=( const ChromeUnwindInfoAndroid32& other) = default; ChromeUnwindInfoAndroid32::ChromeUnwindInfoAndroid32( ChromeUnwindInfoAndroid32&& other) = default; ChromeUnwindInfoAndroid32& ChromeUnwindInfoAndroid32::operator=( ChromeUnwindInfoAndroid32&& other) = default; ChromeUnwindInfoAndroid32 CreateChromeUnwindInfoAndroid32( span data) { BufferIterator data_iterator(data); const auto* header = data_iterator.Object(); DCHECK(header); data_iterator.Seek(header->page_table_byte_offset); const auto page_table = data_iterator.Span(header->page_table_entries); DCHECK(!page_table.empty()); data_iterator.Seek(header->function_offset_table_byte_offset); const auto function_offset_table = data_iterator.Span(header->function_offset_table_size_in_bytes); DCHECK(!function_offset_table.empty()); data_iterator.Seek(header->function_table_byte_offset); const auto function_table = data_iterator.Span(header->function_table_entries); DCHECK(!function_table.empty()); data_iterator.Seek(header->unwind_instruction_table_byte_offset); const auto unwind_instruction_table = data_iterator.Span( header->unwind_instruction_table_size_in_bytes); DCHECK(!unwind_instruction_table.empty()); return ChromeUnwindInfoAndroid32{unwind_instruction_table, function_offset_table, function_table, page_table}; } } // namespace base