improved and corrected trace formatting
This commit is contained in:
@@ -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.6 2005/01/28 07:51:24 marc
|
||||||
|
improved and corrected trace formatting
|
||||||
|
|
||||||
Revision 1.5 2004/10/07 09:25:34 marc
|
Revision 1.5 2004/10/07 09:25:34 marc
|
||||||
new group for suggestions
|
new group for suggestions
|
||||||
new inheritance
|
new inheritance
|
||||||
@@ -93,14 +96,14 @@ enter fn1
|
|||||||
enter fn2
|
enter fn2
|
||||||
UNEXPECTED:N3mrw9exceptionE
|
UNEXPECTED:N3mrw9exceptionE
|
||||||
---------------------------Stack:
|
---------------------------Stack:
|
||||||
[0x8049e51] ../sysdeps/i386/elf/start.S:105 _start
|
[ 0x8048e11] _start ../sysdeps/i386/elf/start.S:105
|
||||||
[0x401cfd3e] ????:0 ????
|
[0x4016e92b] __libc_start_main ????:0
|
||||||
[0x804a3d0] examples/exceptionhandling.cpp:50 main
|
[ 0x8049392] main /.../mrw-c++/mrw/examples/exceptionhandling.cpp:50
|
||||||
[0x804a2a3] examples/exceptionhandling.cpp:38 fn0()
|
[ 0x8049265] fn0() /.../mrw-c++/mrw/examples/exceptionhandling.cpp:38
|
||||||
[0x804a227] examples/exceptionhandling.cpp:32 fn1()
|
[ 0x80491e9] fn1() /.../mrw-c++/mrw/examples/exceptionhandling.cpp:32
|
||||||
[0x804a1c1] examples/exceptionhandling.cpp:25 fn2()
|
[ 0x8049183] fn2() /.../mrw-c++/mrw/examples/exceptionhandling.cpp:25
|
||||||
[0x804fdda] ../mrw/exception.cpp:6 mrw::exception::exception()
|
[0x400494a4] mrw::exception::exception() ????:0
|
||||||
[0x804a8f5] ../mrw/stacktrace.cpp:54 mrw::StackTrace::StackTrace()
|
[0x4005ace5] mrw::StackTrace::StackTrace() ????:0
|
||||||
---------------------------------
|
---------------------------------
|
||||||
EXCEPTION caught in fn0:St13bad_exception
|
EXCEPTION caught in fn0:St13bad_exception
|
||||||
leave fn0
|
leave fn0
|
||||||
|
@@ -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.10 2005/01/28 07:51:24 marc
|
||||||
|
improved and corrected trace formatting
|
||||||
|
|
||||||
Revision 1.9 2005/01/07 00:34:38 marc
|
Revision 1.9 2005/01/07 00:34:38 marc
|
||||||
some changes for solaris
|
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) {
|
mrw::StackTrace::operator std::string() const throw(std::bad_exception) {
|
||||||
static const double LN10(log(10));
|
std::stringstream s;
|
||||||
std::string s;
|
|
||||||
s<<1;
|
|
||||||
bool first(true);
|
bool first(true);
|
||||||
unsigned int lisz(0), fisz(0);
|
unsigned int fusz(0), adsz(0); //lisz(0), fisz(0)
|
||||||
std::list<CodePos> l;
|
std::list<CodePos> l;
|
||||||
for (AddressTrace::const_reverse_iterator it(_trace.rbegin());
|
for (AddressTrace::const_reverse_iterator it(_trace.rbegin());
|
||||||
it!=_trace.rend(); ++it, first=false) {
|
it!=_trace.rend(); ++it, first=false) {
|
||||||
CodePos c(translate(*it));
|
CodePos c(translate(*it));
|
||||||
if (log(c.line+1)/LN10 > lisz) lisz = (unsigned int)(log(c.line+1)/LN10);
|
if (((std::stringstream&)(std::stringstream()<<c.address)).str().size()
|
||||||
if (c.file.size() > fisz) fisz = c.file.size();
|
> adsz)
|
||||||
|
adsz =
|
||||||
|
((std::stringstream&)(std::stringstream()<<c.address)).str().size();
|
||||||
|
if (c.function.size() > fusz) fusz = c.function.size();
|
||||||
l.push_back(c);
|
l.push_back(c);
|
||||||
}
|
}
|
||||||
for (std::list<CodePos>::iterator it(l.begin()); it!=l.end(); ++it)
|
for (std::list<CodePos>::iterator it(l.begin()); it!=l.end(); ++it)
|
||||||
s<<"["<<it->address<<"] "
|
s<<'['<<std::setw(adsz)<<it->address<<"] "
|
||||||
<<it->file<<':'<<it->line
|
<<it->function<<std::setw(fusz-it->function.size()+1)<<' '
|
||||||
<<std::setw(fisz+lisz-it->file.size()-
|
<<it->file<<':'<<it->line<<std::endl;
|
||||||
(unsigned int)(log(it->line+1)/LN10)-1)
|
return s.str();
|
||||||
<<" "<<it->function<<"\n";
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -297,7 +299,7 @@ void mrw::StackTrace::buildSectionMap(bfd* abfd, asection* section,
|
|||||||
*(std::pair<std::string, void*>*)fileoffs;
|
*(std::pair<std::string, void*>*)fileoffs;
|
||||||
bfd_vma vma(bfd_get_section_vma(abfd, section)+
|
bfd_vma vma(bfd_get_section_vma(abfd, section)+
|
||||||
reinterpret_cast<bfd_vma>(fileoffset.second));
|
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);
|
_dic[fileoffset.first][vma] = Translator::mapped_type(vma+sz, section);
|
||||||
_addrs[vma] = fileoffset.first;
|
_addrs[vma] = fileoffset.first;
|
||||||
}
|
}
|
||||||
|
@@ -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.6 2005/01/28 07:51:24 marc
|
||||||
|
improved and corrected trace formatting
|
||||||
|
|
||||||
Revision 1.5 2004/10/13 10:49:12 marc
|
Revision 1.5 2004/10/13 10:49:12 marc
|
||||||
check whether shared libraries are evaluated
|
check whether shared libraries are evaluated
|
||||||
|
|
||||||
@@ -42,10 +45,9 @@ namespace mrw {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<f<<':'<<l;
|
ss<<f<<':'<<l;
|
||||||
std::string st(s);
|
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(pos!=std::string::npos);
|
||||||
CPPUNIT_ASSERT(st.find("mrw::StackTraceTest::StackTrace()", pos)
|
CPPUNIT_ASSERT(st.find(ss.str(), pos) < st.size());
|
||||||
< st.size());
|
|
||||||
CPPUNIT_ASSERT(st.find("CppUnit::TestCase::run")
|
CPPUNIT_ASSERT(st.find("CppUnit::TestCase::run")
|
||||||
< st.size());
|
< st.size());
|
||||||
CPPUNIT_ASSERT(st.find("????:0 ????")
|
CPPUNIT_ASSERT(st.find("????:0 ????")
|
||||||
|
Reference in New Issue
Block a user