aboutsummaryrefslogtreecommitdiff
path: root/gdb/Makefile.in
AgeCommit message (Collapse)AuthorFilesLines
2020-10-09gnulib: Ensure all libraries are used when building gdb/gdbserverAndrew Burgess1-3/+2
An issue was reported here related to building GDB on MinGW: https://sourceware.org/pipermail/gdb/2020-September/048927.html It was suggested here: https://sourceware.org/pipermail/gdb/2020-September/048931.html that the solution might be to make use of $(LIB_GETRANDOM), a variable defined in the gnulib makefile, when linking GDB. In fact I think the issue is bigger than just LIB_GETRANDOM. When using the script binutils-gdb/gnulib/update-gnulib.sh to reimport gnulib there is a lot of output from gnulib's gnulib-tool. Part of that output is this: You may need to use the following makefile variables when linking. Use them in <program>_LDADD when linking a program, or in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library. $(FREXPL_LIBM) $(FREXP_LIBM) $(INET_NTOP_LIB) $(LIBTHREAD) $(LIB_GETLOGIN) $(LIB_GETRANDOM) $(LIB_HARD_LOCALE) $(LIB_MBRTOWC) $(LIB_SETLOCALE_NULL) $(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise What I think this is telling us is that we should be including the value of all these variables on the link line for gdb and gdbserver. The problem though is that these variables are define in gnulib's makefile, but are not (necessarily) defined in GDB's makefile. One solution would be to recreate the checks that gnulib performs in order to recreate these variables in both gdb's and gdbserver's makefile. Though this shouldn't be too hard, most (if not all) of these checks are in the form macros defined in m4 files in the gnulib tree, so we could just reference these as needed. However, in this commit I propose a different solution. Currently, in the top level makefile, we give gdb and gdbserver a dependency on gnulib. Once gnulib has finished building gdb and gdbserver can start, these projects then have a hard coded (relative) path to the compiled gnulib library in their makefiles. In this commit I extend the gnulib configure script to install a new makefile fragment in the gnulib build directory. This new file will have the usual variable substitutions applied to it, and so can include the complete list (see above) of all the extra libraries that are needed when linking against gnulib. In fact the new makefile fragment defines three variables, these are: LIBGNU: The path to the archive containing gnulib. Can be used as a dependency as when this file changes gdb/gdbserver should be relinked. LIBGNU_EXTRA_LIBS: A list of linker -l.... flags that should be included in the link line of gdb/gdbserver. These are libraries that $(LIBGNU) depends on. This list is taken from the output of gnulib-tool, which is run by our gnulib/update-gnulib.sh script. INCGNU: A list of -I.... include paths that should be passed to the compiler, these are where the gnulib headers can be found. Now both gdb and gdbserver can include the makefile fragment and make use of these variables. The makefile fragment relies on the variable GNULIB_BUILDDIR being defined. This is checked for in the fragment, and was already defined in the makefiles of gdb and gdbserver. gdb/ChangeLog: * Makefile.in: Include Makefile.gnulib.inc. Don't define LIBGNU or INCGNU. Make use of LIBGNU_EXTRA_LIBS when linking. gdbserver/ChangeLog: * Makefile.in: Include Makefile.gnulib.inc. Don't define LIBGNU or INCGNU. Make use of LIBGNU_EXTRA_LIBS when linking. gnulib/ChangeLog: * Makefile.gnulib.inc.in: New file. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Install the new file.
2020-10-07Add simple_search_memory unit testsTom Tromey1-0/+1
This adds some unit tests for simple_search_memory. I tried here to reproduce some bugs (PR gdb/11158 and PR gdb/17756), but was unable to. gdb/ChangeLog 2020-10-07 Tom Tromey <tromey@adacore.com> * unittests/search-memory-selftests.c: New file. * Makefile.in (SELFTESTS_SRCS): Add unittests/search-memory-selftests.c.
2020-10-07gdb: put user-supplied CFLAGS at the endSimon Marchi1-3/+7
GDB currently doesn't build cleanly with clang (a -Wdeprecated-copy-dtor error). I configured my clang-based GDB build with CXXFLAGS="-Wno-error=deprecated-copy-dtor", so I can use it despite that problem. However, I found that it had no effect. This is because my -Wno-error=Wdeprecated-copy-dtor switch is followed by -Werror in the command line, which switches back all warnings to be errors. If we want the user-supplied C(XX)FLAGS to be able to override flags added by our configure script, the user-supplied C(XX)FLAGS should appear after the configure-supplied flags. This patch moves the user-supplied CXXFLAGS at the very end of the compilation command line, which fixes the problem described above. This means moving it out of INTERNAL_CFLAGS and inlining it in the users of INTERNAL_CFLAGS. I observed the problem when building GDB, but the same problem could happen with GDBserver, so the change is done there too. In GDBserver, INTERNAL_CFLAGS is passed when linking gdb/ChangeLog: * Makefile.in (COMPILE): Add CXXFLAGS. (INTERNAL_CFLAGS_BASE): Remove CXXFLAGS. (check-headers): Add CXXFLAGS. gdbserver/ChangeLog: * Makefile.in (COMPILE): Add CXXFLAGS. (INTERNAL_CFLAGS_BASE): Remove CXXFLAGS. (gdbserver$(EXEEXT)): Add CXXFLAGS. (gdbreplay$(EXEEXT)): Add CXXFLAGS. ($(IPA_LIB)): Add CXXFLAGS. (IPAGENT_COMPILE): Add CXXFLAGS. Change-Id: I00e054506695e0e9536095c6d14827e48abd8f69
2020-10-05gdb: sync tui header files in HFILES_NO_SRCDIRSimon Marchi1-1/+1
I noticed that tui/tui-windata.h didn't exist anymore, and that tui/tui-out.h wasn't listed. Fix that. gdb/ChangeLog: * Makefile.in (HFILES_NO_SRCDIR): Remove tui/tui-windata.h, add tui/tui-out.h. Change-Id: Ic75cc68432b90ba5be857a2852ad52dea326fe36
2020-09-14Rewrite enum_flags, add unit tests, fix problemsPedro Alves1-0/+1
This patch started by adding comprehensive unit tests for enum_flags. For the testing part, it adds: - tests of normal expected uses of the API. - checks that _invalid_ uses of the API would fail to compile. I.e., it validates that enum_flags really is a strong type, and that incorrect mixing of enum types would be caught at compile time. It pulls that off making use of SFINEA and C++11's decltype/constexpr. This revealed many holes in the enum_flags API. For example, the f1 assignment below currently incorrectly fails to compile: enum_flags<flags> f1 = FLAG1; enum_flags<flags> f2 = FLAG2 | f1; The unit tests also revealed that this useful use case doesn't work: enum flag { FLAG1 = 1, FLAG2 = 2 }; enum_flags<flag> src = FLAG1; enum_flags<flag> f1 = condition ? src : FLAG2; It fails to compile because enum_flags<flag> and flag are convertible to each other. Turns out that making enum_flags be implicitly convertible to the backing raw enum type was not a good idea. If we make it convertible to the underlying type instead, we fix that ternary operator use case, and, we find cases throughout the codebase that should be using the enum_flags but were using the raw backing enum instead. So it's a good change overall. Also, several operators were missing. These holes and more are plugged by this patch, by reworking how the enum_flags operators are implemented, and making use of C++11's feature of being able to delete methods/functions. There are cases in gdb/compile/ where we need to call a function in a C plugin API that expects the raw enum. To address cases like that, this adds a "raw()" method to enum_flags. This way we can keep using the safer enum_flags to construct the value, and then be explicit when we need to get at the raw enum. This makes most of the enum_flags operators constexpr. Beyond enabling more compiler optimizations and enabling the new unit tests, this has other advantages, like making it possible to use operator| with enum_flags values in switch cases, where only compile-time constants are allowed: enum_flags<flags> f = FLAG1 | FLAG2; switch (f) { case FLAG1 | FLAG2: break; } Currently that fails to compile. It also switches to a different mechanism of enabling the global operators. The current mechanism isn't namespace friendly, the new one is. It also switches to C++11-style SFINAE -- instead of wrapping the return type in a SFINAE-friently structure, we use an unnamed template parameter. I.e., this: template <typename enum_type, typename = is_enum_flags_enum_type_t<enum_type>> enum_type operator& (enum_type e1, enum_type e2) instead of: template <typename enum_type> typename enum_flags_type<enum_type>::type operator& (enum_type e1, enum_type e2) Note that the static_assert inside operator~() was converted to a couple overloads (signed vs unsigned), because static_assert is too late for SFINAE-based tests, which is important for the CHECK_VALID unit tests. Tested with gcc {4.8, 7.1, 9.3} and clang {5.0.2, 10.0.0}. gdb/ChangeLog: * Makefile.in (SELFTESTS_SRCS): Add unittests/enum-flags-selftests.c. * btrace.c (ftrace_update_caller, ftrace_fixup_calle): Use btrace_function_flags instead of enum btrace_function_flag. * compile/compile-c-types.c (convert_qualified): Use enum_flags::raw. * compile/compile-cplus-symbols.c (convert_one_symbol) (convert_symbol_bmsym): * compile/compile-cplus-types.c (compile_cplus_convert_method) (compile_cplus_convert_struct_or_union_methods) (compile_cplus_instance::convert_qualified_base): * go-exp.y (parse_string_or_char): Add cast to int. * unittests/enum-flags-selftests.c: New file. * record-btrace.c (btrace_thread_flag_to_str): Change parameter's type to btrace_thread_flags from btrace_thread_flag. (record_btrace_cancel_resume, record_btrace_step_thread): Change local's type to btrace_thread_flags from btrace_thread_flag. Add cast in DEBUG call. gdbsupport/ChangeLog: * enum-flags.h: Include "traits.h". (DEF_ENUM_FLAGS_TYPE): Declare a function instead of defining a structure. (enum_underlying_type): Update comment. (namespace enum_flags_detail): New. Move struct zero_type here. (EnumIsUnsigned, EnumIsSigned): New. (class enum_flags): Make most methods constexpr. (operator&=, operator|=, operator^=): Take an enum_flags instead of an enum_type. Make rvalue ref versions deleted. (operator enum_type()): Delete. (operator&, operator|, operator^, operator~): Delete, moved out of class. (raw()): New method. (is_enum_flags_enum_type_t): Declare. (ENUM_FLAGS_GEN_BINOP, ENUM_FLAGS_GEN_COMPOUND_ASSIGN) (ENUM_FLAGS_GEN_COMP): New. Use them to reimplement global operators. (operator~): Now constexpr and reimplemented. (operator<<, operator>>): New deleted functions. * valid-expr.h (CHECK_VALID_EXPR_5, CHECK_VALID_EXPR_6): New.
2020-08-25arc: Add GNU/Linux support for ARCAnton Kolesov1-0/+1
ARC Linux targets differences from baremetal: - No support for hardware single instruction stepping. - Different access rules to registers. - Use of another instruction for breakpoints. v2: Changes after Tom's remarks [1] arc-linux-tdep.c - Use true/false instead of TRUE/FALSE. - arc_linux_sw_breakpoint_from_kind (): Break long lines into two. - arc_linux_sw_breakpoint_from_kind (): Remove starting blank line. - Use explicit number evaluation, e.g: if (a & b) -> if ((a & b) != 0) arc-tdep.c - Use explicit number evaluation, e.g: if (a & b) -> if ((a & b) != 0) gdb/configure.tgt - arc*-*-linux*): Remove "build_gdbserver=yes". v3: Changes after Simon's remarks [2] arc-linux-tdep.c - Use "return trap_size" instead of cryptic "return 2". - Removed unnecessary curly braces. - Removed "void" from "_initialize_arc_linux_tdep (void)". v5: Changes after Simon's remarks [3] - Remove unnecessary empty lines. - Replace "breakpoint uses" with "breakpoints use" in a comment. - "return condition;" i.s.o. "if (condition) return true; else return false;" [1] Tom's remarks https://sourceware.org/pipermail/gdb-patches/2020-April/167887.html [2] Simon's remarks on v2 https://sourceware.org/pipermail/gdb-patches/2020-May/168513.html [3] Simon's remarks on v4 https://sourceware.org/pipermail/gdb-patches/2020-August/170994.html gdb/ChangeLog: 2020-08-25 Anton Kolesov <anton.kolesov@synopsys.com> * configure.tgt: ARC support for GNU/Linux. * Makefile.in (ALL_TARGET_OBJS): Likewise. * arc-linux-tdep.c: New file. * arc-tdep.h (ARC_STATUS32_L_MASK, ARC_STATUS32_DE_MASK): Declare. * arc-tdep.c (arc_write_pc): Use it.
2020-08-18gdb/Makefile.in: Add DEBUGINFOD_CFLAGS, DEBUGINFOD_LIBS variables.Aaron Merey1-2/+6
Introduce Makefile variables DEBUGINFOD_CFLAGS and DEBUGINFOD_LIBS that map to the configuration variables of the same names. Replace @DEBUGINFOD_LIBS@ with $(DEBUGINFOD_LIBS) in the definition of CLIBS in order to conform to the usage of other *_LIBS variables in Makefile.in. Add DEBUGINFOD_CFLAGS to INTERNAL_CFLAGS_BASE. This fixes an issue where GDB would fail to find debuginfod.h if it was not installed in a default location searched by the compiler. gdb/ChangeLog: * Makefile.in (DEBUGINFOD_CFLAGS, DEBUGINFOD_LIBS): New variables. (INTERNAL_CFLAGS_BASE): Add DEBUGINFOD_CFLAGS. (CLIBS): Add DEBUGINFOD_LIBS.
2020-08-04gdb: support for eBPFJose E. Marchesi1-0/+2
This patch adds basic support for the eBPF target: tdep and build machinery. The accompanying simulator is introduced in subsequent patches. gdb/ChangeLog: 2020-08-04 Weimin Pan <weimin.pan@oracle.com> Jose E. Marchesi <jose.marchesi@oracle.com> * configure.tgt: Add entry for bpf-*-*. * Makefile.in (ALL_TARGET_OBS): Add bpf-tdep.o (ALLDEPFILES): Add bpf-tdep.c. * bpf-tdep.c: New file. * MAINTAINERS: Add bpf target and maintainer. gdb/doc/ChangeLog: 2020-08-04 Jose E. Marchesi <jose.marchesi@oracle.com> * gdb.texinfo (Contributors): Add information for the eBPF support. (BPF): New section.
2020-07-30Unify Solaris procfs and largefile handlingRainer Orth1-1/+2
GDB currently doesn't build on 32-bit Solaris: * On Solaris 11.4/x86: In file included from /usr/include/sys/procfs.h:26, from /vol/src/gnu/gdb/hg/master/dist/gdb/i386-sol2-nat.c:24: /usr/include/sys/old_procfs.h:31:2: error: #error "Cannot use procfs in the large file compilation environment" #error "Cannot use procfs in the large file compilation environment" ^~~~~ * On Solaris 11.3/x86 there are several more instances of this. The interaction between procfs and large-file support historically has been a royal mess on Solaris: * There are two versions of the procfs interface: ** The old ioctl-based /proc, deprecated and not used any longer in either gdb or binutils. ** The `new' (introduced in Solaris 2.6, 1997) structured /proc. * There are two headers one can possibly include: ** <procfs.h> which only provides the structured /proc, definining _STRUCTURED_PROC=1 and then including ... ** <sys/procfs.h> which defaults to _STRUCTURED_PROC=0, the ioctl-based /proc, but provides structured /proc if _STRUCTURED_PROC == 1. * procfs and the large-file environment didn't go well together: ** Until Solaris 11.3, <sys/procfs.h> would always #error in 32-bit compilations when the large-file environment was active (_FILE_OFFSET_BITS == 64). ** In both Solaris 11.4 and Illumos, this restriction was lifted for structured /proc. So one has to be careful always to define _STRUCTURED_PROC=1 when testing for or using <sys/procfs.h> on Solaris. As the errors above show, this isn't always the case in binutils-gdb right now. Also one may need to disable large-file support for 32-bit compilations on Solaris. config/largefile.m4 meant to do this by wrapping the AC_SYS_LARGEFILE autoconf macro with appropriate checks, yielding ACX_LARGEFILE. Unfortunately the macro doesn't always succeed because it neglects the _STRUCTURED_PROC part. To make things even worse, since GCC 9 g++ predefines _FILE_OFFSET_BITS=64 on Solaris. So even if largefile.m4 deciced not to enable large-file support, this has no effect, breaking the gdb build. This patch addresses all this as follows: * All tests for the <sys/procfs.h> header are made with _STRUCTURED_PROC=1, the definition going into the various config.h files instead of having to make them (and sometimes failing) in the affected sources. * To cope with the g++ predefine of _FILE_OFFSET_BITS=64, -U_FILE_OFFSET_BITS is added to various *_CPPFLAGS variables. It had been far easier to have just #undef _FILE_OFFSET_BITS in config.h, but unfortunately such a construct in config.in is commented by config.status irrespective of indentation and whitespace if large-file support is disabled. I found no way around this and putting the #undef in several global headers for bfd, binutils, ld, and gdb seemed way more invasive. * Last, the applicability check in largefile.m4 was modified only to disable largefile support if really needed. To do so, it checks if <sys/procfs.h> compiles with _FILE_OFFSET_BITS=64 defined. If it doesn't, the disabling only happens if gdb exists in-tree and isn't disabled, otherwise (building binutils from a tarball), there's no conflict. What initially confused me was the check for $plugins here, which originally caused the disabling not to take place. Since AC_PLUGINGS does enable plugin support if <dlfcn.h> exists (which it does on Solaris), the disabling never happened. I could find no explanation why the linker plugin needs large-file support but thought it would be enough if gld and GCC's lto-plugin agreed on the _FILE_OFFSET_BITS value. Unfortunately, that's not enough: lto-plugin uses the simple-object interface from libiberty, which includes off_t arguments. So to fully disable large-file support would mean also disabling it in libiberty and its users: gcc and libstdc++-v3. This seems highly undesirable, so I decided to disable the linker plugin instead if large-file support won't work. The patch allows binutils+gdb to build on i386-pc-solaris2.11 (both Solaris 11.3 and 11.4, using GCC 9.3.0 which is the worst case due to predefined _FILE_OFFSET_BITS=64). Also regtested on amd64-pc-solaris2.11 (again on Solaris 11.3 and 11.4), x86_64-pc-linux-gnu and i686-pc-linux-gnu. config: * largefile.m4 (ACX_LARGEFILE) <sparc-*-solaris*|i?86-*-solaris*>: Check for <sys/procfs.h> incompatilibity with large-file support on Solaris. Only disable large-file support and perhaps plugins if needed. Set, substitute LARGEFILE_CPPFLAGS if so. bfd: * bfd.m4 (BFD_SYS_PROCFS_H): New macro. (BFD_HAVE_SYS_PROCFS_TYPE): Require BFD_SYS_PROCFS_H. Don't define _STRUCTURED_PROC. (BFD_HAVE_SYS_PROCFS_TYPE_MEMBER): Likewise. * elf.c [HAVE_SYS_PROCFS_H] (_STRUCTURED_PROC): Don't define. * configure.ac: Use BFD_SYS_PROCFS_H to check for <sys/procfs.h>. * configure, config.in: Regenerate. * Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS. * Makefile.in, doc/Makefile.in: Regenerate. binutils: * Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS. * Makefile.in, doc/Makefile.in: Regenerate. * configure: Regenerate. gas: * Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS. * Makefile.in, doc/Makefile.in: Regenerate. * configure: Regenerate. gdb: * proc-api.c (_STRUCTURED_PROC): Don't define. * proc-events.c: Likewise. * proc-flags.c: Likewise. * proc-why.c: Likewise. * procfs.c: Likewise. * Makefile.in (INTERNAL_CPPFLAGS): Add LARGEFILE_CPPFLAGS. * configure, config.in: Regenerate. gdbserver: * configure, config.in: Regenerate. gdbsupport: * Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS. * common.m4 (GDB_AC_COMMON): Use BFD_SYS_PROCFS_H to check for <sys/procfs.h>. * Makefile.in: Regenerate. * configure, config.in: Regenerate. gnulib: * configure.ac: Run ACX_LARGEFILE before gl_EARLY. * configure: Regenerate. gprof: * Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS. * Makefile.in: Regenerate. * configure: Regenerate. ld: * Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS. * Makefile.in: Regenerate. * configure: Regenerate.
2020-07-24config/debuginfod.m4: Use PKG_CHECK_MODULESAaron Merey1-1/+1
Use PKG_CHECK_MODULES to set debuginfod autoconf vars. Also add pkg.m4 to config/. ChangeLog: * config/debuginfod.m4: use PKG_CHECK_MODULES. * config/pkg.m4: New file. * configure: Rebuild. * configure.ac: Remove AC_DEBUGINFOD. ChangeLog/binutils: * Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS. * Makefile.in: Rebuild. * configure: Rebuild. * doc/Makefile.in: Rebuild. ChangeLog/gdb: * Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS. * configure: Rebuild.
2020-07-06gdb/python: Add gdb.Architecture.registers methodAndrew Burgess1-0/+1
This commit adds a new method gdb.Architecture.registers that returns an object of the new type gdb.RegisterDescriptorIterator. This iterator returns objects of the new type gdb.RegisterDescriptor. A RegisterDescriptor is not a way to read the value of a register, this is already covered by Frame.read_register, a RegisterDescriptor is simply a way to discover from Python, which registers are available for a given architecture. I did consider just returning a string, the name of each register, instead of a RegisterDescriptor, however, I'm aware that it we don't want to break the existing Python API in any way, so if I return just a string now, but in the future we want more information about a register then we would have to add a second API to get that information. By going straight to a descriptor object now, it is easy to add additional properties in the future should we wish to. Right now the only property of a register that a user can access is the name of the register. In future we might want to be able to ask the register about is register groups, or its type. gdb/ChangeLog: * Makefile.in (SUBDIR_PYTHON_SRCS): Add py-registers.c * python/py-arch.c (archpy_registers): New function. (arch_object_methods): Add 'registers' method. * python/py-registers.c: New file. * python/python-internal.h (gdbpy_new_register_descriptor_iterator): Declare. (gdbpy_initialize_registers): Declare. * python/python.c (do_start_initialization): Call gdbpy_initialize_registers. * NEWS: Mention additions to the Python API. gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-names.exp: New file. gdb/doc/ChangeLog: * python.texi (Python API): Add new section the menu. (Frames In Python): Add new @anchor. (Architectures In Python): Document new registers method. (Registers In Python): New section.
2020-06-26Fix --enable-libctf and --disable-staticNick Alcock1-3/+5
This fixes test runs and compilation when --disable-libctf, --disable-static, or --enable-shared are passed. Changes since v2: Use GCC_ENABLE and fix indentation. Fix prototype using 'void'. Use 'unsupported' and gdb_caching_proc. Changes since v3: Adapt to upstream changes providing skip_ctf_tests. Changes since v4: Adapt to upstream changes in the seven months (!) since I last looked at this. gdb/ChangeLog * configure.ac: Add --enable-libctf: handle --disable-static properly. * acinclude.m4: sinclude ../config/enable.m4. * Makefile.in (aclocal_m4_deps): Adjust accordingly. (LIBCTF): Substitute in. (CTF_DEPS): New, likewise. (CLIBS): libctf needs symbols from libbfd: move earlier. (CDEPS): Use CTF_DEPS, not LIBCTF, now LIBCTF can include rpath flags. * ctfread.c: Surround in ENABLE_LIBCTF. (elfctf_build_psymtabs) [!ENABLE_LIBCTF]: New stub. * configure: Regenerate. * config.in: Likewise. gdb/testsuite/ChangeLog * configure.ac: Add --enable-libctf. * aclocal.m4: sinclude ../config/enable.m4. * Makefile.in (site.exp): Add enable_libctf to site.exp. * lib/gdb.exp (skip_ctf_tests): Use it. * gdb.base/ctf-constvars.exp: Error message tweak. * gdb.base/ctf-ptype.exp: Likewise. * configure: Regenerate.
2020-05-15Add a selftest that detects a 'corrupted' command tree structure in GDB.Philippe Waroquiers1-1/+1
The GDB data structure that records the GDB commands is made of 'struct cmd_list_element' defined in cli-decode.h. A cmd_list_element has various pointers to other cmd_list_element structures, All these pointers are together building a graph of commands. However, when following the 'next' and '*prefixlist' pointers of cmd_list_element, the structure must better be a tree. If such pointers do not form a tree, then some other elements of cmd_list_element cannot get a correct semantic. In particular, the prefixname has no correct meaning if the same prefix command can be reached via 2 different paths. This commit introduces a selftest that detects (at least some cases of) errors leading to 'next' and '*prefixlist' not giving a tree structure. The new 'command_structure_invariants' selftest detects one single case where the command structure is not a tree: (gdb) maintenance selftest command_structure_invariants Running selftest command_structure_invariants. list 0x56362e204b98 duplicated, reachable via prefix 'show ' and 'info set '. Duplicated list first command is 'ada' Self test failed: self-test failed at ../../classfix/gdb/unittests/command-def-selftests.c:160 Ran 1 unit tests, 1 failed (gdb) This was fixed by the previous commit. 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * unittests/help-doc-selftests.c: Rename to unittests/command-def-selftests.c * unittests/command-def-selftests.c (help_doc_tests): Update some comments. (command_structure_tests, traverse_command_structure): New namespace and function. (command_structure_invariants_tests): New function. (_initialize_command_def_selftests) Renamed from _initialize_help_doc_selftests, register command_structure_invariants selftest.
2020-04-13Move event-loop.[ch] to gdbsupport/Tom Tromey1-2/+0
This moves event-loop.[ch] to gdbsupport/ and updates the uses in gdb. gdb/ChangeLog 2020-04-13 Tom Tromey <tom@tromey.com> * run-on-main-thread.c: Update include. * unittests/main-thread-selftests.c: Update include. * tui/tui-win.c: Update include. * tui/tui-io.c: Update include. * tui/tui-interp.c: Update include. * tui/tui-hooks.c: Update include. * top.h: Update include. * top.c: Update include. * ser-base.c: Update include. * remote.c: Update include. * remote-notif.c: Update include. * remote-fileio.c: Update include. * record-full.c: Update include. * record-btrace.c: Update include. * python/python.c: Update include. * posix-hdep.c: Update include. * mingw-hdep.c: Update include. * mi/mi-main.c: Update include. * mi/mi-interp.c: Update include. * main.c: Update include. * linux-nat.c: Update include. * interps.c: Update include. * infrun.c: Update include. * inf-loop.c: Update include. * event-top.c: Update include. * event-loop.c: Move to ../gdbsupport/. * event-loop.h: Move to ../gdbsupport/. * async-event.h: Update include. * Makefile.in (COMMON_SFILES, HFILES_NO_SRCDIR): Update. gdbsupport/ChangeLog 2020-04-13 Tom Tromey <tom@tromey.com> * event-loop.h: Move from ../gdb/. * event-loop.cc: Move from ../gdb/.
2020-04-13Introduce async-event.[ch]Tom Tromey1-0/+2
This patch splits out some gdb-specific code from event-loop, into new files async-event.[ch]. Strictly speaking this code could perhaps be put into gdbsupport/, but because gdbserver does not currently use it, it seemed better, for size reasons, to split it out. gdb/ChangeLog 2020-04-13 Tom Tromey <tom@tromey.com> * tui/tui-win.c: Include async-event.h. * remote.c: Include async-event.h. * remote-notif.c: Include async-event.h. * record-full.c: Include async-event.h. * record-btrace.c: Include async-event.h. * infrun.c: Include async-event.h. * event-top.c: Include async-event.h. * event-loop.h: Move some declarations to async-event.h. * event-loop.c: Don't include ser-event.h or top.h. Move some code to async-event.c. * async-event.h: New file. * async-event.c: New file. * Makefile.in (COMMON_SFILES): Add async-event.c. (HFILES_NO_SRCDIR): Add async-event.h.
2020-03-26Move DWARF-constant stringifying code to new fileTom Tromey1-0/+1
This moves the DWARF debugging functions that stringify various constants to a new file, dwarf2/stringify.c. gdb/ChangeLog 2020-03-26 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf_unit_type_name, dwarf_tag_name) (dwarf_attr_name, dwarf_form_name, dwarf_bool_name) (dwarf_type_encoding_name): Move to stringify.c. * Makefile.in (COMMON_SFILES): Add dwarf2/stringify.c. * dwarf2/stringify.c: New file. * dwarf2/stringify.h: New file.
2020-03-26Move code to new file dwarf2/macro.cTom Tromey1-0/+1
This moves some more code out of dwarf2/read.c, introducing new files dwarf2/macro.c and dwarf2/macro.h. gdb/ChangeLog 2020-03-26 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_macro_malformed_definition_complaint) (macro_start_file, consume_improper_spaces) (parse_macro_definition, skip_form_bytes, skip_unknown_opcode) (dwarf_parse_macro_header, dwarf_decode_macro_bytes) (dwarf_decode_macros): Move to macro.c. * dwarf2/macro.c: New file. * dwarf2/macro.h: New file. * Makefile.in (COMMON_SFILES): Add dwarf2/macro.c.
2020-03-26Add dwz.c and dwz_file::read_stringTom Tromey1-0/+1
This changes read_indirect_string_from_dwz to be a method on the dwz_file, and adds a new dwarf2/dwz.c file. gdb/ChangeLog 2020-03-26 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_attribute_value): Update. (read_indirect_string_from_dwz): Move to dwz.c; change into method. (dwarf_decode_macro_bytes): Update. * dwarf2/dwz.h (struct dwz_file) <read_string>: Declare method. * dwarf2/dwz.c: New file. * Makefile.in (COMMON_SFILES): Add dwz.c.
2020-03-16arc: Migrate to new target featuresAnton Kolesov1-0/+2
This patch replaces usage of target descriptions in ARC, where the whole description is fixed in XML, with new target descriptions where XML describes individual features, and GDB assembles those features into actual target description. v2: Removed arc.c from ALLDEPFILES in gdb/Makefile.in. Removed vim modeline from arc-tdep.c to have it in a separate patch. Removed braces from one line "if/else". Undid the type change for "jb_pc" (kept it as "int"). Joined the unnecessary line breaks into one line. No more moving around arm targets in gdb/features/Makefile. Changed pattern checking for ARC features from "arc/{aux,core}" to "arc/". v3: Added include gaurds to arc.h. Added arc_read_description to _create_ target descriptions less. v4: Got rid of ARC_SYS_TYPE_NONE. Renamed ARC_SYS_TYPE_INVALID to ARC_SYS_TYPE_NUM. Fixed a few indentations/curly braces. Converted arc_sys_type_to_str from a macro to an inline function. gdb/ChangeLog: 2020-03-16 Anton Kolesov <anton.kolesov@synopsys.com> Shahab Vahedi <shahab@synopsys.com> * Makefile.in: Add arch/arc.o * configure.tgt: Likewise. * arc-tdep.c (arc_tdesc_init): Use arc_read_description. (_initialize_arc_tdep): Don't initialize old target descriptions. (arc_read_description): New function to cache target descriptions. * arc-tdep.h (arc_read_description): Add proto type. * arch/arc.c: New file. * arch/arc.h: Likewise. * features/Makefile: Replace old target descriptions with new. * features/arc-arcompact.c: Remove. * features/arc-arcompact.xml: Likewise. * features/arc-v2.c: Likewise * features/arc-v2.xml: Likewise * features/arc/aux-arcompact.xml: New file. * features/arc/aux-v2.xml: Likewise. * features/arc/core-arcompact.xml: Likewise. * features/arc/core-v2.xml: Likewise. * features/arc/aux-arcompact.c: Generate. * features/arc/aux-v2.c: Likewise. * features/arc/core-arcompact.c: Likewise. * features/arc/core-v2.c: Likewise. * target-descriptions (maint_print_c_tdesc_cmd): Support ARC features.
2020-03-16gdb: rename i386-cygwin-tdep.c to i386-windows-tdep.cSimon Marchi1-2/+2
Since this file contains things that apply not only to Cygwin binaries, but also to non-Cygwin Windows binaries, I think it would make more sense for it to be called i386-windows-tdep.c. It is analogous to amd64-windows-tdep.c, which we already have. gdb/ChangeLog: * i386-cygwin-tdep.c: Rename to... * i386-windows-tdep.c: ... this. * Makefile.in (ALL_TARGET_OBS): Rename i386-cygwin-tdep.c to i386-windows-tdep.c. * configure.tgt: Likewise.
2020-03-12Don't include selftests objects in build when unit tests are disabledSimon Marchi1-4/+5
While working on the preceding selftests patches, I noticed that some selftests-specific files are included in the build even when selftests are disabled, namely disasm-selftest.c and gdbarch-selftests.c. These files are entirely #if'ed out when building with selftests disabled. This is not a huge problem, but I think it would make more sense if these files were simply not built. With this patch, I propose to put all the selftests-specific source files into a SELFTESTS_SRCS Makefile variable (even selftest-arch.c, which is currently added by the configure script). gdb/ChangeLog: * Makefile.in (SUBDIR_UNITTESTS_SRCS): Rename to... (SELFTESTS_SRCS): ... this. Add disasm-selftests.c, gdbarch-selfselftests.c and selftest-arch.c. (SUBDIR_UNITTESTS_OBS): Rename to... (SELFTESTS_OBS): ... this. (COMMON_SFILES): Remove disasm-selftests.c and gdbarch-selftests.c. * configure.ac: Don't add selftest-arch.{c,o} to CONFIG_{SRCS,OBS}. * disasm-selftests.c, gdbarch-selftests.c: Remove GDB_SELF_TEST preprocessor conditions.
2020-03-12Remove use of deprecated core functions (in NetBSD/ARM)Christian Biesinger1-0/+1
This is in preparation for deleting deprecated_add_core_fns and related code. As a side-effect, this makes it possible to read NetBSD/ARM core files on non-NetBSD/ARM platforms, subject to PR corefiles/25638. I have removed this comment: - /* This is ok: we're running native... */ Since we are using the gdbarch from the regcache, we should be guaranteed to be calling the right function here, so it shouldn't matter whether we are running native. Tested by reading a NetBSD/ARM core file on Linux/x86-64 and NetBSD/ARM; the "info registers" output matches the one from the system GDB. gdb/ChangeLog: 2020-03-12 Christian Biesinger <cbiesinger@google.com> * Makefile.in (HFILES_NO_SRCDIR): Add new arm-nbsd-tdep.h file. * arm-nbsd-nat.c (arm_supply_gregset): Moved to arm-nbsd-tdep and renamed to arm_nbsd_supply_gregset. (fetch_register): Update to call arm_nbsd_supply_gregset. (fetch_regs): Remove in favor of fetch_register with a -1 regno. (arm_netbsd_nat_target::fetch_registers): Update. (fetch_elfcore_registers): Removed. (_initialize_arm_netbsd_nat): Removed call to deprecated_add_core_fns. * arm-nbsd-tdep.c (struct arm_nbsd_reg): New struct. (arm_nbsd_supply_gregset): Moved from arm-nbsd-nat.c and updated to not require NetBSD system headers. (arm_nbsd_regset): New struct. (arm_nbsd_iterate_over_regset_sections): New function. (arm_netbsd_init_abi_common): Updated to call set_gdbarch_iterate_over_regset_sections. * arm-nbsd-tdep.h: New file.
2020-02-26Add debuginfod support to GDBAaron Merey1-1/+3
debuginfod is a lightweight web service that indexes ELF/DWARF debugging resources by build-id and serves them over HTTP. This patch enables GDB to query debuginfod servers for separate debug files and source code when it is otherwise not able to find them. GDB can be built with debuginfod using the --with-debuginfod configure option. This requires that libdebuginfod be installed and found at configure time. debuginfod is packaged with elfutils, starting with version 0.178. For more information see https://sourceware.org/elfutils/. Tested on x86_64 Fedora 31. gdb/ChangeLog: 2020-02-26 Aaron Merey <amerey@redhat.com> * Makefile.in: Handle optional debuginfod support. * NEWS: Update. * README: Add --with-debuginfod summary. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Handle optional debuginfod support. * debuginfod-support.c: debuginfod helper functions. * debuginfod-support.h: Ditto. * doc/gdb.texinfo: Add --with-debuginfod to configure options summary. * dwarf2/read.c (dwarf2_get_dwz_file): Query debuginfod servers when a dwz file cannot be found. * elfread.c (elf_symfile_read): Query debuginfod servers when a debuginfo file cannot be found. * source.c (open_source_file): Query debuginfod servers when a source file cannot be found. * top.c (print_gdb_configuration): Include --{with,without}-debuginfod in the output. gdb/testsuite/ChangeLog: 2020-02-26 Aaron Merey <amerey@redhat.com> * gdb.debuginfod: New directory for debuginfod tests. * gdb.debuginfod/main.c: New test file. * gdb.debuginfod/fetch_src_and_symbols.exp: New tests.
2020-02-22Allow TUI windows in PythonTom Tromey1-0/+1
This patch adds support for writing new TUI windows in Python. 2020-02-22 Tom Tromey <tom@tromey.com> * NEWS: Add entry for gdb.register_window_type. * tui/tui-layout.h (window_factory): New typedef. (tui_register_window): Declare. * tui/tui-layout.c (saved_tui_windows): New global. (tui_apply_current_layout): Use it. (tui_register_window): New function. * python/python.c (do_start_initialization): Call gdbpy_initialize_tui. (python_GdbMethods): Add "register_window_type" function. * python/python-internal.h (gdbpy_register_tui_window) (gdbpy_initialize_tui): Declare. * python/py-tui.c: New file. * Makefile.in (SUBDIR_PYTHON_SRCS): Add py-tui.c. gdb/doc/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * python.texi (Python API): Add menu item. (TUI Windows In Python): New node. gdb/testsuite/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * gdb.python/tui-window.exp: New file. * gdb.python/tui-window.py: New file. Change-Id: I85fbfb923a1840450a00a7dce113a05d7f048baa
2020-02-08Create dwarf2/comp-unit.[ch]Tom Tromey1-0/+1
This creates the new files dwarf2/comp-unit.[ch], moving comp_unit_head and helpers to those files. A couple of functions are turned into methods, because it was convenient to do so now. 2020-02-08 Tom Tromey <tom@tromey.com> * Makefile.in (COMMON_SFILES): Add dwarf2/comp-unit.c. * dwarf2/read.c (struct comp_unit_head): Move to dwarf2/comp-unit.h. (enum class rcuh_kind): Move to comp-unit.h. (get_cu_length, offset_in_cu_p): Now methods on comp_unit_head. (read_comp_unit_head, error_check_comp_unit_head) (read_and_check_comp_unit_head): Move to comp-unit.c. (read_offset, dwarf_unit_type_name): Likewise. (create_debug_type_hash_table, read_cutu_die_from_dwo) (cutu_reader::cutu_reader, read_call_site_scope) (find_partial_die, follow_die_offset): Update. * dwarf2/comp-unit.h: New file, from dwarf2read.c. Change-Id: Id961b9674c0081ed061083c8152c38b27b27388a
2020-02-08Move DWARF line_header to new fileTom Tromey1-0/+1
This moves the line_header class to a pair of new files, making dwarf2/read.c somewhat smaller. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.h (dwarf_line_debug): Declare. * Makefile.in (COMMON_SFILES): Add dwarf2/line-header.c. * dwarf2/read.c: Move line_header code to new files. (dwarf_line_debug): No longer static. * dwarf2/line-header.c: New file. * dwarf2/line-header.h: New file. Change-Id: I8d9d8a2398b4e888e20cc5dd68d041c28b5a06e3
2020-02-08Move DWARF code to dwarf2/ subdirectoryTom Tromey1-15/+15
This moves all the remaining DWARF code to the new dwarf2 subdirectory. This is just a simple renaming, with updates to includes as needed. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/expr.c: Rename from dwarf2expr.c. * dwarf2/expr.h: Rename from dwarf2expr.h. * dwarf2/frame-tailcall.c: Rename from dwarf2-frame-tailcall.c. * dwarf2/frame-tailcall.h: Rename from dwarf2-frame-tailcall.h. * dwarf2/frame.c: Rename from dwarf2-frame.c. * dwarf2/frame.h: Rename from dwarf2-frame.h. * dwarf2/index-cache.c: Rename from dwarf-index-cache.c. * dwarf2/index-cache.h: Rename from dwarf-index-cache.h. * dwarf2/index-common.c: Rename from dwarf-index-common.c. * dwarf2/index-common.h: Rename from dwarf-index-common.h. * dwarf2/index-write.c: Rename from dwarf-index-write.c. * dwarf2/index-write.h: Rename from dwarf-index-write.h. * dwarf2/loc.c: Rename from dwarf2loc.c. * dwarf2/loc.h: Rename from dwarf2loc.h. * dwarf2/read.c: Rename from dwarf2read.c. * dwarf2/read.h: Rename from dwarf2read.h. * dwarf2/abbrev.c, aarch64-tdep.c, alpha-tdep.c, amd64-darwin-tdep.c, arc-tdep.c, arm-tdep.c, bfin-tdep.c, compile/compile-c-symbols.c, compile/compile-cplus-symbols.c, compile/compile-loc2c.c, cris-tdep.c, csky-tdep.c, findvar.c, gdbtypes.c, guile/scm-type.c, h8300-tdep.c, hppa-bsd-tdep.c, hppa-linux-tdep.c, i386-darwin-tdep.c, i386-linux-tdep.c, i386-tdep.c, iq2000-tdep.c, m32c-tdep.c, m68hc11-tdep.c, m68k-tdep.c, microblaze-tdep.c, mips-tdep.c, mn10300-tdep.c, msp430-tdep.c, nds32-tdep.c, nios2-tdep.c, or1k-tdep.c, riscv-tdep.c, rl78-tdep.c, rs6000-tdep.c, rx-tdep.c, s12z-tdep.c, s390-tdep.c, score-tdep.c, sh-tdep.c, sparc-linux-tdep.c, sparc-tdep.c, sparc64-linux-tdep.c, sparc64-tdep.c, tic6x-tdep.c, tilegx-tdep.c, v850-tdep.c, xstormy16-tdep.c, xtensa-tdep.c: Update. * Makefile.in (COMMON_SFILES): Update. (HFILES_NO_SRCDIR): Update. Change-Id: Ied9ce1436cd27ac4a4cffef10ec92e396f181928
2020-02-08Create dwarf2/attribute.[ch]Tom Tromey1-0/+1
This moves the attribute-related code out of dwarf2read.c and into the new files dwarf2/attribute.[ch]. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2read.c (struct attribute, DW_STRING) (DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR) (DW_SIGNATURE, struct dwarf_block, attr_value_as_address) (attr_form_is_block, attr_form_is_section_offset) (attr_form_is_constant, attr_form_is_ref): Move. * dwarf2/attribute.h: New file. * dwarf2/attribute.c: New file, from dwarf2read.c. * Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c. Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08Create dwarf2/abbrev.[ch]Tom Tromey1-0/+1
This moves the abbrev table code out of dwarf2read.c and into new files dwarf2/abbrev.[ch]. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2read.c (abbrev_table_up, struct abbrev_info) (struct attr_abbrev, ABBREV_HASH_SIZE, struct abbrev_table): Move. (read_cutu_die_from_dwo, build_type_psymtabs_1): Update. (abbrev_table::alloc_abbrev, abbrev_table::add_abbrev) (abbrev_table::lookup_abbrev, abbrev_table_read_table): Move to abbrev.c. * dwarf2/abbrev.h: New file. * dwarf2/abbrev.c: New file, from dwarf2read.c. * Makefile.in (COMMON_SFILES): Add dwarf2/abbrev.c. Change-Id: I87911bc5297de4407587ca849fef8e8d19136c30
2020-02-08Create dwarf2/section.[ch]Tom Tromey1-0/+1
This moves some section-handling code from dwarf2read.c into new files, dwarf2/section.[ch]. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2read.h (struct dwarf2_section_info, dwarf2_read_section): Move to dwarf2/section.h. * dwarf2read.c (get_containing_section, get_section_bfd_owner) (get_section_bfd_section, get_section_name) (get_section_file_name, get_section_id, get_section_flags) (dwarf2_section_empty_p, dwarf2_read_section): Moe to dwarf2/section.c. * dwarf2/section.h: New file. * dwarf2/section.c: New file, from dwarf2read.c. * Makefile.in (COMMON_SFILES): Add dwarf2/section.c. Change-Id: I9f8498094cf99d9521e9481622ce8adbd453daf4
2020-02-08Create dwarf2/leb.[ch]Tom Tromey1-1/+2
This moves some scalar-unpacking code into a couple of new files, dwarf2/leb.h and dwarf2/leb.c. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2read.h (read_unsigned_leb128): Don't declare. * dwarf2read.c (read_1_byte, read_1_signed_byte, read_2_bytes) (read_2_signed_bytes, read_3_bytes, read_4_bytes) (read_4_signed_bytes, read_8_bytes): Move to dwarf2/leb.h. (read_unsigned_leb128, read_signed_leb128): Move to dwarf2/leb.c. * dwarf2/leb.h: New file, from dwarf2read.c. * dwarf2/leb.c: New file, from dwarf2read.c. * dwarf2-frame.c (read_1_byte, read_4_bytes, read_8_bytes): Remove. * Makefile.in (CONFIG_SRC_SUBDIR): Add dwarf2. (COMMON_SFILES): Add dwarf2/leb.c. Change-Id: Idd19647686c8f959d226a95fdfca4db47c6e96d0
2020-02-07Move gdbserver to top levelTom Tromey1-5/+0
This patch moves gdbserver to the top level. This patch is as close to a pure move as possible -- gdbserver still builds its own variant of gnulib and gdbsupport. Changing this will be done in a separate patch. [v2] Note that, per Simon's review comment, this patch changes the tree so that gdbserver is not built for or1k or score. This makes sense, because there is apparently not actually a gdbserver port here. [v3] This version of the patch also splits out some configury into a new file, gdbserver/configure.host, so that the top-level configure script can simply rely on it in order to decide whether gdbserver should be built. [v4] This version adds documentation and removes some unnecessary top-level dependencies. [v5] Update docs to mention "make all-gdbserver" and change how top-level configure decides whether to build gdbserver, switching to a single, shared script. Tested by the buildbot. ChangeLog 2020-02-07 Tom Tromey <tom@tromey.com> Pedro Alves <palves@redhat.com> * src-release.sh (GDB_SUPPORT_DIRS): Add gdbserver. * gdbserver: New directory, moved from gdb/gdbserver. * configure.ac (host_tools): Add gdbserver. Only build gdbserver on certain systems. * Makefile.in, configure: Rebuild. * Makefile.def (host_modules, dependencies): Add gdbserver. * MAINTAINERS: Add gdbserver. gdb/ChangeLog 2020-02-07 Tom Tromey <tom@tromey.com> * README: Update gdbserver documentation. * gdbserver: Move to top level. * configure.tgt (build_gdbserver): Remove. * configure.ac: Remove --enable-gdbserver. * configure: Rebuild. * Makefile.in (distclean): Don't mention gdbserver. Change-Id: I826b7565b54604711dc7a11edea0499cd51ff39e
2020-01-14Don't link gdb twice against libibertyTom Tromey1-1/+1
I noticed that gdb includes libiberty twice in its link line. I don't think there's a need for this, so this patch removes one of the references. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * Makefile.in (CLIBS): Remove second use of $(LIBIBERTY). Change-Id: I43bb7100660867081f937c67ea70ff751c62bbfb
2020-01-14Move gdbsupport to the top levelTom Tromey1-85/+14
This patch moves the gdbsupport directory to the top level. This is the next step in the ongoing project to move gdbserver to the top level. The bulk of this patch was created by "git mv gdb/gdbsupport gdbsupport". This patch then adds a build system to gdbsupport and wires it into the top level. Then it changes gdb to use the top-level build. gdbserver, on the other hand, is not yet changed. It still does its own build of gdbsupport. ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * src-release.sh (GDB_SUPPORT_DIRS): Add gdbsupport. * MAINTAINERS: Add gdbsupport. * configure: Rebuild. * configure.ac (configdirs): Add gdbsupport. * gdbsupport: New directory, move from gdb/gdbsupport. * Makefile.def (host_modules, dependencies): Add gnulib. * Makefile.in: Rebuild. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * nat/x86-linux-dregs.c: Include configh.h. * nat/linux-ptrace.c: Include configh.h. * nat/linux-btrace.c: Include configh.h. * defs.h: Include config.h, bfd.h. * configure.ac: Don't source common.host. (CONFIG_OBS, CONFIG_SRCS): Remove gdbsupport files. * configure: Rebuild. * acinclude.m4: Update path. * Makefile.in (SUPPORT, LIBSUPPORT, INCSUPPORT): New variables. (CONFIG_SRC_SUBDIR): Remove gdbsupport. (INTERNAL_CFLAGS_BASE): Add INCSUPPORT. (CLIBS): Add LIBSUPPORT. (CDEPS): Likewise. (COMMON_SFILES): Remove gdbsupport files. (HFILES_NO_SRCDIR): Likewise. (stamp-version): Update path to create-version.sh. (ALLDEPFILES): Remove gdbsupport files. gdb/gdbserver/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * server.h: Include config.h. * gdbreplay.c: Include config.h. * configure: Rebuild. * configure.ac: Don't source common.host. * acinclude.m4: Update path. * Makefile.in (INCSUPPORT): New variable. (INCLUDE_CFLAGS): Add INCSUPPORT. (SFILES): Update paths. (version-generated.c): Update path to create-version.sh. (gdbsupport/%-ipa.o, gdbsupport/%.o): Update paths. gdbsupport/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * common-defs.h: Add GDBSERVER case. Update includes. * acinclude.m4, aclocal.m4, config.in, configure, configure.ac, Makefile.am, Makefile.in, README: New files. * Moved from ../gdb/gdbsupport/ Change-Id: I07632e7798635c1bab389bf885971e584fb4bb78
2020-01-10Add "info connections" command, "info inferiors" connection number/stringPedro Alves1-0/+1
This commit extends the CLI a bit for multi-target, in three ways. #1 - New "info connections" command. This is a new command that lists the open connections (process_stratum targets). For example, if you're debugging two remote connections, a couple local/native processes, and a core dump, all at the same time, you might see something like this: (gdb) info connections Num What Description 1 remote 192.168.0.1:9999 Remote serial target in gdb-specific protocol 2 remote 192.168.0.2:9998 Remote serial target in gdb-specific protocol * 3 native Native process 4 core Local core dump file #2 - New "info inferiors" "Connection" column You'll also see a new matching "Connection" column in "info inferiors", showing you which connection an inferior is bound to: (gdb) info inferiors Num Description Connection Executable 1 process 18526 1 (remote 192.168.0.1:9999) target:/tmp/a.out 2 process 18531 2 (remote 192.168.0.2:9998) target:/tmp/a.out 3 process 19115 3 (native) /tmp/prog1 4 process 6286 4 (core) myprogram * 5 process 19122 3 (native) /bin/hello #3 - Makes "add-inferior" show the inferior's target connection "add-inferior" now shows you the connection you've just bound the inferior to, which is the current process_stratum target: (gdb) add-inferior [New inferior 2] Added inferior 2 on connection 1 (extended-remote localhost:2346) gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_SFILES): Add target-connection.c. * inferior.c (uiout_field_connection): New function. (print_inferior): Add new "connection-id" column. (add_inferior_command): Show connection number/string of added inferior. * process-stratum-target.h (process_stratum_target::connection_string): New virtual method. (process_stratum_target::connection_number): New field. * remote.c (remote_target::connection_string): New override. * target-connection.c: New file. * target-connection.h: New file. * target.c (decref_target): Remove process_stratum targets from the connection list. (target_stack::push): Add process_stratum targets to the connection list. gdb/testsuite/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * gdb.base/kill-detach-inferiors-cmd.exp: Adjust expected output of "add-inferior". * gdb.base/quit-live.exp: Likewise. * gdb.base/remote-exec-file.exp: Likewise. * gdb.guile/scm-progspace.exp: Likewise. * gdb.linespec/linespec.exp: Likewise. * gdb.mi/new-ui-mi-sync.exp: Likewise. * gdb.mi/user-selected-context-sync.exp: Likewise. * gdb.multi/multi-target.exp (setup): Add "info connection" and "info inferiors" tests. * gdb.multi/remove-inferiors.exp: Adjust expected output of "add-inferior". * gdb.multi/watchpoint-multi.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.server/extended-remote-restart.exp: Likewise. * gdb.threads/fork-plus-threads.exp: Adjust expected output of "info inferiors". * gdb.threads/forking-threads-plus-breakpoint.exp: Likewise. * gdb.trace/report.exp: Likewise.
2020-01-06Improve process exit status macros on MinGWEli Zaretskii1-0/+1
When a Windows program is terminated by a fatal exception, its exit code is the value of that exception, as defined by the various EXCEPTION_* symbols in the Windows API headers. This commit emulates WTERMSIG etc. by translating the fatal exception codes to more-or-less equivalent Posix signals. gdb/ChangeLog: 2020-01-06 Eli Zaretskii <eliz@gnu.org> Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_SFILES): Add gdbsupport/gdb_wait.c. * windows-tdep.c: New enumeration of WINDOWS_SIG* signals. (windows_gdb_signal_to_target): New function, uses the above enumeration to convert GDB internal signal codes to equivalent Windows codes. (windows_init_abi): Call set_gdbarch_gdb_signal_to_target. * windows-nat.c: Include "gdb_wait.h". (get_windows_debug_event): Extract the fatal exception from the exit status and convert to the equivalent Posix signal number. * cli/cli-cmds.c (exit_status_set_internal_vars): Account for the possibility that WTERMSIG returns GDB_SIGNAL_UNKNOWN. * gdbsupport/gdb_wait.c: New file, implements windows_status_to_termsig. * gdbsupport/gdb_wait.h (WIFEXITED, WIFSIGNALED, WEXITSTATUS) (WTERMSIG) [__MINGW32__]: Separate definitions for MinGW. gdb/gdbserver/ChangeLog: 2020-01-06 Eli Zaretskii <eliz@gnu.org> Pedro Alves <palves@redhat.com> * win32-low.c (get_child_debug_event): Extract the fatal exception from the exit status and convert to the equivalent Posix signal number. (win32_wait): Allow TARGET_WAITKIND_SIGNALLED status as well. * Makefile.in (OBS, SFILES): Add gdb_wait.[co].
2020-01-01Fix install-strip for cross-compilationHannes Domani1-2/+2
The variable INSTALL_PROGRAM_ENV sets up STRIPPROG for the cross-compiler. If this is not done, the host 'strip' is used, and fails: /bin/sh /c/src/repos/binutils-gdb.git/install-sh -c -s gdb.exe \ /gdb/gdb64-git/bin/$transformed_name.exe strip.exe:C:/gdb/gdb64-git/bin/_inst.33599_: file format not recognized With this change, it's fine: STRIPPROG='x86_64-w64-mingw32-strip' \ /bin/sh /c/src/repos/binutils-gdb.git/install-sh -c -s gdb.exe \ /gdb/gdb64-git/bin/$transformed_name.exe gdb/ChangeLog: 2020-01-01 Hannes Domani <ssbssa@yahoo.de> * Makefile.in: Use INSTALL_PROGRAM_ENV. gdb/gdbserver/ChangeLog: 2020-01-01 Hannes Domani <ssbssa@yahoo.de> * Makefile.in: Use INSTALL_PROGRAM_ENV.
2020-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files.
2019-12-12Ravenscar port for RISC-VTom Tromey1-0/+3
This adds Ravenscar support to gdb for RISC-V targets. This was tested internally using AdaCore's test suite and qemu. gdb/ChangeLog 2019-12-12 Tom Tromey <tromey@adacore.com> * Makefile.in (ALL_TARGET_OBS): Add riscv-ravenscar-thread.o. (HFILES_NO_SRCDIR): Add riscv-ravenscar-thread.h. (ALLDEPFILES): Add riscv-ravenscar-thread.c. * configure.tgt (riscv-*-*): Add riscv-ravenscar-thread.o. * riscv-ravenscar-thread.c: New file. * riscv-ravenscar-thread.h: New file. * riscv-tdep.c (riscv_gdbarch_init): Call register_riscv_ravenscar_ops. Change-Id: Ic47a3b3cfbbe80c2c82a5f48d2e0481845cac8b0
2019-12-04Compare iterators, not values, in filtered_iterator::operator{==,!=}Simon Marchi1-0/+1
The == and != operators on filtered_iterator are not doing the right thing, they compare values pointed by the wrapped iterators instead of comparing the iterators themselves. As a result, operator== will return true if the two iterators point to two equal values at different positions. operator!= will fail similarly. Also, this causes it to deference past-the-end iterators when doing. For example, in for (iter = ...; iter != end_iter; ++iter) the != comparison dereferences end_iter. I don't think this should happen. I don't think it's a problem today, given that we only use filtered_iterator to wrap linked lists of threads and inferiors. Dereferencing past-the-end iterators of these types is not fatal, it just returns NULL, which is not a value we otherwise find in the lists. But in other contexts, it could become problematic. I have added a simple self test that fails without the fix applied. gdb/ChangeLog: * filtered-iterator.h (filtered_iterator) <operator==, operator!=>: Compare wrapped iterators, not wrapped pointers. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/filtered_iterator-selftests.c. * unittests/filtered_iterator-selftests.c: New file.
2019-12-01Fix latent bug in tui_copy_source_lineTom Tromey1-0/+1
tui_copy_source_line has a bug, where it can advance past the terminating \0 in its input string. This patch fixes the bug and adds a test case for this function. gdb/ChangeLog 2019-12-01 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_copy_source_line): Don't advance past \0. * unittests/tui-selftests.c: New file. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add tui-selftests.c. Change-Id: I46cdabe6e57549983149b8f640cda5edd16fa260
2019-11-26Demangle minsyms in parallelTom Tromey1-0/+1
This patch introduces a simple parallel for_each and changes the minimal symbol reader to use it when computing the demangled name for a minimal symbol. This yields a speedup when reading minimal symbols. 2019-11-26 Christian Biesinger <cbiesinger@google.com> Tom Tromey <tom@tromey.com> * minsyms.c (minimal_symbol_reader::install): Use parallel_for_each. * gdbsupport/parallel-for.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add gdbsupport/parallel-for.h. Change-Id: I220341f70e94dd02df5dd424272c50a5afb64978
2019-11-26Implement a thread poolChristian Biesinger1-0/+2
This adds a simple thread pool to gdb. In the end, this seemed preferable to the approach taken in an earlier version of this series; namely, starting threads in the parallel-foreach implementation. This approach reduces the overhead of starting new threads, and also lets the user control (in a subsequent patch) exactly how many worker threads are running. gdb/ChangeLog 2019-11-26 Christian Biesinger <cbiesinger@google.com> Tom Tromey <tom@tromey.com> * gdbsupport/thread-pool.h: New file. * gdbsupport/thread-pool.c: New file. * Makefile.in (COMMON_SFILES): Add thread-pool.c. (HFILES_NO_SRCDIR): Add thread-pool.h. Change-Id: I597bb642780cb9d578ca92373d2a638efb44fe52
2019-11-26Introduce run_on_main_threadTom Tromey1-0/+3
This introduces a way for a callback to be run on the main thread. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * run-on-main-thread.c: New file. * run-on-main-thread.h: New file. * unittests/main-thread-selftests.c: New file. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add main-thread-selftests.c. (HFILES_NO_SRCDIR): Add run-on-main-thread.h. (COMMON_SFILES): Add run-on-main-thread.c. Change-Id: I16ef82f0564e9f8a524bdc64cb31df79a988ad9f
2019-11-26Add RAII class for blocking gdb signalsTom Tromey1-0/+1
This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-11-26Add configure check for std::threadTom Tromey1-4/+8
This adds a configure check for std::thread. This is needed because std::thread is not available on some systems, like some versions of mingw and DJGPP. This also adds configury to make sure that a threaded gdb links against the correct threading library (-lpthread or the like), and passes the right flags (e.g., -pthread) to the compilations. Note that this also links gdbserver against the thread library. This is not strictly necessary at this point in the series, but a later patch will change gdbsupport to use pthread_sigmask, at which point this will be needed. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * acinclude.m4: Include ax_pthread.m4. * Makefile.in (PTHREAD_CFLAGS, PTHREAD_LIBS): New variables. (INTERNAL_CFLAGS_BASE): Use PTHREAD_CFLAGS. (CLIBS): Use PTHREAD_LIBS. (aclocal_m4_deps): Add ax_pthread.m4. * config.in, configure: Rebuild. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for std::thread. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * Makefile.in (PTHREAD_CFLAGS, PTHREAD_LIBS): New variables. (INTERNAL_CFLAGS_BASE): Use PTHREAD_CFLAGS. (GDBSERVER_LIBS): Use PTHREAD_LIBS. * acinclude.m4: Include ax_pthread.m4. * config.in, configure: Rebuild. Change-Id: I00ec55db6077f2615421a93461fc3be57e916aa0
2019-11-21Rename demangle.c to gdb-demangle.c, and some cleanupChristian Biesinger1-1/+1
In addition to renaming demangle.c to match the header file naming, this also makes is_cplus_marker return a bool and removes a duplicate declaration of "bool demangle" from symtab.h. gdb/ChangeLog: 2019-11-21 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Update. * demangle.c: Rename to... * gdb-demangle.c: ..this. (is_cplus_marker): Change return type to bool. (_initialize_demangler): Rename to... (_initialize_gdb_demangle): ...this. * gdb-demangle.h (is_cplus_marker): Change return type to bool. * symtab.h (demangle): Remove declaration; instead include gdb-demangle.h. Change-Id: I83c3b3f7ee71b2bf6f5b5d0f9eb1d4b5208f2a97
2019-11-15Use gnulib's strerror_r on MinGWChristian Biesinger1-3/+2
There is no need to keep mingw-strerror around; we can just always use the code from posix-strerror. The main reason we had that code, it seems, is to handle winsock error codes, but gnulib's version handles those. Unfortunately the code can't be moved into common-utils.c because libinproctrace.so uses common-utils but not gnulib. gdb/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c. * configure: Regenerate. * configure.ac: Don't source common.host. * gdbsupport/common.host: Remove. * gdbsupport/mingw-strerror.c: Remove. * gdbsupport/posix-strerror.c: Rename to... * gdbsupport/safe-strerror.c: ...this. gdb/gdbserver/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Add safe-strerror.c. * configure: Regenerate. * configure.ac: Don't source common.host. Change-Id: I9e6d8a752fc398784201f370cafee65e0ea05474
2019-11-10gdb_vecs.h: Avoid self move assignAndrew Burgess1-0/+1
While working on another patch I ran into an issue with unordered_remove (in gdb_vecs.h), where removing the last item of the vector can cause a self move assign. When compiling the C++ standard library in debug mode (with -D_GLIBCXX_DEBUG=1) this causes an error to trigger. I've fixed the issue in this patch and provided a unit test. The provided unit test includes an assignment operator which checks for self move assign, this removes the need to compile with -D_GLIBCXX_DEBUG=1 in order to spot the bug. If you're keen to see the error reported from the C++ standard library then remove operator= from the unit test and recompile GDB with -D_GLIBCXX_DEBUG=1. gdb/ChangeLog: * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add new file to the list. * unittests/vec-utils-selftests.c: New file. * gdbsupport/gdb_vecs.h (unordered_remove): Avoid self move assign. Change-Id: I80247b20cd5212038117db7412865f5e6a9257cd
2019-10-29Replace bsearch with a std::lower_bound-based searchChristian Biesinger1-0/+1
This is more type-safe and can be faster due to inlining and avoiding overhead from calling through a function pointer. gdb/ChangeLog: 2019-10-29 Christian Biesinger <cbiesinger@google.com> * Makefile.in (HFILES_NO_SRCDIR): Add gdb_binary_search.h. * dwarf2-frame.c (bsearch_fde_cmp): Update. (dwarf2_frame_find_fde): Replace bsearch with gdb::binary_search. * gdbsupport/gdb_binary_search.h: New file. Change-Id: I07e0a0e333f4062b27fc68d3a3f24881ebc68fd4