File: EnumToString.cpp

package info (click to toggle)
lief 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 16,036 kB
  • sloc: cpp: 76,013; python: 6,167; ansic: 3,355; pascal: 404; sh: 98; makefile: 32
file content (103 lines) | stat: -rw-r--r-- 4,198 bytes parent folder | download | duplicates (2)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* Copyright 2017 R. Thomas
 * Copyright 2017 Quarkslab
 *
 * 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.
 */
#include "LIEF/OAT/enums.hpp"
#include "LIEF/OAT/EnumToString.hpp"

#include "frozen.hpp"

#include <map>

namespace LIEF {
namespace OAT {

const char* to_string(OAT_CLASS_TYPES e) {
  CONST_MAP(OAT_CLASS_TYPES, const char*, 3) enumStrings {
    { OAT_CLASS_TYPES::OAT_CLASS_ALL_COMPILED,  "ALL_COMPILED"  },
    { OAT_CLASS_TYPES::OAT_CLASS_SOME_COMPILED, "SOME_COMPILED" },
    { OAT_CLASS_TYPES::OAT_CLASS_NONE_COMPILED, "NONE_COMPILED" },

  };
  auto   it  = enumStrings.find(e);
  return it == enumStrings.end() ? "UNDEFINED" : it->second;
}

const char* to_string(OAT_CLASS_STATUS e) {
  CONST_MAP(OAT_CLASS_STATUS, const char*, 13) enumStrings {
    { OAT_CLASS_STATUS::STATUS_RETIRED,                       "RETIRED"                 },
    { OAT_CLASS_STATUS::STATUS_ERROR,                         "ERROR"                   },
    { OAT_CLASS_STATUS::STATUS_NOTREADY,                      "NOTREADY"                },
    { OAT_CLASS_STATUS::STATUS_IDX,                           "IDX"                     },
    { OAT_CLASS_STATUS::STATUS_LOADED,                        "LOADED"                  },
    { OAT_CLASS_STATUS::STATUS_RESOLVING,                     "RESOLVING"               },
    { OAT_CLASS_STATUS::STATUS_RESOLVED,                      "RESOLVED"                },
    { OAT_CLASS_STATUS::STATUS_VERIFYING,                     "VERIFYING"               },
    { OAT_CLASS_STATUS::STATUS_RETRY_VERIFICATION_AT_RUNTIME, "VERIFICATION_AT_RUNTIME" },
    { OAT_CLASS_STATUS::STATUS_VERIFYING_AT_RUNTIME,          "VERIFYING_AT_RUNTIME"    },
    { OAT_CLASS_STATUS::STATUS_VERIFIED,                      "VERIFIED"                },
    { OAT_CLASS_STATUS::STATUS_INITIALIZING,                  "INITIALIZING"            },
    { OAT_CLASS_STATUS::STATUS_INITIALIZED,                   "INITIALIZED"             },

  };
  auto   it  = enumStrings.find(e);
  return it == enumStrings.end() ? "UNDEFINED" : it->second;
}


const char* to_string(HEADER_KEYS e) {
  CONST_MAP(HEADER_KEYS, const char*, 11) enumStrings {
    { HEADER_KEYS::KEY_IMAGE_LOCATION,     "IMAGE_LOCATION"     },
    { HEADER_KEYS::KEY_DEX2OAT_CMD_LINE,   "DEX2OAT_CMD_LINE"   },
    { HEADER_KEYS::KEY_DEX2OAT_HOST,       "DEX2OAT_HOST"       },
    { HEADER_KEYS::KEY_PIC,                "PIC"                },
    { HEADER_KEYS::KEY_HAS_PATCH_INFO,     "HAS_PATCH_INFO"     },
    { HEADER_KEYS::KEY_DEBUGGABLE,         "DEBUGGABLE"         },
    { HEADER_KEYS::KEY_NATIVE_DEBUGGABLE,  "NATIVE_DEBUGGABLE"  },
    { HEADER_KEYS::KEY_COMPILER_FILTER,    "COMPILER_FILTER"    },
    { HEADER_KEYS::KEY_CLASS_PATH,         "CLASS_PATH"         },
    { HEADER_KEYS::KEY_BOOT_CLASS_PATH,    "BOOT_CLASS_PATH"    },
    { HEADER_KEYS::KEY_CONCURRENT_COPYING, "CONCURRENT_COPYING" },

  };
  auto   it  = enumStrings.find(e);
  return it == enumStrings.end() ? "UNDEFINED" : it->second;
}


const char* to_string(INSTRUCTION_SETS e) {
  CONST_MAP(INSTRUCTION_SETS, const char*, 8) enumStrings {
    { INSTRUCTION_SETS::INST_SET_NONE,    "NONE"    },
    { INSTRUCTION_SETS::INST_SET_ARM,     "ARM"     },
    { INSTRUCTION_SETS::INST_SET_ARM_64,  "ARM_64"  },
    { INSTRUCTION_SETS::INST_SET_THUMB2,  "THUMB2"  },
    { INSTRUCTION_SETS::INST_SET_X86,     "X86"     },
    { INSTRUCTION_SETS::INST_SET_X86_64,  "X86_64"  },
    { INSTRUCTION_SETS::INST_SET_MIPS,    "MIPS"    },
    { INSTRUCTION_SETS::INST_SET_MIPS_64, "MIPS_64" },

  };
  auto   it  = enumStrings.find(e);
  return it == enumStrings.end() ? "UNDEFINED" : it->second;
}





} // namespace OAT
} // namespace LIEF