diff --git a/Control/Hephaestus/CMakeLists.txt b/Control/Hephaestus/CMakeLists.txt index 93dec4ec84fa871ed8ea9071a98c9935bb45ebf3..a70a27fcb3bec39f4efd1de19fa1393aeb17c7c8 100644 --- a/Control/Hephaestus/CMakeLists.txt +++ b/Control/Hephaestus/CMakeLists.txt @@ -1,3 +1,4 @@ +# $Id: CMakeLists.txt 785819 2016-11-22 17:50:02Z krasznaa $ ################################################################################ # Package: Hephaestus ################################################################################ @@ -5,43 +6,60 @@ # Declare the package name: atlas_subdir( Hephaestus ) -# Declare the package's dependencies: -atlas_depends_on_subdirs( PRIVATE - AtlasTest/TestTools ) - # External dependencies: -find_package( Boost COMPONENTS filesystem thread system ) +find_package( Boost ) find_package( PythonLibs ) find_package( libunwind ) # Component(s) in the package: atlas_add_library( Hephaestus - src/hlib/*.c - PUBLIC_HEADERS Hephaestus - INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} ${LIBUNWIND_INCLUDE_DIRS} - PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} - LINK_LIBRARIES ${PYTHON_LIBRARIES} ${LIBUNWIND_LIBRARIES} - PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} TestTools ) + Hephaestus/*.h src/hlib/*.c + PUBLIC_HEADERS Hephaestus + INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} + LINK_LIBRARIES ${PYTHON_LIBRARIES} ) atlas_add_library( MemoryTracker - src/*.c - PUBLIC_HEADERS MemoryTracker - INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} ${LIBUNWIND_INCLUDE_DIRS} - PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} - LINK_LIBRARIES ${PYTHON_LIBRARIES} ${LIBUNWIND_LIBRARIES} Hephaestus - PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} TestTools ) + src/*.c + PUBLIC_HEADERS Hephaestus + PRIVATE_INCLUDE_DIRS ${LIBUNWIND_INCLUDE_DIRS} + PRIVATE_LINK_LIBRARIES ${LIBUNWIND_LIBRARIES} Hephaestus ) + +atlas_add_executable( hephprof + src/HephProf/HephProf.cxx + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ) +# Construct the python loadable modules: add_custom_command( TARGET MemoryTracker POST_BUILD - COMMAND ln -sf "libMemoryTracker.so" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/MemoryTracker.so" - COMMAND ln -sf "libMemoryTracker.so.dbg" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/MemoryTracker.so.dbg" - COMMAND ln -sf "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libMemoryTracker.so" "${CMAKE_PYTHON_OUTPUT_DIRECTORY}/Hephaestus/MemoryTracker.so" - COMMAND ln -sf "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libMemoryTracker.so.dbg" "${CMAKE_PYTHON_OUTPUT_DIRECTORY}/Hephaestus/MemoryTracker.so.dbg" ) + COMMAND ${CMAKE_COMMAND} -E create_symlink + "${CMAKE_SHARED_LIBRARY_PREFIX}MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}" + "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "${CMAKE_SHARED_LIBRARY_PREFIX}MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}.dbg" + "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}.dbg" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "../../${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}" + "${CMAKE_PYTHON_OUTPUT_DIRECTORY}/Hephaestus/MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "../../${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}.dbg" + "${CMAKE_PYTHON_OUTPUT_DIRECTORY}/Hephaestus/MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}.dbg" ) -atlas_add_executable( hephprof - src/HephProf/HephProf.cxx - INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${LIBUNWIND_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${LIBUNWIND_LIBRARIES} TestTools Hephaestus ) +# ...and also install them: +install( PROGRAMS + "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}" + "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}.dbg" + DESTINATION ${CMAKE_INSTALL_LIBDIR} + OPTIONAL ) +install( PROGRAMS + "${CMAKE_PYTHON_OUTPUT_DIRECTORY}/Hephaestus/MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}" + "${CMAKE_PYTHON_OUTPUT_DIRECTORY}/Hephaestus/MemoryTracker${CMAKE_SHARED_LIBRARY_SUFFIX}.dbg" + DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/Hephaestus + OPTIONAL ) + +# Test(s) in the package: +atlas_add_test( stackstash_test + SOURCES test/stackstash_test.cxx + LINK_LIBRARIES Hephaestus ) # Install files from the package: atlas_install_python_modules( python/*.py ) - diff --git a/Control/Hephaestus/Hephaestus/DebugInfo.h b/Control/Hephaestus/Hephaestus/DebugInfo.h old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/Hephaestus/GenericBacktrace.h b/Control/Hephaestus/Hephaestus/GenericBacktrace.h old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/Hephaestus/HashTable.h b/Control/Hephaestus/Hephaestus/HashTable.h old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/Hephaestus/Hephaestus.h b/Control/Hephaestus/Hephaestus/Hephaestus.h old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/Hephaestus/MemoryTrace.h b/Control/Hephaestus/Hephaestus/MemoryTrace.h old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/Hephaestus/UnwindBacktrace.h b/Control/Hephaestus/Hephaestus/UnwindBacktrace.h old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/Hephaestus/Utils.h b/Control/Hephaestus/Hephaestus/Utils.h old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/cmt/fragments/python_extension b/Control/Hephaestus/cmt/fragments/python_extension old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/cmt/fragments/python_extension_header b/Control/Hephaestus/cmt/fragments/python_extension_header old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/cmt/requirements b/Control/Hephaestus/cmt/requirements old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/python/Auditor.py b/Control/Hephaestus/python/Auditor.py old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/python/DeleteChecker.py b/Control/Hephaestus/python/DeleteChecker.py old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/python/MemoryProfiler.py b/Control/Hephaestus/python/MemoryProfiler.py old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/python/__init__.py b/Control/Hephaestus/python/__init__.py old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/src/DebugInfo.c b/Control/Hephaestus/src/DebugInfo.c old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/src/DoubleDeleteChecker.c b/Control/Hephaestus/src/DoubleDeleteChecker.c old mode 100755 new mode 100644 index 65970675b4f4171a46e655429cf151d6b8b81646..08401b6482fe12295b0a42098c908530f9f12418 --- a/Control/Hephaestus/src/DoubleDeleteChecker.c +++ b/Control/Hephaestus/src/DoubleDeleteChecker.c @@ -19,6 +19,11 @@ #include <assert.h> +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + /*- data ------------------------------------------------------------------- */ /* forward declarations */ diff --git a/Control/Hephaestus/src/GenericBacktrace.c b/Control/Hephaestus/src/GenericBacktrace.c old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/src/MemoryTrace.c b/Control/Hephaestus/src/MemoryTrace.c old mode 100755 new mode 100644 index ef222595edc4300afefb41bc5918d85c4bdf2d63..b921d8064100633d95ce9aece1d7d9f58af136f2 --- a/Control/Hephaestus/src/MemoryTrace.c +++ b/Control/Hephaestus/src/MemoryTrace.c @@ -11,6 +11,7 @@ /* _________________________________________________________________________ */ +#if 0 static char *strrstr( const char *s1, const char *s2 ) { /* Kent Irwin, irwin@leland.stanford.edu */ const char *sc2, *psc1, *ps1; @@ -31,6 +32,7 @@ static char *strrstr( const char *s1, const char *s2 ) { return (char*)NULL; } +#endif /* - use an arena for alloction of traces ---------------------------------- */ @@ -56,6 +58,7 @@ struct hhh_MemoryTrace *hhh_MemoryTrace_new() { if ( gPool == NULL ) { fprintf( stderr, "Hephaestus ERROR: memory allocation failed in MemoryTrace_new\n" ); + pthread_mutex_unlock( &gPoolLock ); return NULL; } @@ -102,7 +105,7 @@ void hhh_MemoryTrace_initialize( struct hhh_MemoryTrace *mt, long size, const char* hhh_MemoryTrace_getType( struct hhh_MemoryTrace *mt ) { return 0; - +#if 0 /* get the type that was newed, if available */ int i; void *ctor; @@ -118,6 +121,7 @@ const char* hhh_MemoryTrace_getType( struct hhh_MemoryTrace *mt ) } return s2; +#endif } /* _________________________________________________________________________ */ diff --git a/Control/Hephaestus/src/MemoryTracker.c b/Control/Hephaestus/src/MemoryTracker.c old mode 100755 new mode 100644 index 6b436f8a70f850e8e3de8335d7438810be3c7bb8..63568eb3717df07b950527cc537a8a9443d559fe --- a/Control/Hephaestus/src/MemoryTracker.c +++ b/Control/Hephaestus/src/MemoryTracker.c @@ -20,6 +20,11 @@ #include <assert.h> +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + /*- data ------------------------------------------------------------------- */ /* holder to locate this shared library */ @@ -546,7 +551,7 @@ static void captureTrace( void *result, long size, int isrealloc ) { if ( gFlags & PROFILE ) { if ( ! gProfileStream ) { - remove( "hephaestus.prof" ); + (void)remove( "hephaestus.prof" ); gProfileStream = popen( "gzip -f >> hephaestus.prof", "w" ); } @@ -839,14 +844,14 @@ static void teardown() { if ( gFlags & PROFILE ) { if ( gSymbolFileName ) { - remove( gSymbolFileName ); + (void)remove( gSymbolFileName ); cmd = (char*)malloc( 16+strlen( gSymbolFileName )+1 ); sprintf( cmd, "gzip -f >> %s.symb", gSymbolFileName ); fsymbols = popen( cmd, "w" ); free( cmd ); free( gSymbolFileName ); gSymbolFileName = 0; } else { - remove( "hephaestus.symb" ); + (void)remove( "hephaestus.symb" ); fsymbols = popen( "gzip -f >> hephaestus.symb", "w" ); } @@ -964,6 +969,8 @@ static PyObject* hep_outstream( PyObject* unused, PyObject* args ) { fclose( gReportStream ); fd = dup( fileno( fp ) ); + if (fd < 0) + return 0; gReportStream = fdopen( fd, "w" ); @@ -985,7 +992,7 @@ static PyObject* hep_profname( PyObject* unused, PyObject* args ) { // remove file if it already exists filename = (char*)malloc( 5+strlen(name)+1 ); sprintf( filename, "%s.prof", name ); - remove( filename ); + (void)remove( filename ); free( filename ); // open a pipe to gzip onto the new file diff --git a/Control/Hephaestus/src/UnwindBacktrace.c b/Control/Hephaestus/src/UnwindBacktrace.c old mode 100755 new mode 100644 diff --git a/Control/Hephaestus/src/hlib/HashTable.c b/Control/Hephaestus/src/hlib/HashTable.c old mode 100755 new mode 100644 index f1252e1ff59fd254036ba18b54e910ab9ebc7254..de5014c25933f0f04102425d5daa1b53cd06c5f2 --- a/Control/Hephaestus/src/hlib/HashTable.c +++ b/Control/Hephaestus/src/hlib/HashTable.c @@ -47,6 +47,7 @@ static struct hhh_Cell *hhh_Cell_new() { if ( gPool == NULL ) { fprintf( stderr, "Hephaestus ERROR: memory allocation failed in Cell_new\n" ); + pthread_mutex_unlock( &gPoolLock ); return NULL; } @@ -122,6 +123,9 @@ static int hhh_HashTable_expand( struct hhh_HashTable *ht ) } } + if (size == 0) + return 0; + newtable = (struct hhh_Cell**)calloc( size, sizeof(struct hhh_Cell*) ); if ( ! newtable ) return 0; diff --git a/Control/Hephaestus/src/hlib/Utils.c b/Control/Hephaestus/src/hlib/Utils.c old mode 100755 new mode 100644 index 0dbd0b8febd4e547d6b38dedc5f6ef800bc959e6..b27703b293ab44b09c75e503e928aa07793f3711 --- a/Control/Hephaestus/src/hlib/Utils.c +++ b/Control/Hephaestus/src/hlib/Utils.c @@ -321,7 +321,7 @@ const char* hhh_addrToLine (void* addr_in, const char** symbol) line[0] = ' '; length = addr_readline (pf, line+1, sizeof(line)-1); if (length >= 0) ++length; - fclose (pf); + pclose (pf); if (length < 0 || line[1] == '?') { line[1] = '\0'; length = 0;