From 07e253aa3b7a530f22b84053e661842ccd9da2ea Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 23 Feb 2017 16:14:08 +0000 Subject: Introduce gdb::function_view This commit adds a new function_view type. This type holds a non-owning reference to a callable. It is meant to be used as callback type of functions, instead of using the C-style pair of function pointer and 'void *data' arguments. function_view allows passing references to stateful function objects / lambdas with captures as callbacks efficiently, while function pointer + 'void *' does not. See the intro in the new function-view.h header for more. Unit tests included, put into a new gdb/unittests/ subdir. gdb/ChangeLog: 2017-02-23 Pedro Alves * Makefile.in (SUBDIR_UNITTESTS_SRCS, SUBDIR_UNITTESTS_OBS): New. (%.o) : New pattern. * configure.ac ($development): Add $(SUBDIR_UNITTESTS_OBS) to CONFIG_OBS, and $(SUBDIR_UNITTESTS_SRCS) to CONFIG_SRCS. * common/function-view.h: New file. * unittests/function-view-selftests.c: New file. * configure: Regenerate. --- gdb/Makefile.in | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gdb/Makefile.in') diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 43253d3..268c2c6 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -523,6 +523,12 @@ SUBDIR_PYTHON_DEPS = SUBDIR_PYTHON_LDFLAGS = SUBDIR_PYTHON_CFLAGS = +SUBDIR_UNITTESTS_SRCS = \ + unittests/function-view-selftests.c + +SUBDIR_UNITTESTS_OBS = \ + function-view-selftests.o + # Opcodes currently live in one of two places. Either they are in the # opcode library, typically ../opcodes, or they are in a header file # in INCLUDE_DIR. @@ -1909,6 +1915,10 @@ all: gdb$(EXEEXT) $(CONFIG_ALL) $(COMPILE) $< $(POSTCOMPILE) +%.o: ${srcdir}/unittests/%.c + $(COMPILE) $< + $(POSTCOMPILE) + # Specify an explicit rule for gdb/common/agent.c, to avoid a clash with the # object file generate by gdb/agent.c. common-agent.o: $(srcdir)/common/agent.c -- cgit v1.1