diff options
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Makefile | 1 | ||||
-rw-r--r-- | lib/Support/MemoryUsage.cpp | 25 | ||||
-rw-r--r-- | lib/Support/TreeStream.cpp | 20 |
3 files changed, 36 insertions, 10 deletions
diff --git a/lib/Support/Makefile b/lib/Support/Makefile index a1b46f3c..67272908 100644 --- a/lib/Support/Makefile +++ b/lib/Support/Makefile @@ -12,5 +12,6 @@ LEVEL=../.. LIBRARYNAME=kleeSupport DONT_BUILD_RELINKED=1 BUILD_ARCHIVE=1 +NO_INSTALL=1 include $(LEVEL)/Makefile.common diff --git a/lib/Support/MemoryUsage.cpp b/lib/Support/MemoryUsage.cpp new file mode 100644 index 00000000..676ce307 --- /dev/null +++ b/lib/Support/MemoryUsage.cpp @@ -0,0 +1,25 @@ +//===-- MemoryUsage.cpp ---------------------------------------------------===// +// +// The KLEE Symbolic Virtual Machine +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "klee/Internal/System/MemoryUsage.h" +#include <malloc.h> + +using namespace klee; + +size_t util::GetTotalMallocUsage() { + struct mallinfo mi = ::mallinfo(); + // The malloc implementation in glibc (pmalloc2) + // does not include mmap()'ed memory in mi.uordblks + // but other implementations (e.g. tcmalloc) do. +#if defined(__GLIBC__) + return mi.uordblks + mi.hblkhd; +#else + return mi.uordblks; +#endif +} diff --git a/lib/Support/TreeStream.cpp b/lib/Support/TreeStream.cpp index 0e8b86dd..0d5e4568 100644 --- a/lib/Support/TreeStream.cpp +++ b/lib/Support/TreeStream.cpp @@ -10,12 +10,13 @@ #include "klee/Internal/ADT/TreeStream.h" #include <cassert> -#include <iostream> #include <iomanip> #include <fstream> #include <iterator> #include <map> +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" #include <string.h> using namespace klee; @@ -105,10 +106,9 @@ void TreeStreamWriter::readStream(TreeStreamID streamID, std::ifstream is(path.c_str(), std::ios::in | std::ios::binary); assert(is.good()); -#if 0 - std::cout << "finding chain for: " << streamID << "\n"; -#endif - + DEBUG_WITH_TYPE("TreeStreamWriter", + llvm::errs() << "finding chain for: " << streamID << "\n"); + std::map<unsigned,unsigned> parents; std::vector<unsigned> roots; for (;;) { @@ -137,11 +137,11 @@ void TreeStreamWriter::readStream(TreeStreamID streamID, while (size--) is.get(); } } -#if 0 - std::cout << "roots: "; - std::copy(roots.begin(), roots.end(), std::ostream_iterator<unsigned>(std::cout, " ")); - std::cout << "\n"; -#endif + DEBUG(llvm::errs() << "roots: "; + for (size_t i = 0, e = roots.size(); i < e; ++i) { + llvm::errs() << roots[i] << " "; + } + llvm::errs() << "\n";); is.seekg(0, std::ios::beg); for (;;) { unsigned id; |