SymbolMap.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //=- tools/dsymutil/SymbolMap.h -----------------------------------*- C++ -*-=//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_TOOLS_DSYMUTIL_SYMBOLMAP_H
  9. #define LLVM_TOOLS_DSYMUTIL_SYMBOLMAP_H
  10. #include "llvm/ADT/StringRef.h"
  11. #include <string>
  12. #include <vector>
  13. namespace llvm {
  14. namespace dsymutil {
  15. class DebugMap;
  16. /// Callable class to unobfuscate strings based on a BCSymbolMap.
  17. class SymbolMapTranslator {
  18. public:
  19. SymbolMapTranslator() : MangleNames(false) {}
  20. SymbolMapTranslator(std::vector<std::string> UnobfuscatedStrings,
  21. bool MangleNames)
  22. : UnobfuscatedStrings(std::move(UnobfuscatedStrings)),
  23. MangleNames(MangleNames) {}
  24. StringRef operator()(StringRef Input);
  25. operator bool() const { return !UnobfuscatedStrings.empty(); }
  26. private:
  27. std::vector<std::string> UnobfuscatedStrings;
  28. bool MangleNames;
  29. };
  30. /// Class to initialize SymbolMapTranslators from a BCSymbolMap.
  31. class SymbolMapLoader {
  32. public:
  33. SymbolMapLoader(std::string SymbolMap) : SymbolMap(std::move(SymbolMap)) {}
  34. SymbolMapTranslator Load(StringRef InputFile, const DebugMap &Map) const;
  35. private:
  36. const std::string SymbolMap;
  37. };
  38. } // namespace dsymutil
  39. } // namespace llvm
  40. #endif // LLVM_TOOLS_DSYMUTIL_SYMBOLMAP_H