parent
7338ddc5cf
commit
70ed3fa117
31 changed files with 1346 additions and 420 deletions
Binary file not shown.
@ -0,0 +1,132 @@ |
||||
/** @file
|
||||
|
||||
$Id: autofunctiontracelog4cxx.cpp,v 1.3 2005/04/14 19:12:18 marc Exp $ |
||||
|
||||
$Date: 2005/04/14 19:12:18 $ |
||||
$Author: marc $ |
||||
|
||||
@copy © Marc Wäckerlin |
||||
@license LGPL, see file <a href="license.html">COPYING</a> |
||||
|
||||
1 2 3 4 5 6 7 8 |
||||
5678901234567890123456789012345678901234567890123456789012345678901234567890 |
||||
*/ |
||||
|
||||
#ifndef __GNUG__ |
||||
#error GNU C++ Compiler is required for automatical function trace |
||||
#endif |
||||
|
||||
#include <mrw/string.hpp> |
||||
#include <mrw/stacktrace.hpp> |
||||
#include <iostream> |
||||
#include <iomanip> |
||||
|
||||
#if (__GNUC__==3 && __GNUC_MINOR__<4 || __GNUC__<3) && _REENTRANT && !_MT |
||||
#define _MT |
||||
#endif |
||||
|
||||
// these are special built in functions of GNU Compiler Collection
|
||||
extern "C" void __cyg_profile_func_enter (void *, void *) __attribute__((no_instrument_function)); |
||||
extern "C" void __cyg_profile_func_exit (void *, void *) __attribute__((no_instrument_function)); |
||||
|
||||
namespace mrw { |
||||
|
||||
// workaround doxygen problem:
|
||||
// - the C++ compiler compiles the following code
|
||||
// - doxygen ignores it
|
||||
#ifndef LET_DOXYGEN_IGNORE_THIS // no matching class member found for
|
||||
// int mrw::ThreadInfo::level()
|
||||
struct ThreadInfo { |
||||
int level; |
||||
bool recurse; |
||||
}; |
||||
#endif |
||||
|
||||
#ifdef _MT |
||||
static __thread ThreadInfo info = {0, false}; |
||||
#else |
||||
static ThreadInfo info = {0, false}; |
||||
#endif |
||||
|
||||
static bool mainPassed(false); |
||||
|
||||
class Lock { |
||||
public: |
||||
Lock() __attribute__((no_instrument_function)); |
||||
~Lock() __attribute__((no_instrument_function)); |
||||
}; |
||||
// workaround doxygen problem:
|
||||
// - the C++ compiler compiles the following code
|
||||
// - doxygen ignores it
|
||||
#ifndef LET_DOXYGEN_IGNORE_THIS // doxygen can't match with __attribute__ above
|
||||
Lock::Lock() { |
||||
info.recurse = true; |
||||
} |
||||
Lock::~Lock() { |
||||
info.recurse = false; |
||||
} |
||||
#endif |
||||
} |
||||
|
||||
extern "C" int main(int, char**); |
||||
|
||||
/** @addtogroup FunctionTrace */ |
||||
//@{
|
||||
|
||||
/** @defgroup AutoFunctionTraceStdlog Automatic Function Trace to standard out for GNU g++
|
||||
|
||||
Same as @ref AutoFunctionTrace, but traces to @c stdlog. |
||||
|
||||
If you link to the library @c libmrwautofunctiontracestdlog using |
||||
a linker option such as: @c -lmrwautofunctiontracestdlog and you |
||||
must enable the GNU Compiler Collection specific function trace |
||||
feature with compile and link option @c -finstrument-functions |
||||
then you get an automatical function trace, that traces to @c |
||||
stdlog. You don't need to change a single line in your code! |
||||
|
||||
*/ |
||||
//@{
|
||||
|
||||
//@}
|
||||
|
||||
//@}
|
||||
|
||||
extern "C" void __cyg_profile_func_enter(void *this_fn, void*) { |
||||
if (!mrw::mainPassed) |
||||
if (this_fn == (void*)&::main) // not ANSI C++ conform...
|
||||
mrw::mainPassed=true; |
||||
else |
||||
return; |
||||
try { |
||||
if (mrw::info.recurse) return; |
||||
mrw::Lock lock; |
||||
{ |
||||
static bool init(mrw::StackTrace::createSymtable()); |
||||
if (!init) return; |
||||
mrw::StackTrace::CodePos pos(mrw::StackTrace::translate(this_fn)); |
||||
std::clog<<std::setw(2+mrw::info.level++)<<std::setfill(' ') |
||||
<<"\\ "<<pos.function<<" ("<<pos.file<<':'<<pos.line<<')' |
||||
<<std::endl; |
||||
} |
||||
} catch (...) {} |
||||
} |
||||
|
||||
extern "C" void __cyg_profile_func_exit(void *this_fn, void*) { |
||||
if (!mrw::mainPassed) |
||||
return; |
||||
else |
||||
if (this_fn == (void*)&::main) { // not ANSI C++ conform...
|
||||
mrw::mainPassed=false; |
||||
return; |
||||
} |
||||
try { |
||||
if (mrw::info.recurse || mrw::info.level==0) return; |
||||
mrw::Lock lock; |
||||
{ |
||||
mrw::StackTrace::CodePos pos(mrw::StackTrace::translate(this_fn)); |
||||
std::clog<<std::setw(2+--mrw::info.level)<<std::setfill(' ') |
||||
<<"/ "<<pos.function<<" ("<<pos.file<<':'<<pos.line<<')' |
||||
<<std::endl; |
||||
} |
||||
} catch (...) {} |
||||
} |
@ -1,5 +1,4 @@ |
||||
<div class="status">Last Change: $date</div> |
||||
<div class="feedback"></div> |
||||
<div class="status">Last Build: $date</div> |
||||
<div class="author"><a href="http://marc.waeckerlin.org">The autor's page: http://marc.waeckerlin.org</a></div> |
||||
</body> |
||||
</html> |
||||
|
After Width: | Height: | Size: 36 KiB |
@ -0,0 +1,49 @@ |
||||
/** @file
|
||||
|
||||
$Id$ |
||||
|
||||
$Date$ |
||||
$Author$ |
||||
|
||||
@copy © Marc Wäckerlin |
||||
@license LGPL, see file <a href="license.html">COPYING</a> |
||||
|
||||
$Log$ |
||||
|
||||
1 2 3 4 5 6 7 8 |
||||
5678901234567890123456789012345678901234567890123456789012345678901234567890 |
||||
*/ |
||||
#include <mrw/string.hpp> |
||||
#include <mrw/list.hpp> |
||||
#include <algorithm> |
||||
|
||||
#include <cppunit/TestFixture.h> |
||||
#include <cppunit/ui/text/TestRunner.h> |
||||
#include <cppunit/extensions/HelperMacros.h> |
||||
#include <cppunit/extensions/TestFactoryRegistry.h> |
||||
|
||||
class StringTest: public CppUnit::TestFixture {
|
||||
public: |
||||
void Join() { |
||||
std::list<std::string> l; |
||||
l<<"Hello"<<"World"<<"here"<<"I"<<"am"; |
||||
CPPUNIT_ASSERT(mrw::join(l)=="Hello World here I am"); |
||||
} |
||||
void Split() { |
||||
std::string text("Hello World here I am"); |
||||
std::list<std::string> a(mrw::split(text)), b; |
||||
b<<"Hello"<<"World"<<"here"<<"I"<<"am"; |
||||
CPPUNIT_ASSERT(equal(a.begin(), a.end(), b.begin())); |
||||
} |
||||
CPPUNIT_TEST_SUITE(StringTest); |
||||
CPPUNIT_TEST(Join); |
||||
CPPUNIT_TEST(Split); |
||||
CPPUNIT_TEST_SUITE_END(); |
||||
}; |
||||
CPPUNIT_TEST_SUITE_REGISTRATION(StringTest); |
||||
|
||||
int main() { |
||||
CppUnit::TextUi::TestRunner runner; |
||||
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); |
||||
return runner.run() ? 0 : 1; |
||||
} |
@ -0,0 +1,63 @@ |
||||
# log4cxx ####################################################################### |
||||
{ |
||||
log4cxx-Addr1-TimeZone |
||||
Memcheck:Addr1 |
||||
fun:* |
||||
fun:* |
||||
fun:*log4cxx* |
||||
} |
||||
{ |
||||
log4cxx-Addr2-getProperty |
||||
Memcheck:Addr2 |
||||
fun:* |
||||
fun:*log4cxx* |
||||
} |
||||
{ |
||||
log4cxx-Free-StringTokenizer |
||||
Memcheck:Free |
||||
fun:* |
||||
fun:*log4cxx* |
||||
} |
||||
{ |
||||
log4cxx-Addr1-TimeZone2 |
||||
Memcheck:Addr1 |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:*log4cxx* |
||||
} |
||||
{ |
||||
log4cxx-Addr2-DateFormat::format1 |
||||
Memcheck:Addr2 |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:*log4cxx* |
||||
} |
||||
{ |
||||
log4cxx-Addr2-DateFormat::format2 |
||||
Memcheck:Addr2 |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:*log4cxx* |
||||
} |
||||
{ |
||||
log4cxx-Cond-DateFormat::format |
||||
Memcheck:Cond |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:* |
||||
fun:*log4cxx* |
||||
} |
||||
# system ######################################################################## |
||||
{ |
||||
system-Addr2-getenv |
||||
Memcheck:Addr2 |
||||
fun:getenv |
||||
} |
@ -0,0 +1,49 @@ |
||||
#! /bin/bash |
||||
|
||||
# (c) Siemens Schweiz AG, vertraulich |
||||
# $Id: checklatest.sh 323 2007-02-23 15:32:45Z chawama0 $ |
||||
# |
||||
# 1 2 3 4 5 6 7 8 |
||||
# 3456789012345676890123456789012345678901234567890123456789012345678901234567890 |
||||
|
||||
printUsage() { |
||||
echo "Usage: $0 <program-to-check>" |
||||
echo "" |
||||
echo "This script checks a program using valgrind." |
||||
return 0 |
||||
} |
||||
|
||||
if [ $# -ne 1 -o "$1" = "-h" -o "$1" = "--help" ] ; then |
||||
printUsage |
||||
exit 1 |
||||
fi |
||||
|
||||
if ! valgrind \ |
||||
--show-reachable=yes \ |
||||
--leak-check=full \ |
||||
--gen-suppressions=all \ |
||||
--log-file-exactly=valgrind.log \ |
||||
--suppressions=$(dirname $0)/suppressions.valgrind \ |
||||
$1; then |
||||
echo "******** Valcheck: Testfall fehlgeschlagen! (normaler Fehler)" |
||||
exit 1 |
||||
fi |
||||
|
||||
if ! ( ( grep 'ERROR SUMMARY: 0 errors from 0 contexts' valgrind.log \ |
||||
&& \ |
||||
( grep 'definitely lost: 0 bytes in 0 blocks' valgrind.log \ |
||||
&& \ |
||||
grep 'possibly lost: 0 bytes in 0 blocks' valgrind.log \ |
||||
&& \ |
||||
grep 'still reachable: 0 bytes in 0 blocks' valgrind.log \ |
||||
|| |
||||
grep 'All heap blocks were freed -- no leaks are possible' \ |
||||
valgrind.log |
||||
) |
||||
) 2>&1 > /dev/null ); then |
||||
mv valgrind.log valgrind-$(basename $1).error |
||||
echo "******** Valcheck: Speicherfehler! Siehe valgrind-$(basename $1).error" |
||||
exit 1 |
||||
fi |
||||
|
||||
rm valgrind.log |
Loading…
Reference in new issue