Sometimes DWARF info for a function is incomplete, and the function
can be retrieved by examining symbols. However, when separate debug
files are used it may be that the original file is completely
stripped of symbols. This patch teaches BFD to look at symbols from
the debug file in that case.
The patch also removes arm_elf_find_function, instead implementing
elf_backend_maybe_function_sym. arm_elf_find_function was written
before the generic _bfd_elf_find_function called maybe_function_sym.
aarch64 copied arm, so that file gets the same treatment. There is
some chance this will speed up arm and aarch64 lookup of function/line.
PR 23652
* dwarf2.c (_bfd_dwarf2_stash_syms): New function.
(_bfd_dwarf2_find_nearest_line): Use it here, passing syms to
_bfd_elf_find_function. Call _bfd_elf_find_function in cases
where _bfd_elf_find_nearest_line would do so.
* elf.c (_bfd_elf_find_nearest_line): Omit _bfd_elf_find_function
for dwarf2.
* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Similarly. Tidy.
* elf32-arm.c (elf32_arm_maybe_function_sym): New function.
(elf_backend_maybe_function_sym): Define.
(arm_elf_find_function, elf32_arm_find_nearest_line): Delete.
(bfd_elf32_find_nearest_line): Don't define.
* elfnn-aarch64.c (elfNN_aarch64_maybe_function_sym): New function.
(elf_backend_maybe_function_sym): Define.
(aarch64_elf_find_function, elfNN_aarch64_find_nearest_line): Delete.
(bfd_elfNN_find_nearest_line): Don't define.
Using bfd_vma for insn is to avoid having to worry about sign
propagation in expressions involving insn and sym_value when bfd_vma
is not the same as unsigned long.
* elf32-sh.c (sh_reloc): Use a bfd_vma insn.
(sh_reloc <R_SH_IND12W>): Divide calculated relocation value
by two before applying to insn. Correct overflow test.
* coff-sh.c (sh_reloc): Likewise.
Christian pointed out on irc that the threading series broke the build
on mingw. This patch fixes the problem, by moving the initialization
of gdb_demangle_attempt_core_dump into the appropriate #if.
gdb/ChangeLog
2019-11-26 Tom Tromey <tromey@adacore.com>
* cp-support.c (_initialize_cp_support): Conditionally initialize
gdb_demangle_attempt_core_dump.
Change-Id: I9ace0bea75a51f317ea933b607f6b5a94d651eea
This adds a "name_allocated" field to cmd_list_element, so that
commands can own their "name" when necessary. Then, this changes a
few spots in gdb that currently free the name by hand to instead use
this facility.
gdb/ChangeLog
2019-11-26 Tom Tromey <tom@tromey.com>
* python/py-function.c (fnpy_init): Update.
* value.h (add_internal_function): Adjust declaration.
* value.c (function_destroyer): Remove.
(do_add_internal_function): Don't set destroyer or copy name.
(add_internal_function): Take unique_xmalloc_ptr<char> for name.
Set name_allocated.
* python/py-cmd.c (cmdpy_destroyer): Don't free "name".
(cmdpy_init): Set name_allocated.
* cli/cli-decode.h (struct cmd_list_element) <name_allocated>: New
member.
(~cmd_list_element): Free "name" if needed.
Change-Id: Ie1435cea5bbf4bd92056125f112917c607cbb761
add_internal_function sets a command destroyer that frees the doc
string. However, many callers do not pass in an allocated doc string.
This adds a new overload to clearly differentiate the two cases,
fixing the latent bug.
gdb/ChangeLog
2019-11-26 Tom Tromey <tom@tromey.com>
* value.h (add_internal_function): Add new overload. Move
documentation from value.h.
* value.c (do_add_internal_function): New function.
(add_internal_function): Use it. Add new overload.
(function_destroyer): Don't free doc.
* python/py-function.c (fnpy_init): Update.
Change-Id: I3f6df925bc6b3e1bccbad9eeebc487b908bb5a2a
Python commands manage their "doc" string manually, but
cmd_list_element already has doc_allocated to handle this case. This
changes the Python code to use the existing facility.
gdb/ChangeLog
2019-11-26 Tom Tromey <tom@tromey.com>
* python/py-cmd.c (cmdpy_destroyer): Don't free "doc".
(cmdpy_init): Set "doc_allocated".
Change-Id: I0014edc117b051bba1f4db267687d231e7fe9b56
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
This function is not used in the code base.
gdb/ChangeLog:
* inferior.c (exit_inferior_silent): Remove.
Change-Id: Ib2b7662744da079185ceac2a165b47590bd3113c
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
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
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
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
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
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 6b92c0d353
"[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
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
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
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
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.
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.
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
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
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
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