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);}
 
   50static std::string toStringForRTI(
const std::vector<std::pair<T,T> >& x) {
 
   51  std::ostringstream ss;
 
   53  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;}
 
   58template <
typename F, 
typename S> 
 
   59static std::string toStringForRTI(
const std::vector<std::pair<F,S> >& x) {
 
   60  std::ostringstream ss;
 
   62  for (
typename std::vector<std::pair<F,S> >::const_iterator i = x.begin(); i != x.end(); ++i)
 
   63  {
if (i != x.begin()) ss << 
", "; ss << i->first << 
"->" << i->second;}
 
   68#ifdef ROSE_ENABLE_BINARY_ANALYSIS 
   72     std::ostringstream ss;
 
   74     printf (
"Warning: SgSharedVector iterator support is not finished! \n");
 
   80static std::string toStringForRTI(
const std::vector<bool>& x) {
 
   81  std::ostringstream ss;
 
   83  for (std::vector<bool>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss << 
", "; ss << (*i ? 
"T" : 
"F");}
 
   89static std::string toStringForRTI(
const std::list<T>& x) {
 
   90  std::ostringstream ss;
 
   92  for (
typename std::list<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss << 
", "; ss << (*i);}
 
   98static std::string toStringForRTI(
const std::set<T>& x) {
 
   99  std::ostringstream ss;
 
  101  for (
typename std::set<T>::const_iterator i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss << 
", "; ss << (*i);}
 
  107static std::string toStringForRTI(
const std::unordered_set<T>& x) {
 
  108  std::ostringstream ss;
 
  110  for (
auto i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss << 
", "; ss << (*i);}
 
  116template <
typename K, 
typename V>
 
  117static std::string toStringForRTI(
const std::map<K, V>& x) {
 
  118  std::ostringstream ss;
 
  120  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);}
 
  125template <
typename K, 
typename V>
 
  126static std::string toStringForRTI(
const std::unordered_map<K, V>& x) {
 
  127  std::ostringstream ss;
 
  129  for (
auto i = x.begin(); i != x.end(); ++i) {
if (i != x.begin()) ss << 
", "; ss << i->first << 
"->" << toStringForRTI(i->second);}
 
  136static std::string toStringForRTI(
const std::map<K, std::set<PreprocessingInfo*> >& x) {
 
  137  std::ostringstream ss;
 
  139  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);}
 
  144template <
typename K, 
typename V>
 
  145static std::string toStringForRTI(
const std::multimap<K, V>& x) {
 
  146  std::ostringstream ss;
 
  148  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;}
 
  153#ifdef ROSE_USING_GRAPH_IR_NODES_FOR_BACKWARD_COMPATABILITY 
  156  std::ostringstream ss;
 
  165  std::ostringstream ss;
 
  173  std::ostringstream ss;
 
  181  std::ostringstream ss;
 
  189  std::ostringstream ss;
 
  197  std::ostringstream ss;
 
  203#ifdef ROSE_USING_GRAPH_IR_NODES_FOR_BACKWARD_COMPATABILITY 
  206  std::ostringstream ss;
 
  214  return m.displayString();
 
  218  return m.displayString();
 
  222  return m.displayString();
 
  226  return m.displayString();
 
  230  return m.displayString();
 
  234  return m.displayString();
 
  238  return m.displayString();
 
  242  return m.displayString();
 
  246  return m.displayString();
 
  249static std::string toStringForRTI(
const SgName& n) {
 
  250  return n.getString();
 
  254  std::ostringstream os;
 
  255  os << 
" ( " << x.x << 
", "  << x.y << 
", " << x.z << 
" ) ";
 
  261  return std::to_string(
static_cast<int>(e));
 
  264  return std::to_string(
static_cast<int>(e));
 
  266#ifdef ROSE_ENABLE_BINARY_ANALYSIS 
  267static std::string toStringForRTI(Rose::BinaryAnalysis::JvmInstructionKind &e) {
 
  268  std::ostringstream os;
 
  269  Rose::BinaryAnalysis::JvmInstructionKind kind = Rose::BinaryAnalysis::JvmInstructionKind::nop;
 
  270  int intKind = 
static_cast<int>(kind);
 
  272  return std::to_string(
static_cast<int>(e));
 
  276void 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)
 
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.