Casey Dahlin | 6b95a0e | 2019-03-12 17:50:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _LIBUNWINDSTACK_MEMORY_OFFLINE_H |
| 18 | #define _LIBUNWINDSTACK_MEMORY_OFFLINE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | #include <memory> |
| 23 | #include <string> |
| 24 | #include <vector> |
| 25 | |
| 26 | #include <unwindstack/Memory.h> |
| 27 | |
| 28 | #include "MemoryRange.h" |
| 29 | |
| 30 | namespace unwindstack { |
| 31 | |
| 32 | class MemoryOffline : public Memory { |
| 33 | public: |
| 34 | MemoryOffline() = default; |
| 35 | virtual ~MemoryOffline() = default; |
| 36 | |
| 37 | bool Init(const std::string& file, uint64_t offset); |
| 38 | |
| 39 | size_t Read(uint64_t addr, void* dst, size_t size) override; |
| 40 | |
| 41 | private: |
| 42 | std::unique_ptr<MemoryRange> memory_; |
| 43 | }; |
| 44 | |
| 45 | class MemoryOfflineParts : public Memory { |
| 46 | public: |
| 47 | MemoryOfflineParts() = default; |
| 48 | virtual ~MemoryOfflineParts(); |
| 49 | |
| 50 | void Add(MemoryOffline* memory) { memories_.push_back(memory); } |
| 51 | |
| 52 | size_t Read(uint64_t addr, void* dst, size_t size) override; |
| 53 | |
| 54 | private: |
| 55 | std::vector<MemoryOffline*> memories_; |
| 56 | }; |
| 57 | |
| 58 | } // namespace unwindstack |
| 59 | |
| 60 | #endif // _LIBUNWINDSTACK_MEMORY_OFFLINE_H |