forked from Grive/grive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
615 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
find_library( DL_LIBRARY NAMES dl PATH /usr/lib /usr/lib64 ) | ||
find_library( BFD_LIBRARY NAMES bfd PATH /usr/lib /usr/lib64 ) | ||
|
||
if ( DL_LIBRARY AND BFD_LIBRARY ) | ||
set( BFD_FOUND TRUE ) | ||
endif (DL_LIBRARY AND BFD_LIBRARY) | ||
|
||
if ( BFD_FOUND ) | ||
|
||
message( STATUS "Found libbfd: ${BFD_LIBRARY}") | ||
|
||
|
||
endif ( BFD_FOUND ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
grive: an GPL program to sync a local directory with Google Drive | ||
Copyright (C) 2006 Wan Wai Ho | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation version 2 | ||
of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace gr | ||
{ | ||
typedef void* addr_t ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
grive: an GPL program to sync a local directory with Google Drive | ||
Copyright (C) 2012 Wan Wai Ho | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation version 2 | ||
of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "Backtrace.hh" | ||
|
||
#include "SymbolInfo.hh" | ||
#include "util/CArray.hh" | ||
|
||
#include <algorithm> | ||
#include <cstring> | ||
#include <sstream> | ||
|
||
namespace gr { | ||
|
||
Backtrace::Backtrace( std::size_t skip ) : | ||
m_count( SymbolInfo::Instance()->Backtrace(m_stack, Count(m_stack) )), | ||
m_skip( std::min( skip, m_count ) ) | ||
{ | ||
} | ||
|
||
Backtrace::Backtrace( const Backtrace& bt ) : | ||
m_count( bt.m_count ), | ||
m_skip( bt.m_skip ) | ||
{ | ||
std::memcpy( m_stack, bt.m_stack, m_count * sizeof(m_stack[0]) ) ; | ||
} | ||
|
||
/*! \brief operator<< for printing backtraces | ||
\internal | ||
This function will call SymbolInfo::PrintTrace() to print out a backtrace | ||
to the stream. It will use the SymbolInfo::Instance() singleton to get | ||
the symbol information. | ||
\param os The output stream. | ||
\param b The backtrace information. | ||
\sa SymbolInfo::Backtrace(), SymbolInfo::Instance() | ||
*/ | ||
std::ostream& operator<<( std::ostream& os, const gr::Backtrace& b ) | ||
{ | ||
// the 1st function in the stack is SymbolInfo::Backtrace() | ||
// the 2nd one is the Backtrace() constructor | ||
// both are not interesting to user | ||
for ( std::size_t i = b.m_skip ; i < b.m_count ; i++ ) | ||
SymbolInfo::Instance()->PrintTrace( b.m_stack[i], os, i - b.m_skip ) ; | ||
|
||
return os ; | ||
} | ||
|
||
std::string Backtrace::ToString( ) const | ||
{ | ||
std::ostringstream oss ; | ||
oss << *this ; | ||
return oss.str( ) ; | ||
} | ||
|
||
} // end of namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
grive: an GPL program to sync a local directory with Google Drive | ||
Copyright (C) 2012 Wan Wai Ho | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation version 2 | ||
of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Addr.hh" | ||
|
||
#include <iosfwd> | ||
#include <string> | ||
|
||
namespace gr { | ||
|
||
/// A shortcut to print out backtrace information | ||
/** \internal | ||
The sole reason for this class to exists is to provide the | ||
operator<< overload to allow: | ||
\code | ||
std::cout << Backtrace() << std::endl ; | ||
\endcode | ||
\sa SymbolInfo | ||
*/ | ||
class Backtrace | ||
{ | ||
public : | ||
explicit Backtrace( std::size_t skip = 2 ) ; | ||
Backtrace( const Backtrace& bt ) ; | ||
|
||
friend std::ostream& operator<<( std::ostream& os, | ||
const gr::Backtrace& bt ) ; | ||
|
||
std::string ToString( ) const ; | ||
|
||
private : | ||
addr_t m_stack[100] ; | ||
std::size_t m_count, m_skip ; | ||
} ; | ||
|
||
} // end of namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
grive: an GPL program to sync a local directory with Google Drive | ||
Copyright (C) 2006 Wan Wai Ho | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation version 2 | ||
of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "Debug.hh" | ||
|
||
#include <cassert> | ||
|
||
#ifdef __GNUC__ | ||
#include <cxxabi.h> | ||
#endif | ||
|
||
#include <cstdlib> | ||
#include <ostream> | ||
#include <iomanip> | ||
|
||
namespace gr { | ||
|
||
std::string Demangle( const char *name ) | ||
{ | ||
#ifdef __GNUC__ | ||
assert( name != 0 ) ; | ||
|
||
char *cname = abi::__cxa_demangle( name, 0, 0, 0 ) ; | ||
std::string result( name ) ; | ||
if ( cname != 0 ) | ||
{ | ||
result = cname ; | ||
std::free( cname ) ; | ||
} | ||
return result ; | ||
#else | ||
return std::string( ) ; | ||
#endif | ||
} | ||
|
||
std::ostream& PrintHex( std::ostream& os, const void *buf, std::size_t size ) | ||
{ | ||
const unsigned char *raw = static_cast<const unsigned char*>( buf ) ; | ||
|
||
for ( std::size_t i = 0 ; i < size ; i++ ) | ||
{ | ||
if ( i % 8 == 0 && i > 0 ) | ||
os << std::endl ; | ||
|
||
if ( i % 8 == 0 ) | ||
os << std::hex << std::setw(8) << std::setfill('0') << i << " " ; | ||
|
||
os << "0x" << std::hex << std::setw(2) << std::setfill('0') | ||
<< (int)raw[i] << ", " ; | ||
} | ||
os << std::endl ; | ||
return os ; | ||
} | ||
|
||
} // end of namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
grive: an GPL program to sync a local directory with Google Drive | ||
Copyright (C) 2006 Wan Wai Ho | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation version 2 | ||
of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <iosfwd> | ||
#include <string> | ||
|
||
namespace gr { | ||
|
||
std::string Demangle( const char *name ) ; | ||
|
||
std::ostream& PrintHex( std::ostream& os, const void *buf, std::size_t size ) ; | ||
|
||
} // end of namespace |
Oops, something went wrong.