Fix linux crashes.

develop
Petr Mrázek 2010-04-19 00:32:50 +02:00
parent 39eacd2069
commit 96b42f8ac1
7 changed files with 39 additions and 17 deletions

@ -46,7 +46,7 @@ using namespace DFHack;
class SHMProcess::Private
{
public:
Private()
Private(Process * self_)
{
memdescriptor = NULL;
process_ID = 0;
@ -62,10 +62,12 @@ class SHMProcess::Private
suspend_lock = -1;
attachmentIdx = 0;
locked = false;
self = self_;
};
~Private(){};
memory_info * memdescriptor;
DFWindow * window;
Process * self;
pid_t process_ID;
char *shm_addr;
int shm_ID;
@ -262,9 +264,10 @@ bool SHMProcess::Private::GetLocks()
}
SHMProcess::SHMProcess(uint32_t PID, vector< memory_info* >& known_versions)
: d(new Private())
: d(new Private(this))
{
d->process_ID = PID;
d->memdescriptor = 0;
if(!attach())
{
// couldn't attach to process
@ -335,9 +338,9 @@ bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
try{
if(hash == (*it)->getString("md5")) // are the md5 hashes the same?
{
memory_info * m = *it;
memory_info *m = new memory_info(**it);
memdescriptor = m;
m->setParentProcess((Process*)this);
m->setParentProcess(dynamic_cast<Process *>( self ));
identified = true;
// cerr << "identified " << m->getVersion() << endl;
return true;
@ -357,7 +360,8 @@ SHMProcess::~SHMProcess()
{
detach();
}
// destroy data model. this is assigned by processmanager
if(d->memdescriptor)
delete d->memdescriptor;
if(d->window)
{
delete d->window;

@ -34,7 +34,7 @@ using namespace DFHack;
class WineProcess::Private
{
public:
Private()
Private(Process * self_)
{
my_descriptor = NULL;
my_handle = NULL;
@ -43,10 +43,12 @@ class WineProcess::Private
attached = false;
suspended = false;
memFileHandle = 0;
self = self_;
};
~Private(){};
DFWindow* my_window;
memory_info * my_descriptor;
Process * self;
ProcessHandle my_handle;
uint32_t my_pid;
string memFile;
@ -58,7 +60,7 @@ class WineProcess::Private
};
WineProcess::WineProcess(uint32_t pid, vector <memory_info *> & known_versions)
: d(new Private())
: d(new Private(this))
{
char dir_name [256];
char exe_link_name [256];
@ -69,6 +71,7 @@ WineProcess::WineProcess(uint32_t pid, vector <memory_info *> & known_versions)
int target_result;
d->identified = false;
d->my_descriptor = 0;
sprintf(dir_name,"/proc/%d/", pid);
sprintf(exe_link_name,"/proc/%d/exe", pid);
@ -147,9 +150,11 @@ bool WineProcess::Private::validate(char* exe_file, uint32_t pid, char* mem_file
// are the md5 hashes the same?
if(memory_info::OS_WINDOWS == (*it)->getOS() && hash == thishash)
{
memory_info * m = *it;
// keep track of created memory_info object so we can destroy it later
memory_info *m = new memory_info(**it);
my_descriptor = m;
m->setParentProcess((Process*)this);
m->setParentProcess(dynamic_cast<Process *>( self ));
my_handle = my_pid = pid;
// tell WineProcess about the /proc/PID/mem file
memFile = mem_file;
@ -166,6 +171,9 @@ WineProcess::~WineProcess()
{
detach();
}
// destroy our copy of the memory descriptor
if(d->my_descriptor)
delete d->my_descriptor;
if(d->my_window)
delete d->my_window;
delete d;

@ -33,7 +33,7 @@ using namespace DFHack;
class NormalProcess::Private
{
public:
Private()
Private(Process * self_)
{
my_descriptor = NULL;
my_handle = NULL;
@ -42,6 +42,7 @@ class NormalProcess::Private
attached = false;
suspended = false;
memFileHandle = 0;
self = self_;
};
~Private(){};
DFWindow* my_window;
@ -53,11 +54,12 @@ class NormalProcess::Private
bool attached;
bool suspended;
bool identified;
Process * self;
bool validate(char * exe_file, uint32_t pid, char * mem_file, vector <memory_info *> & known_versions);
};
NormalProcess::NormalProcess(uint32_t pid, vector< memory_info* >& known_versions)
: d(new Private())
: d(new Private(this))
{
char dir_name [256];
char exe_link_name [256];
@ -68,6 +70,7 @@ NormalProcess::NormalProcess(uint32_t pid, vector< memory_info* >& known_version
int target_result;
d->identified = false;
d->my_descriptor = 0;
sprintf(dir_name,"/proc/%d/", pid);
sprintf(exe_link_name,"/proc/%d/exe", pid);
@ -125,8 +128,9 @@ bool NormalProcess::Private::validate(char * exe_file,uint32_t pid, char * memFi
memory_info * m = *it;
if (memory_info::OS_LINUX == m->getOS())
{
my_descriptor = m;
m->setParentProcess((Process*)this);
memory_info *m2 = new memory_info(*m);
my_descriptor = m2;
m2->setParentProcess(dynamic_cast<Process *>( self ));
my_handle = my_pid = pid;
}
else
@ -154,6 +158,9 @@ NormalProcess::~NormalProcess()
{
detach();
}
// destroy our copy of the memory descriptor
if(d->my_descriptor)
delete d->my_descriptor;
// destroy data model. this is assigned by processmanager
if(d->my_window)
delete d->my_window;

@ -110,7 +110,7 @@ bool Buildings::Read (const uint32_t index, t_building & building)
// transform
int32_t type = -1;
d->d->offset_descriptor->resolveObjectToClassID (temp, type);
d->owner->getDescriptor()->resolveObjectToClassID (temp, type);
building.origin = temp;
building.vtable = bld_40d.vtable;
building.x1 = bld_40d.x1;

@ -142,7 +142,6 @@ bool Maps::Start()
d->block = new uint32_t[mx*my*mz];
uint32_t *temp_x = new uint32_t[mx];
uint32_t *temp_y = new uint32_t[my];
uint32_t *temp_z = new uint32_t[mz];
p->read (x_array_loc, mx * sizeof (uint32_t), (uint8_t *) temp_x);
for (uint32_t x = 0; x < mx; x++)
@ -158,7 +157,6 @@ bool Maps::Start()
}
delete [] temp_x;
delete [] temp_y;
delete [] temp_z;
return true;
}

@ -44,10 +44,14 @@ class Materials::Private
Materials::Materials(APIPrivate * d_)
{
d = new Private;
d->d = d_;
d->owner = d_->p;
}
Materials::~Materials(){}
Materials::~Materials()
{
delete d;
}
/*
{
LABEL_53:

@ -1060,6 +1060,7 @@ size=212
<Offset name="map_data_temperature1_offset">0x159c</Offset>
<Offset name="map_data_temperature2_offset">0x179c</Offset>
<Offset name="map_data_biome_stuffs">0x1D9C</Offset>
<Offset name="map_data_pathfinding_offset">0x0D9c</Offset>
<!--
map_data_map_x_offset 0x0058
map_data_map_y_offset 0x005A