ROSE 0.11.145.192
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#include <boost/serialization/access.hpp>
17
18#include <set>
19#include <string>
20
21class SgNode;
22
23namespace Rose {
24namespace BinaryAnalysis {
25
31public:
34
35private:
36 mutable SAWYER_THREAD_TRAITS::Mutex mutex_; // protects the following data members
37 AddressToSource addrToSrc_;
38 SourceToAddress srcToAddr_;
39
40private:
41#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
42 friend class boost::serialization::access;
43
44 template<class S>
45 void serialize(S &s, const unsigned /*version*/) {
46 s & BOOST_SERIALIZATION_NVP(addrToSrc_);
47 s & BOOST_SERIALIZATION_NVP(srcToAddr_);
48 }
49#endif
50
51public:
56
69 void insert(const SourceLocation&, rose_addr_t);
81 void erase(const SourceLocation&, rose_addr_t);
82 void erase(const SourceLocation&, const AddressInterval&);
89 void erase(rose_addr_t);
90 void erase(const AddressInterval&);
95 void erase(const SourceLocation&);
96
98 void clear();
99
105
113 void fillHoles(size_t maxHoleSize = 64);
114
118 SourceLocation get(rose_addr_t) const;
119 SourceLocation operator()(rose_addr_t va) const {
120 return get(va);
121 }
126
132 return firstAddress(loc);
133 }
137 std::set<boost::filesystem::path> allFileNames() const;
138
146
152 void printSrcToAddr(std::ostream&, const std::string &prefix = "") const;
153 void print(std::ostream&, const std::string &prefix = "") const;
159 void printAddrToSrc(std::ostream&, const std::string &prefix = "") const;
160
161private:
162 // Non-synchronized erasing of a link between source code and binary address.
163 void eraseNS(const SourceLocation&, rose_addr_t);
164 void eraseNS(rose_addr_t va);
165};
166
167std::ostream& operator<<(std::ostream&, const SourceLocations&);
168
169} // namespace
170} // namespace
171
172#endif
173#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.
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 erase(rose_addr_t)
Remove all links for the specified addresses regardless of source.
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.
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.
Sawyer::Optional< rose_addr_t > operator()(const SourceLocation &loc) const
Find the first address associated with a source location.
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.
void erase(const SourceLocation &, rose_addr_t)
Remove links between source and addresses.
void erase(const AddressIntervalSet &)
Remove all links for the specified addresses regardless of source.
void insertFromDebug(SgNode *ast)
Insert information from debug tables.
void insert(const SourceLocation &, rose_addr_t)
Insert links between source and adresseses.
void erase(const SourceLocation &)
Remove all links for the specified source location regardless of address.
SourceLocation operator()(rose_addr_t va) const
Find the source location for an address.
SourceLocation get(rose_addr_t) const
Find the source location for an address.
Sawyer::Optional< rose_addr_t > firstAddress(const SourceLocation &) const
Find the first address associated with a source location.
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.
The ROSE library.