[PATCH v1.1 1/3] Introduce gdb::function_view
Yao Qi
qiyaoltc@gmail.com
Wed Feb 22 22:23:00 GMT 2017
On 17-02-22 17:49:22, Pedro Alves wrote:
> diff --git a/gdb/Makefile.in b/gdb/Makefile.in
> index 43253d3..a4cac36 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.
> @@ -1216,7 +1222,8 @@ SFILES = \
> common/xml-utils.c \
> mi/mi-common.c \
> target/waitstatus.c \
> - $(SUBDIR_GCC_COMPILE_SRCS)
> + $(SUBDIR_GCC_COMPILE_SRCS) \
> + $(SUBDIR_UNITTEST_SRCS)
>
> LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
>
> @@ -1800,7 +1807,8 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
> xml-syscall.o \
> xml-tdesc.o \
> xml-utils.o \
> - $(SUBDIR_GCC_COMPILE_OBS)
> + $(SUBDIR_GCC_COMPILE_OBS) \
> + $(SUBDIR_UNITTESTS_OBS)
>
Can we add SUBDIR_UNITESTS_OBS to CONFIG_OBS (in configure.ac) if
GDB_SELF_TEST is defined?
> TSOBS = inflow.o
>
> @@ -1909,6 +1917,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
> @@ -2124,7 +2136,13 @@ test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
> # duplicates. Files in the gdb/ directory can end up appearing in
> # COMMON_OBS (as a .o file) and CONFIG_SRCS (as a .c file).
>
> -INIT_FILES = $(COMMON_OBS) $(TSOBS) $(CONFIG_SRCS) $(SUBDIR_GCC_COMPILE_SRCS)
> +INIT_FILES = \
> + $(COMMON_OBS) \
> + $(TSOBS) \
> + $(CONFIG_SRCS) \
> + $(SUBDIR_GCC_COMPILE_SRCS) \
> + $(SUBDIR_UNITTESTS_SRCS)
> +
If so, SUBDIR_UNITESTS_SRCS is added to CONFIG_SRCS, we don't need this
change.
> diff --git a/gdb/unittests/function-view-selftests.c b/gdb/unittests/function-view-selftests.c
> new file mode 100644
> index 0000000..3e5369b
> --- /dev/null
> +++ b/gdb/unittests/function-view-selftests.c
> @@ -0,0 +1,184 @@
> +/* Self tests for function_view for GDB, the GNU debugger.
> +
> + Copyright (C) 2017 Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +#include "defs.h"
> +#include "selftest.h"
> +#include "common/function-view.h"
> +
> +#if GDB_SELF_TEST
If gdb/unittests/*.c are compiled when GDB_SELF_TEST is defined, we
don't need to check GDB_SELF_TEST here.
> +
> +namespace selftests {
> +namespace function_view {
> +
> +
> +} /* namespace function_view */
> +} /* namespace selftests */
> +
> +#endif
> +
> +void
> +_initialize_function_view_selftests ()
> +{
> +#if GDB_SELF_TEST
This is not needed as well.
> + register_self_test (selftests::function_view::run_tests);
> +#endif
> +}
> --
> 2.5.5
>
>
--
Yao
More information about the Gdb-patches
mailing list