Linux debug...

develop
Petr Mrázek 2011-08-16 23:39:18 +02:00
parent 7898d2b6b2
commit 03e3e9002b
4 changed files with 39 additions and 12 deletions

@ -25,7 +25,7 @@ set(DF_VERSION_MINOR "31")
set(DF_VERSION_PATCH "25") set(DF_VERSION_PATCH "25")
set(DF_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}") set(DF_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}")
set(DFHACK_RELEASE "1") set(DFHACK_RELEASE "3")
## where to install things (after the build is done, classic 'make install' or package structure) ## where to install things (after the build is done, classic 'make install' or package structure)
# the dfhack libraries will be installed here: # the dfhack libraries will be installed here:

@ -407,13 +407,25 @@ bool Core::Init()
vif = new DFHack::VersionInfoFactory(path); vif = new DFHack::VersionInfoFactory(path);
p = new DFHack::Process(vif); p = new DFHack::Process(vif);
vinfo = p->getDescriptor(); vinfo = p->getDescriptor();
// dump offsets to a file
std::ofstream dump("offsets.log"); if(!vinfo)
if(!dump.fail())
{ {
dump << vinfo->PrintOffsets(); cerr << "Couldn't retrieve version information.\n";
dump.close(); errorstate = true;
delete p;
p = NULL;
return false;
} }
if (!p->isIdentified())
{
cerr << "Couldn't identify this version of DF.\n";
errorstate = true;
delete p;
p = NULL;
return false;
}
// init the console. // init the console.
Gui * g = getGui(); Gui * g = getGui();
if(g->init) if(g->init)
@ -426,13 +438,12 @@ bool Core::Init()
} }
else con.init(false); else con.init(false);
if (!p->isIdentified()) // dump offsets to a file
std::ofstream dump("offsets.log");
if(!dump.fail())
{ {
con.printerr("Couldn't identify this version of DF.\n"); dump << vinfo->PrintOffsets();
errorstate = true; dump.close();
delete p;
p = NULL;
return false;
} }
// create mutex for syncing with interactive tasks // create mutex for syncing with interactive tasks

@ -58,6 +58,7 @@ Process::Process(VersionInfoFactory * known_versions)
target_result = readlink(exe_link_name, target_name, sizeof(target_name)-1); target_result = readlink(exe_link_name, target_name, sizeof(target_name)-1);
if (target_result == -1) if (target_result == -1)
{ {
cerr << "Failed to readlink(/proc/self/exe)\n";
return; return;
} }
// make sure we have a null terminated string... // make sure we have a null terminated string...
@ -77,6 +78,14 @@ Process::Process(VersionInfoFactory * known_versions)
my_descriptor->setParentProcess(this); my_descriptor->setParentProcess(this);
identified = true; identified = true;
} }
else
{
cerr << "Unable to retrieve version information.\n";
}
}
else
{
cerr << "This isn't DF.\n";
} }
} }

@ -28,6 +28,7 @@ distribution.
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <iostream>
using namespace std; using namespace std;
#include "dfhack/VersionInfoFactory.h" #include "dfhack/VersionInfoFactory.h"
@ -680,12 +681,18 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
bool VersionInfoFactory::loadFile(string path_to_xml) bool VersionInfoFactory::loadFile(string path_to_xml)
{ {
TiXmlDocument doc( path_to_xml.c_str() ); TiXmlDocument doc( path_to_xml.c_str() );
std::cerr << "Loading " << path_to_xml << " ... ";
//bool loadOkay = doc.LoadFile(); //bool loadOkay = doc.LoadFile();
if (!doc.LoadFile()) if (!doc.LoadFile())
{ {
error = true; error = true;
cerr << "failed!\n";
throw Error::MemoryXmlParse(doc.ErrorDesc(), doc.ErrorId(), doc.ErrorRow(), doc.ErrorCol()); throw Error::MemoryXmlParse(doc.ErrorDesc(), doc.ErrorId(), doc.ErrorRow(), doc.ErrorCol());
} }
else
{
cerr << "OK\n";
}
TiXmlHandle hDoc(&doc); TiXmlHandle hDoc(&doc);
TiXmlElement* pElem; TiXmlElement* pElem;
TiXmlHandle hRoot(0); TiXmlHandle hRoot(0);