improved and corrected trace formatting
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
@license LGPL, see file <a href="license.html">COPYING</a>
|
||||
|
||||
$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
|
||||
|
@@ -9,6 +9,9 @@
|
||||
@license LGPL, see file <a href="license.html">COPYING</a>
|
||||
|
||||
$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<CodePos> 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()<<c.address)).str().size()
|
||||
> adsz)
|
||||
adsz =
|
||||
((std::stringstream&)(std::stringstream()<<c.address)).str().size();
|
||||
if (c.function.size() > fusz) fusz = c.function.size();
|
||||
l.push_back(c);
|
||||
}
|
||||
for (std::list<CodePos>::iterator it(l.begin()); it!=l.end(); ++it)
|
||||
s<<"["<<it->address<<"] "
|
||||
<<it->file<<':'<<it->line
|
||||
<<std::setw(fisz+lisz-it->file.size()-
|
||||
(unsigned int)(log(it->line+1)/LN10)-1)
|
||||
<<" "<<it->function<<"\n";
|
||||
return s;
|
||||
s<<'['<<std::setw(adsz)<<it->address<<"] "
|
||||
<<it->function<<std::setw(fusz-it->function.size()+1)<<' '
|
||||
<<it->file<<':'<<it->line<<std::endl;
|
||||
return s.str();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -297,7 +299,7 @@ void mrw::StackTrace::buildSectionMap(bfd* abfd, asection* section,
|
||||
*(std::pair<std::string, void*>*)fileoffs;
|
||||
bfd_vma vma(bfd_get_section_vma(abfd, section)+
|
||||
reinterpret_cast<bfd_vma>(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;
|
||||
}
|
||||
|
@@ -9,6 +9,9 @@
|
||||
@license LGPL, see file <a href="license.html">COPYING</a>
|
||||
|
||||
$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<<f<<':'<<l;
|
||||
std::string st(s);
|
||||
std::string::size_type pos(st.find(ss.str()));
|
||||
std::string::size_type pos(st.find("mrw::StackTraceTest::StackTrace()"));
|
||||
CPPUNIT_ASSERT(pos!=std::string::npos);
|
||||
CPPUNIT_ASSERT(st.find("mrw::StackTraceTest::StackTrace()", pos)
|
||||
< st.size());
|
||||
CPPUNIT_ASSERT(st.find(ss.str(), pos) < st.size());
|
||||
CPPUNIT_ASSERT(st.find("CppUnit::TestCase::run")
|
||||
< st.size());
|
||||
CPPUNIT_ASSERT(st.find("????:0 ????")
|
||||
|
Reference in New Issue
Block a user