Skip to content

Commit

Permalink
Remove the transitioning GN030 define
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jul 4, 2023
1 parent c7015f3 commit 02be79d
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 96 deletions.
6 changes: 4 additions & 2 deletions Makefile.acr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions src/CodeXMLParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ void AnnotateColor(ANNOTATOR_PARAMS) {
if (attr.empty ()) {
return;
}
#if GN030
int color = attr.as_int(-1);
if (color < 0) {
return;
Expand Down Expand Up @@ -171,7 +170,7 @@ void AnnotateColor(ANNOTATOR_PARAMS) {
default:
return;
}
#else
#if 0
std::string color = attr.as_string();
RSyntaxHighlightType type;
if (color == "keyword") {
Expand Down
2 changes: 0 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ CFLAGS+=-I.
# CFLAGS+=-g
CXXFLAGS+=-g

CXXFLAGS+=-DGN030=1

CXXFLAGS+=-std=c++11
CFLAGS+=$(R2_CFLAGS)

Expand Down
7 changes: 0 additions & 7 deletions src/R2CommentDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions src/R2Scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -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<FunctionSymbol *>(sym);
}

Expand Down
5 changes: 0 additions & 5 deletions src/R2Scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"); }
Expand Down
8 changes: 0 additions & 8 deletions src/R2TypeFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,13 @@ Datatype *R2TypeFactory::queryR2Struct(const string &n, std::set<std::string> &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,
memberTypeName, // std::string(member->name),
memberType
};
fields.push_back(tf);
#else
fields.push_back ({
offset,
memberName,
memberType
});
#endif
}

if (fields.empty ()) {
Expand Down
2 changes: 0 additions & 2 deletions src/R2Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
30 changes: 1 addition & 29 deletions src/SleighAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ static std::unordered_map<std::string, std::string> 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 */ }
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down
6 changes: 1 addition & 5 deletions src/SleighInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 0 additions & 4 deletions src/SleighInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
17 changes: 0 additions & 17 deletions src/core_ghidra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << "<result><function>";
#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 << "</function><code>";
}
switch (mode) {
Expand All @@ -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;
Expand Down

0 comments on commit 02be79d

Please sign in to comment.