|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
|