From b759d6a321ba37cf5dba2e1ef910d544cd44fb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Fri, 28 Jan 2005 07:51:24 +0000 Subject: [PATCH] improved and corrected trace formatting --- mrw/exception.hpp | 19 +++++++++++-------- mrw/stacktrace.cpp | 28 +++++++++++++++------------- mrw/stacktrace_test.cpp | 8 +++++--- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/mrw/exception.hpp b/mrw/exception.hpp index 51ca78a..a116df0 100644 --- a/mrw/exception.hpp +++ b/mrw/exception.hpp @@ -9,6 +9,9 @@ @license LGPL, see file COPYING $Log$ + Revision 1.6 2005/01/28 07:51:24 marc + improved and corrected trace formatting + Revision 1.5 2004/10/07 09:25:34 marc new group for suggestions new inheritance @@ -93,14 +96,14 @@ enter fn1 enter fn2 UNEXPECTED:N3mrw9exceptionE ---------------------------Stack: -[0x8049e51] ../sysdeps/i386/elf/start.S:105 _start -[0x401cfd3e] ????:0 ???? -[0x804a3d0] examples/exceptionhandling.cpp:50 main -[0x804a2a3] examples/exceptionhandling.cpp:38 fn0() -[0x804a227] examples/exceptionhandling.cpp:32 fn1() -[0x804a1c1] examples/exceptionhandling.cpp:25 fn2() -[0x804fdda] ../mrw/exception.cpp:6 mrw::exception::exception() -[0x804a8f5] ../mrw/stacktrace.cpp:54 mrw::StackTrace::StackTrace() +[ 0x8048e11] _start ../sysdeps/i386/elf/start.S:105 +[0x4016e92b] __libc_start_main ????:0 +[ 0x8049392] main /.../mrw-c++/mrw/examples/exceptionhandling.cpp:50 +[ 0x8049265] fn0() /.../mrw-c++/mrw/examples/exceptionhandling.cpp:38 +[ 0x80491e9] fn1() /.../mrw-c++/mrw/examples/exceptionhandling.cpp:32 +[ 0x8049183] fn2() /.../mrw-c++/mrw/examples/exceptionhandling.cpp:25 +[0x400494a4] mrw::exception::exception() ????:0 +[0x4005ace5] mrw::StackTrace::StackTrace() ????:0 --------------------------------- EXCEPTION caught in fn0:St13bad_exception leave fn0 diff --git a/mrw/stacktrace.cpp b/mrw/stacktrace.cpp index de7de73..0334f5f 100644 --- a/mrw/stacktrace.cpp +++ b/mrw/stacktrace.cpp @@ -9,6 +9,9 @@ @license LGPL, see file COPYING $Log$ + Revision 1.10 2005/01/28 07:51:24 marc + improved and corrected trace formatting + Revision 1.9 2005/01/07 00:34:38 marc some changes for solaris @@ -155,26 +158,25 @@ mrw::StackTrace::StackTrace() throw(std::bad_exception) { //---------------------------------------------------------------------------- mrw::StackTrace::operator std::string() const throw(std::bad_exception) { - static const double LN10(log(10)); - std::string s; - s<<1; + std::stringstream s; bool first(true); - unsigned int lisz(0), fisz(0); + unsigned int fusz(0), adsz(0); //lisz(0), fisz(0) std::list l; for (AddressTrace::const_reverse_iterator it(_trace.rbegin()); it!=_trace.rend(); ++it, first=false) { CodePos c(translate(*it)); - if (log(c.line+1)/LN10 > lisz) lisz = (unsigned int)(log(c.line+1)/LN10); - if (c.file.size() > fisz) fisz = c.file.size(); + if (((std::stringstream&)(std::stringstream()< adsz) + adsz = + ((std::stringstream&)(std::stringstream()< fusz) fusz = c.function.size(); l.push_back(c); } for (std::list::iterator it(l.begin()); it!=l.end(); ++it) - s<<"["<address<<"] " - <file<<':'<line - <file.size()- - (unsigned int)(log(it->line+1)/LN10)-1) - <<" "<function<<"\n"; - return s; + s<<'['<address<<"] " + <function<function.size()+1)<<' ' + <file<<':'<line<*)fileoffs; bfd_vma vma(bfd_get_section_vma(abfd, section)+ reinterpret_cast(fileoffset.second)); - bfd_size_type sz(bfd_get_section_size_before_reloc(section)); + bfd_size_type sz(bfd_get_section_size(section)); _dic[fileoffset.first][vma] = Translator::mapped_type(vma+sz, section); _addrs[vma] = fileoffset.first; } diff --git a/mrw/stacktrace_test.cpp b/mrw/stacktrace_test.cpp index 5d6ea31..b8e2edf 100644 --- a/mrw/stacktrace_test.cpp +++ b/mrw/stacktrace_test.cpp @@ -9,6 +9,9 @@ @license LGPL, see file COPYING $Log$ + Revision 1.6 2005/01/28 07:51:24 marc + improved and corrected trace formatting + Revision 1.5 2004/10/13 10:49:12 marc check whether shared libraries are evaluated @@ -42,10 +45,9 @@ namespace mrw { std::stringstream ss; ss<