Make memory analyzer optional
We were doing this in multiple places, this should make it a bit easier to keep set properties consistent among different places. Ideally we could eventually move away from mentioning targets from modules here on the top level (and instead have each module call cprover_default_properties) but this isn't done in this commit. Because memory analyzer depends on GDB being present and further uses platform specific functionality at the moment it had some ifdef functionality to disable itself. This made the code a bit more complicated than it needed to be, and also lead to the code effectively building defunct executables. This removes these ifdefs and instead excludes memory-analyzer (and related tests) from the build unless requested (via WITH_MEMORY_ANALYZER environment variable or CMake option depending on whether it is a Make or CMake build respectively). Also force building memory-analyzer on Linux and test it there by default (unless explicitly unset). Behaviour on other platforms should be preserved.
This commit is contained in:
parent
c70540c234
commit
856aa5c201
14
.travis.yml
14
.travis.yml
|
@ -108,6 +108,7 @@ jobs:
|
|||
env:
|
||||
- COMPILER="ccache /usr/bin/g++-5"
|
||||
- EXTRA_CXXFLAGS="-D_GLIBCXX_DEBUG"
|
||||
- WITH_MEMORY_ANALYZER=1
|
||||
|
||||
# OS X using clang++
|
||||
- stage: Test different OS/CXX/Flags
|
||||
|
@ -118,7 +119,9 @@ jobs:
|
|||
before_install:
|
||||
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache parallel gdb
|
||||
- export PATH=$PATH:/usr/local/opt/ccache/libexec
|
||||
env: COMPILER="ccache clang++"
|
||||
env:
|
||||
- COMPILER="ccache clang++"
|
||||
- WITH_MEMORY_ANALYZER=0
|
||||
|
||||
# Ubuntu Linux with glibc using g++-5, debug mode
|
||||
- stage: Test different OS/CXX/Flags
|
||||
|
@ -144,6 +147,7 @@ jobs:
|
|||
env:
|
||||
- COMPILER="ccache /usr/bin/g++-5"
|
||||
- EXTRA_CXXFLAGS="-DDEBUG"
|
||||
- WITH_MEMORY_ANALYZER=1
|
||||
script: echo "Not running any tests for a debug build."
|
||||
|
||||
# Ubuntu Linux with glibc using clang++-7, debug mode, disable USE_DSTRING
|
||||
|
@ -175,6 +179,7 @@ jobs:
|
|||
- COMPILER="ccache /usr/bin/clang++-7"
|
||||
- EXTRA_CXXFLAGS="-Qunused-arguments -fcolor-diagnostics -DDEBUG -DUSE_STD_STRING"
|
||||
- CCACHE_CPP2=yes
|
||||
- WITH_MEMORY_ANALYZER=1
|
||||
script: echo "Not running any tests for a debug build."
|
||||
|
||||
# cmake build using g++-7, enable NAMED_SUB_IS_FORWARD_LIST
|
||||
|
@ -200,7 +205,7 @@ jobs:
|
|||
install:
|
||||
- ccache -z
|
||||
- ccache --max-size=1G
|
||||
- cmake -H. -Bbuild '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_CXX_COMPILER=/usr/bin/g++-7' '-DCMAKE_CXX_FLAGS=-DNAMED_SUB_IS_FORWARD_LIST'
|
||||
- cmake -H. -Bbuild '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_CXX_COMPILER=/usr/bin/g++-7' '-DCMAKE_CXX_FLAGS=-DNAMED_SUB_IS_FORWARD_LIST' '-DWITH_MEMORY_ANALYZER=On'
|
||||
- git submodule update --init --recursive
|
||||
- cmake --build build -- -j4
|
||||
script: (cd build; bin/unit "[core][irept]")
|
||||
|
@ -228,7 +233,7 @@ jobs:
|
|||
install:
|
||||
- ccache -z
|
||||
- ccache --max-size=1G
|
||||
- cmake -H. -Bbuild '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_CXX_COMPILER=/usr/bin/g++-7' '-DCMAKE_USE_CUDD=true' -DCMAKE_CXX_FLAGS="-DBDD_GUARDS"
|
||||
- cmake -H. -Bbuild '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_CXX_COMPILER=/usr/bin/g++-7' '-DCMAKE_USE_CUDD=true' -DCMAKE_CXX_FLAGS="-DBDD_GUARDS" '-DWITH_MEMORY_ANALYZER=On'
|
||||
- git submodule update --init --recursive
|
||||
- cmake --build build -- -j4
|
||||
script: (cd build; ctest -V -L CORE -j2)
|
||||
|
@ -264,7 +269,7 @@ jobs:
|
|||
install:
|
||||
- ccache -z
|
||||
- ccache --max-size=1G
|
||||
- cmake -H. -Bbuild '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_CXX_COMPILER=/usr/bin/clang++-7' '-DCMAKE_CXX_FLAGS=-Qunused-arguments'
|
||||
- cmake -H. -Bbuild '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_CXX_COMPILER=/usr/bin/clang++-7' '-DCMAKE_CXX_FLAGS=-Qunused-arguments' '-DWITH_MEMORY_ANALYZER=On'
|
||||
- git submodule update --init --recursive
|
||||
- cmake --build build -- -j4
|
||||
script: (cd build; ctest -V -L CORE -j2)
|
||||
|
@ -321,6 +326,7 @@ jobs:
|
|||
env:
|
||||
- NAME="COVERITY_SCAN"
|
||||
- COMPILER="ccache g++"
|
||||
- WITH_MEMORY_ANALYZER=1
|
||||
script: echo "This is coverity build. No need for tests."
|
||||
|
||||
install:
|
||||
|
|
|
@ -104,16 +104,37 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
|
|||
endif()
|
||||
endif()
|
||||
|
||||
function(cprover_default_properties)
|
||||
set(CBMC_CXX_STANDARD 11)
|
||||
set(CBMC_CXX_STANDARD_REQUIRED true)
|
||||
set(CBMC_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY
|
||||
"Developer ID Application: Daniel Kroening")
|
||||
|
||||
set_target_properties(
|
||||
${ARGN}
|
||||
PROPERTIES
|
||||
CXX_STANDARD ${CBMC_CXX_STANDARD}
|
||||
CXX_STANDARD_REQUIRED ${CBMC_CXX_STANDARD_REQUIRED}
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CBMC_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY})
|
||||
endfunction()
|
||||
|
||||
option(WITH_MEMORY_ANALYZER OFF
|
||||
"build the memory analyzer")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
set(WITH_MEMORY_ANALYZER_DEFAULT ON)
|
||||
else()
|
||||
set(WITH_MEMORY_ANALYZER_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
option(WITH_MEMORY_ANALYZER ${WITH_MEMORY_ANALYZER_DEFAULT}
|
||||
"build the memory analyzer")
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(regression)
|
||||
add_subdirectory(unit)
|
||||
|
||||
set(CBMC_CXX_STANDARD 11)
|
||||
set(CBMC_CXX_STANDARD_REQUIRED true)
|
||||
set(CBMC_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY
|
||||
"Developer ID Application: Daniel Kroening")
|
||||
|
||||
set_target_properties(
|
||||
cprover_default_properties(
|
||||
analyses
|
||||
ansi-c
|
||||
assembler
|
||||
|
@ -139,21 +160,13 @@ set_target_properties(
|
|||
json-symtab-language
|
||||
langapi
|
||||
linking
|
||||
memory-analyzer
|
||||
memory-analyzer-lib
|
||||
pointer-analysis
|
||||
solvers
|
||||
symtab2gb
|
||||
testing-utils
|
||||
unit
|
||||
util
|
||||
xml
|
||||
|
||||
PROPERTIES
|
||||
CXX_STANDARD ${CBMC_CXX_STANDARD}
|
||||
CXX_STANDARD_REQUIRED ${CBMC_CXX_STANDARD_REQUIRED}
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CBMC_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY}
|
||||
)
|
||||
xml)
|
||||
|
||||
option(WITH_JBMC "Build the JBMC Java front-end" ON)
|
||||
if(WITH_JBMC)
|
||||
|
|
|
@ -8,7 +8,7 @@ add_custom_target(java-models-library ALL
|
|||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/java-models-library
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
cprover_default_properties(
|
||||
java_bytecode
|
||||
java-models-library
|
||||
jbmc
|
||||
|
@ -20,9 +20,4 @@ set_target_properties(
|
|||
java-testing-utils
|
||||
java-unit
|
||||
miniz
|
||||
|
||||
PROPERTIES
|
||||
CXX_STANDARD ${CBMC_CXX_STANDARD}
|
||||
CXX_STANDARD_REQUIRED ${CBMC_CXX_STANDARD_REQUIRED}
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CBMC_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY}
|
||||
)
|
||||
|
|
|
@ -53,3 +53,7 @@ add_subdirectory(goto-harness)
|
|||
add_subdirectory(goto-cc-file-local)
|
||||
add_subdirectory(linking-goto-binaries)
|
||||
add_subdirectory(symtab2gb)
|
||||
|
||||
if(WITH_MEMORY_ANALYZER)
|
||||
add_subdirectory(memory-analyzer)
|
||||
endif()
|
||||
|
|
|
@ -30,6 +30,23 @@ DIRS = cbmc \
|
|||
symtab2gb \
|
||||
# Empty last line
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
detected_OS := Windows
|
||||
else
|
||||
detected_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
|
||||
endif
|
||||
|
||||
ifeq ($(detected_OS),Linux)
|
||||
ifneq ($(WITH_MEMORY_ANALYZER),0)
|
||||
# only set if it wasn't explicitly unset
|
||||
WITH_MEMORY_ANALYZER=1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WITH_MEMORY_ANALYZER),1)
|
||||
DIRS += memory-analyzer
|
||||
endif
|
||||
|
||||
# Run all test directories in sequence
|
||||
.PHONY: test
|
||||
test:
|
||||
|
|
|
@ -104,5 +104,8 @@ add_subdirectory(goto-instrument)
|
|||
add_subdirectory(goto-analyzer)
|
||||
add_subdirectory(goto-diff)
|
||||
add_subdirectory(goto-harness)
|
||||
add_subdirectory(memory-analyzer)
|
||||
add_subdirectory(symtab2gb)
|
||||
|
||||
if(UNIX OR WITH_MEMORY_ANALYZER)
|
||||
add_subdirectory(memory-analyzer)
|
||||
endif()
|
||||
|
|
13
src/Makefile
13
src/Makefile
|
@ -31,10 +31,21 @@ all: cbmc.dir \
|
|||
goto-diff.dir \
|
||||
goto-instrument.dir \
|
||||
goto-harness.dir \
|
||||
memory-analyzer.dir \
|
||||
symtab2gb.dir \
|
||||
# Empty last line
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
detected_OS := Windows
|
||||
else
|
||||
detected_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
|
||||
endif
|
||||
|
||||
ifeq ($(detected_OS),Linux)
|
||||
all: memory-analyzer.dir
|
||||
else ifeq ($(WITH_MEMORY_ANALYZER),1)
|
||||
all: memory-analyzer.dir
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
|
||||
util.dir: big-int.dir
|
||||
|
|
|
@ -7,15 +7,6 @@ Author: Malte Mues <mail.mues@gmail.com>
|
|||
|
||||
\*******************************************************************/
|
||||
|
||||
// clang-format off
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__unix__) || \
|
||||
defined(__CYGWIN__) || \
|
||||
defined(__MACH__)
|
||||
// clang-format on
|
||||
|
||||
#include "analyze_symbol.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -408,4 +399,3 @@ void symbol_analyzert::process_outstanding_assignments()
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,14 +7,6 @@ Author: Malte Mues <mail.mues@gmail.com>
|
|||
|
||||
\*******************************************************************/
|
||||
|
||||
// clang-format off
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__unix__) || \
|
||||
defined(__CYGWIN__) || \
|
||||
defined(__MACH__)
|
||||
// clang-format on
|
||||
|
||||
#ifndef CPROVER_MEMORY_ANALYZER_ANALYZE_SYMBOL_H
|
||||
#define CPROVER_MEMORY_ANALYZER_ANALYZE_SYMBOL_H
|
||||
|
@ -98,4 +90,3 @@ private:
|
|||
};
|
||||
|
||||
#endif // CPROVER_MEMORY_ANALYZER_ANALYZE_SYMBOL_H
|
||||
#endif
|
||||
|
|
|
@ -10,14 +10,6 @@ Author: Malte Mues <mail.mues@gmail.com>
|
|||
/// \file
|
||||
/// Low-level interface to gdb
|
||||
|
||||
// clang-format off
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__unix__) || \
|
||||
defined(__CYGWIN__) || \
|
||||
defined(__MACH__)
|
||||
// clang-format on
|
||||
|
||||
#include <cctype>
|
||||
#include <cerrno>
|
||||
|
@ -506,5 +498,3 @@ gdb_apit::r_or(const std::string ®ex_left, const std::string ®ex_right)
|
|||
{
|
||||
return R"((?:)" + regex_left + '|' + regex_right + R"())";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,15 +15,6 @@ Author: Malte Mues <mail.mues@gmail.com>
|
|||
/// gdb machine interface (see section "The GDB/MI Interface" in the
|
||||
/// gdb manual to communicate with gdb.
|
||||
|
||||
// clang-format off
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__unix__) || \
|
||||
defined(__CYGWIN__) || \
|
||||
defined(__MACH__)
|
||||
// clang-format on
|
||||
|
||||
#ifndef CPROVER_MEMORY_ANALYZER_GDB_API_H
|
||||
#define CPROVER_MEMORY_ANALYZER_GDB_API_H
|
||||
#include <unistd.h>
|
||||
|
@ -142,4 +133,3 @@ private:
|
|||
};
|
||||
|
||||
#endif // CPROVER_MEMORY_ANALYZER_GDB_API_H
|
||||
#endif
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
// Copyright 2018 Author: Malte Mues <mail.mues@gmail.com>
|
||||
|
||||
// clang-format off
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__unix__) || \
|
||||
defined(__CYGWIN__) || \
|
||||
defined(__MACH__)
|
||||
// clang-format on
|
||||
|
||||
#include "memory_analyzer_parse_options.h"
|
||||
|
||||
|
@ -16,12 +8,3 @@ int main(int argc, const char **argv)
|
|||
memory_analyzer_parse_optionst parse_options(argc, argv);
|
||||
return parse_options.main();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
throw "the memory analyzer is only supported on Unices\n";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,15 +10,6 @@ Author: Malte Mues <mail.mues@gmail.com>
|
|||
/// \file
|
||||
/// Commandline parser for the memory analyzer executing main work.
|
||||
|
||||
// clang-format off
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__unix__) || \
|
||||
defined(__CYGWIN__) || \
|
||||
defined(__MACH__)
|
||||
// clang-format on
|
||||
|
||||
#include "memory_analyzer_parse_options.h"
|
||||
#include "analyze_symbol.h"
|
||||
#include "gdb_api.h"
|
||||
|
@ -183,5 +174,3 @@ void memory_analyzer_parse_optionst::help()
|
|||
<< " --output-file <file> write snapshot to file\n"
|
||||
<< messaget::eom;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,15 +10,6 @@ Author: Malte Mues <mail.mues@gmail.com>
|
|||
/// \file
|
||||
/// This code does the command line parsing for the memory-analyzer tool
|
||||
|
||||
// clang-format off
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__unix__) || \
|
||||
defined(__CYGWIN__) || \
|
||||
defined(__MACH__)
|
||||
// clang-format on
|
||||
|
||||
#ifndef CPROVER_MEMORY_ANALYZER_MEMORY_ANALYZER_PARSE_OPTIONS_H
|
||||
#define CPROVER_MEMORY_ANALYZER_MEMORY_ANALYZER_PARSE_OPTIONS_H
|
||||
|
||||
|
@ -49,4 +40,3 @@ protected:
|
|||
};
|
||||
|
||||
#endif // CPROVER_MEMORY_ANALYZER_MEMORY_ANALYZER_PARSE_OPTIONS_H
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,11 @@ file(GLOB_RECURSE sources "*.cpp" "*.h")
|
|||
|
||||
file(GLOB_RECURSE testing_utils "testing-utils/*.cpp" "testing-utils/*.h")
|
||||
|
||||
if(NOT WITH_MEMORY_ANALYZER)
|
||||
file(GLOB_RECURSE memory_analyzer_sources "memory-analyzer/*.cpp")
|
||||
list(REMOVE_ITEM sources ${memory_analyzer_sources})
|
||||
endif()
|
||||
|
||||
list(REMOVE_ITEM sources
|
||||
# Don't build
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/elf_reader.cpp
|
||||
|
|
|
@ -34,7 +34,6 @@ SRC += analyses/ai/ai.cpp \
|
|||
interpreter/interpreter.cpp \
|
||||
json/json_parser.cpp \
|
||||
json_symbol_table.cpp \
|
||||
memory-analyzer/gdb_api.cpp \
|
||||
path_strategies.cpp \
|
||||
pointer-analysis/value_set.cpp \
|
||||
solvers/bdd/miniBDD/miniBDD.cpp \
|
||||
|
@ -85,6 +84,23 @@ SRC += analyses/ai/ai.cpp \
|
|||
util/unicode.cpp \
|
||||
# Empty last line
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
detected_OS := Windows
|
||||
else
|
||||
detected_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
|
||||
endif
|
||||
|
||||
ifeq ($(detected_OS),Linux)
|
||||
ifneq ($(WITH_MEMORY_ANALYZER),0)
|
||||
# only set if it wasn't explicitly unset
|
||||
WITH_MEMORY_ANALYZER=1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WITH_MEMORY_ANALYZER),1)
|
||||
SRC += memory-analyzer/gdb_api.cpp
|
||||
endif
|
||||
|
||||
INCLUDES= -I ../src/ -I.
|
||||
|
||||
CPROVER_DIR = .
|
||||
|
@ -145,9 +161,14 @@ CPROVER_LIBS =../src/ansi-c/ansi-c$(LIBEXT) \
|
|||
OBJ += $(CPROVER_LIBS) testing-utils/testing-utils$(LIBEXT)
|
||||
|
||||
CATCH_TEST = unit_tests$(EXEEXT)
|
||||
EXCLUDED_TESTS=expr_undefined_casts.cpp
|
||||
ifneq ($(WITH_MEMORY_ANALYZER),1)
|
||||
EXCLUDED_TESTS += gdb_api.cpp
|
||||
endif
|
||||
|
||||
N_CATCH_TESTS = $(shell \
|
||||
cat $$(find . -name "*.cpp" \
|
||||
-a -not -name "expr_undefined_casts.cpp") | \
|
||||
$$(printf ' -not -name %s ' $(EXCLUDED_TESTS))) | \
|
||||
grep -E "(SCENARIO|TEST_CASE)" | grep -c -v '\[\.\]')
|
||||
|
||||
CLEANFILES = $(CATCH_TEST) testing-utils/testing-utils$(LIBEXT)
|
||||
|
|
|
@ -9,19 +9,6 @@ Author: Malte Mues <mail.mues@gmail.com>
|
|||
|
||||
#include <testing-utils/use_catch.h>
|
||||
|
||||
// clang-format off
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__unix__) || \
|
||||
defined(__CYGWIN__) || \
|
||||
defined(__MACH__)
|
||||
#define RUN_GDB_API_TESTS
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#ifdef RUN_GDB_API_TESTS
|
||||
|
||||
#include <cstdio>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
|
@ -103,18 +90,13 @@ void gdb_api_internals_test()
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST_CASE("gdb api internals test", "[core][memory-analyzer]")
|
||||
{
|
||||
#ifdef RUN_GDB_API_TESTS
|
||||
gdb_api_internals_test();
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("gdb api test", "[core][memory-analyzer]")
|
||||
{
|
||||
#ifdef RUN_GDB_API_TESTS
|
||||
check_for_gdb();
|
||||
compile_test_file();
|
||||
|
||||
|
@ -249,5 +231,4 @@ TEST_CASE("gdb api test", "[core][memory-analyzer]")
|
|||
REQUIRE(!value.string);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue