Skip to content

Commit

Permalink
GP-3276 Put all C++ classes in ghidra namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
caheckman committed Apr 7, 2023
1 parent ca9a56b commit fe137f2
Show file tree
Hide file tree
Showing 217 changed files with 1,636 additions and 555 deletions.
4 changes: 4 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "coreaction.hh"

namespace ghidra {

/// Specify the name, group, and properties of the Action
/// \param f is the collection of property flags
/// \param nm is the Action name
Expand Down Expand Up @@ -1156,3 +1158,5 @@ Action *ActionDatabase::deriveAction(const string &baseaction, const string &grp
registerAction(grp,newact);
return newact;
}

} // End namespace ghidra
7 changes: 5 additions & 2 deletions Ghidra/Features/Decompiler/src/decompile/cpp/action.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
*/
/// \file action.hh
/// \brief Action, Rule, and other associates classes supporting transformations on function data-flow
#ifndef __CPUI_ACTION__
#define __CPUI_ACTION__
#ifndef __ACTION_HH__
#define __ACTION_HH__

#include "block.hh"

namespace ghidra {

/// \brief The list of groups defining a \e root Action
///
/// Any Rule or \e leaf Action belongs to a \b group. This class
Expand Down Expand Up @@ -321,4 +323,5 @@ public:
void universalAction(Architecture *glb); ///< Build the universal action
};

} // End ghidra namespace
#endif
4 changes: 4 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "address.hh"
#include "translate.hh"

namespace ghidra {

AttributeId ATTRIB_FIRST = AttributeId("first",27);
AttributeId ATTRIB_LAST = AttributeId("last",28);
AttributeId ATTRIB_UNIQ = AttributeId("uniq",29);
Expand Down Expand Up @@ -991,3 +993,5 @@ int4 power2Divide(int4 n,uint8 divisor,uint8 &q,uint8 &r)
}
return 0;
}

} // End namespace ghidra
7 changes: 5 additions & 2 deletions Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
/// by placing them in their own space, separate from RAM. Indirection
/// (i.e. pointers) must be simulated through the LOAD and STORE ops.

#ifndef __CPUI_ADDR__
#define __CPUI_ADDR__
#ifndef __ADDRESS_HH__
#define __ADDRESS_HH__

#include "space.hh"

namespace ghidra {

class AddrSpaceManager;

extern AttributeId ATTRIB_FIRST; ///< Marshaling attribute "first"
Expand Down Expand Up @@ -555,4 +557,5 @@ extern void unsignedSubtract128(uint8 *a,uint8 *b);
extern int4 unsignedCompare128(uint8 *a,uint8 *b);
extern int4 power2Divide(int4 n,uint8 divisor,uint8 &q,uint8 &r);

} // End namespace ghidra
#endif
7 changes: 7 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#endif
#ifdef CPUI_STATISTICS
#include <cmath>
#endif

namespace ghidra {

#ifdef CPUI_STATISTICS
using std::sqrt;
#endif

Expand Down Expand Up @@ -1532,3 +1537,5 @@ void Statistics::printResults(ostream &s)
}

#endif

} // End namespace ghidra
7 changes: 5 additions & 2 deletions Ghidra/Features/Decompiler/src/decompile/cpp/architecture.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
/// \file architecture.hh
/// \brief Architecture and associated classes that help manage a single processor architecture and load image
#ifndef __CPUI_ARCHITECTURE__
#define __CPUI_ARCHITECTURE__
#ifndef __ARCHITECTURE_HH__
#define __ARCHITECTURE_HH__

#include "capability.hh"
#include "varmap.hh"
Expand All @@ -34,6 +34,8 @@
#include "transform.hh"
#include "prefersplit.hh"

namespace ghidra {

#ifdef CPUI_STATISTICS
/// \brief Class for collecting statistics while processing over multiple functions
///
Expand Down Expand Up @@ -397,4 +399,5 @@ inline bool Architecture::highPtrPossible(const Address &loc,int4 size) const {
return !nohighptr.inRange(loc,size);
}

} // End namespace ghidra
#endif
4 changes: 4 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
#include "bfd_arch.hh"

namespace ghidra {

// Constructing this object registers capability
BfdArchitectureCapability BfdArchitectureCapability::bfdArchitectureCapability;

Expand Down Expand Up @@ -169,3 +171,5 @@ void BfdArchitecture::restoreXml(DocumentStorage &store)
SleighArchitecture::restoreXml(store);
}
}

} // End namespace ghidra
7 changes: 7 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
*/
/// \file bfd_arch.hh
/// \brief Specific implementation of Architecture using GNU BFD libraries
#ifndef __BFD_ARCH_HH__
#define __BFD_ARCH_HH__

#include "sleigh_arch.hh"
#include "loadimage_bfd.hh"

namespace ghidra {

extern ElementId ELEM_BFD_SAVEFILE; ///< Marshaling element \<bfd_savefile>

/// \brief Extension point for building a GNU BFD capable Architecture
Expand Down Expand Up @@ -47,3 +51,6 @@ public:
BfdArchitecture(const string &fname,const string &targ,ostream *estream); ///< Constructor
virtual ~BfdArchitecture(void) {}
};

} // End namespace ghidra
#endif
4 changes: 4 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "block.hh"
#include "funcdata.hh"

namespace ghidra {

AttributeId ATTRIB_ALTINDEX = AttributeId("altindex",75);
AttributeId ATTRIB_DEPTH = AttributeId("depth",76);
AttributeId ATTRIB_END = AttributeId("end",77);
Expand Down Expand Up @@ -3566,3 +3568,5 @@ FlowBlock *BlockMap::createBlock(const string &name)
sortlist.push_back(bl);
return bl;
}

} // End namespace ghidra
7 changes: 5 additions & 2 deletions Ghidra/Features/Decompiler/src/decompile/cpp/block.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
/// \file block.hh
/// \brief Classes related to \e basic \e blocks and control-flow structuring

#ifndef __CPUI_BLOCK__
#define __CPUI_BLOCK__
#ifndef __BLOCK_HH__
#define __BLOCK_HH__

#include "jumptable.hh"

namespace ghidra {

class BlockBasic; // Forward declarations
class BlockList;
class BlockCopy;
Expand Down Expand Up @@ -816,4 +818,5 @@ inline bool BlockSwitch::CaseOrder::compare(const CaseOrder &a,const CaseOrder &
return (a.depth < b.depth);
}

} // End namespace ghidra
#endif
4 changes: 4 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/blockaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "blockaction.hh"
#include "funcdata.hh"

namespace ghidra {

/// Retrieve the current edge (as a \e top FlowBlock and the index of the outgoing edge).
/// If the end-points have been collapsed together, this returns NULL.
/// The top and bottom nodes of the edge are updated to FlowBlocks in the current collapsed graph.
Expand Down Expand Up @@ -2350,3 +2352,5 @@ int4 ActionNodeJoin::apply(Funcdata &data)
}
return 0;
}

} // End namespace ghidra
7 changes: 5 additions & 2 deletions Ghidra/Features/Decompiler/src/decompile/cpp/blockaction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BLOCK_ACTION__
#define __BLOCK_ACTION__
#ifndef __BLOCKACTION_HH__
#define __BLOCKACTION_HH__

/// \file blockaction.hh
/// \brief Actions and classes associated with transforming and structuring the control-flow graph

#include "action.hh"

namespace ghidra {

/// \brief Class for holding an edge while the underlying graph is being manipulated
///
/// The original FlowBlock nodes that define the end-points of the edge may get
Expand Down Expand Up @@ -355,4 +357,5 @@ public:
virtual int4 apply(Funcdata &data);
};

} // End namespace ghidra
#endif
3 changes: 3 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/callgraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "callgraph.hh"
#include "funcdata.hh"

namespace ghidra {

ElementId ELEM_CALLGRAPH = ElementId("callgraph",226);
ElementId ELEM_NODE = ElementId("node",227);

Expand Down Expand Up @@ -463,3 +465,4 @@ void CallGraph::decoder(Decoder &decoder)
decoder.closeElement(elemId);
}

} // End namespace ghidra
7 changes: 5 additions & 2 deletions Ghidra/Features/Decompiler/src/decompile/cpp/callgraph.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CPUI_CALLGRAPH__
#define __CPUI_CALLGRAPH__
#ifndef __CALLGRAPH_HH__
#define __CALLGRAPH_HH__

#include "address.hh"

namespace ghidra {

// Forward declarations
class Architecture;
class Funcdata;
Expand Down Expand Up @@ -122,4 +124,5 @@ public:
void decoder(Decoder &decoder);
};

} // End namespace ghidra
#endif
3 changes: 3 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/capability.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
#include "capability.hh"

namespace ghidra {

/// Access static vector of CapabilityPoint objects that are registered during static initialization
/// The list itself is created once on the first call to this method
/// \e after all the static initializers have run
Expand Down Expand Up @@ -46,3 +48,4 @@ void CapabilityPoint::initializeAll(void)
list.clear();
}

} // End namespace ghidra
8 changes: 5 additions & 3 deletions Ghidra/Features/Decompiler/src/decompile/cpp/capability.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
/// \file capability.hh
/// \brief Infrastructure for discovering code extensions to the decompiler
#ifndef __CAPABILITY__
#define __CAPABILITY__
#ifndef __CAPABILITY_HH__
#define __CAPABILITY_HH__

#include "types.h"
#include <vector>
#include <string>

namespace ghidra {

using std::vector;
using std::string;

Expand Down Expand Up @@ -49,5 +51,5 @@ public:
static void initializeAll(void); ///< Finish initialization for all extension points
};


} // End namespace ghidra
#endif
4 changes: 4 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/cast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "cast.hh"
#include "op.hh"

namespace ghidra {

/// Sets the TypeFactory used to produce data-types for the arithmeticOutputStandard() method
/// \param t is the TypeFactory
void CastStrategy::setTypeFactory(TypeFactory *t)
Expand Down Expand Up @@ -530,3 +532,5 @@ bool CastStrategyJava::isZextCast(Datatype *outtype,Datatype *intype) const
if (intype->getSize()>=4) return false; // cast is not zext for int and long
return true;
}

} // End namespace ghidra
7 changes: 5 additions & 2 deletions Ghidra/Features/Decompiler/src/decompile/cpp/cast.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
/// \file cast.hh
/// \brief API and specific strategies for applying type casts

#ifndef __CPUI_CAST__
#define __CPUI_CAST__
#ifndef __CAST_HH__
#define __CAST_HH__

#include "type.hh"

namespace ghidra {

class Varnode;
class PcodeOp;

Expand Down Expand Up @@ -199,4 +201,5 @@ public:
virtual bool isZextCast(Datatype *outtype,Datatype *intype) const;
};

} // End namespace ghidra
#endif
4 changes: 4 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/codedata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "codedata.hh"
#include "loadimage_bfd.hh"

namespace ghidra {

// Constructing this registers the capability
IfaceCodeDataCapability IfaceCodeDataCapability::ifaceCodeDataCapability;

Expand Down Expand Up @@ -786,3 +788,5 @@ void IfcCodeDataDumpTargetHits::execute(istream &s)
{
codedata->dumpTargetHits(*status->fileoptr);
}

} // End namespace ghidra
7 changes: 5 additions & 2 deletions Ghidra/Features/Decompiler/src/decompile/cpp/codedata.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CPUI_CODEDATA__
#define __CPUI_CODEDATA__
#ifndef __CODEDATA_HH__
#define __CODEDATA_HH__

#include "ifacedecomp.hh"

namespace ghidra {

class IfaceCodeDataCapability : public IfaceCapability {
static IfaceCodeDataCapability ifaceCodeDataCapability; // Singleton instance
IfaceCodeDataCapability(void); // Singleton
Expand Down Expand Up @@ -194,4 +196,5 @@ public:
virtual void execute(istream &s);
};

} // End namespace ghidra
#endif
4 changes: 4 additions & 0 deletions Ghidra/Features/Decompiler/src/decompile/cpp/comment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "comment.hh"
#include "funcdata.hh"

namespace ghidra {

ElementId ELEM_COMMENT = ElementId("comment",86);
ElementId ELEM_COMMENTDB = ElementId("commentdb",87);
ElementId ELEM_TEXT = ElementId("text",88);
Expand Down Expand Up @@ -400,3 +402,5 @@ void CommentSorter::setupHeader(uint4 headerType)
subsort.pos = 0xffffffff;
opstop = commmap.upper_bound(subsort);
}

} // End namespace ghidra
Loading

0 comments on commit fe137f2

Please sign in to comment.