ROSE 0.11.145.192
LibraryInfo.h
1#ifndef LIBRARY_INFO_H
2#define LIBRARY_INFO_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_LIBRARY_IDENTIFICATION
5
6#include <Rose/BinaryAnalysis/AstHasher.h>
7#include <time.h>
8#include "Combinatorics.h"
9
10// Deprecated [Robb Matzke 2022-01-20]
11namespace LibraryIdentification {
12
13const std::string unknownLibraryName = "UNKNOWN";
14const std::string multiLibraryName = "MULTIPLE_LIBS";
15
16// Deprecated [Robb Matzke 2022-01-20]
17class LibraryInfo {
18public:
19 // Constructor.
20 //
21 // Combines all the information required to identify a library. This constructor allows the user to define
22 // everything.
23 //
24 // @param[in] libName Name of the library to add.
25 // @param[in] libVersion Version of the library. Please use Fowler-Noll-Vo HasherFnv class in Combinatorics.h.
26 // @param[in] libHash Unique Hash of the library to add. Please use Fowler-Noll-Vo HasherFnv class in Combinatorics.h.
27 // @param[in] architecture architecture library was built for.
28 LibraryInfo(const std::string& libName, const std::string& libVersion, const std::string& libHash,
29 const std::string& architecture)
30 : libName(libName), libVersion(libVersion), libHash(libHash), architecture(architecture) {
31 analysisTime = time(NULL);
32 }
33
34 // Constructor.
35 //
36 // Only takes the hash, Rest to be filled in from matching in the database.
37 //
38 // @param[in] libHash Unique Hash of the library to add
39 LibraryInfo(const std::string& libHash)
40 : libName(unknownLibraryName), libVersion(unknownLibraryName), libHash(libHash), architecture(unknownLibraryName) {}
41
42 // True if the hashes are in ascending order.
43 //
44 // Lessthan operator for sorting and recognizing duplicates.
45 friend bool operator<(const LibraryInfo& lhs,const LibraryInfo& rhs) {
46 return lhs.libHash < rhs.libHash;
47 }
48
49 // Factory for "Unknown Library" instance.
50 //
51 // Constructs and returns the special sentinal "Unknown Library" instance for functions that couldn't be identified.
52 static LibraryInfo getUnknownLibraryInfo() {
53 return LibraryInfo(unknownLibraryName, unknownLibraryName, unknownLibraryName, unknownLibraryName);
54 }
55
56 // Factory for "Multi Library" instance.
57 //
58 // Constructs and returns the special sentinal "Multi Library" instance for functions that couldn't be uniquely
59 // identified. ie, a function with this hash appears in multiple libraries (probably with multiple names).
60 static LibraryInfo getMultiLibraryInfo() {
61 return LibraryInfo(multiLibraryName, multiLibraryName, multiLibraryName, multiLibraryName);
62 }
63
64 // Human readable libary identifier
65 std::string toString() {
66 return libName + "." + libVersion;
67 }
68
69 // The name of the library.
70 std::string libName;
71
72 // The version of the library.
73 std::string libVersion;
74
75 // A hash that should uniquely identify the library.
76 std::string libHash;
77
78 // Instruction set for which library was built.
79 std::string architecture;
80
81 // The time when this library was processed.
82 time_t analysisTime;
83};
84
85} // namespace
86
87#endif
88#endif
ROSE_UTIL_API std::string toString(const Path &)
Convert a path to a string.