1#ifndef ROSE_RTIHELPERS_H
2#define ROSE_RTIHELPERS_H
10#include <boost/lexical_cast.hpp>
11#include <Sawyer/BitVector.h>
12#include <Rose/BinaryAnalysis/AddressInterval.h>
13#include <Rose/BinaryAnalysis/AddressIntervalSet.h>
19#include <valgrind/valgrind.h>
20#include <valgrind/memcheck.h>
22static void doUninitializedFieldCheck(
const char* fieldName,
void* fieldPointer,
size_t fieldSize,
void* wholeObject,
const char* className) {
23 if (VALGRIND_CHECK_READABLE(fieldPointer, fieldSize)) {
24 fprintf(stderr,
"Warning: uninitialized field p_%s of object %p of class %s\n", fieldName, wholeObject, className);
30static std::string toStringForRTI(
const T& x) {
31 std::ostringstream ss;
37 return "0x" + x.
toHex();
41static std::string toStringForRTI(
const std::vector<T>& x) {
42 std::ostringstream ss;
44 for (
typename std::vector<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i);}
51static std::string toStringForRTI(
const std::vector<std::pair<T,T> >& x) {
52 std::ostringstream ss;
54 for (
typename std::vector<std::pair<T,T> >::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
60template <
typename F,
typename S>
61static std::string toStringForRTI(
const std::vector<std::pair<F,S> >& x) {
62 std::ostringstream ss;
64 for (
typename std::vector<std::pair<F,S> >::const_iterator i = x.begin(); i != x.end(); ++i)
65 {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
71static std::string toStringForRTI(
const ExtentMap &x)
73 std::ostringstream ss;
75 for (ExtentMap::const_iterator i=x.
begin(); i!=x.
end(); ++i) {
78 ss << i->first <<
"->" << i->second;
84#ifdef ROSE_ENABLE_BINARY_ANALYSIS
89 std::ostringstream ss;
92 printf (
"Warning: SgSharedVector iterator support is not finished! \n");
102static std::string toStringForRTI(
const std::vector<bool>& x) {
103 std::ostringstream ss;
105 for (std::vector<bool>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i ?
"T" :
"F");}
111static std::string toStringForRTI(
const std::list<T>& x) {
112 std::ostringstream ss;
114 for (
typename std::list<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i);}
120static std::string toStringForRTI(
const std::set<T>& x) {
121 std::ostringstream ss;
123 for (
typename std::set<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << (*i);}
128template <
typename K,
typename V>
129static std::string toStringForRTI(
const std::map<K, V>& x) {
130 std::ostringstream ss;
132 for (
typename std::map<K, V>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << toStringForRTI(i->second);}
139static std::string toStringForRTI(
const std::map<K, std::set<PreprocessingInfo*> >& x) {
140 std::ostringstream ss;
142 for (
typename std::map<K, std::set<PreprocessingInfo*> >::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << toStringForRTI(i->second);}
148template <
typename K,
typename V>
149static std::string toStringForRTI(
const std::multimap<K, V>& x) {
150 std::ostringstream ss;
152 for (
typename std::multimap<K, V>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
158static std::string toStringForRTI(
const std::map<std::pair<
int,std::pair<int,int> >, uint64_t > & x) {
159 std::ostringstream ss;
168static std::string toStringForRTI(
const std::map<uint64_t ,std::pair<
int,std::pair<int,int> > > & x) {
169 std::ostringstream ss;
182#ifdef ROSE_USING_GRAPH_IR_NODES_FOR_BACKWARD_COMPATABILITY
186 std::ostringstream ss;
196 std::ostringstream ss;
205 std::ostringstream ss;
214 std::ostringstream ss;
223 std::ostringstream ss;
232 std::ostringstream ss;
241static std::string toStringForRTI(
const rose_undirected_graph_hash_multimap & x)
243 std::ostringstream ss;
253static std::string toStringForRTI(
const rose_directed_graph_hash_multimap & x)
255 std::ostringstream ss;
263#ifdef ROSE_USING_GRAPH_IR_NODES_FOR_BACKWARD_COMPATABILITY
268 std::ostringstream ss;
280static std::string toStringForRTI(
const std::map<int, SgGraphNode*> & x)
282 std::ostringstream ss;
285 for (std::map<int, SgGraphNode*>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss <<
", "; ss << i->first <<
"->" << i->second;}
295static std::string toStringForRTI(
const rose_undirected_graph_hash_multimap & x)
297 std::ostringstream ss;
309 return m.displayString();
313 return m.displayString();
317 return m.displayString();
321 return m.displayString();
325 return m.displayString();
329 return m.displayString();
333 return m.displayString();
337 return m.displayString();
341 return m.displayString();
344static std::string toStringForRTI(
const SgName& n) {
345 return n.getString();
349 std::ostringstream os;
350 os <<
" ( " << x.x <<
", " << x.y <<
", " << x.z <<
" ) ";
356 return std::to_string(
static_cast<int>(e));
359 return std::to_string(
static_cast<int>(e));
361#ifdef ROSE_ENABLE_BINARY_ANALYSIS
362static std::string toStringForRTI(Rose::BinaryAnalysis::JvmInstructionKind &e) {
363 std::ostringstream os;
364 Rose::BinaryAnalysis::JvmInstructionKind kind = Rose::BinaryAnalysis::JvmInstructionKind::nop;
365 int intKind =
static_cast<int>(kind);
367 return std::to_string(
static_cast<int>(e));
374template <
typename Sym>
375static std::string toStringForRTISymbol(Sym* sym) {
376 std::ostringstream ss;
379 ss <<
": varsym " << sym->get_name().str() <<
" declared at 0x" << std::hex << (sym->get_declaration());
384static std::string toStringForRTI(
SgVariableSymbol* sym) {
return toStringForRTISymbol(sym);}
385static std::string toStringForRTI(
SgFunctionSymbol* sym) {
return toStringForRTISymbol(sym);}
388static std::string toStringForRTI(
const SgSymbolTable&) {
return "<no output operator defined for this type>";}
389static std::string toStringForRTI(
const SgSymbolHashBase::iterator&) {
return "<no output operator defined for this type>";}
392void doRTI(
const char* fieldNameBase,
void* fieldPtr,
size_t fieldSize,
void* thisPtr,
const char* className,
const char* typeString,
const char* fieldName,
const std::string& fieldContents,
RTIMemberData& memberData);
Access to C++ Run Time Information (RTI)
iterator begin()
First-item iterator.
iterator end()
End-item iterator.
std::string toHex(const BitRange &range) const
Convert to a hexadecimal string.
This class represents modifiers for SgDeclaration (declaration statements).
WordsPerEntry
Enum for words-per-entry in a Jovial table.
StructureSpecifier
Enum for Jovial structure specifiers.
This class represents strings within the IR nodes.
This class represents modifiers specific to storage.
This class represents the symbol tables used in both SgScopeStatement and the SgFunctionTypeSymbolTab...
This class represents the concept of a variable name within the compiler (a shared container for the ...