DexFile.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef _LIBUNWINDSTACK_DEX_FILE_H
  17. #define _LIBUNWINDSTACK_DEX_FILE_H
  18. #include <stdint.h>
  19. #include <map>
  20. #include <memory>
  21. #include <string>
  22. #include <utility>
  23. #include <vector>
  24. #include <art_api/dex_file_support.h>
  25. namespace unwindstack {
  26. class DexFile : protected art_api::dex::DexFile {
  27. public:
  28. virtual ~DexFile() = default;
  29. bool GetMethodInformation(uint64_t dex_offset, std::string* method_name, uint64_t* method_offset);
  30. static std::unique_ptr<DexFile> Create(uint64_t dex_file_offset_in_memory, Memory* memory,
  31. MapInfo* info);
  32. protected:
  33. DexFile(art_api::dex::DexFile&& art_dex_file) : art_api::dex::DexFile(std::move(art_dex_file)) {}
  34. };
  35. class DexFileFromFile : public DexFile {
  36. public:
  37. static std::unique_ptr<DexFileFromFile> Create(uint64_t dex_file_offset_in_file,
  38. const std::string& file);
  39. private:
  40. DexFileFromFile(art_api::dex::DexFile&& art_dex_file) : DexFile(std::move(art_dex_file)) {}
  41. };
  42. class DexFileFromMemory : public DexFile {
  43. public:
  44. static std::unique_ptr<DexFileFromMemory> Create(uint64_t dex_file_offset_in_memory,
  45. Memory* memory, const std::string& name);
  46. private:
  47. DexFileFromMemory(art_api::dex::DexFile&& art_dex_file, std::vector<uint8_t>&& memory)
  48. : DexFile(std::move(art_dex_file)), memory_(std::move(memory)) {}
  49. std::vector<uint8_t> memory_;
  50. };
  51. } // namespace unwindstack
  52. #endif // _LIBUNWINDSTACK_DEX_FILE_H