2#ifndef ROSE_SgAsmGenericFile_H
3#define ROSE_SgAsmGenericFile_H
5#include <Cxx_GrammarDeclarations.h>
6#include <SgAsmExecutableFileFormat.h>
27#include <Rose/BinaryAnalysis/Address.h>
28#include <Rose/BinaryAnalysis/MemoryMap.h>
29#include <Rose/BinaryAnalysis/AddressIntervalSet.h>
31#include "DataConversion.h"
32#include "StatSerializer.h"
34#ifdef ROSE_SgAsmGenericFile_IMPL
35#include <SgAsmDwarfCompilationUnitList.h>
36#include <SgAsmGenericSectionList.h>
37#include <SgAsmGenericHeaderList.h>
47#if !defined(DOCUMENTATION)
62#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
64 friend class boost::serialization::access;
70 s & BOOST_SERIALIZATION_NVP(p_dwarfInfo);
71 s & BOOST_SERIALIZATION_NVP(p_name);
72 s & BOOST_SERIALIZATION_NVP(p_sb);
73 s & BOOST_SERIALIZATION_NVP(p_data);
74 s & BOOST_SERIALIZATION_NVP(p_headers);
75 s & BOOST_SERIALIZATION_NVP(p_holes);
76 s & BOOST_SERIALIZATION_NVP(p_truncateZeros);
77 s & BOOST_SERIALIZATION_NVP(p_trackingReferences);
78 s & BOOST_SERIALIZATION_NVP(p_referencedExtents);
79 s & BOOST_SERIALIZATION_NVP(p_neuter);
89 ADDRSP_MEMORY = 0x0001,
117 std::string
const&
get_name()
const;
127 int const& get_fd()
const;
128 void set_fd(
int const&);
132 struct stat const& get_sb()
const;
167 bool const& get_truncateZeros()
const;
168 void set_truncateZeros(
bool const&);
175 bool const& get_trackingReferences()
const;
176 void set_trackingReferences(
bool const&);
191 bool const& get_neuter()
const;
192 void set_neuter(
bool const&);
216 void unparse(std::ostream&)
const;
219 void extendToEof(std::ostream&)
const;
222 void dump(FILE*)
const;
230 void dumpAll(
bool in_cwd=
true,
const char *ext=NULL);
233 void dumpAll(
const std::string& dumpname);
304 SgAsmGenericSectionPtrList get_mappedSections()
const;
307 SgAsmGenericSectionPtrList get_sections(
bool include_holes=
true)
const;
310 SgAsmGenericSectionPtrList get_sectionsById(
int id)
const;
313 SgAsmGenericSectionPtrList get_sectionsByName(std::string,
char sep=
'\0')
const;
344 SgAsmGenericSection *get_sectionByName(
const std::string&,
char sep=0,
size_t *nfound=0)
const;
469 const char *formatName()
const;
481 bool get_truncate_zeros() const ROSE_DEPRECATED("use get_truncateZeros");
482 void set_truncate_zeros(
bool) ROSE_DEPRECATED("use set_truncateZeros");
483 bool get_tracking_references() const ROSE_DEPRECATED("use get_trackingReferences");
484 void set_tracking_references(
bool) ROSE_DEPRECATED("use set_trackingReferences");
485 const
Rose::BinaryAnalysis::AddressIntervalSet& get_referenced_extents() const ROSE_DEPRECATED("use get_referencedExtents");
486 void set_referenced_extents(const
Rose::BinaryAnalysis::AddressIntervalSet&) ROSE_DEPRECATED("use set_referencedExtents");
487 void extend_to_eof(std::ostream&) const ROSE_DEPRECATED("use extendToEof");
488 void dump_all(
bool in_cwd=true, const
char *ext=NULL) ROSE_DEPRECATED("use dumpAll");
489 void dump_all(const std::
string& dumpname) ROSE_DEPRECATED("use dumpAll");
490 const
Rose::BinaryAnalysis::AddressIntervalSet& get_unreferenced_extents() const
491 ROSE_DEPRECATED("use get_unreferencedExtents");
492 void mark_referenced_extent(
Rose::BinaryAnalysis::Address,
Rose::BinaryAnalysis::Address)
493 ROSE_DEPRECATED("use markReferencedExtent");
494 DataConverter* get_data_converter() const ROSE_DEPRECATED("use get_dataConverter");
495 void set_data_converter(
DataConverter*) ROSE_DEPRECATED("use set_dataConverter");
496 Rose::BinaryAnalysis::Address get_current_size() const ROSE_DEPRECATED("use get_currentSize");
497 Rose::BinaryAnalysis::Address get_orig_size() const ROSE_DEPRECATED("use get_originalSize");
498 size_t read_content(
Rose::BinaryAnalysis::Address,
void*,
Rose::BinaryAnalysis::Address,
bool=true)
499 ROSE_DEPRECATED("use readContent");
500 size_t read_content(const
Rose::BinaryAnalysis::MemoryMap::Ptr&,
Rose::BinaryAnalysis::Address,
void*,
501 Rose::BinaryAnalysis::Address,
bool=true) ROSE_DEPRECATED("use readContent");
502 std::
string read_content_str(const
Rose::BinaryAnalysis::MemoryMap::Ptr&,
Rose::BinaryAnalysis::Address,
bool=true)
503 ROSE_DEPRECATED("use readContentString");
504 std::
string read_content_str(
Rose::BinaryAnalysis::Address,
bool=true) ROSE_DEPRECATED("use readContentString");
505 SgAsmGenericSectionPtrList get_mapped_sections() const ROSE_DEPRECATED("use get_mappedSections");
506 SgAsmGenericSectionPtrList get_sections_by_id(
int id) const ROSE_DEPRECATED("use get_sectionById");
507 SgAsmGenericSectionPtrList get_sections_by_name(std::
string,
char='\0') const ROSE_DEPRECATED("use get_sectionsByName");
508 SgAsmGenericSectionPtrList get_sections_by_offset(
Rose::BinaryAnalysis::Address,
Rose::BinaryAnalysis::Address) const
509 ROSE_DEPRECATED("use get_sectionsByOffset");
510 SgAsmGenericSectionPtrList get_sections_by_rva(
Rose::BinaryAnalysis::Address) const ROSE_DEPRECATED("use get_sectionsByRva");
511 SgAsmGenericSectionPtrList get_sections_by_va(
Rose::BinaryAnalysis::Address) const ROSE_DEPRECATED("use get_sectionsByVa");
512 SgAsmGenericSection *get_section_by_id(
int,
size_t* =
nullptr) const ROSE_DEPRECATED("use get_sectionById");
513 SgAsmGenericSection *get_section_by_name(const std::
string&,
char=0,
size_t* =
nullptr) const
514 ROSE_DEPRECATED("use get_sectionByName");
516 ROSE_DEPRECATED("use get_sectionByOffset");
518 ROSE_DEPRECATED("use get_sectionByRva");
520 ROSE_DEPRECATED("use get_sectionByVa");
522 ROSE_DEPRECATED("use get_bestSectionByVa");
523 static
SgAsmGenericSection *best_section_by_va(const SgAsmGenericSectionPtrList&,
Rose::BinaryAnalysis::Address)
524 ROSE_DEPRECATED("use bestSectionByVa");
526 ROSE_DEPRECATED("use shiftExtend");
528 ROSE_DEPRECATED("use shiftExtend");
529 Rose::BinaryAnalysis::Address get_next_section_offset(
Rose::BinaryAnalysis::Address)
530 ROSE_DEPRECATED("use get_nextSectionOffset");
533 void fill_holes() ROSE_DEPRECATED("use fillHoles");
534 void unfill_holes() ROSE_DEPRECATED("use unfillHoles");
537 const
char *format_name() const ROSE_DEPRECATED("use formatName");
553 void initializeProperties();
572 virtual std::
string class_name() const override;
575 virtual VariantT variantT() const override;
580 enum { static_variant = V_SgAsmGenericFile };
595 static const unsigned pool_size;
597 static std::vector<unsigned char *> pools;
602 static unsigned long initializeStorageClassArray(SgAsmGenericFileStorageClass *);
605 static void clearMemoryPool();
606 static void deleteMemoryPool();
609 static void extendMemoryPoolForFileIO();
614 static SgAsmGenericFile * getPointerFromGlobalIndex(AstSpecificDataManagingClass *,
unsigned long);
617 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long);
619 static void resetValidFreepointers();
621 static unsigned long getNumberOfLastValidPointer();
624#if defined(INLINE_FUNCTIONS)
626 inline void *
operator new (
size_t size);
629 void *
operator new (
size_t size);
632 void operator delete (
void* pointer,
size_t size);
635 void operator delete (
void* pointer)
681#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
684 virtual RTIReturnType
roseRTI()
override;
698 virtual const char*
sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
704 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
886 friend class SgAsmGenericFileStorageClass;
889 friend class AstSpecificDataManagingClass;
892 friend class AstSpecificDataManagingClassStorageClass;
924#define BUILD_ATERM_SUPPORT 0
925 #if BUILD_ATERM_SUPPORT
926 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
938 virtual ATerm generate_ATerm()
override;
941 virtual void generate_ATerm_Annotation(ATerm & term)
override;
1005bool p_truncateZeros;
1009bool p_trackingReferences;
Class holding static data and functions supporting File I/O.
Attribute containing a regex expression as a string.
Encodes and decodes a buffer using an algorithm defined in subclasses.
Base class for binary files.
List of pointers to file sections.
Contiguous region of a file.
Supporting class from copy mechanism within ROSE.
This class represents the base class for all IR nodes within Sage III.
virtual RTIReturnType roseRTI()
return C++ Runtime-Time-Information
virtual size_t get_numberOfTraversalSuccessors() const
return number of children in the traversal successor list
virtual std::vector< std::string > get_traversalSuccessorNamesContainer() const
container of names of variables or container indices used used in the traversal to access AST success...
virtual void debugSerializationEnd(const char *className)
Called by generated serializers.
static std::string getNodeIdString(SgNode *sgnode)
compute the NodeId for a particular SgNode*.
virtual bool isInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
int variant() const
Older version function returns enum value "NODE".
virtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler *)
FOR INTERNAL USE Processes pairs of references to SgNode* and strings for use in AST tools
virtual size_t get_childIndex(SgNode *child) const
index-based access to traversal successors by child node
virtual std::vector< SgNode * > get_traversalSuccessorContainer() const
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
virtual long getChildIndex(SgNode *childNode) const
FOR INTERNAL USE Returns a unique index value for the childNode in the list of children at this IR no...
virtual void debugSerializationBegin(const char *className)
Called by generated serializers.
virtual SgNode * get_traversalSuccessorByIndex(size_t idx) const
index-based access to traversal successors by index number
static void visitRepresentativeNode(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for type-based traversal.
virtual void checkDataMemberPointersIfInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
static size_t numberOfNodes()
Returns the total number of IR nodes of this type.
virtual void accept(ROSE_VisitorPattern &visitor)
support for the classic visitor pattern done in GoF
static void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
void executeVisitorMemberFunction(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
static SgNode * getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx)
Find a node by its variant type, pool index, and item index.
static size_t memoryUsage()
Returns the size in bytes of the total memory allocated for all IR nodes of this type.
static void traverseMemoryPoolNodes(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
virtual const char * sage_class_name() const
generates string representing the class name: (e.g. for SgNode returns "SgNode").
virtual std::vector< std::pair< SgNode *, std::string > > returnDataMemberPointers() const
FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools
static SgNode * getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx)
FOR INTERNAL USE Find an SgNode from its memory pool and location therin.
SgNode * addRegExpAttribute(std::string s, AstRegExAttribute *a)
Support for AST matching using regular expression.
virtual void destructorHelper()
This gets called by all Rosebud-generated destructors.
void parse(SgAsmGenericFile *)
Main function to parse DWARF information.
std::uint64_t Address
Address.
void serialize(std::ostream &output, Graph &graph)
Serialize a graph into a stream of bytes.
ROSE_DLL_API int set_name(SgInitializedName *initializedNameNode, SgName new_name)
set_name of symbol in symbol table.
std::string get_name(const SgNode *node)
Generate a useful name to describe the SgNode.
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.
const char * Elasticity(int64_t)
Convert SgAsmGenericFile::Elasticity enum constant to a string.
const char * AddressSpace(int64_t)
Convert SgAsmGenericFile::AddressSpace enum constant to a string.