Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Automate the tool build process.

This change extends the valgrind/Makefile to include downloading, patching,
and building the valgrind tool.  Additionally, it's no longer necessary to
install the valgrind tool since we can use VALGRIND_LIB to look for the
tool in the source tree if the memview binary is not installed.
  • Loading branch information...
commit f148c910408af7fed91c1f597335803a5a796f53 1 parent a5db4cf
Andrew Clinton authored
16 Loader.C
View
@@ -34,12 +34,16 @@
#define SHARED_NAME "/memview"
#define THREAD_LOADS
-Loader::Loader(MemoryState *state, StackTraceMap *stack, MMapMap *mmapmap)
+Loader::Loader(MemoryState *state,
+ StackTraceMap *stack,
+ MMapMap *mmapmap,
+ const std::string &path)
: QThread(0)
, myState(state)
, myStackTrace(stack)
, myMMapMap(mmapmap)
, myTotalEvents(0)
+ , myPath(path)
, myPendingClear(false)
, myBlockSize(MV_BlockSize)
, myChild(-1)
@@ -169,6 +173,16 @@ Loader::openPipe(int argc, char *argv[])
args[i+vg_args] = argv[i];
args[argc+vg_args] = NULL;
+ if (myPath != "/usr/bin/")
+ {
+ // If the executable is not executing from the install
+ // directory, look for valgrind in the source tree.
+ std::string valgrind_dir =
+ myPath + "valgrind/valgrind_src/.in_place";
+
+ setenv("VALGRIND_LIB", valgrind_dir.c_str(), 1);
+ }
+
if (execvp(valgrind, (char * const *)args) == -1)
{
char buf[256];
6 Loader.h
View
@@ -62,7 +62,10 @@ typedef std::shared_ptr<LoaderBlock> LoaderBlockHandle;
class Loader : public QThread {
public:
- Loader(MemoryState *state, StackTraceMap *stack, MMapMap *mmapmap);
+ Loader(MemoryState *state,
+ StackTraceMap *stack,
+ MMapMap *mmapmap,
+ const std::string &path);
~Loader();
bool openPipe(int argc, char *argv[]);
@@ -119,6 +122,7 @@ class Loader : public QThread {
MMapMap *myMMapMap;
MMapNameMap myMMapNames;
uint64 myTotalEvents;
+ std::string myPath;
QMutex myPendingLock;
std::unique_ptr<MemoryState> myPendingState;
21 README.md
View
@@ -23,29 +23,20 @@ Build the visualizer front end:
qmake
make -j<nprocs>
-To build the valgrind tool, check out the latest valgrind baseline, install
-the patches in the valgrind/ director, and then build valgrind. Here,
-`<valgrind-dir>` is the location of the valgrind repository.
+Build the valgrind tool. This will automatically download the valgrind
+source code prior to patching and building it:
- svn co svn://svn.valgrind.org/valgrind/trunk <valgrind-dir>
cd valgrind
- make patch VALGRIND_SRC=<valgrind-dir>
- cd <valgrind-dir>
- ./autogen.sh
- ./configure --prefix=<valgrind-install-dir>
- make -j<nprocs> install
+ make -j<nprocs>
## Execution
-Test the tool:
-
- valgrind --tool=memview ls
-
-Test the front end:
+If you built the front and tool successfully, the following command should
+work:
./memview ls
-If you were unable to patch the valgrind tool but you have a valgrind
+If you were unable to build the valgrind tool but you have a valgrind
binary installed, you can try the front end (without the tool) using:
./memview --tool=lackey ls
2  Window.C
View
@@ -277,7 +277,7 @@ MemViewWidget::MemViewWidget(int argc, char *argv[],
myStackTrace = new StackTraceMap;
myStackSelection = 0;
myMMapMap = new MMapMap;
- myLoader = new Loader(myState, myStackTrace, myMMapMap);
+ myLoader = new Loader(myState, myStackTrace, myMMapMap, myPath);
if (myLoader->openPipe(argc, argv))
{
2  debian/Makefile
View
@@ -4,7 +4,7 @@ BIN_INSTALL_DIR = debian/usr/bin
SHARE_INSTALL_DIR = debian/usr/share/memview
VALGRIND_INSTALL_DIR = debian/usr/lib/valgrind
-VALGRIND_SRC = ~/projects/repo/valgrind
+VALGRIND_SRC = ../valgrind/valgrind_src
# depends: dpkg-shlibdeps --ignore-missing-info -O debian/usr/bin/memview
39 valgrind/Makefile
View
@@ -1,7 +1,27 @@
-top:
+VALGRIND_SRC = valgrind_src
-patch:
- cp -rf memview $(VALGRIND_SRC)
+top: $(VALGRIND_SRC)
+ $(MAKE) -C $(VALGRIND_SRC)
+
+# We currently require changes from the development baseline for the
+# memview tool to work. When the next valgrind version is released, it
+# should be possible to patch the tarball directly.
+ifdef USE_TARBALL
+
+VALGRIND_VERSION = valgrind-3.8.1
+VALGRIND_TARBALL = $(VALGRIND_VERSION).tar.bz2
+
+$(VALGRIND_TARBALL):
+ wget http://valgrind.org/downloads/$(VALGRIND_TARBALL)
+
+$(VALGRIND_SRC): $(VALGRIND_TARBALL)
+ tar xjf $(VALGRIND_TARBALL)
+ mv $(VALGRIND_VERSION) $(VALGRIND_SRC)
+
+else
+
+$(VALGRIND_SRC):
+ svn co svn://svn.valgrind.org/valgrind/trunk $(VALGRIND_SRC)
cp -rf patch_memview.diff $(VALGRIND_SRC)
cp -rf patch_wrapmalloc.diff $(VALGRIND_SRC)
cp -rf patch_vex_floattypes.diff $(VALGRIND_SRC)/VEX
@@ -10,3 +30,16 @@ patch:
patch -p0 < patch_wrapmalloc.diff
cd $(VALGRIND_SRC)/VEX; \
patch -p0 < patch_vex_floattypes.diff
+ cp -rf memview $(VALGRIND_SRC)
+ # Make symbolic links for mv_ipc.h and mv_main.c for simpler
+ # development
+ rm -f $(VALGRIND_SRC)/mv_ipc.h
+ rm -f $(VALGRIND_SRC)/mv_main.c
+ ln -s memview/mv_ipc.h $(VALGRIND_SRC)/mv_ipc.h
+ ln -s memview/mv_main.c $(VALGRIND_SRC)/mv_main.c
+ cd $(VALGRIND_SRC); ./autogen.sh; ./configure
+
+endif
+
+clean:
+ rm -rf $(VALGRIND_SRC)
Please sign in to comment.
Something went wrong with that request. Please try again.