• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 #include <unwindstack/DexFiles.h>
18 
19 #if defined(DEXFILE_SUPPORT)
20 #include "DexFile.h"
21 #endif
22 
23 #include "GlobalDebugImpl.h"
24 
25 namespace unwindstack {
26 
27 #if defined(DEXFILE_SUPPORT)
28 
29 template <>
Load(Maps * maps,std::shared_ptr<Memory> & memory,uint64_t addr,uint64_t size,std::shared_ptr<DexFile> & dex)30 bool GlobalDebugInterface<DexFile>::Load(Maps* maps, std::shared_ptr<Memory>& memory, uint64_t addr,
31                                          uint64_t size, /*out*/ std::shared_ptr<DexFile>& dex) {
32   dex = DexFile::Create(addr, size, memory.get(), maps->Find(addr));
33   return dex.get() != nullptr;
34 }
35 
CreateDexFiles(ArchEnum arch,std::shared_ptr<Memory> & memory,std::vector<std::string> search_libs)36 std::unique_ptr<DexFiles> CreateDexFiles(ArchEnum arch, std::shared_ptr<Memory>& memory,
37                                          std::vector<std::string> search_libs) {
38   return CreateGlobalDebugImpl<DexFile>(arch, memory, search_libs, "__dex_debug_descriptor");
39 }
40 
41 #else
42 
43 template <>
44 bool GlobalDebugInterface<DexFile>::Load(Maps*, std::shared_ptr<Memory>&, uint64_t, uint64_t,
45                                          std::shared_ptr<DexFile>&) {
46   return false;
47 }
48 
49 std::unique_ptr<DexFiles> CreateDexFiles(ArchEnum, std::shared_ptr<Memory>&,
50                                          std::vector<std::string>) {
51   return nullptr;
52 }
53 
54 #endif
55 
56 }  // namespace unwindstack
57