From 02be79ddcd39fc97ba6b48f23de7134946aa0be9 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 4 Jul 2023 16:41:30 +0200 Subject: [PATCH] Remove the transitioning GN030 define --- Makefile.acr | 6 ++++-- meson.build | 1 - src/CodeXMLParse.cpp | 3 +-- src/Makefile | 2 -- src/R2CommentDatabase.h | 7 ------- src/R2Scope.cpp | 12 ------------ src/R2Scope.h | 5 ----- src/R2TypeFactory.cpp | 8 -------- src/R2Utils.h | 2 -- src/SleighAsm.cpp | 30 +----------------------------- src/SleighInstruction.cpp | 6 +----- src/SleighInstruction.h | 4 ---- src/core_ghidra.cpp | 17 ----------------- 13 files changed, 7 insertions(+), 96 deletions(-) diff --git a/Makefile.acr b/Makefile.acr index ca196719..0081275c 100644 --- a/Makefile.acr +++ b/Makefile.acr @@ -3,7 +3,9 @@ DESTDIR?= GHIDRA_NATIVE_COMMIT=0.3.3 -all: ghidra-native ghidra-processors.txt third-party/pugixml +PUGIXML=third-party/pugixml/Makefile + +all: ghidra-native ghidra-processors.txt $(PUGIXML) $(MAKE) -C src $(MAKE) -C ghidra @@ -47,7 +49,7 @@ ghidra-native: cd ghidra-native && git checkout $(GHIDRA_NATIVE_COMMIT) $(MAKE) -C ghidra-native patch -third-party/pugixml: +$(PUGIXML): git submodule update --init mrproper: clean diff --git a/meson.build b/meson.build index 8fa5cddd..568b5ee7 100644 --- a/meson.build +++ b/meson.build @@ -41,7 +41,6 @@ else endif cpp = meson.get_compiler('cpp') -add_global_arguments('-DGN030=1', language:'cpp') if cpp.get_id() == 'msvc' incdirs += [ 'radare2/include/libr', diff --git a/src/CodeXMLParse.cpp b/src/CodeXMLParse.cpp index 7aabd8b6..18675de7 100644 --- a/src/CodeXMLParse.cpp +++ b/src/CodeXMLParse.cpp @@ -134,7 +134,6 @@ void AnnotateColor(ANNOTATOR_PARAMS) { if (attr.empty ()) { return; } -#if GN030 int color = attr.as_int(-1); if (color < 0) { return; @@ -171,7 +170,7 @@ void AnnotateColor(ANNOTATOR_PARAMS) { default: return; } -#else +#if 0 std::string color = attr.as_string(); RSyntaxHighlightType type; if (color == "keyword") { diff --git a/src/Makefile b/src/Makefile index ab438ce4..d0387057 100644 --- a/src/Makefile +++ b/src/Makefile @@ -49,8 +49,6 @@ CFLAGS+=-I. # CFLAGS+=-g CXXFLAGS+=-g -CXXFLAGS+=-DGN030=1 - CXXFLAGS+=-std=c++11 CFLAGS+=$(R2_CFLAGS) diff --git a/src/R2CommentDatabase.h b/src/R2CommentDatabase.h index 7fc8c548..bed23c86 100644 --- a/src/R2CommentDatabase.h +++ b/src/R2CommentDatabase.h @@ -31,15 +31,8 @@ class R2CommentDatabase : public CommentDatabase { CommentSet::const_iterator beginComment(const Address &fad) const override; CommentSet::const_iterator endComment(const Address &fad) const override; -#if GN030 void encode(Encoder &encoder) const override { cache.encode(encoder); } void decode(Decoder &decoder) override { throw LowlevelError("CommentDatabaseGhidra::decode unimplemented"); } -#else - void saveXml(ostream &s) const override { cache.saveXml(s); } - void restoreXml(const Element *el, const AddrSpaceManager *trans) override { - throw LowlevelError("commentdb::restoreXml unimplemented"); - } -#endif }; #endif //R2GHIDRA_R2COMMENTDATABASE_H diff --git a/src/R2Scope.cpp b/src/R2Scope.cpp index 0abcc886..4960dd04 100644 --- a/src/R2Scope.cpp +++ b/src/R2Scope.cpp @@ -318,7 +318,6 @@ FunctionSymbol *R2Scope::registerFunction(RAnalFunction *fcn) const { return; } -#if GN030 int4 paramTrialIndex = params.whichTrial(addr, type->getSize()); if (paramTrialIndex < 0) { arch->addWarning ("Failed to determine arg index of " + to_string(var->name)); @@ -331,13 +330,6 @@ FunctionSymbol *R2Scope::registerFunction(RAnalFunction *fcn) const { } paramIndex++; } -#else - paramIndex = params.whichTrial(addr, type->getSize()); - if (paramIndex < 0) { - arch->addWarning ("Failed to determine arg index of " + to_string(var->name)); - return; - } -#endif } varRanges.insertRange(addr.getSpace(), addr.getOffset(), last); @@ -433,12 +425,8 @@ FunctionSymbol *R2Scope::registerFunction(RAnalFunction *fcn) const { child (&doc, "rangelist"); -#if GN030 XmlDecode dec(arch, &doc); auto sym = cache->addMapSym (dec); -#else - auto sym = cache->addMapSym (&doc); -#endif return dynamic_cast(sym); } diff --git a/src/R2Scope.h b/src/R2Scope.h index 6dfb7b3f..199a24b3 100644 --- a/src/R2Scope.h +++ b/src/R2Scope.h @@ -82,13 +82,8 @@ class R2Scope : public Scope { void renameSymbol(Symbol *sym,const string &newname) override { throw LowlevelError("renameSymbol unimplemented"); } void retypeSymbol(Symbol *sym,Datatype *ct) override { throw LowlevelError("retypeSymbol unimplemented"); } string makeNameUnique(const string &nm) const override { throw LowlevelError("makeNameUnique unimplemented"); } -#if GN030 void encode(Encoder &encoder) const override { cache->encode(encoder); } void decode(Decoder &decoder) override { throw LowlevelError("not implemented"); } -#else - void saveXml(ostream &s) const override { cache->saveXml(s); } - void restoreXml(const Element *el) override { throw LowlevelError("restoreXml unimplemented"); } -#endif void printEntries(ostream &s) const override { throw LowlevelError("printEntries unimplemented"); } int4 getCategorySize(int4 cat) const override { throw LowlevelError("getCategorySize unimplemented"); } Symbol *getCategorySymbol(int4 cat,int4 ind) const override { throw LowlevelError("getCategorySymbol unimplemented"); } diff --git a/src/R2TypeFactory.cpp b/src/R2TypeFactory.cpp index d2093692..8a196705 100644 --- a/src/R2TypeFactory.cpp +++ b/src/R2TypeFactory.cpp @@ -101,7 +101,6 @@ Datatype *R2TypeFactory::queryR2Struct(const string &n, std::set &s if (elements > 0) { memberType = getTypeArray (elements, memberType); } -#if GN030 TypeField tf = { (int4)offset, // id = offset by default (int4)offset, // Currently, this is 0 most of the time: member->offset, @@ -109,13 +108,6 @@ Datatype *R2TypeFactory::queryR2Struct(const string &n, std::set &s memberType }; fields.push_back(tf); -#else - fields.push_back ({ - offset, - memberName, - memberType - }); -#endif } if (fields.empty ()) { diff --git a/src/R2Utils.h b/src/R2Utils.h index 1c4f64f7..bb5ac527 100644 --- a/src/R2Utils.h +++ b/src/R2Utils.h @@ -3,8 +3,6 @@ #ifndef R2GHIDRA_R2UTILS_H #define R2GHIDRA_R2UTILS_H -#define GN030 1 - typedef struct r_list_t RList; typedef struct r_list_iter_t RListIter; diff --git a/src/SleighAsm.cpp b/src/SleighAsm.cpp index a2ba4e0d..32e1d5cb 100644 --- a/src/SleighAsm.cpp +++ b/src/SleighAsm.cpp @@ -128,11 +128,7 @@ static std::unordered_map parseRegisterData(const Elem hidden = (*iter)->getAttributeValue("hidden"); unused = (*iter)->getAttributeValue("unused"); rename = (*iter)->getAttributeValue("rename"); -#if GN030 } catch (const DecoderError &e) { -#else - } catch (const XmlError &e) { -#endif std::string err_prefix("Unknown attribute: "); if (e.explain == err_prefix + "group") { /* nothing */ } else if (e.explain == err_prefix + "hidden") { /* nothing */ } @@ -165,11 +161,7 @@ void SleighAsm::parseProcConfig(DocumentStorage &store) { for (iter = list.begin(); iter != list.end (); iter++) { const string &elname ((*iter)->getName ()); if (elname == "context_data") { -#if GN030 context.decodeFromSpec (decoder); // , &trans); -#else - context.restoreFromSpec (*iter, &trans); -#endif } else if (elname == "programcounter") { pc_name = (*iter)->getAttributeValue ("register"); } else if (elname == "register_data") { @@ -199,11 +191,7 @@ void SleighAsm::buildSpecfile(DocumentStorage &store) try { Document *doc = store.openDocument(processorfile); store.registerTag(doc->getRoot()); -#if GN030 } catch (DecoderError &err) { -#else - } catch (XmlError &err) { -#endif ostringstream serr; serr << "XML error parsing processor specification: " << processorfile; serr << "\n " << err.explain; @@ -218,11 +206,7 @@ void SleighAsm::buildSpecfile(DocumentStorage &store) try { Document *doc = store.openDocument(compilerfile); store.registerTag(doc->getRoot()); -#if GN030 } catch (DecoderError &err) { -#else - } catch (XmlError &err) { -#endif ostringstream serr; serr << "XML error parsing compiler specification: " << compilerfile; serr << "\n " << err.explain; @@ -236,11 +220,7 @@ void SleighAsm::buildSpecfile(DocumentStorage &store) try { Document *doc = store.openDocument (slafile); store.registerTag (doc->getRoot()); -#if GN030 } catch (DecoderError &err) { -#else - } catch (XmlError &err) { -#endif ostringstream serr; serr << "XML error parsing SLEIGH file: " << slafile; serr << "\n " << err.explain; @@ -336,11 +316,7 @@ void SleighAsm::loadLanguageDescription(const string &specfile) { Document *doc; try { doc = xml_tree (s); -#if GN030 } catch (DecoderError &err) { -#else - } catch (XmlError &err) { -#endif throw LowlevelError ("Unable to parse sleigh specfile: " + specfile); } Element *el = doc->getRoot(); @@ -351,11 +327,7 @@ void SleighAsm::loadLanguageDescription(const string &specfile) { continue; } description.push_back(LanguageDescription()); -#if GN030 - //description.back().decoder(*iter); -#else - description.back().restoreXml(*iter); -#endif + // UHM description.back().decoder(*iter); } delete doc; } diff --git a/src/SleighInstruction.cpp b/src/SleighInstruction.cpp index 77963377..440ac7b5 100644 --- a/src/SleighInstruction.cpp +++ b/src/SleighInstruction.cpp @@ -493,11 +493,7 @@ Address SleighInstructionPrototype::getHandleAddr(FixedHandle &hand, AddrSpace * return Address(); } Address newaddr (hand.space, hand.space->wrapOffset (hand.offset_offset)); -#if GN030 -// #pragma warning TODO -#else - newaddr.toPhysical (); -#endif + // UHM newaddr.toPhysical (); #if 0 // if we are in an address space, translate it if (curSpace.isOverlaySpace()) { diff --git a/src/SleighInstruction.h b/src/SleighInstruction.h index 2f834662..680d32c8 100644 --- a/src/SleighInstruction.h +++ b/src/SleighInstruction.h @@ -258,11 +258,7 @@ class SleighParserContext : public ParserContext { SleighInstructionPrototype *prototype = nullptr; public: -#if GN030 SleighParserContext(ContextCache *ccache, Translate *trans): ParserContext(ccache, trans) {} -#else - SleighParserContext(ContextCache *ccache): ParserContext(ccache) {} -#endif SleighInstructionPrototype *getPrototype() { return prototype; } void setPrototype(SleighInstructionPrototype *p); }; diff --git a/src/core_ghidra.cpp b/src/core_ghidra.cpp index f798f52e..db14568b 100644 --- a/src/core_ghidra.cpp +++ b/src/core_ghidra.cpp @@ -194,27 +194,19 @@ static void Decompile(RCore *core, ut64 addr, DecompileMode mode, std::stringstr case DecompileMode::OFFSET: case DecompileMode::DISASM: case DecompileMode::STATEMENTS: -#if GN030 arch.print->setMarkup(true); -#else - arch.print->setXML(true); -#endif break; default: break; } if (mode == DecompileMode::XML) { out_stream << ""; -#if GN030 { //func->encode (out_stream); //PrettyXmlEncode enc(out_stream); XmlEncode enc(out_stream); func->encode(enc, 0, true); } -#else - func->saveXml (out_stream, 0, true); -#endif out_stream << ""; } switch (mode) { @@ -234,19 +226,10 @@ static void Decompile(RCore *core, ut64 addr, DecompileMode mode, std::stringstr } break; case DecompileMode::DEBUG_XML: -#if GN030 -#if 0 - PrettyXmlEncode enc(out_stream); - arch.encode(enc); -#else { XmlEncode enc(out_stream); arch.encode(enc); } -#endif -#else - arch.saveXml (out_stream); -#endif break; default: break;