ROSE 0.11.145.263
SourceLocations.h
1#ifndef ROSE_BinaryAnalysis_SourceLocations_H
2#define ROSE_BinaryAnalysis_SourceLocations_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/AddressInterval.h>
7#include <Rose/BinaryAnalysis/AddressIntervalSet.h>
8#include <Rose/SourceLocation.h>
9
10#include <Sawyer/IntervalMap.h>
11#include <Sawyer/Map.h>
12#include <Sawyer/Optional.h>
13#include <Sawyer/Synchronization.h>
14
15#include <boost/filesystem.hpp>
16
17#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
18#include <boost/serialization/access.hpp>
19#endif
20
21#include <set>
22#include <string>
23
24class SgNode;
25
26namespace Rose {
27namespace BinaryAnalysis {
28
34public:
37
38private:
39 mutable SAWYER_THREAD_TRAITS::Mutex mutex_; // protects the following data members
40 AddressToSource addrToSrc_;
41 SourceToAddress srcToAddr_;
42
43private:
44#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
45 friend class boost::serialization::access;
46
47 template<class S>
48 void serialize(S &s, const unsigned /*version*/) {
49 s & BOOST_SERIALIZATION_NVP(addrToSrc_);
50 s & BOOST_SERIALIZATION_NVP(srcToAddr_);
51 }
52#endif
53
54public:
59
85 void erase(const SourceLocation&, const AddressInterval&);
93 void erase(const AddressInterval&);
98 void erase(const SourceLocation&);
99
101 void clear();
102
108
116 void fillHoles(size_t maxHoleSize = 64);
117
123 return get(va);
124 }
129
135 return firstAddress(loc);
136 }
140 std::set<boost::filesystem::path> allFileNames() const;
141
149
155 void printSrcToAddr(std::ostream&, const std::string &prefix = "") const;
156 void print(std::ostream&, const std::string &prefix = "") const;
162 void printAddrToSrc(std::ostream&, const std::string &prefix = "") const;
163
164private:
165 // Non-synchronized erasing of a link between source code and binary address.
166 void eraseNS(const SourceLocation&, Address);
167 void eraseNS(Address va);
168};
169
170std::ostream& operator<<(std::ostream&, const SourceLocations&);
171
172} // namespace
173} // namespace
174
175#endif
176#endif
Bidirectional mapping between addresses and source locations.
void fillHoles(size_t maxHoleSize=64)
Fill in small holes in the address space.
void insert(const SourceLocation &, const AddressIntervalSet &)
Insert links between source and adresseses.
void erase(const SourceLocation &, Address)
Remove links between source and addresses.
Sawyer::Optional< Address > operator()(const SourceLocation &loc) const
Find the first address associated with a source location.
SourceLocation nextSourceLocation(const SourceLocation &current=SourceLocation()) const
Given a source location, return the next source location.
void erase(const SourceLocation &, const AddressIntervalSet &)
Remove links between source and addresses.
void insert(const SourceLocation &, const AddressInterval &)
Insert links between source and adresseses.
void printAddrToSrc(std::ostream &, const std::string &prefix="") const
Print the address to source mapping.
void printSrcToAddr(std::ostream &, const std::string &prefix="") const
Print the source to address mapping.
void erase(const AddressInterval &)
Remove all links for the specified addresses regardless of source.
void insert(const SourceLocation &, Address)
Insert links between source and adresseses.
SourceLocation operator()(Address va) const
Find the source location for an address.
AddressIntervalSet get(const SourceLocation &) const
Find the addresses associated with a source location.
void print(std::ostream &, const std::string &prefix="") const
Print the source to address mapping.
void erase(const SourceLocation &, const AddressInterval &)
Remove links between source and addresses.
std::set< boost::filesystem::path > allFileNames() const
Get the list of all known source files.
SourceLocations & operator=(const SourceLocations &)
Atomic copy.
SourceLocations(const SourceLocations &)
Atomic copy.
Sawyer::Optional< Address > firstAddress(const SourceLocation &) const
Find the first address associated with a source location.
void erase(const AddressIntervalSet &)
Remove all links for the specified addresses regardless of source.
void insertFromDebug(SgNode *ast)
Insert information from debug tables.
SourceLocation get(Address) const
Find the source location for an address.
void erase(const SourceLocation &)
Remove all links for the specified source location regardless of address.
void erase(Address)
Remove all links for the specified addresses regardless of source.
Information about a source location.
An associative container whose keys are non-overlapping intervals.
Container associating values with keys.
Definition Sawyer/Map.h:72
Holds a value or nothing.
Definition Optional.h:56
This class represents the base class for all IR nodes within Sage III.
std::uint64_t Address
Address.
Definition Address.h:11
The ROSE library.