binutils-gdb/gdbsupport/ChangeLog
Simon Marchi 6abd4cf281 gdb: check for empty strings in get_standard_cache_dir/get_standard_config_dir
As reported in PR 27157, if some environment variables read at startup
by GDB are defined but empty, we hit the assert in gdb_abspath:

    $ XDG_CACHE_HOME= ./gdb -nx --data-directory=data-directory -q
    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==2007040==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000001b0 (pc 0x5639d4aa4127 bp 0x7ffdac232c00 sp 0x7ffdac232bf0 T0)
    ==2007040==The signal is caused by a READ memory access.
    ==2007040==Hint: address points to the zero page.
        #0 0x5639d4aa4126 in target_stack::top() const /home/smarchi/src/binutils-gdb/gdb/target.h:1334
        #1 0x5639d4aa41f1 in inferior::top_target() /home/smarchi/src/binutils-gdb/gdb/inferior.h:369
        #2 0x5639d4a70b1f in current_top_target() /home/smarchi/src/binutils-gdb/gdb/target.c:120
        #3 0x5639d4b00591 in gdb_readline_wrapper_cleanup::gdb_readline_wrapper_cleanup() /home/smarchi/src/binutils-gdb/gdb/top.c:1046
        #4 0x5639d4afab31 in gdb_readline_wrapper(char const*) /home/smarchi/src/binutils-gdb/gdb/top.c:1104
        #5 0x5639d4ccce2c in defaulted_query /home/smarchi/src/binutils-gdb/gdb/utils.c:893
        #6 0x5639d4ccd6af in query(char const*, ...) /home/smarchi/src/binutils-gdb/gdb/utils.c:985
        #7 0x5639d4ccaec1 in internal_vproblem /home/smarchi/src/binutils-gdb/gdb/utils.c:373
        #8 0x5639d4ccb3d1 in internal_verror(char const*, int, char const*, __va_list_tag*) /home/smarchi/src/binutils-gdb/gdb/utils.c:439
        #9 0x5639d5151a92 in internal_error(char const*, int, char const*, ...) /home/smarchi/src/binutils-gdb/gdbsupport/errors.cc:55
        #10 0x5639d5162ab4 in gdb_abspath(char const*) /home/smarchi/src/binutils-gdb/gdbsupport/pathstuff.cc:132
        #11 0x5639d5162fac in get_standard_cache_dir[abi:cxx11]() /home/smarchi/src/binutils-gdb/gdbsupport/pathstuff.cc:228
        #12 0x5639d3e76a81 in _initialize_index_cache() /home/smarchi/src/binutils-gdb/gdb/dwarf2/index-cache.c:325
        #13 0x5639d4dbbe92 in initialize_all_files() /home/smarchi/build/binutils-gdb/gdb/init.c:321
        #14 0x5639d4b00259 in gdb_init(char*) /home/smarchi/src/binutils-gdb/gdb/top.c:2344
        #15 0x5639d4440715 in captured_main_1 /home/smarchi/src/binutils-gdb/gdb/main.c:950
        #16 0x5639d444252e in captured_main /home/smarchi/src/binutils-gdb/gdb/main.c:1229
        #17 0x5639d44425cf in gdb_main(captured_main_args*) /home/smarchi/src/binutils-gdb/gdb/main.c:1254
        #18 0x5639d3923371 in main /home/smarchi/src/binutils-gdb/gdb/gdb.c:32
        #19 0x7fa002d3f0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
        #20 0x5639d392314d in _start (/home/smarchi/build/binutils-gdb/gdb/gdb+0x4d414d)

gdb_abspath doesn't handle empty strings, so handle this case in the
callers.  If a variable is defined but empty, I think it's reasonable in
this case to just ignore it, as if it was not defined.

Note that this sometimes also lead to a segfault, because the failed
assertion happens very early during startup, before things are fully
initialized.

gdbsupport/ChangeLog:

	PR gdb/27157
	* pathstuff.cc (get_standard_cache_dir, get_standard_config_dir,
	find_gdb_home_config_file): Add empty string check.

gdb/testsuite/ChangeLog:

	PR gdb/27157
	* gdb.base/empty-host-env-vars.exp: New test.

Change-Id: I8654d8e97e74e1dff6d308c111ae4b1bbf07bef9
2021-01-08 13:46:56 -05:00

504 lines
15 KiB
Plaintext

2021-01-08 Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/27157
* pathstuff.cc (get_standard_cache_dir, get_standard_config_dir,
find_gdb_home_config_file): Add empty string check.
2021-01-06 Mike Frysinger <vapier@gentoo.org>
* common-utils.h (align_up): Fix typo in header comment.
2021-01-04 Simon Marchi <simon.marchi@efficios.com>
* common-debug.h (debug_print_depth): New.
(struct scoped_debug_start_end): New.
(scoped_debug_start_end): New.
(scoped_debug_enter_exit): New.
* common-debug.cc (debug_prefixed_vprintf): Print indentation.
2020-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
* gdbsupport/common-utils.cc: Change 'ctype.h' include to
'safe-ctype.h'.
(extract_string_maybe_quoted): Use safe-ctype function versions.
(is_digit_in_base): Likewise.
(digit_to_int): Likewise.
(strtoulst): Likewise.
(skip_spaces): Likewise.
(skip_to_space): Likewise.
2020-12-11 Simon Marchi <simon.marchi@polymtl.ca>
* common-debug.h (debug_prefixed_printf_cond): New.
* event-loop.h (event_loop_debug_printf): Use
debug_prefixed_printf_cond.
2020-12-08 Alexander Fedotov <alfedotov@gmail.com>
* pathstuff.cc (get_standard_cache_dir): Use LOCALAPPDATA environment
variable when running on Windows.
2020-12-01 Andrew Burgess <andrew.burgess@embecosm.com>
* tdesc.cc (print_xml_feature::visit): Print enum fields using
'evalue' syntax.
2020-12-01 Chungyi Chi <demonic@csie.io>
* tdesc.cc (print_xml_feature::visit): Print enum size attribute.
2020-11-20 Tom Tromey <tromey@adacore.com>
* thread-pool.cc (thread_pool::set_thread_count): Ignore system
errors.
2020-11-10 Tom Tromey <tromey@adacore.com>
PR build/26848:
* pathstuff.h: Move include block here...
* pathstuff.cc: ... from here.
2020-11-02 Tom Tromey <tom@tromey.com>
* pathstuff.h (get_standard_config_dir): Declare.
* pathstuff.cc (get_standard_config_dir): New function.
2020-11-02 Simon Marchi <simon.marchi@efficios.com>
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
* common-debug.cc (debug_prefixed_printf): New.
* common-debug.h (debug_prefixed_printf): New declaration.
* event-loop.cc (event_loop_debug_printf_1): Remove.
* event-loop.h (event_loop_debug_printf_1): Remove.
(event_loop_debug_printf): Use debug_prefixed_printf.
(event_loop_ui_debug_printf): Use debug_prefixed_printf.
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
* common.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
AC_LANG_PROGRAM.
* configure: Re-generate.
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
* common.m4: Replace AC_FUNC_VFORK with AC_FUNC_FORK.
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
* configure: Re-generate.
* warning.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
AC_LANG_PROGRAM.
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
* configure: Re-generate.
* ptrace.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
AC_LANG_PROGRAM.
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
* configure: Re-generate.
* ptrace.m4: Re-indent.
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
* aclocal.m4: Re-generate.
* configure: Re-generate.
* configure.ac: Remove AM_PROG_CC_STDC.
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
* configure.ac: Use AC_CANONICAL_{BUILD,HOST,TARGET} instead of
AC_CANONICAL_SYSTEM.
* configure: Re-generate.
2020-10-26 Pedro Alves <pedro@palves.net>
* eintr.h (handle_eintr): Replace Ret template parameter with
ErrorValType. Use it as type of the failure value. Deduce the
function's return type using decltype. Use lowercase for function
parameter names.
2020-10-25 Simon Marchi <simon.marchi@polymtl.ca>
* Makefile.in: Re-generate.
* acinclude.m4: Update ptrace.m4 path.
* ptrace.m4: Move here.
2020-10-08 Andrew Burgess <andrew.burgess@embecosm.com>
* tdesc.h (allocate_target_description): Update return type.
2020-10-07 Tom Tromey <tromey@adacore.com>
* Makefile.in: Rebuild.
* Makefile.am (libgdbsupport_a_SOURCES): Add search.cc.
* search.h: New file.
* search.cc: New file.
2020-10-02 Simon Marchi <simon.marchi@polymtl.ca>
* event-loop.h (debug_event_loop): New variable declaration.
(event_loop_debug_printf_1): New function declaration.
(event_loop_debug_printf): New macro.
* event-loop.cc (debug_event_loop): New variable.
(handle_file_event): Add debug print.
(event_loop_debug_printf_1): New function.
2020-10-02 Simon Marchi <simon.marchi@polymtl.ca>
* common-debug.cc (debug_prefixed_vprintf): Move here.
* common-debug.h (debug_prefixed_vprintf): Move here.
2020-10-02 Simon Marchi <simon.marchi@polymtl.ca>
* event-loop.h (add_file_handler): Add "name" parameter.
* event-loop.cc (struct file_handler) <name>: New field.
(create_file_handler): Add "name" parameter, assign it to file
handler.
(add_file_handler): Add "name" parameter.
2020-10-01 Kamil Rytarowski <n54@gmx.com>
* agent.cc (gdb_connect_sync_socket): Preinitialize addr with zeros.
2020-09-29 Pedro Alves <pedro@palves.net>
* valid-expr.h (CHECK_VALID_EXPR_INT): Make archetype a template
class instead of an alias template and adjust static_assert.
2020-09-24 Simon Marchi <simon.marchi@efficios.com>
* event-loop.c (struct file_handler): Remove typedef, re-format.
2020-09-16 John Baldwin <jhb@FreeBSD.org>
* common.m4 (GDB_AC_COMMON): Refactor checks for kinfo_getfile().
* configure, config.in: Regenerate.
2020-09-14 Pedro Alves <pedro@palves.net>
* 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-09-14 Pedro Alves <pedro@palves.net>
* traits.h (struct nonesuch, struct detector, detected_or)
(detected_or_t, is_detected, detected_t, detected_or)
(detected_or_t, is_detected_exact, is_detected_convertible): New.
* valid-expr.h (CHECK_VALID_EXPR_INT): Use gdb::is_detected_exact.
2020-09-10 Kamil Rytarowski <n54@gmx.com>
* eintr.h: New file.
2020-08-13 Simon Marchi <simon.marchi@polymtl.ca>
* selftest.h (run_tests): Change parameter to array_view.
* selftest.c (run_tests): Change parameter to array_view and use
it.
2020-07-30 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* 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.
2020-07-28 Tom de Vries <tdevries@suse.de>
PR build/26281
* gdb_optional.h (class optional): Add volatile member to union
contaning m_dummy and m_item.
2020-07-17 Andrew Burgess <andrew.burgess@embecosm.com>
* tdesc.h (struct target_desc_deleter): Moved here
from gdb/target-descriptions.h, extend comment.
(target_desc_up): Likewise.
2020-06-30 Tom Tromey <tromey@adacore.com>
PR build/26183:
* gdb_string_view.h (basic_string_view::to_string): Remove.
(gdb::to_string): New function.
2020-06-27 Simon Marchi <simon.marchi@efficios.com>
* tdesc.h (class print_xml_feature) <add_line>: Add
ATTRIBUTE_PRINTF.
2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
* tdesc.cc (print_xml_feature::visit_pre): Use add_line to add
output content, and call indent as needed in all overloaded
variants.
(print_xml_feature::visit_post): Likewise.
(print_xml_feature::visit): Likewise.
(print_xml_feature::add_line): Two new overloaded functions.
* tdesc.h (print_xml_feature::indent): New member function.
(print_xml_feature::add_line): Two new overloaded member
functions.
(print_xml_feature::m_depth): New member variable.
2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
* tdesc.cc (print_xml_feature::visit_pre): Print compatible
information.
* tdesc.h (struct tdesc_compatible_info): Declare new struct.
(tdesc_compatible_info_up): New typedef.
(tdesc_compatible_info_list): Declare new function.
(tdesc_compatible_info_arch_name): Declare new function.
2020-05-25 Michael Weghorn <m.weghorn@posteo.de>
* common-utils.cc, common-utils.h (stringify_argv): Drop
now unused function stringify_argv
2020-05-25 Michael Weghorn <m.weghorn@posteo.de>
* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
Adapt to take a gdb::array_view<char * const> parameter.
Adapt call site.
2020-05-25 Michael Weghorn <m.weghorn@posteo.de>
* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
Adapt to handle zero args and return a std::string.
Adapt call site.
2020-05-25 Michael Weghorn <m.weghorn@posteo.de>
* common-inferior.h, common-inferior.cc: (construct_inferior_arguments):
Move function here from gdb/infcmd.c, gdb/inferior.h
2020-05-14 Kevin Buettner <kevinb@redhat.com>
* btrace-common.h (btrace_cpu_vendor): Add CV_AMD.
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* common-regcache.h (regcache_read_pc_protected): New function
declaration.
2020-04-28 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb-sigmask.h: Fix typo (pthead_sigmask -> pthread_sigmask).
2020-04-27 Simon Marchi <simon.marchi@polymtl.ca>
* common-defs.h: Include cstdlib.h.
2020-04-20 Tom Tromey <tromey@adacore.com>
* scoped_mmap.h (scoped_mmap): Mark move constructor as noexcept.
Use initialization style. Don't call destroy.
* scoped_fd.h (class scoped_fd): Mark move constructor as
noexcept.
* gdb_ref_ptr.h (class ref_ptr): Mark move constructor as
noexcept.
2020-04-13 Tom Tromey <tom@tromey.com>
* event-loop.c: Move comment. Remove obsolete comment.
2020-04-13 Tom Tromey <tom@tromey.com>
* event-loop.h: Move from ../gdb/.
* event-loop.cc: Move from ../gdb/.
2020-04-13 Tom Tromey <tom@tromey.com>
* errors.h (flush_streams): Declare.
2020-04-13 Tom Tromey <tom@tromey.com>
* gdb_select.h: Move from ../gdb/.
2020-04-13 Tom Tromey <tom@tromey.com>
* config.in, configure: Rebuild.
* common.m4 (GDB_AC_COMMON): Check for poll.h, sys/poll.h,
sys/select.h, and poll.
2020-03-31 Tom Tromey <tromey@adacore.com>
* btrace-common.cc (btrace_data_append): Conditionally call
memcpy.
2020-03-27 Andrew Burgess <andrew.burgess@embecosm.com>
* create-version.sh: Resolve issues highlighted by shellcheck.
2020-03-20 Simon Marchi <simon.marchi@efficios.com>
* config.in: Re-generate.
* configure: Re-generate.
2020-03-17 Kamil Rytarowski <n54@gmx.com>
* common-defs.h: Include alloca.h if HAVE_ALLOCA_H is defined.
2020-03-12 Tom Tromey <tom@tromey.com>
* common-types.h: Remove GDBSERVER code.
(gdb_byte, CORE_ADDR, LONGEST, ULONGEST): Redefine.
* common-defs.h: Remove GDBSERVER code.
2020-03-12 Simon Marchi <simon.marchi@efficios.com>
* selftest.m4: Moved from gdb/.
* acinclude.m4: Update path to selftest.m4.
2020-03-12 Simon Marchi <simon.marchi@efficios.com>
* configure.ac: Don't source bfd/development.sh.
* common.m4: Source bfd/development.sh.
* configure: Re-generate.
2020-03-12 Simon Marchi <simon.marchi@efficios.com>
* configure: Re-generate.
2020-03-11 Simon Marchi <simon.marchi@efficios.com>
* configure: Re-generate.
* warning.m4: Enable -Wmissing-prototypes.
2020-03-08 Tom Tromey <tom@tromey.com>
* gdb_binary_search.h: Fix two typos.
2020-03-06 Andrew Burgess <andrew.burgess@embecosm.com>
* .dir-locals.el: New file.
2020-03-05 Vyacheslav Petrishchev <vyachemail@gmail.com>
* configure.ac: Added call development.sh.
* configure: Regenerate.
2020-03-05 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* .gitattributes: New file.
2020-03-03 Simon Marchi <simon.marchi@efficios.com>
* Makefile.in: Re-generate.
2020-02-28 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb-dlfcn.h (gdb_dlopen): Update comment.
2020-02-19 Andrew Burgess <andrew.burgess@embecosm.com>
* configure: Regenerate.
2020-02-14 Tom Tromey <tom@tromey.com>
* common-defs.h: Change path to gnulib/config.h.
2020-02-13 Simon Marchi <simon.marchi@efficios.com>
* Makefile.am: Rename source files from .c to .cc.
(CC, CFLAGS): Don't override.
(AM_CFLAGS): Rename to ...
(AM_CXXFLAGS): ... this.
* Makefile.in: Re-generate.
* %.c: Rename to %.cc.
2020-02-11 Simon Marchi <simon.marchi@efficios.com>
* configure: Re-generate.
2020-02-11 Simon Marchi <simon.marchi@efficios.com>
* warning.m4: Add -Wstrict-null-sentinel.
* configure: Re-generate.
2020-02-11 Simon Marchi <simon.marchi@efficios.com>
* warning.m4: Move here, from gdb/warning.m4.
* acinclude.m4: Update warning.m4 path.
* Makefile.in: Re-generate.
2020-02-11 Simon Marchi <simon.marchi@efficios.com>
* acinclude.m4: Include ../gdb/warning.m4.
* configure.ac: Use AM_GDB_WARNINGS.
* Makefile.am: Set AM_CFLAGS to WARN_CFLAGS and WERROR_CFLAGS.
* Makefile.in: Re-generate.
* configure: Re-generate.
2020-02-10 Tom de Vries <tdevries@suse.de>
* environ.c (gdb_environ::set): Cast concat NULL sentinel to char *.
2020-01-24 Christian Biesinger <cbiesinger@google.com>
* thread-pool.c (set_thread_name): Add an overload for the NetBSD
version of pthread_setname_np.
2020-01-17 Pedro Alves <palves@redhat.com>
* Makefile.am: Append CXX_DIALECT to CXX.
* Makefile.in: Regenerate.
2020-01-17 Pedro Alves <palves@redhat.com>
* configure.ac: Generate config.h instead of support-config.h.
* common-defs.h: Include <gdbsupport/config.h> instead of
<gdbsupport/support-config.h>.
* Makefile.in: Regenerate.
* configure: Regenerate.
2020-01-14 Tom Tromey <tom@tromey.com>
* Makefile.in: Rebuild.
* Makefile.am (check-defines): New target.
* check-defines.el: New file.
2020-01-14 Tom Tromey <tom@tromey.com>
* configure, Makefile.in, aclocal.m4, common.m4, config.in:
Rebuild.
* common.m4 (GDB_AC_COMMON): Move many checks from
gdb/configure.ac.
* acinclude.m4: Include bfd.m4, ptrace.m4.
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/