File: dex_file_tracking_registrar.h

package info (click to toggle)
android-platform-art 11.0.0%2Br48-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,932 kB
  • sloc: cpp: 459,858; java: 163,268; asm: 22,644; python: 9,815; sh: 6,330; ansic: 4,117; xml: 2,855; perl: 77; makefile: 73
file content (81 lines) | stat: -rw-r--r-- 2,787 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ART_LIBDEXFILE_DEX_DEX_FILE_TRACKING_REGISTRAR_H_
#define ART_LIBDEXFILE_DEX_DEX_FILE_TRACKING_REGISTRAR_H_

#include <deque>
#include <tuple>

#include "dex_file.h"

namespace art {
namespace dex {
namespace tracking {

// Class for (un)poisoning various sections of Dex Files
//
// This class provides the means to log accesses only of sections whose
// accesses are needed. All accesses are displayed as stack traces in
// logcat.
class DexFileTrackingRegistrar {
 public:
  explicit DexFileTrackingRegistrar(const DexFile* const dex_file)
      : dex_file_(dex_file) {
  }

  // This function is where the functions below it are called to actually
  // poison sections.
  void SetDexSections();

  // Uses data contained inside range_values_ to poison memory through the
  // memory tool.
  void SetCurrentRanges();

 private:
  void SetDexFileRegistration(bool should_poison);

  // Set of functions concerning Code Items of dex_file_
  void SetAllCodeItemRegistration(bool should_poison);
  // Sets the insns_ section of all code items.
  void SetAllInsnsRegistration(bool should_poison);
  // This function finds the code item of a class based on class name.
  void SetCodeItemRegistration(const char* class_name, bool should_poison);
  // Sets the size and offset information along with first instruction in insns_
  // section of all code items.
  void SetAllCodeItemStartRegistration(bool should_poison);

  // Set of functions concerning String Data Items of dex_file_
  void SetAllStringDataRegistration(bool should_poison);
  // Sets the first byte of size value and data section of all string data
  // items.
  void SetAllStringDataStartRegistration(bool should_poison);

  // Contains tuples of all ranges of memory that need to be explicitly
  // (un)poisoned by the memory tool.
  std::deque<std::tuple<const void *, size_t, bool>> range_values_;

  const DexFile* const dex_file_;
};

// This function is meant to called externally to use DexfileTrackingRegistrar
void RegisterDexFile(const DexFile* dex_file);

}  // namespace tracking
}  // namespace dex
}  // namespace art

#endif  // ART_LIBDEXFILE_DEX_DEX_FILE_TRACKING_REGISTRAR_H_