aboutsummaryrefslogtreecommitdiff
path: root/src/tools/linux/dump_syms/Makefile
blob: 17f947223447f25785acbaa2d4f0dcd7d812e363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# 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++
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=

# Arguments to pass to the test programs.
TEST_ARGS=

### 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				\
	dump_symbols.o				\
	dump_syms.o				\
	dwarf2diehandler.o			\
	dwarf2reader.o				\
	dwarf_cfi_to_module.o			\
	dwarf_cu_to_module.o			\
	dwarf_line_to_module.o			\
	file_id.o				\
	language.o				\
	module.o				\
	stabs_reader.o				\
	stabs_to_module.o			\
	$(empty)
CPP_EXECUTABLES += dump_syms
clean::
	rm -f dump_syms

dump_syms.o: dump_syms.cc

VPATH += $(SRC)/common
dwarf_cfi_to_module.o: dwarf_cfi_to_module.cc
COVERAGE_SOURCES += dwarf_cfi_to_module.cc
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
language.o: language.cc
module.o: module.cc
COVERAGE_SOURCES += module.cc
stabs_reader.o: stabs_reader.cc
COVERAGE_SOURCES += stabs_reader.cc
stabs_to_module.o: stabs_to_module.cc
COVERAGE_SOURCES += stabs_to_module.cc

VPATH += $(SRC)/common/linux
dump_symbols.o: dump_symbols.cc
file_id.o: file_id.cc

VPATH += $(SRC)/common/dwarf
bytereader.o: bytereader.cc
COVERAGE_SOURCES += bytereader.cc
cfi_assembler.o: cfi_assembler.cc
dwarf2diehandler.o: dwarf2diehandler.cc
COVERAGE_SOURCES += dwarf2diehandler.cc
dwarf2reader.o: dwarf2reader.cc
COVERAGE_SOURCES += 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)


### google_breakpad::TestAssembler, for constructing binary test data
VPATH += $(SRC)/common
test_assembler.o: test_assembler.cc
test_assembler.o: override CPPFLAGS += $(TEST_ASSEMBLER_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				\
	test_assembler.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:				\
	file_id.o				\
	gmock-all.o				\
	gtest-all.o				\
	gtest_main.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:				\
	gmock-all.o				\
	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-stabs_to_module_unittest
check-stabs_to_module_unittest: stabs_to_module_unittest
stabs_to_module_unittest:				\
	gtest-all.o					\
	gtest_main.o					\
	module.o					\
	stabs_to_module.o				\
	stabs_to_module_unittest.o			\
	$(empty)
CPP_EXECUTABLES += stabs_to_module_unittest
stabs_to_module_unittest.o: stabs_to_module_unittest.cc
stabs_to_module_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
						 $(GMOCK_CPPFLAGS)
clean::
	rm -f stabs_to_module_unittest


### Unit tests for dwarf2reader::DwarfDIEDispatcher.
check: check-dwarf2diehandler_unittest
check-dwarf2diehandler_unittest: dwarf2diehandler_unittest
dwarf2diehandler_unittest:			\
	dwarf2diehandler.o			\
	gmock-all.o				\
	gtest-all.o				\
	gtest_main.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:			\
	dwarf_line_to_module.o			\
	gtest-all.o				\
	gtest_main.o				\
	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



### Unit tests for dwarf2reader::CallFrameInfo.
check: check-dwarf2reader_cfi_unittest
check-dwarf2reader_cfi_unittest: dwarf2reader_cfi_unittest
dwarf2reader_cfi_unittest:      		\
	bytereader.o				\
	cfi_assembler.o				\
	dwarf2reader.o				\
	gmock-all.o				\
	gtest-all.o				\
	gtest_main.o				\
	test_assembler.o			\
	$(empty)
CPP_EXECUTABLES += dwarf2reader_cfi_unittest
dwarf2reader_cfi_unittest.o: dwarf2reader_cfi_unittest.cc
dwarf2reader_cfi_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
						  $(GMOCK_CPPFLAGS) \
						  $(TEST_ASSEMBLER_CPPFLAGS)
clean::
	rm -f dwarf2reader_cfi_unittest



### Unit tests for google_breakpad::DwarfCFIToModule.
check: check-dwarf_cfi_to_module_unittest
check-dwarf_cfi_to_module_unittest: dwarf_cfi_to_module_unittest
dwarf_cfi_to_module_unittest:      		\
	dwarf_cfi_to_module.o			\
	gmock-all.o				\
	gtest-all.o				\
	gtest_main.o				\
	module.o				\
	$(empty)
CPP_EXECUTABLES += dwarf_cfi_to_module_unittest
dwarf_cfi_to_module_unittest.o: dwarf_cfi_to_module_unittest.cc
dwarf_cfi_to_module_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
						     $(GMOCK_CPPFLAGS)
clean::
	rm -f dwarf_cfi_to_module_unittest



### Unit tests for google_breakpad::ByteReader
check: check-bytereader_unittest
check-bytereader_unittest: bytereader_unittest
bytereader_unittest:				\
	bytereader.o				\
	cfi_assembler.o				\
	gtest-all.o				\
	gtest_main.o				\
	module.o				\
	test_assembler.o			\
	$(empty)
CPP_EXECUTABLES += bytereader_unittest
bytereader_unittest.o: bytereader_unittest.cc
bytereader_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
					    $(GMOCK_CPPFLAGS)
clean::
	rm -f bytereader_unittest



### Unit tests for google_breakpad::ByteBuffer and google_breakpad::ByteCursor.
check: check-byte_cursor_unittest
check-byte_cursor_unittest: byte_cursor_unittest
byte_cursor_unittest:				\
	gmock-all.o				\
	gtest-all.o				\
	gtest_main.o				\
	$(empty)
CPP_EXECUTABLES += byte_cursor_unittest
VPATH += $(SRC)/common
byte_cursor_unittest.o: byte_cursor_unittest.cc
byte_cursor_unittest.o: override CPPFLAGS += $(GTEST_CPPFLAGS) \
					     $(GMOCK_CPPFLAGS)
COVERAGE_SOURCES += byte_cursor_unittest.cc
clean::
	rm -f byte_cursor_unittest



### Generic compilation rules.

# Link C++ executables using the C++ compiler; see CPP_EXECUTABLES above.
$(CPP_EXECUTABLES): %: %.o
	$(CXX) $(CXXFLAGS) $(COVERAGE_LDFLAGS) $(LDFLAGS) -o $@ $^

# Allow #include directives to refer to files below 'src'; generate
# dependency files automatically; and I doubt _REENTRANT is needed at all.
BREAKPAD_CPPFLAGS = -I$(SRC) -MMD -D_REENTRANT -DHAVE_A_OUT_H

# Bring in whatever dependency files we have generated by compiling with -MMD.
-include *.d

%.o: %.cc
	$(CXX) -c $< -o $@ $(CPPFLAGS) $(BREAKPAD_CPPFLAGS) $(CXXFLAGS)
%.o: %.c
	$(CC)  -c $< -o $@ $(CPPFLAGS) $(BREAKPAD_CPPFLAGS) $(CFLAGS)

clean::
	rm -f *.o *.d 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-%: %
	$(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