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

Loading…
Cancel
Save