new method createSymtable that takes a list of arguments
-> untested!
This commit is contained in:
@@ -9,6 +9,10 @@
|
|||||||
@license LGPL, see file <a href="license.html">COPYING</a>
|
@license LGPL, see file <a href="license.html">COPYING</a>
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.5 2004/10/07 16:59:12 marc
|
||||||
|
new method createSymtable that takes a list of arguments
|
||||||
|
-> untested!
|
||||||
|
|
||||||
Revision 1.4 2004/10/07 09:32:45 marc
|
Revision 1.4 2004/10/07 09:32:45 marc
|
||||||
correction in parameter (const&)
|
correction in parameter (const&)
|
||||||
|
|
||||||
@@ -180,7 +184,8 @@ namespace mrw {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool StackTrace::createSymtable(const std::string& fname) throw(std::bad_exception) {
|
bool StackTrace::createSymtable(const std::string& fname)
|
||||||
|
throw(std::bad_exception) {
|
||||||
if (_dic.get()) return true;
|
if (_dic.get()) return true;
|
||||||
AutoBfd abfd(bfd_openr((fname!="" ? fname : filename()).c_str(), 0));
|
AutoBfd abfd(bfd_openr((fname!="" ? fname : filename()).c_str(), 0));
|
||||||
long memsz(-1);
|
long memsz(-1);
|
||||||
@@ -204,6 +209,35 @@ namespace mrw {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool StackTrace::createSymtable(const std::list<std::string>& fnames)
|
||||||
|
throw(std::bad_exception) {
|
||||||
|
if (_dic.get()) return true;
|
||||||
|
for (std::list<std::string>::const_iterator it(fnames.begin());
|
||||||
|
it!=fnames.end(); ++it) {
|
||||||
|
AutoBfd abfd(bfd_openr(it->c_str(), 0));
|
||||||
|
long memsz(-1);
|
||||||
|
Auto<char**>::Free m(0);
|
||||||
|
if (!abfd || bfd_check_format(abfd, bfd_archive) ||
|
||||||
|
!bfd_check_format_matches(abfd, bfd_object, &(m.getClean())) ||
|
||||||
|
!(bfd_get_file_flags(const_cast<bfd*>(static_cast<const bfd*>(abfd)))
|
||||||
|
&HAS_SYMS) ||
|
||||||
|
(memsz=bfd_get_symtab_upper_bound
|
||||||
|
(const_cast<bfd*>(static_cast<const bfd*>(abfd))))<0)
|
||||||
|
return false;
|
||||||
|
std::auto_ptr<asymbol*> syms(new asymbol*[memsz]);
|
||||||
|
if (bfd_canonicalize_symtab(const_cast<bfd*>(static_cast<const bfd*>(abfd)),
|
||||||
|
syms.get())<0)
|
||||||
|
return false;
|
||||||
|
_bfd = abfd;
|
||||||
|
_syms = syms;
|
||||||
|
if (!_dic.get()) _dic = std::auto_ptr<Translator>(new Translator());
|
||||||
|
bfd_map_over_sections(_bfd, buildSectionMap, 0);
|
||||||
|
}
|
||||||
|
std::sort(_addrs.begin(), _addrs.end());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string StackTrace::filename() throw(std::bad_exception) {
|
std::string StackTrace::filename() throw(std::bad_exception) {
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
|
@@ -9,6 +9,10 @@
|
|||||||
@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 2004/10/07 16:59:12 marc
|
||||||
|
new method createSymtable that takes a list of arguments
|
||||||
|
-> untested!
|
||||||
|
|
||||||
Revision 1.5 2004/10/07 09:32:45 marc
|
Revision 1.5 2004/10/07 09:32:45 marc
|
||||||
correction in parameter (const&)
|
correction in parameter (const&)
|
||||||
|
|
||||||
@@ -30,6 +34,7 @@
|
|||||||
#define __MRW_STACKTRACE_HPP__
|
#define __MRW_STACKTRACE_HPP__
|
||||||
#include <mrw/auto.hpp>
|
#include <mrw/auto.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -173,7 +178,8 @@ namespace mrw {
|
|||||||
/// evaluate the stack trace and print it to a stream
|
/// evaluate the stack trace and print it to a stream
|
||||||
const StackTrace& print(std::ostream& os) const throw(std::bad_exception);
|
const StackTrace& print(std::ostream& os) const throw(std::bad_exception);
|
||||||
/// evaluates and returns all information from a raw address
|
/// evaluates and returns all information from a raw address
|
||||||
static CodePos translate(void* addr) throw(std::bad_exception);
|
static CodePos translate(void* addr)
|
||||||
|
throw(std::bad_exception);
|
||||||
|
|
||||||
/** @brief read the symbol table from the executable file
|
/** @brief read the symbol table from the executable file
|
||||||
|
|
||||||
@@ -191,11 +197,40 @@ namespace mrw {
|
|||||||
(that means for the creation of a mrw::StackTrace object) a
|
(that means for the creation of a mrw::StackTrace object) a
|
||||||
call to this method is not yet needed.
|
call to this method is not yet needed.
|
||||||
|
|
||||||
|
@note Call only one of both createSymtable methods!
|
||||||
|
|
||||||
@note If this method is called more than once, the symbols
|
@note If this method is called more than once, the symbols
|
||||||
are created only the first time, so you don't loose too much
|
are created only the first time, so you don't loose too much
|
||||||
time.
|
time.
|
||||||
*/
|
*/
|
||||||
static bool createSymtable(const std::string& fname="") throw(std::bad_exception);
|
static bool createSymtable(const std::string& fname="")
|
||||||
|
throw(std::bad_exception);
|
||||||
|
|
||||||
|
/** @brief read the symbol table from a list of an executable file and
|
||||||
|
shared libraries
|
||||||
|
|
||||||
|
@param fnames The list of file names that must contain the
|
||||||
|
executable plus all shared libraries that should be included
|
||||||
|
in stack traces.
|
||||||
|
|
||||||
|
@return @c true in case of success. If @c false is returned,
|
||||||
|
the symbol table was not completely read and the evaluation
|
||||||
|
cannot be done. Printing then only prints the raw addresses,
|
||||||
|
without file, line nmber information and method names.
|
||||||
|
|
||||||
|
@note This method must be executed once before a stack trace
|
||||||
|
is printed the very first time. For storing a stack trace
|
||||||
|
(that means for the creation of a mrw::StackTrace object) a
|
||||||
|
call to this method is not yet needed.
|
||||||
|
|
||||||
|
@note Call only one of both createSymtable methods!
|
||||||
|
|
||||||
|
@note If this method is called more than once, the symbols
|
||||||
|
are created only the first time, so you don't loose too much
|
||||||
|
time.
|
||||||
|
*/
|
||||||
|
static bool createSymtable(const std::list<std::string>& fnames) throw(std::bad_exception);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//............................................................... typedefs
|
//............................................................... typedefs
|
||||||
typedef std::map<bfd_vma, std::pair<bfd_vma, asection*> >
|
typedef std::map<bfd_vma, std::pair<bfd_vma, asection*> >
|
||||||
|
Reference in New Issue
Block a user