some changes for solaris

master
Marc Wäckerlin 20 years ago
parent 027537dbcf
commit cabcaa0475
  1. 21
      mrw/stacktrace.cpp

@ -9,6 +9,9 @@
@license LGPL, see file <a href="license.html">COPYING</a>
$Log$
Revision 1.9 2005/01/07 00:34:38 marc
some changes for solaris
Revision 1.8 2004/12/20 13:22:25 marc
mrw string now throws exceptions, catch needed
@ -103,8 +106,12 @@ namespace mrw {
confusing the demangler. */
const char* p(name);
while (p && *p == '.') ++p;
Auto<char*>::Free res(cplus_demangle(p, DMGL_ANSI | DMGL_PARAMS));
# ifdef __solaris__
char res[1024];
if (cplus_demangle(p, res, 1024)) return name;
# else
Auto<char*>::Free res(cplus_demangle(p, DMGL_ANSI | DMGL_PARAMS));
# endif
if (res) {
/* Now put back any stripped dots. */
if (p==name) return static_cast<const char*>(res);
@ -244,17 +251,17 @@ bool mrw::StackTrace::createSymtable(const mrw::StackTrace::BinFiles& files)
mrw::StackTrace::BinFiles mrw::StackTrace::filename()
throw(std::bad_exception) {
mrw::StackTrace::BinFiles res;
# if defined(__solaris__)
# if defined(__solaris__)
{
std::string s;
s<<"/proc/"<<getpid();
AutoFile fd(open(s.str(), O_RDONLY));
AutoFile fd(open(s.c_str(), O_RDONLY));
prpsinfo_t status;
if (fd==-1 || ioctl(fd, PIOCPSINFO, &status)==-1) return res;
s = status.pr_psargs;
return res<<BinFiles::value_type(s.substr(0, s.find(' ')), 0);
}
# elif defined(__linux__)
# elif defined(__linux__)
{
res<<BinFiles::value_type("/proc/self/exe", 0);
std::ifstream is("/proc/self/maps");
@ -270,14 +277,14 @@ mrw::StackTrace::BinFiles mrw::StackTrace::filename()
} catch (...) {} // ignore non matching lines
return res;
}
# else
# else
{
# warning "Don't know how to get executable file name in your system!"
# warning "Impossible to get function names in stack trace!"
# warning "Give the path to the executable to StackTrace::createSymtable!"
return res; // empty
}
# endif
# endif
}
//----------------------------------------------------------------------------

Loading…
Cancel
Save