string debugging tags

This commit is contained in:
caheckman 2020-04-23 12:43:21 -04:00
parent 547a4f2ab5
commit 9ea9790e88
5 changed files with 263 additions and 155 deletions

View file

@ -232,7 +232,7 @@ Datatype *CastStrategyC::castStandard(Datatype *reqtype,Datatype *curtype,
isptr = true;
}
if (curtype == reqtype) return (Datatype *)0; // Different typedefs could point to the same type
if ((reqbase->getMetatype()==TYPE_VOID)||(reqbase->getMetatype()==TYPE_VOID))
if ((reqbase->getMetatype()==TYPE_VOID)||(curtype->getMetatype()==TYPE_VOID))
return (Datatype *)0; // Don't cast from or to VOID
if (reqbase->getSize() != curbase->getSize()) {
if (reqbase->isVariableLength() && isptr && reqbase->hasSameVariableBase(curbase)) {
@ -375,7 +375,7 @@ Datatype *CastStrategyJava::castStandard(Datatype *reqtype,Datatype *curtype,
if ((reqbase->getMetatype()==TYPE_PTR)||(curbase->getMetatype()==TYPE_PTR))
return (Datatype *)0; // There must be explicit cast op between objects, so assume no cast necessary
if ((reqbase->getMetatype()==TYPE_VOID)||(reqbase->getMetatype()==TYPE_VOID))
if ((reqbase->getMetatype()==TYPE_VOID)||(curtype->getMetatype()==TYPE_VOID))
return (Datatype *)0; // Don't cast from or to VOID
if (reqbase->getSize() != curbase->getSize()) return reqtype; // Always cast change in size
switch(reqbase->getMetatype()) {

View file

@ -170,29 +170,31 @@ int main(int argc,char **argv)
{
const char *initscript = (const char *)0;
vector<string> extrapaths;
int4 i=1;
while((i<argc)&&(argv[i][0]=='-')) {
if (argv[i][1]=='i')
initscript = argv[++i];
else if (argv[i][1]=='s')
extrapaths.push_back(argv[++i]);
i += 1;
}
string ghidraroot = FileManage::discoverGhidraRoot(argv[0]);
if (ghidraroot.size() == 0) {
const char *sleighhomepath = getenv("SLEIGHHOME");
if (sleighhomepath == (const char *)0) {
if (extrapaths.empty()) {
cerr << "Could not discover root of Ghidra installation" << endl;
exit(1);
}
{
vector<string> extrapaths;
int4 i = 1;
while ((i < argc) && (argv[i][0] == '-')) {
if (argv[i][1] == 'i')
initscript = argv[++i];
else if (argv[i][1] == 's')
extrapaths.push_back(argv[++i]);
i += 1;
}
else
ghidraroot = sleighhomepath;
string ghidraroot = FileManage::discoverGhidraRoot(argv[0]);
if (ghidraroot.size() == 0) {
const char *sleighhomepath = getenv("SLEIGHHOME");
if (sleighhomepath == (const char*) 0) {
if (extrapaths.empty()) {
cerr << "Could not discover root of Ghidra installation" << endl;
exit(1);
}
}
else
ghidraroot = sleighhomepath;
}
startDecompilerLibrary(ghidraroot.c_str(), extrapaths);
}
startDecompilerLibrary(ghidraroot.c_str(),extrapaths);
IfaceStatus *status;
try {

View file

@ -111,40 +111,42 @@ void StringManager::saveXml(ostream &s) const
/// Read \<stringmanage> tag, with \<string> sub-tags.
/// \param el is the root tag element
/// \param m is the manager for looking up AddressSpaces
void StringManager::restoreXml(const Element *el,const AddrSpaceManager *m)
void StringManager::restoreXml(const Element *el, const AddrSpaceManager *m)
{
const List &list(el->getChildren());
List::const_iterator iter;
iter = list.begin();
Address addr = Address::restoreXml(*iter, m);
++iter;
StringData &stringData(stringMap[addr]);
stringData.isTruncated = xml_readbool((*iter)->getAttributeValue("trunc"));
istringstream is((*iter)->getContent());
int4 val;
char c1, c2;
is >> ws;
c1 = is.get();
c2 = is.get();
while ((c1 > 0) && (c2 > 0)) {
if (c1 <= '9')
c1 = c1 - '0';
else if (c1 <= 'F')
c1 = c1 + 10 - 'A';
else
c1 = c1 + 10 - 'a';
if (c2 <= '9')
c2 = c2 - '0';
else if (c2 <= 'F')
c2 = c2 + 10 - 'A';
else
c2 = c2 + 10 - 'a';
val = c1 * 16 + c2;
stringData.byteData.push_back((uint1) val);
List::const_iterator iter1;
for (iter1 = list.begin(); iter1 != list.end(); ++iter1) {
List::const_iterator iter2 = (*iter1)->getChildren().begin();
Address addr = Address::restoreXml(*iter2, m);
++iter2;
StringData &stringData(stringMap[addr]);
stringData.isTruncated = xml_readbool((*iter2)->getAttributeValue("trunc"));
istringstream is((*iter2)->getContent());
int4 val;
char c1, c2;
is >> ws;
c1 = is.get();
c2 = is.get();
while ((c1 > 0) && (c2 > 0)) {
if (c1 <= '9')
c1 = c1 - '0';
else if (c1 <= 'F')
c1 = c1 + 10 - 'A';
else
c1 = c1 + 10 - 'a';
if (c2 <= '9')
c2 = c2 - '0';
else if (c2 <= 'F')
c2 = c2 + 10 - 'A';
else
c2 = c2 + 10 - 'a';
val = c1 * 16 + c2;
stringData.byteData.push_back((uint1) val);
is >> ws;
c1 = is.get();
c2 = is.get();
}
}
}
@ -285,6 +287,9 @@ const vector<uint1> &StringManagerUnicode::getStringData(const Address &addr,Dat
stringData.isTruncated = false;
isTrunc = false;
if (charType->isOpaqueString()) // Cannot currently test for an opaque encoding
return stringData.byteData; // Return the empty buffer
int4 curBufferSize = 0;
int4 charsize = charType->getSize();
bool foundTerminator = false;