breakpad/src/tools/linux/dump_syms/Makefile
jimblandy 057aa1f617 Breakpad Linux Dumper: Add DWARF support.
This adds DWARF support to the Breakpad Linux dumper. This is
implemented as two handler classes: google_breakpad::DwarfCUToModule
accepts data from dwarf2reader::CompilationUnit, and
google_breakpad::DwarfLineToModule accepts data from a
dwarf2reader::LineInfo, each populating a google_breakpad::Module with
the results. Behaviors specific to particular source languages are
handled by instances of a new class, google_breakpad::Language.

An input executable may contain both STABS and DWARF debugging
information: the dumper automatically recognizes what sorts of
information are available, and integrates the data into a single
output file.

All classes have unit tests, providing line and branch coverage of all
interesting code. Unit tests are written using the Google C++ Testing
Framework, and the Google C++ Mocking Framework where appropriate.

a=jimblandy, r=ccoutant


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@497 4c0a9323-5329-0410-9bdc-e9ce6186880e
2010-01-23 05:29:16 +00:00

313 lines
8.8 KiB
Makefile

# Build all executables.
all::
# Delete all generated files: executables, object files, test coverage
# reports, etc.
clean::
# Run all tests.
# You can run a specific test FOO with the command: 'make check-FOO'.
check:
# 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:
# 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:
.PHONY: all clean check coverage coverage-reset
### Variables that are useful to override on the command line.
CC = gcc
CXX = g++
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=
# A wrapper for running 'make check' targets. This is inserted before
# the test executable name in the commands for 'check' targets. So if
# 'make check' would normally execute some test program with the
# command:
#
# SOME_ENV_VAR=value ./some-test-executable test-args
#
# then setting TEST_WRAPPER to 'valgrind' (say) would have 'make
# check' run the this command line:
#
# SOME_ENV_VAR=value valgrind ./some-test-executable test-args
TEST_WRAPPER=
### Variables used internally by this Makefile.
# The top of the breakpad source tree.
SRC = ../../..
# 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 =
# Add the names of source files whose coverage you'd like 'make
# coverage' to report on to this variable. Value accumulated
# throughout the file.
COVERAGE_SOURCES =
### dump_syms: a program to produce Breakpad symbol files from the
### debugging information in Linux executables.
all:: dump_syms
dump_syms: \
bytereader.o \
dwarf_cu_to_module.o \
dwarf_line_to_module.o \
dump_stabs.o \
dump_symbols.o \
dump_syms.o \
dwarf2diehandler.o \
dwarf2reader.o \
file_id.o \
language.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
dwarf_cu_to_module.o: dwarf_cu_to_module.cc
COVERAGE_SOURCES += dwarf_cu_to_module.cc
dwarf_line_to_module.o: dwarf_line_to_module.cc
COVERAGE_SOURCES += dwarf_line_to_module.cc
dump_stabs.o: dump_stabs.cc
COVERAGE_SOURCES += dump_stabs.cc
dump_symbols.o: dump_symbols.cc
file_id.o: file_id.cc
language.o: language.cc
module.o: module.cc
COVERAGE_SOURCES += module.cc
stabs_reader.o: stabs_reader.cc
COVERAGE_SOURCES += stabs_reader.cc
VPATH += $(SRC)/common/dwarf
bytereader.o: bytereader.cc
dwarf2diehandler.o: dwarf2diehandler.cc
COVERAGE_SOURCES += dwarf2diehandler.cc
dwarf2reader.o: dwarf2reader.cc
### Google C++ Testing Framework.
VPATH += $(SRC)/testing/gtest/src
GTEST_CPPFLAGS = -I$(SRC)/testing/gtest/include -I$(SRC)/testing/gtest
gtest-all.o: gtest-all.cc
gtest_main.o: gtest_main.cc
gtest-all.o gtest_main.o: override CPPFLAGS += $(GTEST_CPPFLAGS)
### Google C++ Mocking Framework.
VPATH += $(SRC)/testing/src
GMOCK_CPPFLAGS = -I$(SRC)/testing -I$(SRC)/testing/include
gmock-all.o: gmock-all.cc
gmock-all.o: override CPPFLAGS += $(GTEST_CPPFLAGS) $(GMOCK_CPPFLAGS)
### Unit tests for google_breakpad::StabsReader.
check: check-stabs_reader_unittest
check-stabs_reader_unittest: stabs_reader_unittest
stabs_reader_unittest: \
gmock-all.o \
gtest-all.o \
gtest_main.o \
stabs_reader.o \
$(empty)
CPP_EXECUTABLES += stabs_reader_unittest
stabs_reader_unittest.o: stabs_reader_unittest.cc
stabs_reader_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
$(GMOCK_CPPFLAGS)
clean::
rm -f stabs_reader_unittest
### Unit tests for google_breakpad::FileID.
check: check-file_id_unittest
check-file_id_unittest: file_id_unittest
file_id_unittest: \
gmock-all.o \
gtest-all.o \
gtest_main.o \
file_id.o \
$(empty)
CPP_EXECUTABLES += file_id_unittest
file_id_unittest.o: file_id_unittest.cc
file_id_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
$(GMOCK_CPPFLAGS)
clean::
rm -f file_id_unittest
### Unit tests for google_breakpad::Module.
check: check-module_unittest
check-module_unittest: module_unittest
module_unittest: \
gtest-all.o \
gtest_main.o \
module.o \
module_unittest.o \
$(empty)
CPP_EXECUTABLES += module_unittest
module_unittest.o: module_unittest.cc
module_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) $(GMOCK_CPPFLAGS)
clean::
rm -f module_unittest
### Unit tests for google_breakpad::DumpStabsHandler.
check: check-dump_stabs_unittest
check-dump_stabs_unittest: dump_stabs_unittest
dump_stabs_unittest: \
gtest-all.o \
gtest_main.o \
dump_stabs.o \
dump_stabs_unittest.o \
module.o \
$(empty)
CPP_EXECUTABLES += dump_stabs_unittest
dump_stabs_unittest.o: dump_stabs_unittest.cc
dump_stabs_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) $(GMOCK_CPPFLAGS)
clean::
rm -f dump_stabs_unittest
### Unit tests for dwarf2reader::DwarfDIEDispatcher.
check: check-dwarf2diehandler_unittest
check-dwarf2diehandler_unittest: dwarf2diehandler_unittest
dwarf2diehandler_unittest: \
gmock-all.o \
gtest-all.o \
gtest_main.o \
dwarf2diehandler.o \
$(empty)
CPP_EXECUTABLES += dwarf2diehandler_unittest
dwarf2diehandler_unittest.o: dwarf2diehandler_unittest.cc
dwarf2diehandler_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
$(GMOCK_CPPFLAGS)
clean::
rm -f dwarf2diehandler_unittest
### Unit tests for google_breakpad::DwarfLineToModule.
check: check-dwarf_line_to_module_unittest
check-dwarf_line_to_module_unittest: dwarf_line_to_module_unittest
dwarf_line_to_module_unittest: \
gtest-all.o \
gtest_main.o \
module.o \
dwarf_line_to_module.o \
$(empty)
CPP_EXECUTABLES += dwarf_line_to_module_unittest
dwarf_line_to_module_unittest.o: dwarf_line_to_module_unittest.cc
dwarf_line_to_module_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
$(GMOCK_CPPFLAGS)
clean::
rm -f dwarf_line_to_module_unittest
### Unit tests for google_breakpad::DwarfCUToModule.
check: check-dwarf_cu_to_module_unittest
check-dwarf_cu_to_module_unittest: dwarf_cu_to_module_unittest
dwarf_cu_to_module_unittest: \
bytereader.o \
dwarf2reader.o \
dwarf_cu_to_module.o \
dwarf_line_to_module.o \
gmock-all.o \
gtest-all.o \
gtest_main.o \
language.o \
module.o \
$(empty)
CPP_EXECUTABLES += dwarf_cu_to_module_unittest
dwarf_cu_to_module_unittest.o: dwarf_cu_to_module_unittest.cc
dwarf_cu_to_module_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
$(GMOCK_CPPFLAGS)
clean::
rm -f dwarf_cu_to_module_unittest
### 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_WRAPPER) ./$< $(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