aboutsummaryrefslogtreecommitdiff
path: root/src/tools/linux/dump_syms
diff options
context:
space:
mode:
authorjimblandy@gmail.com <jimblandy@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2009-12-15 16:28:43 +0000
committerjimblandy@gmail.com <jimblandy@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2009-12-15 16:28:43 +0000
commit1c9c0568e097e8b3cfe6e1c4f954d0877fb03711 (patch)
treecdc44b0a3a339f5340ce939d4eec55d766e611ca /src/tools/linux/dump_syms
parentMozilla bug 532713 - OS X client code doesn't decoded extended family ids in ... (diff)
downloadbreakpad-1c9c0568e097e8b3cfe6e1c4f954d0877fb03711.tar.xz
Issue 39001: Breakpad Linux dumper: Refactor Makefile.
Use GNU Make features to make the dumper, unit tests, and maintenance targets more independent, so I get fewer conflicts as I work on different parts of the patch series. In particular: - Provide targets to run tests and produce test coverage reports. - Gather C and C++ build rules in one place. - Avoid variables that list object files, as pattern rules can compute these values directly from the dependencies. - Use VPATH to find sources in other directories. a=jimb, r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@441 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/tools/linux/dump_syms')
-rw-r--r--src/tools/linux/dump_syms/Makefile147
1 files changed, 123 insertions, 24 deletions
diff --git a/src/tools/linux/dump_syms/Makefile b/src/tools/linux/dump_syms/Makefile
index 289dc4d8..61aee177 100644
--- a/src/tools/linux/dump_syms/Makefile
+++ b/src/tools/linux/dump_syms/Makefile
@@ -1,37 +1,136 @@
-CXX=g++
-CC=gcc
+### Variables that can be overridden on the command line.
+CC = gcc
+CXX = g++
+CPPFLAGS = -DNDEBUG
+CXXFLAGS = -g3 -O2 -Wall -m32
-CPPFLAGS=-DNDEBUG
-CXXFLAGS=-g3 -O2 -Wall -m32
+# To produce test coverage reports:
+# 1) Build all .o files and executables without optimization and with
+# 'COVERAGE=1' on the make command line.
+# 2) Run the tests.
+# 3) Do 'make coverage'.
+# All in one command:
+# $ make CFLAGS='-O0' CXXFLAGS='-O0' COVERAGE=1 clean check coverage
+COVERAGE=
+# Build all executables.
+all::
-# These flags are necessary to compile correctly; the 'override'
-# command makes sure these are added even if the user sets CPPFLAGS on
-# the command line.
-override CPPFLAGS+=-I../../.. -D_REENTRANT
+# Delete all generated files: executables, object files, test coverage
+# reports, etc.
+clean::
-.PHONY:all clean
+# Run all tests.
+# You can run a specific test FOO with the command: 'make check-FOO'.
+check:
-BIN=dump_syms
+# Generate coverage reports for the execution that has taken place
+# since the coverage data files were last deleted. Only files that
+# have been added to COVERAGE_SOURCES (see below) get reported on.
+coverage:
-all:$(BIN)
+# Reset all coverage counts. When coverage is enabled, each time you
+# run the program, it adds its execution counts into the profiling
+# data files in the build directory. 'make coverage-reset' deletes
+# those files, so the counts reported by 'make coverage' start from
+# zero again. Note that 'make clean' does this automatically.
+coverage-reset:
-DUMP_OBJ=dump_symbols.o dump_syms.o file_id.o stabs_reader.o module.o
+.PHONY: all clean check coverage coverage-reset
-dump_syms:$(DUMP_OBJ)
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^
-dump_symbols.o:../../../common/linux/dump_symbols.cc
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^
+### Variables used internally by this Makefile.
-stabs_reader.o:../../../common/linux/stabs_reader.cc
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^
+# The top of the breakpad source tree.
+SRC = ../../..
-module.o:../../../common/linux/module.cc
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^
+# A list of the executables that we should use the C++ compiler to
+# link. GNU make's default executable-from-object rule uses $(CC),
+# which doesn't include libstdc++, and perhaps does some other things
+# wrong as well. Every executable listed in this variable uses the
+# pattern rule provided at the bottom, which links all the
+# dependencies using $(CXX). Value accumulated throughout the file.
+CPP_EXECUTABLES =
-file_id.o:../../../common/linux/file_id.cc
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^
+# Source files whose coverage we are interested in. Value accumulated
+# throughout the file.
+COVERAGE_SOURCES =
-clean:
- rm -f $(BIN) $(DUMP_OBJ)
+
+### dump_syms: a program to produce Breakpad symbol files from the
+### debugging information in Linux executables.
+all:: dump_syms
+dump_syms: \
+ dump_syms.o \
+ dump_symbols.o \
+ file_id.o \
+ module.o \
+ stabs_reader.o \
+ $(empty)
+CPP_EXECUTABLES += dump_syms
+clean::
+ rm -f dump_syms
+
+dump_syms.o: dump_syms.cc
+
+VPATH += $(SRC)/common/linux
+dump_symbols.o: dump_symbols.cc
+file_id.o: file_id.cc
+module.o: module.cc
+stabs_reader.o: stabs_reader.cc
+
+
+### Generic compilation rules.
+
+# Link C++ executables using the C++ compiler; see CPP_EXECUTABLES above.
+$(CPP_EXECUTABLES): %: %.o
+ $(CXX) $(CXXFLAGS) $(COVERAGE_LDFLAGS) $(LDFLAGS) -o $@ $^
+
+# These flags are required for breakpad sources to compile correctly.
+BREAKPAD_CPPFLAGS = -I$(SRC) -D_REENTRANT
+
+%.o: %.cc
+ $(CXX) -c $^ -o $@ $(CPPFLAGS) $(BREAKPAD_CPPFLAGS) $(CXXFLAGS)
+%.o: %.c
+ $(CC) -c $^ -o $@ $(CPPFLAGS) $(BREAKPAD_CPPFLAGS) $(CFLAGS)
+
+clean::
+ rm -f *.o core
+
+### Generic testing rules.
+
+### To define a test, make the 'check' target depend on a particular
+### target 'check-FOO' that runs your test, where FOO is the name of
+### the test executable, or something else people will expect.
+###
+### This pattern rule provides commands for 'check-FOO' that are
+### appropriate for Google C++ Testing Framework test programs. But
+### you can provide your own commands.
+check-%: %
+ srcdir=$(SRC) ./$< $(TEST_ARGS)
+
+
+### Generic coverage reporting rules.
+coverage:
+ gcov --branch-probabilities $(COVERAGE_SOURCES)
+
+coverage-reset:
+ rm -f *.gcda
+
+# If code coverage is enabled, pass the appropriate coverage flags to
+# the compiler for the sources we care about.
+ifdef COVERAGE
+
+COVERAGE_C_SOURCES = $(filter %.c,$(COVERAGE_SOURCES))
+$(COVERAGE_C_SOURCES:.c=.o): override CFLAGS += --coverage
+
+COVERAGE_CXX_SOURCES = $(filter %.cc,$(COVERAGE_SOURCES))
+$(COVERAGE_CXX_SOURCES:.cc=.o): override CXXFLAGS += --coverage
+
+COVERAGE_LDFLAGS = --coverage
+
+endif
+
+clean:: coverage-reset
+clean::
+ rm -f *.gcno *.gcov