added getPath() for all linux versions as well, should work fine

develop
belal 2010-09-16 18:21:41 -07:00
parent d2db7524a1
commit 6661d7e1f7
4 changed files with 35 additions and 2 deletions

@ -920,3 +920,14 @@ bool SHMProcess::Private::Aux_Core_Attach(bool & versionOK, pid_t & PID)
#endif
return true;
}
string SHMProcess::getPath()
{
char cwd_name[256];
char target_name[1024];
int target_result;
sprintf(cwd_name,"/proc/%d/cwd", getPID());
// resolve /proc/PID/exe link
target_result = readlink(cwd_name, target_name, sizeof(target_name));
return(string(target_name));
}

@ -637,4 +637,15 @@ string WineProcess::readClassName (uint32_t vptr)
string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 2);// trim @@ from end
return raw;
}
}
string WineProcess::getPath()
{
char cwd_name[256];
char target_name[1024];
int target_result;
sprintf(cwd_name,"/proc/%d/cwd", getPID());
// resolve /proc/PID/exe link
target_result = readlink(cwd_name, target_name, sizeof(target_name));
return(string(target_name));
}

@ -586,3 +586,14 @@ string NormalProcess::readClassName (uint32_t vptr)
size_t end = raw.length();
return raw.substr(start,end-start);
}
string NormalProcess::getPath()
{
char cwd_name[256];
char target_name[1024];
int target_result;
sprintf(cwd_name,"/proc/%d/cwd", getPID());
// resolve /proc/PID/exe link
target_result = readlink(cwd_name, target_name, sizeof(target_name));
return(string(target_name));
}

@ -368,7 +368,7 @@ namespace DFHack
// get the SHM start if available
char * getSHMStart (void){return 0;};
bool SetAndWait (uint32_t state){return false;};
std::string getPath() {return std::string()}; //FIXME should be pretty trival
std::string getPath();
};
#endif
}