mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-2358 Packed protocol for decompiler marshaling
This commit is contained in:
parent
6a1a649213
commit
79c3508f54
119 changed files with 4238 additions and 2207 deletions
|
@ -46,14 +46,14 @@ const VarnodeData &GhidraTranslate::getRegister(const string &nm) const
|
|||
map<string,VarnodeData>::const_iterator iter = nm2addr.find(nm);
|
||||
if (iter != nm2addr.end())
|
||||
return (*iter).second;
|
||||
XmlDecode decoder(glb);
|
||||
PackedDecode decoder(glb);
|
||||
try {
|
||||
if (!glb->getRegister(nm,decoder)) // Ask Ghidra client about the register
|
||||
throw LowlevelError("No register named "+nm);
|
||||
}
|
||||
catch(XmlError &err) {
|
||||
catch(DecoderError &err) {
|
||||
ostringstream errmsg;
|
||||
errmsg << "Error parsing XML response for query of register: " << nm;
|
||||
errmsg << "Error decoding response for query of register: " << nm;
|
||||
errmsg << " -- " << err.explain;
|
||||
throw LowlevelError(errmsg.str());
|
||||
}
|
||||
|
@ -100,9 +100,10 @@ int4 GhidraTranslate::oneInstruction(PcodeEmit &emit,const Address &baseaddr) co
|
|||
|
||||
{
|
||||
int4 offset;
|
||||
uint1 *doc;
|
||||
PackedDecode decoder(glb);
|
||||
bool success;
|
||||
try {
|
||||
doc = glb->getPcodePacked(baseaddr); // Request p-code for one instruction
|
||||
success = glb->getPcode(baseaddr,decoder); // Request p-code for one instruction
|
||||
}
|
||||
catch(JavaError &err) {
|
||||
ostringstream s;
|
||||
|
@ -110,34 +111,26 @@ int4 GhidraTranslate::oneInstruction(PcodeEmit &emit,const Address &baseaddr) co
|
|||
baseaddr.printRaw(s);
|
||||
throw LowlevelError(s.str());
|
||||
}
|
||||
if (doc == (uint1 *)0) {
|
||||
if (!success) {
|
||||
ostringstream s;
|
||||
s << "No pcode could be generated at address: " << baseaddr.getShortcut();
|
||||
baseaddr.printRaw(s);
|
||||
throw BadDataError(s.str());
|
||||
}
|
||||
|
||||
uintb val;
|
||||
const uint1 *ptr = PcodeEmit::unpackOffset(doc+1,val);
|
||||
offset = (int4)val;
|
||||
|
||||
if (*doc == PcodeEmit::unimpl_tag) {
|
||||
int4 el = decoder.openElement();
|
||||
offset = decoder.readSignedInteger(ATTRIB_OFFSET);
|
||||
if (el == ELEM_UNIMPL) {
|
||||
ostringstream s;
|
||||
s << "Instruction not implemented in pcode:\n ";
|
||||
baseaddr.printRaw(s);
|
||||
delete [] doc;
|
||||
throw UnimplError(s.str(),offset);
|
||||
}
|
||||
|
||||
int4 spcindex = (int4)(*ptr++ - 0x20);
|
||||
AddrSpace *spc = getSpace(spcindex);
|
||||
uintb instoffset;
|
||||
ptr = PcodeEmit::unpackOffset(ptr,instoffset);
|
||||
Address pc(spc,instoffset);
|
||||
Address pc = Address::decode(decoder);
|
||||
|
||||
while(*ptr == PcodeEmit::op_tag)
|
||||
ptr = emit.restorePackedOp(pc,ptr,this);
|
||||
delete [] doc;
|
||||
while(decoder.peekElement() != 0)
|
||||
emit.decodeOp(pc,decoder);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue