deliverable/binutils-gdb.git
4 years agoSet names of worker threads
Tom Tromey [Sat, 12 Oct 2019 19:06:18 +0000 (13:06 -0600)] 
Set names of worker threads

This adds some configury so that gdb can set the names of worker
threads.  This makes them show up more nicely when debugging gdb
itself.

2019-11-26  Tom Tromey  <tom@tromey.com>

* gdbsupport/thread-pool.c (thread_pool::set_thread_count): Set
name of worker thread.
* gdbsupport/common.m4 (GDB_AC_COMMON): Check for
pthread_setname_np.
* configure, config.in: Rebuild.

gdb/gdbserver/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

* configure, config.in: Rebuild.

Change-Id: I60473d65ae9ae14d8c56ddde39684240c16aaf35

4 years agoUse run_on_main_thread in gdb.post_event
Tom Tromey [Sat, 8 Jun 2019 14:15:57 +0000 (08:15 -0600)] 
Use run_on_main_thread in gdb.post_event

This changes gdb.post_event to use the new run_on_main_thread
function.  This is somewhat tricky because the Python GIL must be held
while manipulating reference counts.

2019-11-26  Tom Tromey  <tom@tromey.com>

* python/python.c (class gdbpy_gil): New.
(struct gdbpy_event): Add constructor, destructor, operator().
(gdbpy_post_event): Use run_on_main_thread.
(gdbpy_initialize_events): Remove.
(do_start_initialization): Update.

Change-Id: Ie4431e60f328dae48bd96b6c6a8e875e70bda1de

4 years agoAdd maint set/show worker-threads
Tom Tromey [Sat, 16 Mar 2019 20:36:57 +0000 (14:36 -0600)] 
Add maint set/show worker-threads

This adds maint commands to control the number of worker threads that
gdb can use.

2019-11-26  Tom Tromey  <tom@tromey.com>

* NEWS: Add entry.
* maint.c (_initialize_maint_cmds): Add "worker-threads" maint
commands.  Call update_thread_pool_size.
(update_thread_pool_size, maintenance_set_worker_threads): New
functions.
(n_worker_threads): New global.

gdb/doc/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

* gdb.texinfo (Maintenance Commands): Document new maint
commands.

Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a

4 years agoDemangle minsyms in parallel
Tom Tromey [Sun, 3 Mar 2019 17:15:30 +0000 (10:15 -0700)] 
Demangle minsyms in parallel

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

4 years agoImplement a thread pool
Christian Biesinger [Tue, 1 Oct 2019 23:38:35 +0000 (18:38 -0500)] 
Implement a thread pool

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

4 years agoIntroduce thread-safe way to handle SIGSEGV
Tom Tromey [Mon, 4 Mar 2019 22:12:04 +0000 (15:12 -0700)] 
Introduce thread-safe way to handle SIGSEGV

The gdb demangler installs a SIGSEGV handler in order to protect gdb
from demangler bugs.  However, this is not thread-safe, as signal
handlers are global to the process.

This patch changes gdb to always install a global SIGSEGV handler, and
then lets threads indicate their interest in handling the signal by
setting a thread-local variable.

This patch then arranges for the demangler code to use this; being
sure to arrange for calls to warning and the like to be done on the
main thread.

One thing I wondered while writing this patch is if there are any
systems that do not have "sigaction".  If gdb could assume this, it
would simplify this code.

gdb/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

* event-top.h (thread_local_segv_handler): Declare.
* event-top.c (thread_local_segv_handler): New global.
(install_handle_sigsegv, handle_sigsegv): New functions.
(async_init_signals): Install SIGSEGV handler.
* cp-support.c (gdb_demangle_jmp_buf): Change type.  Now
thread-local.
(report_failed_demangle): New function.
(gdb_demangle): Make core_dump_allowed atomic.  Remove signal
handler-setting code, instead use segv_handler.  Run warning code
on main thread.

Change-Id: Ic832bbb033b64744e4b44f14b41db7e4168ce427

4 years agoIntroduce run_on_main_thread
Tom Tromey [Fri, 8 Mar 2019 22:51:06 +0000 (15:51 -0700)] 
Introduce run_on_main_thread

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

4 years agoIntroduce alternate_signal_stack RAII class
Tom Tromey [Sun, 29 Sep 2019 15:27:11 +0000 (09:27 -0600)] 
Introduce alternate_signal_stack RAII class

This introduces a new RAII class that temporarily installs an
alternate signal stack (on systems that have sigaltstack); then
changes the one gdb use of sigaltstack to use this class instead.

This will be used in a later patch, when creating new threads that may
want to handle SIGSEGV.

gdb/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

* main.c (setup_alternate_signal_stack): Remove.
(captured_main_1): Use gdb::alternate_signal_stack.
* gdbsupport/alt-stack.h: New file.

Change-Id: I721c047ae9d51a35fd274a6dbc00a58c6440dae6

4 years agoAdd RAII class for blocking gdb signals
Tom Tromey [Sun, 29 Sep 2019 14:50:15 +0000 (08:50 -0600)] 
Add RAII class for blocking gdb signals

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

4 years agoAdd configure check for std::thread
Tom Tromey [Fri, 15 Mar 2019 23:38:06 +0000 (17:38 -0600)] 
Add configure check for std::thread

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

4 years agoDefer minimal symbol name-setting
Tom Tromey [Sat, 2 Mar 2019 20:19:44 +0000 (13:19 -0700)] 
Defer minimal symbol name-setting

Currently the demangled name of a minimal symbol is set when creating
the symbol.  However, there is no intrinsic need to do this.  This
patch instead arranges for the demangling to be done just before the
minsym hash tables are filled.  This will be useful in a later patch.

gdb/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

* symtab.h (struct minimal_symbol) <name_set>: New member.
* minsyms.c (minimal_symbol_reader::record_full): Copy name.
Don't call symbol_set_names.
(minimal_symbol_reader::install): Call symbol_set_names.

Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76

4 years agoFix crashes due to python GIL released too early
Philippe Waroquiers [Sat, 23 Nov 2019 10:08:12 +0000 (11:08 +0100)] 
Fix crashes due to python GIL released too early

When running GDB tests under Valgrind, various tests are failing due
to invalid memory access.
Here is the stack trace reported by Valgrind, for gdb.base/freebpcmd.exp :
  ==18658== Invalid read of size 8
  ==18658==    at 0x7F9107: is_main (signalmodule.c:195)
  ==18658==    by 0x7F9107: PyOS_InterruptOccurred (signalmodule.c:1730)
  ==18658==    by 0x3696E2: check_quit_flag() (extension.c:829)
  ==18658==    by 0x36980B: restore_active_ext_lang(active_ext_lang_state*) (extension.c:782)
  ==18658==    by 0x48F617: gdbpy_enter::~gdbpy_enter() (python.c:235)
  ==18658==    by 0x47BB71: add_thread_object(thread_info*) (object.h:470)
  ==18658==    by 0x53A84D: operator() (std_function.h:687)
  ==18658==    by 0x53A84D: notify (observable.h:106)
  ==18658==    by 0x53A84D: add_thread_silent(ptid_t) (thread.c:311)
  ==18658==    by 0x3CD954: inf_ptrace_target::create_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&
  , char**, int) (inf-ptrace.c:139)
  ==18658==    by 0x3FE644: linux_nat_target::create_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
   char**, int) (linux-nat.c:1094)
  ==18658==    by 0x3D5727: run_command_1(char const*, int, run_how) (infcmd.c:633)
  ==18658==    by 0x2C05D1: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1948)
  ==18658==    by 0x53F29F: execute_command(char const*, int) (top.c:639)
  ==18658==    by 0x3638EB: command_handler(char const*) (event-top.c:586)
  ==18658==    by 0x36468C: command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) (event-top.c:771)
  ==18658==    by 0x36407C: gdb_rl_callback_handler(char*) (event-top.c:217)
  ==18658==    by 0x5B2A1F: rl_callback_read_char (callback.c:281)
  ==18658==    by 0x36346D: gdb_rl_callback_read_char_wrapper_noexcept() (event-top.c:175)
  ==18658==    by 0x363F70: gdb_rl_callback_read_char_wrapper(void*) (event-top.c:192)
  ==18658==    by 0x3633AF: stdin_event_handler(int, void*) (event-top.c:514)
  ==18658==    by 0x362504: gdb_wait_for_event (event-loop.c:857)
  ==18658==    by 0x362504: gdb_wait_for_event(int) (event-loop.c:744)
  ==18658==    by 0x362676: gdb_do_one_event() [clone .part.11] (event-loop.c:321)
  ==18658==    by 0x3627AD: gdb_do_one_event (event-loop.c:303)
  ==18658==    by 0x3627AD: start_event_loop() (event-loop.c:370)
  ==18658==    by 0x41D35A: captured_command_loop() (main.c:381)
  ==18658==    by 0x41F2A4: captured_main (main.c:1224)
  ==18658==    by 0x41F2A4: gdb_main(captured_main_args*) (main.c:1239)
  ==18658==    by 0x227D0A: main (gdb.c:32)
  ==18658==  Address 0x10 is not stack'd, malloc'd or (recently) free'd

The problem seems to be created by gdbpy_enter::~gdbpy_enter () releasing the GIL lock
too early:
~gdbpy_enter () does:
      ...
      PyGILState_Release (m_state);
      python_gdbarch = m_gdbarch;
      python_language = m_language;

      restore_active_ext_lang (m_previous_active);
    }

So, it releases the GIL lock, does 2 assignments and then leads to the following
call sequence:
  restore_active_ext_lang => check_quit_flag => python.c gdbpy_check_quit_flag
     => PyOS_InterruptOccurred => is_main.
is_main code is:
    static int
    is_main(_PyRuntimeState *runtime)
    {
        unsigned long thread = PyThread_get_thread_ident();
        PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp;
        return (thread == runtime->main_thread
                && interp == runtime->interpreters.main);
    }

The macros and functions to access the thread state are documented as:
    /* Variable and macro for in-line access to current thread
       and interpreter state */

    #define _PyRuntimeState_GetThreadState(runtime) \
        ((PyThreadState*)_Py_atomic_load_relaxed(&(runtime)->gilstate.tstate_current))

    /* Get the current Python thread state.

       Efficient macro reading directly the 'gilstate.tstate_current' atomic
       variable. The macro is unsafe: it does not check for error and it can
       return NULL.

       The caller must hold the GIL.

       See also PyThreadState_Get() and PyThreadState_GET(). */
    #define _PyThreadState_GET() _PyRuntimeState_GetThreadState(&_PyRuntime)

So, we see that GDB releases the GIL and then potentially calls
_PyRuntimeState_GetThreadState that needs the GIL.

It is not very clear why the problem is only observed when running under
Valgrind.  Probably caused by the slowdown due to Valgrind and/or to the 'single
thread' scheduling by Valgrind.

This patch fixes the crashes by releasing the GIT lock later.

2019-11-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* python/python.c (gdbpy_enter::~gdbpy_enter): Release GIL after
restore_active_ext_lang, as GIL is needed for (indirectly)
called PyOS_InterruptOccurred.

4 years agoFix declaration of sparc_xfer_wcookie
Simon Marchi [Tue, 26 Nov 2019 17:12:04 +0000 (12:12 -0500)] 
Fix declaration of sparc_xfer_wcookie

When building sparc-nat.c with -Wmissing-declarations, we get:

      CXX    sparc-nat.o
    /home/smarchi/src/binutils-gdb/gdb/sparc-nat.c: In function ‘target_xfer_status sparc_xfer_wcookie(target_ops*, target_object, const char*, gdb_byte*, const gdb_byte*, ULONGEST, ULONGEST, ULONGEST*)’:
    /home/smarchi/src/binutils-gdb/gdb/sparc-nat.c:255:1: error: no previous declaration for ‘target_xfer_status sparc_xfer_wcookie(target_ops*, target_object, const char*, gdb_byte*, const gdb_byte*, ULONGEST, ULONGEST, ULONGEST*)’ [-Werror=missing-declarations]
     sparc_xfer_wcookie (struct target_ops *ops, enum target_object object,
     ^~~~~~~~~~~~~~~~~~

Indeed, the declaration is not in sync with the definition, fix that.

sparc_xfer_wcookie is used in sparc_target::xfer_partial.  sparc_target
is only used in the BSD sparc native files.  The error above was
obtained by running "make sparc-nat.o" on Linux with a cross-compiler
for sparc64-linux-gnu.  But I presume that if we were to build for real
with a BSD/sparc compiler, we would end up with an undefined symbol.

gdb/ChangeLog:

* sparc-nat.c (sparc_xfer_wcookie): Sync declaration with
definition.

Change-Id: Id41e706e5516968ff6a49469ddc48eceb29dd3ea

4 years agoRemove simulator_command declaration, make static
Simon Marchi [Tue, 26 Nov 2019 17:12:04 +0000 (12:12 -0500)] 
Remove simulator_command declaration, make static

The simulator_command function is not used outside its file, so make it
static.  Remove the declaration, which is not needed and not even in
sync with the definition.

gdb/ChangeLog:

* remote-sim.c (simulator_command): Make static, remove
declaration.

Change-Id: I40bd1e3662f849c4c9970443931ab9ee0ccccea1

4 years agoMake functions static in unittests
Simon Marchi [Tue, 26 Nov 2019 17:12:03 +0000 (12:12 -0500)] 
Make functions static in unittests

Enabling -Wmissing-declarations points out that a bunch of function in
the unittests can be made static, do that.

gdb/ChangeLog:

* unittests/array-view-selftests.c (check_ptr_size_ctor2): Make
static.
* unittests/basic_string_view/capacity/1.cc (test01): Likewise.
* unittests/basic_string_view/cons/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/cons/char/2.cc (test03): Likewise.
(main): Likewise.
* unittests/basic_string_view/cons/char/3.cc (test05): Likewise.
(main): Likewise.
* unittests/basic_string_view/element_access/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/element_access/char/empty.cc (main): Likewise.
* unittests/basic_string_view/element_access/char/front_back.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/inserters/char/2.cc (test05): Likewise.
(main): Likewise.
* unittests/basic_string_view/modifiers/remove_prefix/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/modifiers/remove_suffix/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/modifiers/swap/char/1.cc (test01): Likewise.
* unittests/basic_string_view/operations/compare/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/compare/char/13650.cc (test01): Likewise.
* unittests/basic_string_view/operations/copy/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/data/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/find/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/find/char/2.cc (test02): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/find/char/3.cc (test03): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/find/char/4.cc (main): Likewise.
* unittests/basic_string_view/operations/rfind/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/rfind/char/2.cc (test02): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/rfind/char/3.cc (test03): Likewise.
(main): Likewise.
* unittests/basic_string_view/operations/substr/char/1.cc (test01): Likewise.
(main): Likewise.
* unittests/basic_string_view/operators/char/2.cc (main): Likewise.
* unittests/optional/assignment/1.cc (test): Likewise.
* unittests/optional/assignment/2.cc (test): Likewise.
* unittests/optional/assignment/3.cc (test): Likewise.
* unittests/optional/assignment/4.cc (test): Likewise.
* unittests/optional/assignment/5.cc (test): Likewise.
* unittests/optional/assignment/6.cc (test): Likewise.
* unittests/optional/assignment/7.cc (test): Likewise.
* unittests/optional/cons/copy.cc (test): Likewise.
* unittests/optional/cons/default.cc (test): Likewise.
* unittests/optional/cons/move.cc (test): Likewise.
* unittests/optional/cons/value.cc (test): Likewise.
* unittests/optional/in_place.cc (test): Likewise.
* unittests/optional/observers/1.cc (test): Likewise.
* unittests/optional/observers/2.cc (test): Likewise.

Change-Id: I66626db864cb877cacc570d4660df633530554f5

4 years agoRemove declaration of tui_set_var_cmd, make definition static
Simon Marchi [Tue, 26 Nov 2019 17:12:03 +0000 (12:12 -0500)] 
Remove declaration of tui_set_var_cmd, make definition static

The declaration of tui_set_var_cmd is not in sync with the definition.
Since tui_set_var_cmd is only used in the file where it's defined,
remove the declaration and make the definition static.

gdb/ChangeLog:

* tui-win.h (tui_set_var_cmd): Remove.
* tui-win.c (tui_set_var_cmd): Make static.

Change-Id: If4bddbfb573347fb7254fb6f1a940052a72f464f

4 years agoRemove unused rbreak_command_wrapper and other declarations
Simon Marchi [Tue, 26 Nov 2019 17:12:03 +0000 (12:12 -0500)] 
Remove unused rbreak_command_wrapper and other declarations

rbreak_command_wrapper is unused, so remove it.  And while at it, remove
other declarations around it.

gdb/ChangeLog:

* breakpoint.h (hbreak_command_wrapper, thbreak_command_wrapper,
rbreak_command_wrapper): Remove.
* symtab.c (rbreak_command_wrapper): Remove.

Change-Id: If9782f205e4913f8dfc5beeaa526544f25e099c6

4 years agoRemove info_terminal_command declaration, make definition static
Simon Marchi [Tue, 26 Nov 2019 17:12:02 +0000 (12:12 -0500)] 
Remove info_terminal_command declaration, make definition static

The info_terminal_command declaration in inflow.h does not match the
current definition.  It is not needed anyway, as info_terminal_command
is only used locally, so remove it and make the definition static.

gdb/ChangeLog:

* inferior.h (info_terminal_command): Remove declaration.
* inflow.c (info_terminal_command): Make static.

Change-Id: I22c3fcc44244e3cf877b5e27eff189af11c39503

4 years agoRemove unused overload of exit_inferior_silent
Simon Marchi [Tue, 26 Nov 2019 17:12:02 +0000 (12:12 -0500)] 
Remove unused overload of exit_inferior_silent

This function is not used in the code base.

gdb/ChangeLog:

* inferior.c (exit_inferior_silent): Remove.

Change-Id: Ib2b7662744da079185ceac2a165b47590bd3113c

4 years agoRemove dict_empty/mdict_empty
Simon Marchi [Tue, 26 Nov 2019 17:12:01 +0000 (12:12 -0500)] 
Remove dict_empty/mdict_empty

These functions are not used in the code base, remove them.

gdb/ChangeLog:

* dictionary.c (dict_empty, mdict_empty): Remove.
* dictionary.c (mdict_empty): Remove.

Change-Id: I4c1b08c730f6790b2f3d28b680607618e3c08e48

4 years agoMake a bunch of functions static
Simon Marchi [Tue, 26 Nov 2019 17:12:01 +0000 (12:12 -0500)] 
Make a bunch of functions static

All these functions are only used in their respective files, they are
missing the static keyword, add them.

gdb/ChangeLog:

 * arc-tdep.c (arc_insn_get_memory_base_reg): Make static.
 (arc_insn_get_memory_offset): Likewise.
 (arc_insn_dump): Likewise.
 * cp-support.c (test_cp_symbol_name_matches): Likewise.
 * csky-linux-tdep.c (csky_supply_fregset): Likewise.
 * dictionary.c (dict_iterator_next): Likewise.
 (dict_iter_match_first): Likewise.
 (dict_iter_match_next): Likewise.
 * f-lang.c (evaluate_subexp_f): Likewise.
 * hppa-tdep.c (hppa_read_pc): Likewise.
 * i386-tdep.c (i386_floatformat_for_type): Likewise.
 * parse.c (write_exp_elt_msym): Likewise.
 * ppc-linux-tdep.c (ppc_floatformat_for_type): Likewise.
 * remote.c (remote_packet_size): Likewise.
 (remote_notif_stop_parse): Likewise.
 * rs6000-aix-tdep.c (aix_sighandle_frame_sniffer): Likewise.
 * s12z-tdep.c (s12z_disassemble_info): Likewise.
 * source.c (prepare_path_for_appending): Likewise.
 * sparc64-linux-tdep.c
 (sparc64_linux_handle_segmentation_fault); Likewise.
 * stack.c (frame_selection_by_function_completer): Likewise.

Change-Id: I18e187ad279075b961e3e22e5b034f5c0f6188f0

4 years agoRemove unused function set_gdb_completion_word_break_characters
Simon Marchi [Tue, 26 Nov 2019 17:12:01 +0000 (12:12 -0500)] 
Remove unused function set_gdb_completion_word_break_characters

gdb/ChangeLog:

* completer.c (set_gdb_completion_word_break_characters):
Remove.

Change-Id: If39b8d01f215a42ea3d01fb8290014613ec0bb8b

4 years agoAdd missing includes in dwarf-index-write.c and mi/mi-interp.c
Simon Marchi [Tue, 26 Nov 2019 17:12:00 +0000 (12:12 -0500)] 
Add missing includes in dwarf-index-write.c and mi/mi-interp.c

The following errors show that these files are missing the include of
their matching header, add them.

  CXX    dwarf-index-write.o
/home/smarchi/src/binutils-gdb/gdb/dwarf-index-write.c: In function ‘void write_psymtabs_to_index(dwarf2_per_objfile*, const char*, const char*, const char*, dw_index_kind)’:
/home/smarchi/src/binutils-gdb/gdb/dwarf-index-write.c:1670:1: error: no previous declaration for ‘void write_psymtabs_to_index(dwarf2_per_objfile*, const char*, const char*, const char*, dw_index_kind)’ [-Werror=missing-declarations]
 write_psymtabs_to_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
 ^~~~~~~~~~~~~~~~~~~~~~~

  CXX    mi/mi-interp.o
/home/smarchi/src/binutils-gdb/gdb/mi/mi-interp.c: In function ‘void mi_output_solib_attribs(ui_out*, so_list*)’:
/home/smarchi/src/binutils-gdb/gdb/mi/mi-interp.c:1030:1: error: no previous declaration for ‘void mi_output_solib_attribs(ui_out*, so_list*)’ [-Werror=missing-declarations]
 mi_output_solib_attribs (ui_out *uiout, struct so_list *solib)
 ^~~~~~~~~~~~~~~~~~~~~~~

gdb/ChangeLog:

* dwarf-index-write.c: Include dwarf-index-write.h.
* mi/mi-interp.c: Include mi/mi-interp.h.

Change-Id: I0103b8669e16e0fcaa476f8c5e96f49608157745

4 years agoInclude aarch32-tdep.h in aarch32-tdep.c
Simon Marchi [Tue, 26 Nov 2019 17:12:00 +0000 (12:12 -0500)] 
Include aarch32-tdep.h in aarch32-tdep.c

The error below shows that aarch32-tdep.c is missing an include for
aarch32-tdep.h, add it.

      CXX    aarch32-tdep.o
    /home/smarchi/src/binutils-gdb/gdb/aarch32-tdep.c: In function ‘const target_desc* aarch32_read_description()’:
    /home/smarchi/src/binutils-gdb/gdb/aarch32-tdep.c:27:1: error: no previous declaration for ‘const target_desc* aarch32_read_description()’ [-Werror=missing-declarations]
     aarch32_read_description ()
     ^~~~~~~~~~~~~~~~~~~~~~~~

Putting the include of aarch32-tdep.h early in aarch32-tdep.c gives us
an error about target_desc not being defined.  Indeed, aarch32-tdep.h
uses target_desc without forward-declaring it or including the proper
header.  Add a forward-declaration for it.

gdb/ChangeLog:

* aarch32-tdep.c: Include aarch32-tdep.h.
* aarch32-tdep.h: Forward-declare struct target_desc.

Change-Id: Ica4be4de0fbd7f22d56a29a40fbf0a31b5abdb16

4 years agoUse safe_strerror instead of strerror where possible
Christian Biesinger [Fri, 22 Nov 2019 20:31:35 +0000 (14:31 -0600)] 
Use safe_strerror instead of strerror where possible

This provides threadsafety. Unfortunately, since libinproctrace.so
does not link to gnulib, we can't use it there, especially since it
still includes the gnulib headers (so it is difficult to directly
call the system strerror_r).

gdb/ChangeLog:

2019-11-26  Christian Biesinger  <cbiesinger@google.com>

* linux-nat.c (detach_one_lwp): Call safe_strerror instead of
strerror.
* nto-procfs.c (nto_procfs_target::create_inferior): Likewise.
* windows-nat.c (windows_nat_target::create_inferior): Likewise.

gdb/gdbserver/ChangeLog:

2019-11-26  Christian Biesinger  <cbiesinger@google.com>

* debug.c (debug_set_output): Call safe_strerror instead of
strerror.
* linux-low.c (attach_proc_task_lwp_callback): Likewise.
(linux_kill_one_lwp): Likewise.
(linux_detach_one_lwp): Likewise.
(linux_wait_for_event_filtered): Likewise.
(store_register): Likewise.
* lynx-low.c (lynx_attach): Likewise.
* mem-break.c (insert_memory_breakpoint): Likewise.
(remove_memory_breakpoint): Likewise.
(delete_fast_tracepoint_jump): Likewise.
(set_fast_tracepoint_jump): Likewise.
(uninsert_fast_tracepoint_jumps_at): Likewise.
(reinsert_fast_tracepoint_jumps_at): Likewise.
* nto-low.c (nto_xfer_memory): Likewise.
(nto_resume): Likewise.

Change-Id: I9e259cdcaa6e11bbcc4ee6bdc5b7127d73e11abe

4 years agoFix gdbserver ChangeLog entry
Tom Tromey [Tue, 26 Nov 2019 17:50:01 +0000 (10:50 -0700)] 
Fix gdbserver ChangeLog entry

Christian pointed out that I had accidentally put a ChangeLog entry
into gdbserver that was meant for testsuite.

I'm checking in this patch to fix it.

Change-Id: Iba6124cea6f63539ad66494d3355fb657b78a66d

4 years agoIntroduce new .text.sorted.* sections.
Martin Liska [Wed, 18 Sep 2019 11:23:34 +0000 (13:23 +0200)] 
Introduce new .text.sorted.* sections.

gold/ChangeLog:

2019-11-26  Martin Liska  <mliska@suse.cz>

* layout.cc (Layout::special_ordering_of_input_section):
Add ".text.sorted".
* output.cc: Special case ".text.sorted".
* testsuite/section_sorting_name.cc: Cover also .text.sorted
subsections.
* testsuite/section_sorting_name.sh: Likewise.

ld/ChangeLog:

2019-11-26  Martin Liska  <mliska@suse.cz>

* scripttempl/arclinux.sc: Add .text.sorted.* which is sorted
by default.
* scripttempl/elf.sc: Likewise.
* scripttempl/elf64bpf.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* testsuite/ld-arm/arm-no-rel-plt.ld: Expect .text.sorted.*
in the default linker script.
* testsuite/ld-arm/fdpic-main.ld: Likewise.
* testsuite/ld-arm/fdpic-shared.ld: Likewise.

4 years agoFix comparison operations in SH code that trigger warning in clang.
Nick Clifton [Tue, 26 Nov 2019 14:06:12 +0000 (14:06 +0000)] 
Fix comparison operations in SH code that trigger warning in clang.

* elf32-sh.c (sh_elf_reloc): Use a signed_vma when checking for a
negative relocated value.
* coff-sh.c (sh_reloc): Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 26 Nov 2019 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years ago[gdb/contrib] Add -c option to words.sh script
Tom de Vries [Mon, 25 Nov 2019 22:00:03 +0000 (23:00 +0100)] 
[gdb/contrib] Add -c option to words.sh script

The words.sh script in its current form extracts c comments from files, which
it then transforms into a list of words.

To use the script on the documentation (as I did for commit 6b92c0d3533
"[gdb/doc] Fix typos"), I needed to disable the "extract c comments" part.

Add an option -c that enables extracting c comments, and is off by default.

gdb/ChangeLog:

2019-11-25  Tom de Vries  <tdevries@suse.de>

* contrib/words.sh: Add -c option.

Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d

4 years agoReplace int with bool in solib.c
Christian Biesinger [Fri, 15 Nov 2019 22:04:33 +0000 (14:04 -0800)] 
Replace int with bool in solib.c

This does not touch "int from_tty" and a couple of other instances
that require a bigger change.

gdb/ChangeLog:

2019-11-25  Christian Biesinger  <cbiesinger@google.com>

* solib.c (solib_find_1): Change int to bool.
(exec_file_find): Change int to bool.
(solib_find): Change int to bool.
(solib_read_symbols): Change int to bool.
(solib_used): Change int to bool.
(solib_add): Change int to bool.
(info_sharedlibrary_command): Change int to bool.
(solib_contains_address_p): Change int to bool.
(solib_keep_data_in_core): Change int to bool.
(in_solib_dynsym_resolve_code): Change int to bool.
(reload_shared_libraries_1): Change int to bool.
(gdb_sysroot_changed): Change int to bool.
* solib.h (solib_read_symbols): Change int to bool.
(solib_contains_address_p): Change int to bool.
(solib_keep_data_in_core): Change int to bool.
(in_solib_dynsym_resolve_code): Change int to bool.
(libpthread_name_p): Change int to bool.

Change-Id: Id695ed4ed0c3526af477d4d2bf585a7193c36cab

4 years agoFix "psb CSYNC" and "bti C".
Andrew Pinski [Thu, 21 Nov 2019 20:53:02 +0000 (12:53 -0800)] 
Fix "psb CSYNC" and "bti C".

psb CYSNC was not finding that CSYNC was a correct spelling.
The problem was upper case version was being put in the
wrong hashtable.  This fixes the problem by using the
correct hashtable.
Also adds testcases for the upper case versions.

        * config/tc-aarch64.c (md_begin): Use correct
        hash table for uppercase version of hint.
        * testsuite/gas/aarch64/system-2.s: Extend psb case to uppercase.
        * testsuite/gas/aarch64/system-2.d: Update.

Change-Id: If43f8b85cacd24840d596c3092b0345e5f212766

4 years ago[Debugging output] Make remote packet truncation length adjustable
Luis Machado [Mon, 25 Nov 2019 15:27:44 +0000 (12:27 -0300)] 
[Debugging output] Make remote packet truncation length  adjustable

While debugging, i felt the need to adjust the truncation length of remote
packets so i could see more or less data as needed. The default is currently
set to 512 bytes.

This patch makes this option adjustable through the new "set debug
remote-packet-max-chars" command. It can be set to unlimited if we want to
completely disable truncation.

Update on v5:

- Adjusted function and variable documentation, NEWS entry and GDB manual.

gdb/ChangeLog:

2019-11-25  Luis Machado  <luis.machado@linaro.org>

* NEWS (New Commands): Mention "set debug remote-packet-max-chars".
* remote.c (REMOTE_DEBUG_MAX_CHAR): Remove.
(remote_packet_max_chars): New static global.
(show_remote_packet_max_chars): New function.
(remote_target::putpkt_binary): Adjust to use new
remote_packet_max_chars option.
(remote_target::getpkt_or_notif_sane_1): Likewise.
(_initialize_remote): Register new remote-packet-max-chars option.

gdb/doc/ChangeLog:

2019-11-25  Luis Machado  <luis.machado@linaro.org>

* gdb.texinfo (Debugging Output): Document set debug
remote-packet-max-chars.

Change-Id: I2e871b37bfcaa6376537c3fe3db8f016dd806a7c

4 years agoPass section when available to bfd_octets_per_byte
Alan Modra [Sun, 24 Nov 2019 23:37:40 +0000 (10:07 +1030)] 
Pass section when available to bfd_octets_per_byte

and other tidies.  I think it's better to default to passing the
section to bfd_octets_per_byte, even in cases where we know it won't
make a difference.

A number of the coff reloc functions used bfd_octets_per_byte wrongly,
not factoring it into the offset into the data buffer.  As it happens,
the targets using those files always had bfd_octets_per_byte equal to
one, so there wasn't any detectable wrong behaviour.  However, it is
wrong in the source and might cause trouble for anyone creating a new
target.  Besides fixing that, the patch also defines OCTETS_PER_BYTE
as one in target files where that is appropriate.

bfd/
* archures.c (bfd_octets_per_byte): Tail call
bfd_arch_mach_octets_per_byte.
* coff-arm.c (OCTETS_PER_BYTE): Define.
(coff_arm_reloc): Introduce new "octets" temp.  Use OCTETS_PER_BYTE
with section.  Correct "addr".  Remove ATTRIBUTE_UNUSED.
* coff-i386.c (coff_i386_reloc): Similarly.
* coff-mips.c (mips_reflo_reloc): Similarly.
* coff-x86_64.c (coff_amd64_reloc): Similarly.
* elf32-msp430.c (OCTETS_PER_BYTE): Define.
(rl78_sym_diff_handler): Use OCTETS_PER_BYTE, with section.
* elf32-nds32.c (nds32_elf_get_relocated_section_contents): Similarly.
* elf32-ppc.c (ppc_elf_addr16_ha_reloc): Similarly.
* elf32-pru.c (pru_elf32_do_ldi32_relocate): Similarly.
* elf32-s12z.c (opru18_reloc): Similarly.
* elf32-sh.c (sh_elf_reloc): Similarly.
* elf32-spu.c (spu_elf_rel9): Similarly.
* elf32-xtensa.c (bfd_elf_xtensa_reloc): Similarly.
* elf64-ppc.c (ppc64_elf_ha_reloc, ppc64_elf_brtaken_reloc),
(ppc64_elf_toc64_reloc): Similarly.
* bfd.c (bfd_get_section_limit): Pass section to bfd_octets_per_byte.
* cofflink.c (_bfd_coff_link_input_bfd),
(_bfd_coff_reloc_link_order): Likewise.
* elf.c (_bfd_elf_section_offset): Likewise.
* elflink.c (resolve_section, bfd_elf_perform_complex_relocation),
(elf_link_input_bfd, elf_reloc_link_order, elf_fixup_link_order),
(bfd_elf_final_link): Likewise.
* elf.c (_bfd_elf_make_section_from_shdr): Don't strncmp twice
to set SEC_ELF_OCTETS.
* reloc.c (bfd_perform_relocation): Tidy SEC_ELF_OCTETS special case.
(bfd_install_relocation): Likewise.
(_bfd_final_link_relocate): Don't recalculate octets.
* syms.c (_bfd_stab_section_find_nearest_line): Introduc new
"octets" temp.
* bfd-in2.h: Regenerate.
ld/
* ldexp.c (fold_name): Pass section to bfd_octets_per_byte.
* ldlang.c (init_opb): Don't call bfd_arch_mach_octets_per_byte
unnecessarily.

4 years agoIntroduce new section flag: SEC_ELF_OCTETS
Christian Eggers [Thu, 21 Nov 2019 21:17:29 +0000 (22:17 +0100)] 
Introduce new section flag: SEC_ELF_OCTETS

All symbols, sizes and relocations in this section are octets instead of
bytes.  Required for DWARF debug sections as DWARF information is
organized in octets, not bytes.

bfd/
* section.c (struct bfd_section): New flag SEC_ELF_OCTETS.
* archures.c (bfd_octets_per_byte): New parameter sec.
If section is not NULL and SEC_ELF_OCTETS is set, one octet es
returned [ELF targets only].
* bfd.c (bfd_get_section_limit): Provide section parameter to
bfd_octets_per_byte.
* bfd-in2.h: regenerate.
* binary.c (binary_set_section_contents): Move call to
bfd_octets_per_byte into section loop. Provide section parameter
to bfd_octets_per_byte.
* coff-arm.c (coff_arm_reloc): Provide section parameter
to bfd_octets_per_byte.
* coff-i386.c (coff_i386_reloc): likewise.
* coff-mips.c (mips_reflo_reloc): likewise.
* coff-x86_64.c (coff_amd64_reloc): likewise.
* cofflink.c (_bfd_coff_link_input_bfd): likewise.
(_bfd_coff_reloc_link_order): likewise.
* elf.c (_bfd_elf_section_offset): likewise.
(_bfd_elf_make_section_from_shdr): likewise.
Set SEC_ELF_OCTETS for sections with names .gnu.build.attributes,
.debug*, .zdebug* and .note.gnu*.
* elf32-msp430.c (rl78_sym_diff_handler): Provide section parameter
to bfd_octets_per_byte.
* elf32-nds.c (nds32_elf_get_relocated_section_contents): likewise.
* elf32-ppc.c (ppc_elf_addr16_ha_reloc): likewise.
* elf32-pru.c (pru_elf32_do_ldi32_relocate): likewise.
* elf32-s12z.c (opru18_reloc): likewise.
* elf32-sh.c (sh_elf_reloc): likewise.
* elf32-spu.c (spu_elf_rel9): likewise.
* elf32-xtensa.c (bfd_elf_xtensa_reloc): likewise
* elf64-ppc.c (ppc64_elf_brtaken_reloc): likewise.
(ppc64_elf_addr16_ha_reloc): likewise.
(ppc64_elf_toc64_reloc): likewise.
* elflink.c (bfd_elf_final_link): likewise.
(bfd_elf_perform_complex_relocation): likewise.
(elf_fixup_link_order): likewise.
(elf_link_input_bfd): likewise.
(elf_link_sort_relocs): likewise.
(elf_reloc_link_order): likewise.
(resolve_section): likewise.
* linker.c (_bfd_generic_reloc_link_order): likewise.
(bfd_generic_define_common_symbol): likewise.
(default_data_link_order): likewise.
(default_indirect_link_order): likewise.
* srec.c (srec_set_section_contents): likewise.
(srec_write_section): likewise.
* syms.c (_bfd_stab_section_find_nearest_line): likewise.
* reloc.c (_bfd_final_link_relocate): likewise.
(bfd_generic_get_relocated_section_contents): likewise.
(bfd_install_relocation): likewise.
For section which have SEC_ELF_OCTETS set, multiply output_base
and output_offset with bfd_octets_per_byte.
(bfd_perform_relocation): likewise.
include/
* coff/ti.h (GET_SCNHDR_SIZE, PUT_SCNHDR_SIZE, GET_SCN_SCNLEN),
(PUT_SCN_SCNLEN): Adjust bfd_octets_per_byte calls.
binutils/
* objdump.c (disassemble_data): Provide section parameter to
bfd_octets_per_byte.
(dump_section): likewise
(dump_section_header): likewise. Show SEC_ELF_OCTETS flag if set.
gas/
* as.h: Define SEC_OCTETS as SEC_ELF_OCTETS if OBJ_ELF.
* dwarf2dbg.c: (dwarf2_finish): Set section flag SEC_OCTETS for
.debug_line, .debug_info, .debug_abbrev, .debug_aranges, .debug_str
and .debug_ranges sections.
* write.c (maybe_generate_build_notes): Set section flag
SEC_OCTETS for .gnu.build.attributes section.
* frags.c (frag_now_fix): Don't divide by OCTETS_PER_BYTE if
SEC_OCTETS is set.
* symbols.c (resolve_symbol_value): Likewise.
ld/
* ldexp.c (fold_name): Provide section parameter to
bfd_octets_per_byte.
* ldlang (init_opb): New argument s. Set opb_shift to 0 if
SEC_ELF_OCTETS for the current section is set.
(print_input_section): Pass current section to init_opb.
(print_data_statement,print_reloc_statement,
print_padding_statement): Likewise.
(lang_check_section_addresses): Call init_opb for each
section.
(lang_size_sections_1,lang_size_sections_1,
lang_do_assignments_1): Likewise.
(lang_process): Pass NULL to init_opb.

4 years agoReverts patches providing octet support in dwarf
Christian Eggers [Thu, 21 Nov 2019 21:17:24 +0000 (22:17 +0100)] 
Reverts patches providing octet support in dwarf

Reverts "dwarf2: Align relocation within .debug_line section"
commit 204f543cae7a5dc908264b49d558191d0ceb989c,
Reverts "dwarf2: Pad size of .debug_line section."
commit 145c4477d239fef4e31a457ff8a1ba7153e9a448,
Reverts "dwarf2: Use octets for .debug_line prologue"
commit 38c24f42c97af59ad83505ed735e689c63d3ca45,
Mostly reverts "dwarf2: Use octets for dwarf2 headers"
commit 7235427998571b6d8267e7ac72a52d7b082f4c2b,
Mostly reverts "Symbols with octets value"
commit d18d199917337537713f9fc4b7ae4d6568f740cf.

* dwarf2dbg.c (out_set_addr): Revert 2019-03-13 change.
(out_debug_line, out_debug_aranges, out_debug_info): Likewise.
* symbols.h (symbol_set_value_now_octets, symbol_octets_p): Remove.
* symbols.c (struct symbol_flags): Remove member sy_octets.
(symbol_temp_new_now_octets): Don't set symbol_flags::sy_octets.
(resolve_symbol_value): Revert: Return octets instead of bytes if
sy_octets is set.
(symbol_set_value_now_octets): Remove.
(symbol_octets_p): Remove.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Nov 2019 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoInclude gdbarch.h in m68k-linux-nat.c
Simon Marchi [Sun, 24 Nov 2019 20:04:21 +0000 (15:04 -0500)] 
Include gdbarch.h in m68k-linux-nat.c

Fix this compilation error, and a bunch of similar ones:

      CXX    m68k-linux-nat.o
    /home/smarchi/src/binutils-gdb/gdb/m68k-linux-nat.c: In function ‘void fetch_register(regcache*, int)’:
    /home/smarchi/src/binutils-gdb/gdb/m68k-linux-nat.c:133:9: error: ‘gdbarch_register_name’ was not declared in this scope
             gdbarch_register_name (gdbarch, regno),
             ^~~~~~~~~~~~~~~~~~~~~

gdb/ChangeLog:

* m68k-linux-nat.c: Include gdbarch.h.

Change-Id: I7cd47bc5d094241b2596e29c244eb55ed11f7a02

4 years agoUse bool in require_partial_symbols
Tom Tromey [Sun, 24 Nov 2019 18:12:20 +0000 (11:12 -0700)] 
Use bool in require_partial_symbols

This changes require_partial_symbols to use bool as its parameter
type.

gdb/ChangeLog
2019-11-24  Tom Tromey  <tom@tromey.com>

* symfile.c (read_symbols): Update.
* psymtab.c (require_partial_symbols): Change type of "verbose" to
bool.
(psym_map_symtabs_matching_filename, find_pc_sect_psymtab)
(psym_lookup_symbol, psym_find_last_source_symtab)
(psym_forget_cached_source_info, psym_print_stats)
(psym_expand_symtabs_for_function, psym_expand_all_symtabs)
(psym_expand_symtabs_with_fullname, psym_map_symbol_filenames)
(psym_map_matching_symbols, psym_expand_symtabs_matching)
(psym_find_compunit_symtab_by_address)
(maintenance_print_psymbols, maintenance_info_psymtabs)
(maintenance_check_psymtabs): Update.
* psymtab.h (require_partial_symbols): Change type of "verbose" to
bool.

Change-Id: Iae87aa5e4590706bb9e90a33adb86f1fe0fbf3c7

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 24 Nov 2019 00:00:56 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Nov 2019 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoRestore parameter names in observable.h
Tom Tromey [Thu, 21 Nov 2019 00:04:22 +0000 (17:04 -0700)] 
Restore parameter names in observable.h

Ages ago, when we switched observables to be templates, Joel asked me
to restore the parameter names that were used in the old
observer.texi.

I've finally done this, putting the names into comments.  I also
updated the comments in this file to use the GNU metasyntactic
variable convention as well.

gdb/ChangeLog
2019-11-22  Tom Tromey  <tom@tromey.com>

* observable.h: Update comments.

Change-Id: Id71bea7a7fcaa8f5d4491f33aa8861c56ba9c3f0

4 years agoAvoid crash in print_ada_task_info
Tom Tromey [Thu, 21 Nov 2019 16:05:10 +0000 (09:05 -0700)] 
Avoid crash in print_ada_task_info

In MI mode, print_ada_task_info can crash in find_thread_ptid when
trying to print an Ada task that is no longer alive.  This patch
avoids the problem by checking for this case.

Because this is Ada-specific, and because Joel approved it internally,
I am checking it in.

gdb/ChangeLog
2019-11-22  Tom Tromey  <tromey@adacore.com>

* ada-tasks.c (ada_task_is_alive): Make parameter const.
(print_ada_task_info): Don't try to fetch thread id if task is not
alive.

gdb/gdbserver/ChangeLog
2019-11-22  Tom Tromey  <tromey@adacore.com>

* gdb.ada/tasks.exp: Add -ada-task-info regression test.
* gdb.ada/tasks/foo.adb: Add another stopping location.

Change-Id: If25eae6507eebb7537eb8adbcbaa1fc1eec88f5c

4 years agoReplace SYMBOL_*_NAME accessors with member functions
Christian Biesinger [Fri, 22 Nov 2019 18:05:14 +0000 (12:05 -0600)] 
Replace SYMBOL_*_NAME accessors with member functions

Similar to the MSYMBOL version of this patch, improves readability
and will eventually allow making name private.

gdb/ChangeLog:

2019-11-22  Christian Biesinger  <cbiesinger@google.com>

* ada-exp.y: Update.
* ada-lang.c (sort_choices): Update.
(ada_print_symbol_signature): Update.
(resolve_subexp): Update.
(ada_parse_renaming): Update.
(ada_read_renaming_var_value): Update.
(lesseq_defined_than): Update.
(remove_extra_symbols): Update.
(remove_irrelevant_renamings): Update.
(ada_add_block_symbols): Update.
(ada_collect_symbol_completion_matches): Update.
(ada_is_renaming_symbol): Update.
(aggregate_assign_from_choices): Update.
(ada_evaluate_subexp): Update.
(ada_has_this_exception_support): Update.
(ada_is_non_standard_exception_sym): Update.
(ada_add_exceptions_from_frame): Update.
(ada_add_global_exceptions): Update.
(ada_print_subexp): Update.
* ax-gdb.c (gen_var_ref): Update.
(gen_maybe_namespace_elt): Update.
(gen_expr_for_cast): Update.
(gen_expr): Update.
* block.h: Update.
* blockframe.c (find_pc_partial_function): Update.
* breakpoint.c (print_breakpoint_location): Update.
(update_static_tracepoint): Update.
* btrace.c (ftrace_print_function_name): Update.
(ftrace_function_switched): Update.
* buildsym.c (find_symbol_in_list): Update.
* c-exp.y: Update.
* c-typeprint.c (c_print_typedef): Update.
(c_type_print_template_args): Update.
* cli/cli-cmds.c (edit_command): Update.
(list_command): Update.
(print_sal_location): Update.
* coffread.c (patch_opaque_types): Update.
(process_coff_symbol): Update.
(coff_read_enum_type): Update.
* compile/compile-c-symbols.c (c_symbol_substitution_name): Update.
(convert_one_symbol): Update.
(hash_symname): Update.
(eq_symname): Update.
* compile/compile-cplus-symbols.c (convert_one_symbol): Update.
* compile/compile-cplus-types.c (debug_print_scope): Update.
* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update.
* compile/compile-object-load.c (get_out_value_type): Update.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
(search_symbol_list): Update.
(cp_lookup_symbol_imports_or_template): Update.
* cp-support.c (overload_list_add_symbol): Update.
* ctfread.c (psymtab_to_symtab): Update.
* dbxread.c (cp_set_block_scope): Update.
* dictionary.c (iter_match_first_hashed): Update.
(iter_match_next_hashed): Update.
(insert_symbol_hashed): Update.
(iter_match_next_linear): Update.
* dictionary.h: Update.
* dwarf2loc.c (func_get_frame_base_dwarf_block): Update.
(locexpr_describe_location_piece): Update.
(locexpr_describe_location_1): Update.
(locexpr_generate_c_location): Update.
(loclist_describe_location): Update.
(loclist_generate_c_location): Update.
* dwarf2read.c (dw2_debug_names_lookup_symbol): Update.
(read_func_scope): Update.
(process_enumeration_scope): Update.
(new_symbol): Update.
(dwarf2_const_value): Update.
(dwarf2_symbol_mark_computed): Update.
* eval.c (evaluate_funcall): Update.
(evaluate_subexp_standard): Update.
* expprint.c (print_subexp_standard): Update.
(dump_subexp_body_standard): Update.
* f-valprint.c (info_common_command_for_block): Update.
* findvar.c (get_hosting_frame): Update.
(default_read_var_value): Update.
* go-lang.c (go_symbol_package_name): Update.
* guile/scm-block.c (bkscm_print_block_smob): Update.
* guile/scm-symbol.c (syscm_print_symbol_smob): Update.
(gdbscm_symbol_name): Update.
(gdbscm_symbol_linkage_name): Update.
(gdbscm_symbol_print_name): Update.
* infcall.c (get_function_name): Update.
* infcmd.c (jump_command): Update.
(finish_command): Update.
* infrun.c (insert_exception_resume_breakpoint): Update.
* linespec.c (canonicalize_linespec): Update.
(create_sals_line_offset): Update.
(convert_linespec_to_sals): Update.
(complete_label): Update.
(find_label_symbols_in_block): Update.
* m2-typeprint.c (m2_print_typedef): Update.
* mdebugread.c (mdebug_reg_to_regnum): Update.
(parse_symbol): Update.
(mylookup_symbol): Update.
* mi/mi-cmd-stack.c (list_arg_or_local): Update.
(list_args_or_locals): Update.
* objc-lang.c (compare_selectors): Update.
(info_selectors_command): Update.
(compare_classes): Update.
(info_classes_command): Update.
(find_imps): Update.
* p-typeprint.c (pascal_print_typedef): Update.
* printcmd.c (build_address_symbolic): Update.
(info_address_command): Update.
(print_variable_and_value): Update.
* python/py-framefilter.c (extract_sym): Update.
(py_print_single_arg): Update.
* python/py-symbol.c (sympy_str): Update.
(sympy_get_name): Update.
(sympy_get_linkage_name): Update.
* python/python.c (gdbpy_rbreak): Update.
* record-btrace.c (btrace_get_bfun_name): Update.
(btrace_call_history): Update.
* rust-lang.c (rust_print_typedef): Update.
* solib-frv.c (frv_fdpic_find_canonical_descriptor): Update.
* stabsread.c (stab_reg_to_regnum): Update.
(define_symbol): Update.
(read_enum_type): Update.
(common_block_end): Update.
(cleanup_undefined_types_1): Update.
(scan_file_globals): Update.
* stack.c (print_frame_arg): Update.
(print_frame_args): Update.
(find_frame_funname): Update.
(info_frame_command_core): Update.
(iterate_over_block_locals): Update.
(print_block_frame_labels): Update.
(do_print_variable_and_value): Update.
(iterate_over_block_arg_vars): Update.
(return_command): Update.
* symmisc.c (dump_symtab_1): Update.
(print_symbol): Update.
* symtab.c (eq_symbol_entry): Update.
(symbol_cache_dump): Update.
(lookup_language_this): Update.
(find_pc_sect_line): Update.
(skip_prologue_sal): Update.
(symbol_search::compare_search_syms): Update.
(treg_matches_sym_type_name): Update.
(search_symbols): Update.
(print_symbol_info): Update.
(rbreak_command): Update.
(completion_list_add_symbol): Update.
(find_gnu_ifunc): Update.
(get_symbol_address): Update.
(search_module_symbols): Update.
(info_module_subcommand): Update.
* symtab.h (SYMBOL_NATURAL_NAME): Remove.
(SYMBOL_LINKAGE_NAME): Remove.
(SYMBOL_DEMANGLED_NAME): Remove.
(SYMBOL_PRINT_NAME): Remove.
(SYMBOL_SEARCH_NAME): Remove.
* tracepoint.c (set_traceframe_context): Update.
(validate_actionline): Update.
(collection_list::collect_symbol): Update.
(encode_actions_1): Update.
(info_scope_command): Update.
(print_one_static_tracepoint_marker): Update.
* typeprint.c (typedef_hash_table::add_template_parameters): Update.
* valops.c (address_of_variable): Update.
(find_overload_match): Update.
(find_oload_champ): Update.

Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2

4 years agoReplace the MSYMBOL_*_NAME macros with member functions
Christian Biesinger [Fri, 22 Nov 2019 18:05:14 +0000 (12:05 -0600)] 
Replace the MSYMBOL_*_NAME macros with member functions

Improves readability. In the future, it will also allow making the name
private, once the name setter functions become member functions.

gdb/ChangeLog:

2019-11-22  Christian Biesinger  <cbiesinger@google.com>

* ada-lang.c (ada_lookup_simple_minsym): Update.
(ada_collect_symbol_completion_matches): Update.
* ada-tasks.c (read_atcb): Update.
* amd64-windows-tdep.c (amd64_skip_main_prologue): Update.
(amd64_windows_skip_trampoline_code): Update.
* arm-tdep.c (skip_prologue_function): Update.
(arm_skip_stack_protector): Update.
* arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update.
(arm_wince_skip_main_prologue): Update.
* ax-gdb.c (gen_expr): Update.
* block.c (call_site_for_pc): Update.
* blockframe.c (find_pc_partial_function): Update.
* breakpoint.c (set_breakpoint_location_function): Update.
* btrace.c (ftrace_print_function_name): Update.
(ftrace_function_switched): Update.
* c-valprint.c (print_unpacked_pointer): Update.
* coffread.c (coff_symfile_read): Update.
* compile/compile-c-symbols.c (convert_symbol_bmsym): Update.
* compile/compile-cplus-symbols.c (convert_symbol_bmsym): Update.
* dwarf-index-write.c (write_psymbols): Update.
* dwarf2loc.c (call_site_to_target_addr): Update.
(func_verify_no_selftailcall): Update.
(tailcall_dump): Update.
(call_site_find_chain_1): Update.
(dwarf_expr_reg_to_entry_parameter): Update.
* elfread.c (elf_gnu_ifunc_record_cache): Update.
* eval.c (evaluate_funcall): Update.
(evaluate_subexp_standard): Update.
(evaluate_subexp_for_sizeof): Update.
* expprint.c (print_subexp_standard): Update.
(dump_subexp_body_standard): Update.
* frame.c (get_prev_frame_always_1): Update.
* frv-tdep.c (frv_skip_main_prologue): Update.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Update.
* gnu-v3-abi.c (gnuv3_rtti_type): Update.
(gnuv3_get_typename_from_type_info): Update.
(gnuv3_skip_trampoline): Update.
* hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update.
* i386-tdep.c (i386_skip_main_prologue): Update.
(i386_pe_skip_trampoline_code): Update.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update.
* infcall.c (get_function_name): Update.
* linespec.c (minsym_found): Update.
* linux-fork.c (info_checkpoints_command): Update.
* m32c-tdep.c (m32c_m16c_address_to_pointer): Update.
(m32c_m16c_pointer_to_address): Update.
* maint.c (maintenance_translate_address): Update.
* minsyms.c (add_minsym_to_hash_table): Update.
(add_minsym_to_demangled_hash_table): Update.
(lookup_minimal_symbol_mangled): Update.
(lookup_minimal_symbol_demangled): Update.
(lookup_minimal_symbol_linkage): Update.
(lookup_minimal_symbol_text): Update.
(lookup_minimal_symbol_by_pc_name): Update.
(minimal_symbol_is_less_than): Update.
(compact_minimal_symbols): Update.
(build_minimal_symbol_hash_tables): Update.
(find_solib_trampoline_target): Update.
* mips-tdep.c (mips_stub_frame_sniffer): Update.
(mips_skip_pic_trampoline_code): Update.
* msp430-tdep.c (msp430_skip_trampoline_code): Update.
* objc-lang.c (info_selectors_command): Update.
(info_classes_command): Update.
(find_methods): Update.
(find_imps): Update.
* p-valprint.c (pascal_val_print): Update.
* ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code): Update.
* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
* printcmd.c (build_address_symbolic): Update.
(info_symbol_command): Update.
* psymtab.c (psymbol_name_matches): Update.
(match_partial_symbol): Update.
(lookup_partial_symbol): Update.
(print_partial_symbols): Update.
(sort_pst_symbols): Update.
(maintenance_check_psymtabs): Update.
* python/py-framefilter.c (py_print_frame): Update.
* python/python.c (gdbpy_rbreak): Update.
* record-btrace.c (btrace_get_bfun_name): Update.
(btrace_call_history): Update.
* rs6000-tdep.c (rs6000_skip_main_prologue): Update.
(rs6000_skip_trampoline_code): Update.
* sol-thread.c (info_cb): Update.
* stabsread.c (scan_file_globals): Update.
* stack.c (find_frame_funname): Update.
(info_frame_command_core): Update.
* symmisc.c (dump_msymbols): Update.
* symtab.c (symbol_natural_name): Rename to..,
(general_symbol_info::natural_name): ...this.
(symbol_demangled_name): Rename to...
(general_symbol_info::demangled_name): ...this.
(symbol_search_name): Rename to...
(general_symbol_info::search_name): ...this.
(symbol_matches_search_name): Update.
(find_pc_sect_line): Update.
(skip_prologue_sal): Update.
(search_symbols): Update.
(print_msymbol_info): Update.
(rbreak_command): Update.
(completion_list_add_msymbol): Update.
(completion_list_objc_symbol): Update.
(get_msymbol_address): Update.
* symtab.h (struct general_symbol_info): Add member functions
natural_name (), linkage_name (), print_name (), demangled_name (),
and search_name ().
(SYMBOL_NATURAL_NAME): Update.
(symbol_natural_name): Move to a member function on general_symbol_info.
(SYMBOL_DEMANGLED_NAME): Update.
(symbol_demangled_name): Move to a member function on
general_symbol_info.
(SYMBOL_SEARCH_NAME): Update.
(symbol_search_name): Move to a member function on general_symbol_info.
(MSYMBOL_NATURAL_NAME): Remove.
(MSYMBOL_LINKAGE_NAME): Remove.
(MSYMBOL_PRINT_NAME): Remove.
(MSYMBOL_DEMANGLED_NAME): Remove.
(MSYMBOL_SEARCH_NAME): Remove.
* x86-tdep.c (x86_in_indirect_branch_thunk): Update.

Change-Id: I65aa529843a9903e174ce799037e41f954a9fcee

4 years agoCreate a correctly-sized demangled names hashtable
Christian Biesinger [Mon, 18 Nov 2019 22:37:31 +0000 (16:37 -0600)] 
Create a correctly-sized demangled names hashtable

If we have a minsym count, we know the demangled names hashtable will
be at least that big.  So use that count to size it, so we don't
have to resize/rehash it as much.

This is a 6% improvement in minsym loading time.

2019-11-22  Christian Biesinger  <cbiesinger@google.com>

* symtab.c (create_demangled_names_hash): Use per_bfd->
minimal_symbol_count for computing the initial size, if greater
than our default size.

Change-Id: I1f074d38e1d90af58705ec852f90c84cc034cd2e

4 years ago[gdb/contrib] Improve words extraction in words.sh script
Tom de Vries [Fri, 22 Nov 2019 15:23:22 +0000 (16:23 +0100)] 
[gdb/contrib] Improve words extraction in words.sh script

Remove more punctuation and quoting in words.sh script.

gdb/ChangeLog:

2019-11-22  Tom de Vries  <tdevries@suse.de>

* contrib/words.sh: Improve words extraction.

Change-Id: I1d9eea165731af4e6c4e1c7e09aed9b07af6395c

4 years ago[gdb/contrib] Combine sed invocations in words.sh script
Tom de Vries [Fri, 22 Nov 2019 15:23:22 +0000 (16:23 +0100)] 
[gdb/contrib] Combine sed invocations in words.sh script

Currently running words.sh on all the c source and header files in the repo
takes ~16s in user time:
...
$ time ./gdb/contrib/words.sh \
    $(find -type f -name "*.c" -o -name "*.h") \
    >/dev/null

real    0m7,787s
user    0m16,349s
sys     0m0,367s
...

Rewrite the sed invocations using the -e option from this:
...
   | sed <sedprog1>
   | sed <sedprog2>
...
into this:
...
   | sed \
       -e <sedprog1>
       -e <sedprog2>
...
and reduce user time to ~11s:
...
$ time ./gdb/contrib/words.sh \
    $(find -type f -name "*.c" -o -name "*.h") \
    >/dev/null

real    0m7,243s
user    0m11,220s
sys     0m0,205s
...

gdb/ChangeLog:

2019-11-22  Tom de Vries  <tdevries@suse.de>

* contrib/words.sh: Combine sed invocations.

Change-Id: Ib08453f3712f32ed02d9f503ee960711ebb9421b

4 years agoArm: Change CRC from fpu feature to archititectural extension
Mihail Ionescu [Fri, 22 Nov 2019 13:44:17 +0000 (13:44 +0000)] 
Arm: Change CRC from fpu feature to archititectural extension

This patch changes the CRC extension to use the core feature bits instead
of the coproc/fpu feature bits.
CRC is not an fpu feature and it causes issues with the new fpu reset
patch (f439988037a589de3798f44e7268301adaec21a9). CRC can be set using
the '.arch_extension' directive, which sets bits in the coproc bitfield. When
a '.fpu' directive is encountered, the CRC feature bit gets removed and
there is no way to set it back using '.fpu'.
With this patch, CRC will be marked in the feature core bits, which prevents
it from getting removed when setting/changing the fpu options.

gas/ChangeLog:

* config/tc-arm.c (arm_ext_crc): New.
(crc_ext_armv8): Remove.
(insns): Rename crc_ext_armv8 to arm_ext_crc.
(arm_cpus): Replace CRC_EXT_ARMV8 with ARM_EXT2_CRC.
(armv8a_ext_table, armv8r_ext_table,
arm_option_extension_value_table): Redefine the crc
extension in terms of ARM_EXT2_CRC.
* gas/testsuite/gas/arm/crc-ext.s: New.
* gas/testsuite/gas/arm/crc-ext.d: New.

include/ChangeLog:

* opcode/arm.h (ARM_EXT2_CRC): New extension feature
to replace CRC_EXT_ARMV8.
(CRC_EXT_ARMV8): Remove and mark bit as unused.
(ARM_ARCH_V8A_CRC, ARM_ARCH_V8_1A, ARM_ARCH_V8_2A,
ARM_ARCH_V8_3A, ARM_ARCH_V8_4A, ARM_ARCH_V8_5A,
ARM_ARCH_V8_6A): Redefine using ARM_EXT2_CRC instead of
CRC_EXT_ARMV8.

opcodes/ChangeLog:

* opcodes/arm-dis.c (arm_opcodes, thumb32_opcodes):
Change the coproc CRC conditions to use the extension
feature set, second word, base on ARM_EXT2_CRC.

4 years agoUpdate the linker documentation regarding the /DISCARD/ linker script section and...
Nick Clifton [Fri, 22 Nov 2019 13:24:58 +0000 (13:24 +0000)] 
Update the linker documentation regarding the /DISCARD/ linker script section and its interaction with ELF section groups.

* ld.texi (Output Section Discarding): Add note indicating that
/DISCARD/ed sections ignore ELF section grouping.

4 years agoReplace unnecessary null check with a cast.
Nick Clifton [Fri, 22 Nov 2019 13:12:01 +0000 (13:12 +0000)] 
Replace unnecessary null check with a cast.

* ldlang.h (LANG_FOR_EACH_INPUT_STATEMENT): Use cast instead of
extra check.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 22 Nov 2019 00:00:14 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoRename demangle.c to gdb-demangle.c, and some cleanup
Christian Biesinger [Thu, 21 Nov 2019 19:02:07 +0000 (13:02 -0600)] 
Rename demangle.c to gdb-demangle.c, and some cleanup

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

4 years agoHandle %I64d in format_pieces
Tom Tromey [Thu, 14 Nov 2019 22:00:19 +0000 (15:00 -0700)] 
Handle %I64d in format_pieces

We found a bug internally where gdb would crash while disassembling a
certain instruction.  This was tracked down to the handling of %I64d
in format_pieces.

format_pieces will convert %ll to %I64d on mingw -- so format_pieces
should also handle parsing this format.  In this patch, I've made the
parsing unconditional, since I think it is harmless to accept extra
formats.  I've also taken the opportunity to convert the length
modifier test to a "switch".

Tested internally using our failing test case.

gdb/ChangeLog
2019-11-21  Tom Tromey  <tromey@adacore.com>

* gdbsupport/format.c (format_pieces): Parse %I64d.
* unittests/format_pieces-selftests.c (test_windows_formats): New
function.
(run_tests): Call it.

Change-Id: If335c7c2fc8d01e629cd55182394a483334d79c7

4 years agoAdjust byte order variable display/change if DW_AT_endianity is present.
Peeter Joot [Fri, 6 Oct 2017 20:13:04 +0000 (16:13 -0400)] 
Adjust byte order variable display/change if DW_AT_endianity is present.

- Rationale:
It is possible for compilers to indicate the desired byte order
interpretation of scalar variables using the DWARF attribute:
   DW_AT_endianity

A type flagged with this variable would typically use one of:
   DW_END_big
   DW_END_little
which instructs the debugger what the desired byte order interpretation
of the variable should be.

The GCC compiler (as of V6) has a mechanism for setting the desired byte
ordering of the fields within a structure or union.  For, example, on a
little endian target, a structure declared as:
   struct big {
       int v;
       short a[4];
   } __attribute__( ( scalar_storage_order( "big-endian" ) ) );
could be used to ensure all the structure members have a big-endian
interpretation (the compiler would automatically insert byte swap
instructions before and after respective store and load instructions).

- To reproduce
GCC V8 is required to correctly emit DW_AT_endianity DWARF attributes
in all situations when the scalar_storage_order attribute is used.

A fix for (dwarf endianity instrumentation) for GCC V6-V7 can be found
in the URL field of the following PR:
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509

- Test-case:
A new test case (testsuite/gdb.base/endianity.*) is included with this
patch.

Manual testing for mixed endianity code has also been done with GCC V8.
See:
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509#c4

- Observed vs. expected:

Without this change, using scalar_storage_order that doesn't match the
target, such as

struct otherendian
{
  int v;
} __attribute__( ( scalar_storage_order( "big-endian" ) ) );

would behave like the following on a little endian target:

   Breakpoint 1 at 0x401135: file endianity.c, line 41.
   (gdb) run
   Starting program: /home/pjoot/freeware/t/a.out
   Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64

   Breakpoint 1, main () at endianity.c:41
   41        struct otherendian o = {3};
   (gdb) n
   43        do_nothing (&o); /* START */
   (gdb) p o
   $1 = {v = 50331648}
   (gdb) p /x
   $2 = {v = 0x3000000}

whereas with this gdb enhancement we can access the variable with the user
specified endianity:

   Breakpoint 1, main () at endianity.c:41
   41        struct otherendian o = {3};
   (gdb) p o
   $1 = {v = 0}
   (gdb) n
   43        do_nothing (&o); /* START */
   (gdb) p o
   $2 = {v = 3}
   (gdb) p o.v = 4
   $3 = 4
   (gdb) p o.v
   $4 = 4
   (gdb) x/4xb &o.v
   0x7fffffffd90c: 0x00    0x00    0x00    0x04

(observe that the 4 byte int variable has a big endian representation in the
 hex dump.)

gdb/ChangeLog
2019-11-21  Peeter Joot  <peeter.joot@lzlabs.com>

Byte reverse display of variables with DW_END_big, DW_END_little
(DW_AT_endianity) dwarf attributes if different than the native
byte order.
* ada-lang.c (ada_value_binop):
Use type_byte_order instead of gdbarch_byte_order.
* ada-valprint.c (printstr):
(ada_val_print_string):
* ada-lang.c (value_pointer):
(ada_value_binop):
Use type_byte_order instead of gdbarch_byte_order.
* c-lang.c (c_get_string):
Use type_byte_order instead of gdbarch_byte_order.
* c-valprint.c (c_val_print_array):
Use type_byte_order instead of gdbarch_byte_order.
* cp-valprint.c (cp_print_class_member):
Use type_byte_order instead of gdbarch_byte_order.
* dwarf2loc.c (rw_pieced_value):
Use type_byte_order instead of gdbarch_byte_order.
* dwarf2read.c (read_base_type): Handle DW_END_big,
DW_END_little
* f-lang.c (f_get_encoding):
Use type_byte_order instead of gdbarch_byte_order.
* findvar.c (default_read_var_value):
Use type_byte_order instead of gdbarch_byte_order.
* gdbtypes.c (check_types_equal):
Require matching TYPE_ENDIANITY_NOT_DEFAULT if set.
(recursive_dump_type): Print TYPE_ENDIANITY_BIG,
and TYPE_ENDIANITY_LITTLE if set.
(type_byte_order): new function.
* gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): New macro.
(struct main_type) <flag_endianity_not_default>:
New field.
(type_byte_order): New function.
* infcmd.c (default_print_one_register_info):
Use type_byte_order instead of gdbarch_byte_order.
* p-lang.c (pascal_printstr):
Use type_byte_order instead of gdbarch_byte_order.
* p-valprint.c (pascal_val_print):
Use type_byte_order instead of gdbarch_byte_order.
* printcmd.c (print_scalar_formatted):
Use type_byte_order instead of gdbarch_byte_order.
* solib-darwin.c (darwin_current_sos):
Use type_byte_order instead of gdbarch_byte_order.
* solib-svr4.c (solib_svr4_r_ldsomap):
Use type_byte_order instead of gdbarch_byte_order.
* stap-probe.c (stap_modify_semaphore):
Use type_byte_order instead of gdbarch_byte_order.
* target-float.c (target_float_same_format_p):
Use type_byte_order instead of gdbarch_byte_order.
* valarith.c (scalar_binop):
(value_bit_index):
Use type_byte_order instead of gdbarch_byte_order.
* valops.c (value_cast):
Use type_byte_order instead of gdbarch_byte_order.
* valprint.c (generic_emit_char):
(generic_printstr):
(val_print_string):
Use type_byte_order instead of gdbarch_byte_order.
* value.c (unpack_long):
(unpack_bits_as_long):
(unpack_value_bitfield):
(modify_field):
(pack_long):
(pack_unsigned_long):
Use type_byte_order instead of gdbarch_byte_order.
* findvar.c (unsigned_pointer_to_address):
(signed_pointer_to_address):
(unsigned_address_to_pointer):
(address_to_signed_pointer):
(default_read_var_value):
(default_value_from_register):
Use type_byte_order instead of gdbarch_byte_order.
* gnu-v3-abi.c (gnuv3_make_method_ptr):
Use type_byte_order instead of gdbarch_byte_order.
* riscv-tdep.c (riscv_print_one_register_info):
Use type_byte_order instead of gdbarch_byte_order.

gdb/testsuite/ChangeLog
2019-11-21  Peeter Joot  <peeter.joot@lzlabs.com>

* gdb.base/endianity.c: New test.
* gdb.base/endianity.exp: New file.

Change-Id: I4bd98c1b4508c2d7c5a5dbb15d7b7b1cb4e667e2

4 years agoFix potentially undefined behaviour in the linker when parsing input statements.
Nick Clifton [Thu, 21 Nov 2019 17:02:40 +0000 (17:02 +0000)] 
Fix potentially undefined behaviour in the linker when parsing input statements.

* ldlang.h (LANG_FOR_EACH_INPUT_STATEMENT): Check for an empty
file chain before examining the first input statement.

4 years agogdb/testsuite: skip gdb.arch/amd64-eval.exp when target is not x86_64
Lukas Durfina [Thu, 21 Nov 2019 07:37:28 +0000 (08:37 +0100)] 
gdb/testsuite: skip gdb.arch/amd64-eval.exp when target is not x86_64

4 years agogdb: remove gen_ret_current_ui_field_ptr
Simon Marchi [Thu, 21 Nov 2019 14:32:15 +0000 (09:32 -0500)] 
gdb: remove gen_ret_current_ui_field_ptr

I think it would be clearer to not use gen_ret_current_ui_field_ptr to
generate the implementation of current_ui_gdb_stdout_ptr et al.  It
doesn't save much code, but adds a layer of complexity for the reader.
Plus, it doesn't work well with IDEs, for example if you ask to find all
usages the m_gdb_stdout field.

gdb/ChangeLog:

* top.c (current_ui_gdb_stdout_ptr): Spell out by hand.
(current_ui_gdb_stdin_ptr): Likewise.
(current_ui_gdb_stderr_ptr): Likewise.
(current_ui_gdb_stdlog_ptr): Likewise.
(current_ui_current_uiout_ptr): Likewise.
(gen_ret_current_ui_field_ptr): Remove.

Change-Id: I86f821c9d119453701caedf0e47124ccddfbab2d

4 years agoPR273, SOM size -A
Alan Modra [Thu, 21 Nov 2019 10:14:54 +0000 (20:44 +1030)] 
PR273, SOM size -A

The SOM backend creates BFD sections for "spaces", and "sub-spaces".
"sub-spaces" are what we normally think of as a section, "spaces"
aggregate "sub-spaces".  Thus it does not really make sense to include
"spaces" for size -A since that would double count total size.

It so happens that real sections ought to have at least one of the
ALLOC and HAS_CONTENTS flags set, so this patch excludes "spaces" but
excluding BFD sections with no flags set.

PR 273
* size.c (sysv_internal_sizer, sysv_internal_printer): Exclude
sections with no flag bits set.
* testsuite/binutils-all/size.exp: Allow $CODE$ as a text section.

4 years agoFix potential buffer overrun in objcopy's note merging code.
Nick Clifton [Thu, 21 Nov 2019 10:54:20 +0000 (10:54 +0000)] 
Fix potential buffer overrun in objcopy's note merging code.

* objcopy.c (merge_gnu_build_notes): Allow for the possibility
that the new notes might actually be larger than the original
notes.

4 years agoARM cmse_scan segfault
Alan Modra [Wed, 20 Nov 2019 22:27:00 +0000 (08:57 +1030)] 
ARM cmse_scan segfault

This code in elf_link_add_object_symbols:

      ret = elf_add_dt_needed_tag (abfd, info, soname, add_needed);
      if (ret < 0)
goto error_return;

      /* If we have already included this dynamic object in the
 link, just ignore it.  There is no reason to include a
 particular dynamic object more than once.  */
      if (ret > 0)
return TRUE;

prevents a shared library from being loaded twice by ensuring that any
library soname doesn't match the soname of one already loaded.  This
happens before sym_hashes are allocated, which leaves sym_hashes NULL.

cmse_scan looks at library symbols, and when attempting to look up a
global symbol will segfault if sym_hashes is zero.

* elf32-arm.c (elf32_arm_size_stubs): Exclude dynamic library
BFDs that have not been loaded.

4 years ago[gdb] Only force INTERP_CONSOLE ui_out for breakpoint commands in MI mode
Tom de Vries [Thu, 21 Nov 2019 10:02:27 +0000 (11:02 +0100)] 
[gdb] Only force INTERP_CONSOLE ui_out for breakpoint commands in MI mode

The problem reported in PR mi/25055 is that the output of the backtrace
command, when executed as breakpoint command does not show when executing
using the MI interpreter:
...
$ gdb a.out
Reading symbols from a.out...
(gdb) break main
Breakpoint 1 at 0x4003c0: file test.c, line 19.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>bt
>end
(gdb) interpreter-exec mi "-exec-run"
^done

Breakpoint 1, main () at test.c:19
19        return foo (4);
(gdb)
...

Interestingly, the function print_frame is called twice during -exec-run:
- once during tui_on_normal_stop where the ui_out is temporarily set to
  tui->interp_ui_out (), resulting in the part after the comma in
  "Breakpoint 1, main () at test.c:19"
- once during execute_control_command, where the ui_out is the default for the
  current interpreter: mi_ui_out, which ignores calls to output text.

The commit 3a87ae656c2 "Use console uiout when executing breakpoint commands"
fixes the problem by temporarily switching to the ui_out of INTERP_CONSOLE in
execute_control_command.

This however caused a regression in redirection (escaping '#' using '\' for
git commit message convenience):
...
$ rm -f gdb.txt; gdb a.out
Reading symbols from a.out...
(gdb) break main
Breakpoint 1 at 0x4003c0: file test.c, line 19.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>bt
>end
(gdb) set logging redirect on
(gdb) set logging on
Redirecting output to gdb.txt.
Copying debug output to gdb.txt.
(gdb) run
\#0  main () at test.c:19
(gdb) q
A debugging session is active.

        Inferior 1 [process 22428] will be killed.

Quit anyway? (y or n) y
$ cat gdb.txt
Starting program: /data/gdb_versions/devel/a.out

Breakpoint 1, main () at test.c:19
19        return foo (4);
...

The problem is that the '#0  main () at test.c:19' ends up in the gdb output
output rather than in gdb.txt.  This is due to the fact that the redirect is
setup for the current ui_out (which is tui->interp_ui_out ()), while the
backtrace output is printed to the INTERP_CONSOLE ui_out.

Fix this by limiting switching to INTERP_CONSOLE ui_out to when INTERP_MI is
active.

Tested on x86_64-linux.

gdb/ChangeLog:

2019-11-21  Tom de Vries  <tdevries@suse.de>

PR gdb/24956
* cli/cli-script.c (execute_control_command): Only switch to
INTERP_CONSOLE's ui_out when INTERP_MI is active.

gdb/testsuite/ChangeLog:

2019-11-21  Tom de Vries  <tdevries@suse.de>

PR gdb/24956
* gdb.base/ui-redirect.exp: Test output of user-defined command.

Change-Id: Id1771e7fcc9496a7d97ec2b2ea6b1487596f1ef7

4 years agoPR46, cygwin: FAIL: cdtest with -Ur
Alan Modra [Thu, 21 Nov 2019 06:52:41 +0000 (17:22 +1030)] 
PR46, cygwin: FAIL: cdtest with -Ur

See the comment in pe.sc to understand why ld -Ur won't work.

PR 46
binutils/
* testsuite/lib/binutils-common.exp (is_pecoff_format): Rewrite
with positive logic and add more target triples.
ld/
* scripttempl/pe.sc: Comment on ld -Ur fail.  Wrap .gcc_exc comment.
* scripttempl/pep.sc: Likewise.
* testsuite/ld-cdtest/cdtest.exp (test2): xfail for pe.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Nov 2019 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoAdd missing parentheses on 'print' (gdb.python/py-progspace.exp)
Sergio Durigan Junior [Wed, 20 Nov 2019 21:31:35 +0000 (16:31 -0500)] 
Add missing parentheses on 'print' (gdb.python/py-progspace.exp)

Commit 33d569b709886a1208145806da80b689d9cae9da ("gdb/python: Return
None from Progspace.block_for_pc on error") added a few tests on
gdb.python/py-progspace.exp which use 'print', but forgot to use
parentheses when passing the arguments to be printed.  This fails on
Python 3.

This commit adds these missing parentheses.  Pushed as obvious.

gdb/testsuite/ChangeLog:
2019-11-20  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.python/py-progspace.exp: Add missing parentheses on some
'print' commands.

Change-Id: Iac0a7578855d128bbee3b98e7ea5888dae55fc00

4 years agoImprove target description check for SVE in gdbserver
Luis Machado [Mon, 18 Nov 2019 19:36:53 +0000 (16:36 -0300)] 
Improve target description check for SVE in gdbserver

The current code checks for the presence of a SVE target description by
comparing the number of registers.  This is a bit fragile since the number
of registers can change whenever we add new sets. Like PAC, for example.

If the comparison breaks, then we're left with SVE registers in the
description, but gdbserver doesn't send the registers to GDB, which in
turn displays stale information to the user.

The following patch changes the check to use the SVE feature string instead,
which hopefully should be more stable.

gdb/gdbserver/ChangeLog:

2019-11-20  Luis Machado  <luis.machado@linaro.org>

* linux-aarch64-low.c (is_sve_tdesc): Check against target feature
instead of register count.
* tdesc.c (tdesc_contains_feature): New function.
* tdesc.h (tdesc_contains_feature): New prototype.

Change-Id: I28b782cb1677560ca9a06a1be442974b25aabae4

4 years agoPR24944, gas doesn't read enough digits when parsing a floating point number
Alan Modra [Wed, 20 Nov 2019 11:24:07 +0000 (21:54 +1030)] 
PR24944, gas doesn't read enough digits when parsing a floating point number

PR 24944
* atof-generic.c (atof_generic): Increase decimal guard digits.
* testsuite/gas/i386/fp.s: Add more tests.
* testsuite/gas/i386/fp.d: Update.

4 years agocpu: fix comment in bpf.cpu
Jose E. Marchesi [Wed, 20 Nov 2019 09:16:24 +0000 (10:16 +0100)] 
cpu: fix comment in bpf.cpu

2019-11-20  Jose E. Marchesi  <jose.marchesi@oracle.com>

* bpf.cpu: Fix comment describing the 128-bit instruction format.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 20 Nov 2019 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoFix the "winheight" command
Tom Tromey [Sat, 26 Oct 2019 22:56:27 +0000 (16:56 -0600)] 
Fix the "winheight" command

The "winheight" command is broken.  I probably broke it in one of my
TUI refactoring patches, though I didn't track down exactly which one.

The bug is that the code does:

  *buf_ptr = '\0';

... but then never advances buf_ptr past this point, so no window name
is seen.

This patch refactors the code a bit so that a copy of the argument
string is not needed, also fixing the bug.

A new test case is included.

gdb/ChangeLog
2019-11-19  Tom Tromey  <tom@tromey.com>

* tui/tui-win.c (tui_partial_win_by_name): Move from tui-data.c.
Now static.  Change type of "name".
(tui_set_win_height_command): Don't copy "arg".
* tui/tui-data.h (tui_partial_win_by_name): Don't declare.
* tui/tui-data.c (tui_partial_win_by_name): Move to tui-win.c.

gdb/testsuite/ChangeLog
2019-11-19  Tom Tromey  <tom@tromey.com>

* gdb.tui/winheight.exp: New file.

Change-Id: I0871e93777a70036dbec9c9543f862f42e3a81e5

4 years agoReplace "if (attr)" with "if (attr != nullptr)".
Ali Tamur [Tue, 19 Nov 2019 03:22:05 +0000 (19:22 -0800)] 
Replace "if (attr)" with "if (attr != nullptr)".

This is a cleanup patch in response to a reviewer comment on "Dwarf 5: Handle
debug_str_offsets" patch.

4 years agoReport GetLastError value when DebugActiveProcess fails
Tom Tromey [Wed, 6 Nov 2019 16:43:52 +0000 (09:43 -0700)] 
Report GetLastError value when DebugActiveProcess fails

When DebugActiveProcess fails, the error message is fairly generic:

    error (_("Can't attach to process."));

It would be more useful for diagnosing problems if the Windows error
code was included in the message.  This patch implements this.

gdb/ChangeLog
2019-11-19  Tom Tromey  <tromey@adacore.com>

* windows-nat.c (windows_nat_target::attach): Include GetLastError
result in error when DebugActiveProcess fails.

Change-Id: Ie1bf502a0d96bb7c09bd5b1c5e0c924ba58cd68c

4 years agoPR24499, ignore --add-gnu-debuglink for archives
Alan Modra [Tue, 19 Nov 2019 10:49:24 +0000 (21:19 +1030)] 
PR24499, ignore --add-gnu-debuglink for archives

objcopy --add-gnu-debuglink=foo.a.dbg foo.a just doesn't make any
sense.  Who puts executables in archives?

PR 24499
* objcopy.c (copy_file): Ignore --add-gnu-debuglink for archives.

4 years agoPR24968, make objcopy use output ELF arch if -B not given
Alan Modra [Tue, 19 Nov 2019 08:45:20 +0000 (19:15 +1030)] 
PR24968, make objcopy use output ELF arch if -B not given

This should make objcopy -B redundant for the common case of producing
ELF output where the -O target defaults to the desired arch:mach.

PR 24968
* objcopy.c (copy_object): For ELF output and non-ELF input without
arch, take arch from output file if not given by -B.  Don't
bfd_get_arch_info when we already have iarch.

4 years agoPR25191, internal error in _bfd_elf_set_section_contents
Alan Modra [Tue, 19 Nov 2019 04:23:44 +0000 (14:53 +1030)] 
PR25191, internal error in _bfd_elf_set_section_contents

This PR copies a fuzzed PE input file to ELF output, in the process
confusing the ELF backend by copying COFF-only section flags to the
output.  SEC_COFF_SHARED has the same value as SEC_ELF_COMPRESS.  One
approach to fixing this problem is of course not to reuse flag bits,
but we've run out.  So this patch only copies section flags that are
in the bfd_applicable_section_flags set when changing the flavour of
the output file.

PR 25191
* objcopy.c (is_nondebug_keep_contents_section): Use bfd_get_flavour.
(copy_object): Likewise.
(setup_section): Likewise.  If flavour of input and output files
differ, restrict section flags to the intersection of input and
output bfd_applicable_section_flags.

4 years agoPR25197, assertion fail coffgen.c
Alan Modra [Tue, 19 Nov 2019 01:08:36 +0000 (11:38 +1030)] 
PR25197, assertion fail coffgen.c

The testcase in this PR triggered "BFD_ASSERT (p2->is_sym)" by
sneakily generating a C_FILE sym whose value pointed into auxents.
The fix then is in the last changed line of this patch, to check
p->is_sym as well as p->u.syment.n_sclass.  The other changes fix
various overflow checks that weren't as solid as they could be.

PR 25197
* coffgen.c (coff_find_nearest_line_with_names): Check that C_FILE
u.syment.n_value does point at another C_FILE sym and not into
some auxent that happens to look like a C_FILE.  Properly check
for integer overflow and avoid possible pointer wrap-around.
Simplify pr17512 checks.

4 years agoAdd space between program name and file for objcopy/strip/objdump messages
Alan Modra [Mon, 18 Nov 2019 21:36:24 +0000 (08:06 +1030)] 
Add space between program name and file for objcopy/strip/objdump messages

The GNU coding standard does indicate there should be no space in
messages like these, but we tend to put a space in all other
messages.  This patch cures the inconsistency in:

$ binutils/strip-new -F elf32-little -N .text -o pr25200 pr25200.bin
binutils/strip-new: pr25200: R_X86_64_PLT32 unsupported
binutils/strip-new:pr25200: sorry, cannot handle this file

* bucomm.c (bfd_nonfatal_message): Add a space between program
name and file.

4 years agogdb/testsuite: Merge whatis.exp and ctf-whatis.exp
Andrew Burgess [Tue, 15 Oct 2019 21:58:08 +0000 (22:58 +0100)] 
gdb/testsuite: Merge whatis.exp and ctf-whatis.exp

The recently added gdb.base/ctf-whatis.exp test is a slightly modified
version of gdb.base/whatis.exp, with a few tests removed, and the
source compiled with different compiler options.  This patch merges
the two tests together into a single test script.

I tested using a version of GCC with CTF support added.

gdb/testsuite/ChangeLog:

* gdb.base/ctf-whatis.c: Delete.
* gdb.base/ctf-whatis.exp: Delete.
* gdb.base/whatis.exp: Rewrite to compile as both dwarf and ctf.

Change-Id: I09e11c70f197b79d2b1e0ae8c86a21c622be6c51

4 years agogdb/testsuite: Merge cvexpr.exp and ctf-cvexpr.exp
Andrew Burgess [Tue, 8 Oct 2019 09:13:54 +0000 (10:13 +0100)] 
gdb/testsuite: Merge cvexpr.exp and ctf-cvexpr.exp

The recently added gdb.base/ctf-cvexpr.exp is just a copy of
gdb.base/cvexpr.exp but compiled with different options.  This patch
merges these two tests together into a single test script.

I tested this change using a version of GCC with CTF support added.

gdb/testsuite/ChangeLog:

* gdb.base/ctf-cvexpr.exp: Delete.
* gdb.base/cvexpr.exp: Rewrite to compile as both dwarf and ctf.

Change-Id: If678c3e38cb444867defa970203d26563f15dba4

4 years agogdb/testsuite: Introduce skip_ctf_tests guard function
Andrew Burgess [Tue, 8 Oct 2019 09:09:31 +0000 (10:09 +0100)] 
gdb/testsuite: Introduce skip_ctf_tests guard function

Most versions of GCC in the wild don't support CTF debug format right
now, so, rather than attempting to compile the tests and failing each
time, this patch introduces a guard function to check if the compiler
supports CTF.  If we don't have CTF support then the CTF tests are
skipped.

This patch only updates 3 of the 4 CTF tests, the fourth will be
handled in the next patch.

gdb/testsuite/ChangeLog:

* gdb.base/ctf-constvars.exp: Skip test if CTF is not supported in
the compiler.  Clean up header comment a little.
* gdb.base/ctf-ptype.exp: Likewise.
* gdb.base/ctf-whatis.exp: Likewise.
* lib/gdb.exp (skip_ctf_tests): New proc.

Change-Id: I505c11169a9bc9871a31fc0c61e119f92f32cc63

4 years agoFix crash with core + TUI + run
Sergio Durigan Junior [Wed, 30 Oct 2019 17:58:29 +0000 (13:58 -0400)] 
Fix crash with core + TUI + run

Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1765117

A segfault can happen in a specific scenario when using TUI + a
corefile, as explained in the bug mentioned above.  The problem
happens when opening a corefile on GDB:

  $ gdb ./core program

entering TUI (C-x a), and then issuing a "run" command.  GDB segfaults
with the following stack trace:

  (top-gdb) bt
  #0  0x00000000004cd5da in target_ops::shortname (this=0x0) at ../../binutils-gdb/gdb/target.h:449
  #1  0x0000000000ac08fb in target_shortname () at ../../binutils-gdb/gdb/target.h:1323
  #2  0x0000000000ac09ae in tui_locator_window::make_status_line[abi:cxx11]() const (this=0x23e1fa0 <_locator>) at ../../binutils-gdb/gdb/tui/tui-stack.c:86
  #3  0x0000000000ac1043 in tui_locator_window::rerender (this=0x23e1fa0 <_locator>) at ../../binutils-gdb/gdb/tui/tui-stack.c:231
  #4  0x0000000000ac1632 in tui_show_locator_content () at ../../binutils-gdb/gdb/tui/tui-stack.c:369
  #5  0x0000000000ac63b6 in tui_set_key_mode (mode=TUI_COMMAND_MODE) at ../../binutils-gdb/gdb/tui/tui.c:321
  #6  0x0000000000aaf9be in tui_inferior_exit (inf=0x2d446a0) at ../../binutils-gdb/gdb/tui/tui-hooks.c:181
  #7  0x000000000044cddf in std::_Function_handler<void (inferior*), void (*)(inferior*)>::_M_invoke(std::_Any_data const&, inferior*&&) (__functor=..., __args#0=@0x7fffffffd650: 0x2d446a0)
      at /usr/include/c++/9/bits/std_function.h:300
  #8  0x0000000000757db9 in std::function<void (inferior*)>::operator()(inferior*) const (this=0x2cf3168, __args#0=0x2d446a0) at /usr/include/c++/9/bits/std_function.h:690
  #9  0x0000000000757876 in gdb::observers::observable<inferior*>::notify (this=0x23de0c0 <gdb::observers::inferior_exit>, args#0=0x2d446a0)
      at ../../binutils-gdb/gdb/gdbsupport/observable.h:106
  #10 0x000000000075532d in exit_inferior_1 (inftoex=0x2d446a0, silent=1) at ../../binutils-gdb/gdb/inferior.c:191
  #11 0x0000000000755460 in exit_inferior_silent (inf=0x2d446a0) at ../../binutils-gdb/gdb/inferior.c:234
  #12 0x000000000059f47c in core_target::close (this=0x2d68590) at ../../binutils-gdb/gdb/corelow.c:265
  #13 0x0000000000a7688c in target_close (targ=0x2d68590) at ../../binutils-gdb/gdb/target.c:3293
  #14 0x0000000000a63d74 in target_stack::push (this=0x23e1800 <g_target_stack>, t=0x23c38c8 <the_amd64_linux_nat_target>) at ../../binutils-gdb/gdb/target.c:568
  #15 0x0000000000a63dbf in push_target (t=0x23c38c8 <the_amd64_linux_nat_target>) at ../../binutils-gdb/gdb/target.c:583
  #16 0x0000000000748088 in inf_ptrace_target::create_inferior (this=0x23c38c8 <the_amd64_linux_nat_target>, exec_file=0x2d58d30 "/usr/bin/cat", allargs="", env=0x25f12b0, from_tty=1)
      at ../../binutils-gdb/gdb/inf-ptrace.c:128
  #17 0x0000000000795ccb in linux_nat_target::create_inferior (this=0x23c38c8 <the_amd64_linux_nat_target>, exec_file=0x2d58d30 "/usr/bin/cat", allargs="", env=0x25f12b0, from_tty=1)
      at ../../binutils-gdb/gdb/linux-nat.c:1094
  #18 0x000000000074eae9 in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at ../../binutils-gdb/gdb/infcmd.c:639
  ...

The problem happens because 'tui_locator_window::make_status_line'
needs the value of 'target_shortname' in order to update the status
line.  'target_shortname' is a macro which expands to:

  #define target_shortname (current_top_target ()->shortname ())

and, in our scenario, 'current_top_target ()' returns NULL, which
obviously causes a segfault.  But why does it return NULL, since,
according to its comment on target.h, it should never do that?

What is happening is that we're being caught in the middle of a
"target switch".  We had the 'core_target' on top, because we were
inspecting a corefile, but when the user decided to invoke "run" GDB
had to actually create the inferior, which ends up detecting that we
have a target already, and tries to close it (from target.c):

  /* See target.h.  */

  void
  target_stack::push (target_ops *t)
  {
    /* If there's already a target at this stratum, remove it.  */
    strata stratum = t->stratum ();

    if (m_stack[stratum] != NULL)
      {
target_ops *prev = m_stack[stratum];
m_stack[stratum] = NULL;
target_close (prev); // <-- here
      }
  ...

When the current target ('core_target') is being closed, it checks for
possible observers registered with it and calls them.  TUI is one of
those observers, it gets called, tries to update the status line, and
GDB crashes.

The real problem is that we are clearing 'm_stack[stratum]', but
forgetting to adjust 'm_top'.  Interestingly, this scenario is covered
in 'target_stack::unpush', but Pedro said he forgot to call it here..
The fix, therefore, is to call '::unpush' if there's a target on the
stack.

This patch has been tested on the Buildbot and no regressions have
been found.  I'm also submitting a testcase for it.

gdb/ChangeLog:
2019-11-18  Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1765117
* target.c (target_stack::push): Call 'unpush' if there's a
target on top of the stack.

gdb/testsuite/ChangeLog:
2019-11-18  Sergio Durigan Junior  <sergiodj@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1765117
* gdb.tui/corefile-run.exp: New file.

Change-Id: I39e2f8b538c580c8ea5bf1d657ee877e47746c8f

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 19 Nov 2019 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years ago[GOLD] OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols output
Alan Modra [Wed, 2 Oct 2019 01:11:01 +0000 (10:41 +0930)] 
[GOLD] OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols output

This patch arranges to have OSABI set to ELFOSABI_GNU (if not set to
some other non-zero value) when gold outputs an ifunc local or global
symbol, or a unique global symbol to either .dynsym or .symtab.
STT_GNU_IFUNC and STB_GNU_UNIQUE have values in the LOOS to HIOS range
and therefore require interpretation according to OSABI.

I'm not sure why parameters->target() is const Target& while
parameters->sized_target() is Sized_target*, but it's inconvenient to
use the latter in Symbol_table::finalize.  So this patch adds another
const_cast complained about in layout.cc and gold.cc.

PR 24853
* symtab.h (set_has_gnu_output, has_gnu_output_): New.
* symtab.cc (Symbol_table::Symbol_table): Init has_gnu_output_.
(Symbol_table::finalize): Set ELFOSABI_GNU when has_gnu_output_.
(Symbol_table::set_dynsym_indexes, Symbol_table::sized_finalize):
Call set_has_gnu_output for STT_GNU_IFUNC and STB_GNU_UNIQUE globals.
* object.cc (Sized_relobj_file::do_finalize_local_symbols): Call
set_has_gnu_output when STT_GNU_IFUNC locals will be output.

4 years agoPR25200, SIGSEGV in _bfd_elf_validate_reloc
Alan Modra [Mon, 18 Nov 2019 20:59:26 +0000 (07:29 +1030)] 
PR25200, SIGSEGV in _bfd_elf_validate_reloc

PR 25200
* reloc.c (bfd_default_reloc_type_lookup): Don't BFD_FAIL.
* elf.c (_bfd_elf_validate_reloc): Don't segfault on NULL howto.

4 years agoFix a bunch of python leaks due to missing calls to tp_free in *_dealloc functions.
Philippe Waroquiers [Sun, 17 Nov 2019 21:48:48 +0000 (22:48 +0100)] 
Fix a bunch of python leaks due to missing calls to tp_free in *_dealloc functions.

valgrind reports leaks in many python tests, such as:
==17162== VALGRIND_GDB_ERROR_BEGIN
==17162== 8,208 (5,472 direct, 2,736 indirect) bytes in 57 blocks are definitely lost in loss record 7,551 of 7,679
==17162==    at 0x4835753: malloc (vg_replace_malloc.c:307)
==17162==    by 0x6EAFD1: _PyObject_New (object.c:279)
==17162==    by 0x4720E6: blpy_iter(_object*) (py-block.c:92)
==17162==    by 0x698772: PyObject_GetIter (abstract.c:2577)
==17162==    by 0x2343BE: _PyEval_EvalFrameDefault (ceval.c:3159)
==17162==    by 0x22E9E2: function_code_fastcall (call.c:283)
==17162==    by 0x2340A8: _PyObject_Vectorcall (abstract.h:127)
==17162==    by 0x2340A8: call_function (ceval.c:4987)
==17162==    by 0x2340A8: _PyEval_EvalFrameDefault (ceval.c:3486)
==17162==    by 0x22E9E2: function_code_fastcall (call.c:283)
==17162==    by 0x82172B: _PyObject_Vectorcall (abstract.h:127)
==17162==    by 0x82172B: method_vectorcall (classobject.c:67)
==17162==    by 0x6AF474: _PyObject_Vectorcall (abstract.h:127)
==17162==    by 0x6AF474: _PyObject_CallNoArg (abstract.h:153)
==17162==    by 0x6AF474: _PyObject_CallFunctionVa (call.c:914)
==17162==    by 0x6B0673: callmethod (call.c:1010)
==17162==    by 0x6B0673: _PyObject_CallMethod_SizeT (call.c:1103)
==17162==    by 0x477DFE: gdb_PyObject_CallMethod<> (python-internal.h:182)
==17162==    by 0x477DFE: get_py_iter_from_func(_object*, char const*) (py-framefilter.c:272)
==17162==    by 0x4791B4: py_print_args (py-framefilter.c:706)
==17162==    by 0x4791B4: py_print_frame(_object*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, htab*) (py-framefilter.c:960)
==17162==    by 0x47A130: gdbpy_apply_frame_filter(extension_language_defn const*, frame_info*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, int) (py-framefilter.c:1236)
==17162==    by 0x369C39: apply_ext_lang_frame_filter(frame_info*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, int) (extension.c:563)
==17162==    by 0x4EC9C9: backtrace_command_1 (stack.c:2031)
==17162==    by 0x4EC9C9: backtrace_command(char const*, int) (stack.c:2183)
...

Most of the leaks in python tests are due to the fact that many
PyObject xxxxx_dealloc functions are missing the line to free self
or obj such as:
   Py_TYPE (self)->tp_free (self);
or
   Py_TYPE (obj)->tp_free (obj);

With this patch, the number of python tests leaking decreases from 52 to 12.

gdb/ChangeLog

2019-11-18  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* python/py-block.c (blpy_dealloc): Call tp_free.
(blpy_block_syms_dealloc): Likewise.
* python/py-finishbreakpoint.c (bpfinishpy_dealloc): Likewise.
* python/py-inferior.c (infpy_dealloc): Likewise.
* python/py-lazy-string.c (stpy_dealloc): Likewise.
* python/py-linetable.c (ltpy_iterator_dealloc): Likewise.
* python/py-symbol.c (sympy_dealloc): Likewise.
* python/py-symtab.c (stpy_dealloc): Likewise.
* python/py-type.c (typy_iterator_dealloc): Likewise.

4 years agoDon't use class-initialization for the owner union
Christian Biesinger [Mon, 18 Nov 2019 01:13:49 +0000 (19:13 -0600)] 
Don't use class-initialization for the owner union

As reported by PhilippeW, valgrind reports that symtab is uninitialized
when compiling with GCC 4.8.5, which is the default compiler on CentOS 7.

This is apparently a compiler bug fixed in later versions, but to keep
CentOS 7 working, this patch initializes the union explicitly instead of
using a class initializer.

gdb/ChangeLog:

2019-11-18  Christian Biesinger  <cbiesinger@google.com>

* symtab.h (struct symbol) <owner>: Initialize explicitly in the
constructor instead of using a class initializer.

Change-Id: I94f48afeae5d29cf81a280295e2d02e2d7e1c1f1

4 years agoelf_backend_init_file_header
Alan Modra [Mon, 18 Nov 2019 06:39:40 +0000 (17:09 +1030)] 
elf_backend_init_file_header

This patch renames elf_backend_post_process_headers and moves the
prep_headers code into the new function.  Naming the backend functions
elf_backend_init_file_header and elf_backend_modify_headers makes it
clear which function is called first.

* elf-bfd.h (struct elf_backend_data <elf_backend_init_file_header>):
Rename from elf_backend_post_process_headers.
(_bfd_elf_post_process_headers): Delete.
(_bfd_elf_init_file_header): Declare.
* elf.c (_bfd_elf_compute_section_file_positions): Call new function
in place of prep_headers and elf_backend_post_process_headers.
(_bfd_elf_init_file_header): Renamed from prep_headers with
updated args and made global.  Delete dead code.
(_bfd_elf_post_process_headers): Delete.
* elf32-arm.c (elf32_arm_init_file_header): Rename from
elf32_arm_post_process_headers and call _bfd_elf_init_file_header.
Return status.
(elf_backend_init_file_header): Define.
(elf_backend_post_process_headers): Don't define.
* elf32-i386.c (elf_i386_fbsd_init_file_header): Similarly.
* elf32-m68hc1x.c (elf32_m68hc11_init_file_header): Similarly.
* elf32-metag.c (elf_metag_init_file_header): Similarly.
* elf32-spu.c (spu_elf_init_file_header
* elf32-visium.c (visium_elf_init_file_header
* elf64-alpha.c (elf64_alpha_fbsd_init_file_header
* elf64-hppa.c (elf64_hppa_init_file_header
* elf64-ia64-vms.c (elf64_vms_init_file_header
* elfnn-aarch64.c (elfNN_aarch64_init_file_header
* elfnn-ia64.c (elfNN_hpux_init_file_header
* elfxx-mips.c (_bfd_mips_init_file_header
* elfxx-mips.h (_bfd_mips_post_process_headers): Delete.
(_bfd_mips_init_file_header): Declare.
(elf_backend_post_process_headers): Delete.
(elf_backend_init_file_header): Define.
* elfxx-target.h (elf_backend_post_process_headers): Delete.
(elf_backend_init_file_header): Define and use.
* elf32-m68hc12.c (elf_backend_init_file_header): Define.
(elf_backend_post_process_headers): Don't define.
* elf32-m68hc1x.h (elf32_m68hc11_post_process_headers): Delete.
(elf32_m68hc11_init_file_header): Declare.
* elf32-ppc.c (elf_backend_post_process_headers): Remove
unnecessary undef.

4 years agoelf_backend_modify_headers
Alan Modra [Mon, 18 Nov 2019 06:39:01 +0000 (17:09 +1030)] 
elf_backend_modify_headers

This patch renames elf_backend_modify_program_headers and moves the
elf.c code tweaking the ELF file header for -pie -Ttext-segment to a
new function, _bfd_elf_modify_headers, which then becomes the default
elf_backed_modify_headers and is called from any other target
elf_backed_modify_headers.

* elf-bfd.h (struct elf_backend_data <elf_backend_modify_headers>):
Rename from elf_backend_modify_program_headers.
(_bfd_elf_modify_headers): Declare.
* elf.c (assign_file_positions_except_relocs): Set
elf_program_header_size.  Always call elf_backend_modify_headers.
Extract code modifying file header..
(_bfd_elf_modify_headers): ..to here.  New function.
* elf32-arm.c (elf_backend_modify_headers): Renamed from
elf_backend_modify_program_headers.
* elf32-i386.c: Similarly.
* elf64-x86-64.c: Similarly.
* elfxx-target.h: Similarly.  Default elf_backend_modify_headers
to _bfd_elf_modify_headers.
* elf-nacl.h (nacl_modify_headers): Rename from
nacl_modify_program_headers.
* elf-nacl.c (nacl_modify_headers): Rename from
nacl_modify_program_headers and call _bfd_elf_modify_headers.
* elf32-rx.c (elf32_rx_modify_headers): Similarly.
* elf32-spu.c (spu_elf_modify_headers): Similarly.
* elfnn-ia64.c (elfNN_ia64_modify_headers): Similarly.
* elf32-sh.c (elf_backend_modify_program_headers): Don't undef.

4 years agoPR25196, abort in rewrite_elf_program_header
Alan Modra [Mon, 18 Nov 2019 02:01:55 +0000 (12:31 +1030)] 
PR25196, abort in rewrite_elf_program_header

This patch introduces a new "sorry, cannot handle this file" bfd error
status.  The idea is to use this error in cases where bfd hasn't found
a bfd_bad_value error, ie. an input file or set of options that are
invalid, but rather an input file that is simply too difficult to
process.  Typically this might happen with fuzzed object files such as
the one in the PR, a wildly improbable core file.  Some things are
just not worth wasting time over to fix "properly".

PR 25196
* bfd.c (bfd_error_type): Add bfd_error_sorry.
(bfd_errmsgs): Likewise.
* elf.c (rewrite_elf_program_header): Don't abort on confused
lma/alignment.  Replace bfd_error_bad_value with bfd_error_sorry.
(_bfd_elf_validate_reloc): Use bfd_error_sorry.
(_bfd_elf_final_write_processing): Likewise.
* bfd-in2.h: Regenerate.

4 years agogas: Add --gdwarf-cie-version command line flag
Andrew Burgess [Mon, 4 Nov 2019 12:27:45 +0000 (12:27 +0000)] 
gas: Add --gdwarf-cie-version command line flag

Add a flag to control the version of CIE that is generated.  By
default gas produces CIE version 1, and this continues to be the
default after this patch.

However, a user can now provide --gdwarf-cie-version=NUMBER to switch
to either version 3 or version 4 of CIE, version 2 was never released,
and so causes an error as does any number less than 1 or greater than
4.

Producing version 4 CIE requires two new fields to be added to the
CIE, an address size field, and an segment selector field.  For a flat
address space the DWARF specification indicates that the segment
selector should be 0, and the address size fields just contains the
address size in bytes.  For now we support 4 or 8 byte addresses, and
the segment selector is always produced as 0.  At some future time we
might need to allow targets to override this.

gas/ChangeLog:

* as.c (parse_args): Parse --gdwarf-cie-version option.
(flag_dwarf_cie_version): New variable.
* as.h (flag_dwarf_cie_version): Declare.
* dw2gencfi.c (output_cie): Switch from DW_CIE_VERSION to
flag_dwarf_cie_version.
* doc/as.texi (Overview): Document --gdwarf-cie-version.
* NEWS: Likewise.
* testsuite/gas/cfi/cfi.exp: Add new tests.
* testsuite/gas/cfi/cie-version-0.d: New file.
* testsuite/gas/cfi/cie-version-1.d: New file.
* testsuite/gas/cfi/cie-version-2.d: New file.
* testsuite/gas/cfi/cie-version-3.d: New file.
* testsuite/gas/cfi/cie-version-4.d: New file.
* testsuite/gas/cfi/cie-version.s: New file.

include/ChangeLog:

* dwarf2.h (DW_CIE_VERSION): Delete.

Change-Id: I9de19461aeb8332b5a57bbfe802953d0725a7ae8

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 18 Nov 2019 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoPR25198, use of out of date pointer
Alan Modra [Sun, 17 Nov 2019 22:46:19 +0000 (09:16 +1030)] 
PR25198, use of out of date pointer

PR 25198
* prdbg.c (tg_start_class_type): Correct scope of idbuf.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 17 Nov 2019 00:01:15 +0000 (00:01 +0000)] 
Automatic date update in version.in

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 16 Nov 2019 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoUse gnulib's strerror_r on MinGW
Christian Biesinger [Wed, 13 Nov 2019 03:55:15 +0000 (21:55 -0600)] 
Use gnulib's strerror_r on MinGW

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

4 years agoAdd no-dist to gnulib configure
Tom Tromey [Fri, 15 Nov 2019 20:48:27 +0000 (13:48 -0700)] 
Add no-dist to gnulib configure

This adds the no-dist option to the gnulib configure script.  gdb
doesn't use "make dist", so there's no need for this.  Adding this
option makes the Makefiles less verbose.

gnulib/ChangeLog
2019-11-15  Tom Tromey  <tromey@adacore.com>

* aclocal.m4, configure, Makefile.in, import/Makefile.in:
Rebuild.
* configure.ac: Remove obsolete comment.  Add no-dist.

Change-Id: I5224e18af9acd5284acb79d5756b0e84b00406e9

4 years agoMinor updates to readline configury
Tom Tromey [Fri, 15 Nov 2019 20:40:53 +0000 (13:40 -0700)] 
Minor updates to readline configury

Christian's recent patches to gnulib made me realize that readline
should be changed to use AC_CONFIG_MACRO_DIRS (ACLOCAL_AMFLAGS is
deprecated) and that it can put the automake options into
configure.ac.  I also added no-define to the automake options.  This
doesn't matter much (we don't generate a config.h here), but gnulib
does it, and it does make configure slightly smaller.

readline/ChangeLog
2019-11-15  Tom Tromey  <tromey@adacore.com>

* configure, Makefile.in: Rebuild.
* configure.ac: Use AC_CONFIG_MACRO_DIRS.  Pass options to
AM_INIT_AUTOMAKE.
* Makefile.am (AUTOMAKE_OPTIONS, ACLOCAL_AMFLAGS): Remove.

Change-Id: If421599cc9dd9c4c3c37b9b439ab2c22c01742ed

4 years agoUse ctime_r and localtime_r for threadsafety
Christian Biesinger [Thu, 31 Oct 2019 21:02:41 +0000 (16:02 -0500)] 
Use ctime_r and localtime_r for threadsafety

To make these calls threadsafe. localtime_r is provided by gnulib if
necessary, and for ctime_r we can just use it because it is in a linux-
specific file.

gdb/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

* maint.c (scoped_command_stats::print_time): Use localtime_r
instead of localtime (provided through gnulib if necessary).
* nat/linux-osdata.c (time_from_time_t): Use ctime_r instead
of ctime.

Change-Id: I329bbdc39d5b576f51859ba00f1617e024c30cbd

4 years agoImport the time_r gnulib module
Christian Biesinger [Fri, 8 Nov 2019 17:25:17 +0000 (11:25 -0600)] 
Import the time_r gnulib module

This allows GDB to use localtime_r unconditionally.

See https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00022.html
for details on the compile error mentioned below.

gdb/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

* gdbsupport/common-defs.h: Include time.h before pathmax.h to
avoid compile errors.

gnulib/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* import/Makefile.am: Update.
* import/Makefile.in: Regenerate.
* import/m4/gnulib-cache.m4: Update.
* import/m4/gnulib-comp.m4: Update.
* import/m4/time_r.m4: New file.
* import/time_r.c: New file.
* update-gnulib.sh: Import time_r.

Change-Id: I53fc861b192940d613ca97f2910b4533c730f667

4 years agoImport the strerror_r-posix module and use it in GDB.
Christian Biesinger [Wed, 6 Nov 2019 18:49:52 +0000 (12:49 -0600)] 
Import the strerror_r-posix module and use it in GDB.

Makes sure to assign the return value of strerror_r to an int,
so that we get a compile error if we accidentally get the
wrong version.

gdb/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

* config.in: Regenerate.
* configure: Regenerate.
* gdbsupport/common.m4: No longer check for strerror_r.
* gdbsupport/posix-strerror.c (safe_strerror): Always call the
POSIX version of strerror_r, now that gnulib provides it if
necessary.

gdb/gdbserver/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

* config.in: Regenerate.
* configure: Regenerate.

gnulib/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* import/Makefile.am: Update.
* import/Makefile.in: Regenerate.
* import/extra/config.rpath: New file.
* import/glthread/lock.c: New file.
* import/glthread/lock.h: New file.
* import/glthread/threadlib.c: New file.
* import/m4/gnulib-cache.m4: Update.
* import/m4/gnulib-comp.m4: Update.
* import/m4/lib-ld.m4: New file.
* import/m4/lib-link.m4: New file.
* import/m4/lib-prefix.m4: New file.
* import/m4/lock.m4: New file.
* import/m4/strerror_r.m4: New file.
* import/m4/threadlib.m4: New file.
* import/strerror_r.c: New file.
* update-gnulib.sh: Import strerror_r-posix.

Change-Id: I5cfeb12a5203a4cd94a78581541e6085a68685c3

This page took 0.061948 seconds and 4 git commands to generate.