Commit Graph

106182 Commits

Author SHA1 Message Date
Nick Clifton
23182ac0d8 Fix an indirection via uninitialised memory when parsing a corrupt input file.
PR 27839
	* simple.c (simple_dummy_add_to_set): New function.
	(simple_dummy_constructor): New function.
	(simple_dummy_multiple_common): New function.
	(bfd_simple_get_relocated_section_contents): Zero out the
	callbacks structure, and then set the add_to_set, constructor and
	multiple_common fields.
2021-05-10 14:44:31 +01:00
Dimitar Dimitrov
5b45e89f56 Enable linker garbage collection for the PRU target.
bfd	* elf32-pru.c (elf_backend_can_gc_sections): Define as 1.

ld	* testsuite/ld-elf/group8a.d: Remove pru from XFAIL list.
	* testsuite/ld-elf/group8b.d: Ditto.
	* testsuite/ld-elf/group9a.d: Ditto.
	* testsuite/ld-elf/group9b.d: Ditto.
	* testsuite/ld-elf/pr12851.d: Ditto.
	* testsuite/ld-elf/pr22677.d: Ditto.
	* testsuite/lib/ld-lib.exp (check_gc_sections_available): Remove
	pru from list.
2021-05-10 14:00:00 +01:00
Dimitar Dimitrov
261980de18 PRU: Add alignment for resource table, and allow sizes of memory regions to be set from the command line.
ld	* scripttempl/pru.sc (.resource_table): Add ALIGN directive.
	Use symbols for memory sizes.
2021-05-10 13:58:17 +01:00
Sergey Belyashov
e4b1ab2062 Add support for 8-bit and 24-bit shifts in the z80 assembler.
PR 27415
	* config/tc-z80.c (emit_data_val): Add support for 8-bit and
	24-bit shifts.
	* testsuite/gas/z80/z80_reloc.a: Update tests.
	* testsuite/gas/z80/z80_reloc.d: Update expected disassembly.
2021-05-10 13:36:08 +01:00
Thomas Wolff
749c700282 Restore old behaviour of windres so that options containing spaces are not enclosed in double quotes.
PR 4356
	PR 26865
	PR 27594
	* windres.c (quot): Revert previous delta.  Do not use double
	quotes when spaces are detected in options.
	* doc/binutils.texi (windres): Remove suggestion that the
	--preprocessor option can take arguments.
2021-05-10 11:28:15 +01:00
Andrew Burgess
802021d46d gdb/doc: reword a sentence
Change this:

  The available watchpoint types represented by constants are defined
  in the gdb module:

to this:

  The available watchpoint types are represented by constants defined
  in the gdb module:

The new version matches a similar line a few lines up the document
which reads:

  The available types are represented by constants defined in the gdb
  module:

gdb/doc/ChangeLog:

	* guile.texinfo (Breakpoints In Guile): Reword sentence.
	* python.texinfo (Breakpoints In Python): Reword sentence.
2021-05-10 10:09:33 +01:00
Alan Modra
2d4b49864e Avoid possible pointer wrap
PTR supplied to these macros can be read from user input, END is an
end of buffer pointer.  It's safer to do arithmetic on END than on PTR.

	* dwarf.c (SAFE_BYTE_GET): Check bounds by subtracting amount from
	END rather than adding amount to PTR.
	(SAFE_SIGNED_BYTE_GET, SAFE_BYTE_GET64): Likewise.
2021-05-10 10:03:00 +09:30
GDB Administrator
400f0c9b88 Automatic date update in version.in 2021-05-10 00:00:37 +00:00
Andrew Burgess
9dffa1aa8e gdb/doc: document 'set debug py-unwind'
When the 'set debug py-unwind' flag was added, it was never documented
in the manual.  This commit adds some text for this command to the
manual.

gdb/doc/ChangeLog:

	* python.texinfo (Python Commands): Document 'set debug
	py-unwind' and 'show debug py-unwind'.
2021-05-09 16:50:16 +01:00
Andrew Burgess
75140e3b75 gdb/py: add some debugging to py-breakpoint.c
Adds some new debugging to python/py-breakpoint.c.

gdb/ChangeLog:

	* python/py-breakpoint.c (pybp_debug): New static global.
	(show_pybp_debug): New function.
	(pybp_debug_printf): Define.
	(PYBP_SCOPED_DEBUG_ENTER_EXIT): Define.
	(gdbpy_breakpoint_created): Add some debugging.
	(gdbpy_breakpoint_deleted): Likewise.
	(gdbpy_breakpoint_modified): Likewise.
	(_initialize_py_breakpoint): New function.

gdb/doc/ChangeLog:

	* python.texinfo (Python Commands): Document 'set debug
	py-breakpoint' and 'show debug py-breakpoint'.
2021-05-09 16:50:16 +01:00
Andrew Burgess
1ef40c1362 gdb/py: convert debug logging in py-unwind to use new scheme
Converts the debug print out in python/py-unwind.c to use the new
debug printing scheme.  I have also modified what is printed in a few
places, for example, rather than printing frame pointers, I now print
the frame level, this matches what we do in the general 'set debug
frame' tracing, and is usually more helpful (I think).

I also added a couple of ENTER/EXIT scope printers.

gdb/ChangeLog:

	* python/py-unwind.c (pyuw_debug): Convert to bool.
	(show_pyuw_debug): New function.
	(pyuw_debug_printf): Define.
	(PYUW_SCOPED_DEBUG_ENTER_EXIT): Define.
	(pyuw_this_id): Convert to new debug print macros.
	(pyuw_prev_register): Likewise.
	(pyuw_sniffer): Likewise.
	(pyuw_dealloc_cache): Likewise.
	(_initialize_py_unwind): Update now pyuw_debug is a bool, and add
	show function when registering.
2021-05-09 16:50:15 +01:00
Andrew Burgess
927c4e355e gdb: replace fprint_frame_id
Replace fprint_frame_id with a member function frame_id::to_string
that returns a std::string.  Convert all of the previous users of
fprint_frame_id to use the new member function.  This means that
instead of writing things like this:

  fprintf_unfiltered (file, " id=");
  fprint_frame_id (file, s->id.id);

We can write this:

  fprintf_unfiltered (file, " id=%s", s->id.id.to_string ().c_str ());

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* dummy-frame.c (fprint_dummy_frames): Convert use of
	fprint_frame_id to use frame_id::to_string.
	* frame.c (fprint_field): Delete.
	(fprint_frame_id): Moved to...
	(frame_id::to_string): ...this, rewritten to return a string.
	(fprint_frame): Convert use of fprint_frame_id to use
	frame_id::to_string.
	(compute_frame_id): Likewise.
	(frame_id_p): Likewise.
	(frame_id_eq): Likewise.
	(frame_id_inner): Likewise.
	* frame.h (struct frame_id) <to_string>: New member function.
	(fprint_frame_id): Delete declaration.
	* guile/scm-frame.c (frscm_print_frame_smob): Convert use of
	fprint_frame_id to use frame_id::to_string.
	* python/py-frame.c (frame_object_to_frame_info): Likewise.
	* python/py-unwind.c (unwind_infopy_str): Likewise.
	(pyuw_this_id): Likewise.
2021-05-09 16:50:15 +01:00
Alan Modra
4821e618ad Use htab_eq_string in libctf
* ctf-impl.h (ctf_dynset_eq_string): Don't declare.
	* ctf-hash.c (ctf_dynset_eq_string): Delete function.
	* ctf-dedup.c (make_set_element): Use htab_eq_string.
	(ctf_dedup_atoms_init, ADD_CITER, ctf_dedup_init): Likewise.
	(ctf_dedup_conflictify_unshared): Likewise.
	(ctf_dedup_walk_output_mapping): Likewise.
2021-05-09 12:28:32 +09:30
Alan Modra
b05a0fc79b Use htab_eq_string in binutils
A quick check says this is the only place in all of bfd, opcodes,
binutils, gas, ld, gprof that duplicates the new libiberty
htab_eq_string.

	* objcopy.c (eq_string): Delete.
	(create_symbol_htab): Use htab_eq_string.
2021-05-09 12:28:18 +09:30
Simon Marchi
b6703327bb gdbsupport: re-generate configure & friends
I get these changes when re-generating the autoconf stuff in gdbsupport,
fallouts from 4655f8509f ("Don't run personality syscall at configure
time; don't check it at all").

gdbsupport/ChangeLog:

	* Makefile.in: Re-generate.
	* config.in: Re-generate.
	* configure: Re-generate.

Change-Id: Ie1876ee58d6f4f1cf25fa14900eecf4c85a744c1
2021-05-08 21:27:49 -04:00
Simon Marchi
8d06918ff5 gdb, gdbserver: make status_to_str return std::string
Instead of using a static buffer.  This is safer, and we don't really
mind about any extra dynamic allocation here, since it's only used for
debug purposes.

gdb/ChangeLog:

	* nat/linux-waitpid.c (status_to_str): Return std::string.
	* nat/linux-waitpid.h (status_to_str): Likewise.
	* linux-nat.c (linux_nat_post_attach_wait): Adjust.
	(linux_nat_target::attach): Adjust.
	(linux_handle_extended_wait): Adjust.
	(wait_lwp): Adjust.
	(stop_wait_callback): Adjust.
	(linux_nat_filter_event): Adjust.
	(linux_nat_wait_1): Adjust.
	* nat/linux-waitpid.c (status_to_str): Adjust.
	* nat/linux-waitpid.h (status_to_str): Adjust.

gdbserver/ChangeLog:

	* linux-low.cc (linux_process_target::wait_for_event_filtered):
	Adjust to status_to_str returning std::string.

Change-Id: Ia8aead70270438a5690f243e6faafff6c38ff757
2021-05-08 21:07:20 -04:00
Simon Marchi
550e9289ab gdb: add missing space in infrun_debug_printf
gdb/ChangeLog:

	* infrun.h (infrun_debug_printf): Add missing space.

Change-Id: I476096a098451ff2019ab38caa41ebfef0e04a1c
2021-05-08 20:37:27 -04:00
GDB Administrator
9ef1d5f4c9 Automatic date update in version.in 2021-05-09 00:00:37 +00:00
Mike Frysinger
bb608f811b sim: h8300: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port.

Disable h8_set_macS for now as it's unused.
Initialize trace & intMask before using them.
Mark local set_h8300h function static.
2021-05-08 12:43:06 -04:00
Mike Frysinger
b50a658ac1 sim: touch modules target
If there are no updates to the file, touch the result so we don't
keep trying to regenerate it.
2021-05-08 12:35:08 -04:00
Mike Frysinger
532497fe6f sim: cgen: tweak trace format
Fixes build warnings when the address size isn't an integer.
2021-05-08 12:33:08 -04:00
Mike Frysinger
1227922933 sim: cgen: namespace mode_names a bit
These are exported in the library linkage, so add a cgen_ prefix.
2021-05-08 12:29:00 -04:00
Mike Frysinger
6ae9091ab0 sim: cgen: tweak cgen_rtx_error to fix warnings
The function was missing a prototype, and passing a constant string
as the format string instead of going through a %s format.
2021-05-08 12:27:45 -04:00
Mike Frysinger
aac7ce3c87 sim: cgen: tweak initializers to avoid warnings
Use {} instead of {0} to avoid warnings:

common/cgen-utils.c:59:1: warning: missing braces around initializer [-Wmissing-braces]
   59 | {
      | ^
   60 |   {
   61 |     VIRTUAL_INSN_X_INVALID, "--invalid--", NULL, 0, { V, { 0 } }
      |                                                            {{}}

Generated code should be the same.
2021-05-08 12:10:27 -04:00
Mike Frysinger
354c317ea4 binutils: update release docs process
Now that we generate multiple html & pdf forms, update the release
process to show how they get updated.
2021-05-08 12:06:41 -04:00
Mike Frysinger
cf758b3960 support generating multi-html pages in parallel
Use the pattern from other projects where we generate the html pages
in a dir named the same as the project.  So now we have:
gas/doc/gas.html - single html page
gas/doc/gas/ - multiple html pages

This works for projects that have a doc/ subdir already, but gprof &
ld require a little tweaking since they generate their docs in their
respective toplevels.
2021-05-08 12:06:07 -04:00
Mike Frysinger
2faf902da5 generate single html manual page by default
This better matches other GNU projects like autoconf/automake where
the html manual is the single page form.  We'll support the multi-page
form in a follow up change.
2021-05-08 11:58:19 -04:00
Mike Frysinger
0d0878d72e sim: add html & pdf stubs
We stub out the info targets already since we don't provide any.
2021-05-08 11:55:22 -04:00
Tom Tromey
65a9835b29 sim: use htab_eq_string
This changes the sim to use htab_eq_string from libiberty.

sim/common/ChangeLog
2021-05-08  Tom Tromey  <tom@tromey.com>

	* sim-options.c (compare_strings): Remove.
	(dup_arg_p): Use htab_eq_string.
2021-05-08 07:50:47 -06:00
Pedro Alves
4655f8509f Don't run personality syscall at configure time; don't check it at all
Currently, in order to tell whether support for disabling address
space randomization on Linux is available, GDB checks if the
personality syscall works, at configure time.  I.e., it does a run
test, instead of a compile/link test:

  AC_RUN_IFELSE([PERSONALITY_TEST],
		[have_personality=true],
		[have_personality=false],

This is a bit bogus, because the machine the build is done on may not
(and is when you consider distro gdbs) be the machine that eventually
runs gdb.  It would be better if this were a compile/link test
instead, and then at runtime, GDB coped with the personality syscall
failing.  Actually, GDB already copes.

One environment where this is problematic is building GDB in a Docker
container -- by default, Docker runs the container with seccomp, with
a profile that disables the personality syscall.  You can tell Docker
to use a less restricted seccomp profile, but I think we should just
fix it in GDB.

"man 2 personality" says:

       This system call first appeared in Linux 1.1.20 (and thus first
       in a stable kernel release with Linux 1.2.0); library support
       was added in glibc 2.3.

...

       ADDR_NO_RANDOMIZE (since Linux 2.6.12)
              With this flag set, disable address-space-layout randomization.

glibc 2.3 was released in 2002.
Linux 2.6.12 was released in 2005.

The original patch that added the configure checks was submitted in
2008.  The first version of the patch that was submitted to the list
called personality from common code:

 https://sourceware.org/pipermail/gdb-patches/2008-June/058204.html

and then was moved to Linux-specific code:

 https://sourceware.org/pipermail/gdb-patches/2008-June/058209.html

Since HAVE_PERSONALITY is only checked in Linux code, and
ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely
removing the configure checks.

If for some odd reason, some remotely modern system still needs a
configure check, then we can revert this commit but drop the
AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE
cross-compile fallback.

gdb/ChangeLog:

	* linux-nat.c (linux_nat_target::supports_disable_randomization):
	Remove references to HAVE_PERSONALITY.
	* nat/linux-personality.c: Remove references to HAVE_PERSONALITY.
	(maybe_disable_address_space_randomization)
	(~maybe_disable_address_space_randomizatio): Remove references to
	HAVE_PERSONALITY.
	* config.in, configure: Regenerate.

gdbserver/ChangeLog:

	* linux-low.cc:
	(linux_process_target::supports_disable_randomization): Remove
	reference to HAVE_PERSONALITY.
	* config.in, configure: Regenerate.

gdbsupport/ChangeLog:

	* common.m4 (personality test): Remove.
2021-05-08 13:45:36 +01:00
Pedro Alves
e2ea3a381a Don't include sys/personality.h in linux-low.cc anymore
Lancelot pointed out that since the refactor at:

  https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html

the sys/personality.h include is not needed in linux-low.cc anymore,
as it does not call personality directly itself anymore.

gdbserver/ChangeLog:

	* linux-low.cc: Don't include sys/personality.h or define
	ADDR_NO_RANDOMIZE.
2021-05-08 13:09:52 +01:00
Mike Frysinger
8a16cc4b93 sim: m68hc11: fix up cycle buffer printing
Make sure the local static buffer is large enough, and simplify the
sprintf for merging the fields all into one.  This fixes compiler
warnings from buf possibly being overflowed.
2021-05-07 21:55:27 -04:00
GDB Administrator
f6593c3d4b Automatic date update in version.in 2021-05-08 00:00:38 +00:00
Andrew Burgess
1845e25464 gdb/guile: perform tilde expansion when sourcing guile scripts
Before this patch:

  (gdb) source ~/script.scm
  ERROR: In procedure apply-smob/1:
  ERROR: In procedure primitive-load-path: Unable to find file "~/script.scm" in load path
  Error while executing Scheme code.
  (gdb)

This is because the path is not tilde expanded.  In contrast, when
sourcing a .py or .gdb script the path is tilde expanded.

This commit fixes this oversight, and allows the above source command
to work as expected.

The tilde expansion is done in the generic GDB code before we call the
sourcer function for any particular extension language.

gdb/ChangeLog:

	* cli/cli-cmds.c: Add 'gdbsupport/gdb_tilde_expand.h'
	include.
	(source_script_with_search): Perform tilde expansion.

gdb/testsuite/ChangeLog:

	* gdb.guile/guile.exp: Add an extra test.
2021-05-07 22:20:47 +01:00
Andrew Burgess
a3237c7cc7 gdb/testsuite: use gdb_test_no_output instead of send_gdb
I noticed gdb.base/ptype-offsets.exp failing occasionally, this was
due to lines like this in the test script:

  send_gdb "set print type hex on\n"

As this does not match the '(gdb)' prompt that is produced, the prompt
would sometimes be matched against the next test, causing the next
test to think its output was missing and fail.

Fix this by switching to:

  gdb_test_no_output "set print type hex on"

gdb/testsuite/ChangeLog:

	* gdb.base/ptype-offsets.exp: Replace use of send_gdb with
	gdb_test_no_output.
2021-05-07 22:19:41 +01:00
Simon Marchi
91e3c425d6 gdb: make target_desc_info::filename an std::string
To make the management of memory automatic.

As to why I chose to make this an std::string and not an
std::unique_xmalloc_ptr<char>: some parts of the code consider both a
NULL value and an empty string value to mean "no filename".
target_desc_info_from_user_p, however, doesn't check for a non-NULL but
empty string value.  So it seems like having two ways of denoting "no
filename" can lead to these kinds of inconsistencies.  Using
std::string, "no filename" is only represented by an empty value.

As a bonus, using an std::string lets us copy target_desc_info objects
using the default assignment operator.

gdb/ChangeLog:

	* target-descriptions.c (struct target_desc_info) <filename>:
	Make std::string.
	(copy_inferior_target_desc_info): Adjust.
	(target_desc_info_free): Adjust.
	(target_find_description): Adjust.
	(set_tdesc_filename_cmd): Adjust.
	(show_tdesc_filename_cmd): Adjust.
	(unset_tdesc_filename_cmd): Adjust.
	(maint_print_c_tdesc_cmd): Adjust.

Change-Id: I4e3a6ad8ccda2b88c202471d4f54249753cad127
2021-05-07 16:28:56 -04:00
Simon Marchi
0b2f7ade53 gdb: (de-)allocate target_desc_info with new/delete
In preparation for using non-POD types in the struct.

gdb/ChangeLog:

	* target-descriptions.c (struct target_desc_info): Initialize
	fields.
	(get_tdesc_info): Use new.
	(target_desc_info_free): Use delete.

Change-Id: I10fdaeeae7cdbd7930ae7adeeb13f7f363c67c7a
2021-05-07 16:28:56 -04:00
Simon Marchi
820c449092 gdb: change target_desc_info::fetched to bool
gdb/ChangeLog:

	* target-descriptions.c (struct target_desc_info) <fetched>:
	bool.
	(target_find_description): Adjust.
	(target_clear_description): Adjust.

Change-Id: Ib69e097b38cf270e674f1249105d535a312954e1
2021-05-07 16:28:56 -04:00
Simon Marchi
c2962e6ab4 gdb: remove target description macros
In my opinion, the target_desc_fetched, current_target_desc and
target_description_filename macros in target-descriptions.c are not very
useful.  I don't think it's useful to hide that they operate on the
current inferior, as everything currently works under the assumption
that the various tdesc commands operate on the current inferior, and I
don't see that changing in the foreseeable future.

This change also avoids having multiple unnecessary calls to
current_inferior and get_tdesc_info per function.

gdb/ChangeLog:

	* target-descriptions.c (struct target_desc_info) <tdesc>:
	Adjust doc.
	(target_desc_fetched): Remove.
	(current_target_desc): Remove.
	(target_description_filename): Remove.
	(target_find_description): Adjust.
	(target_clear_description): Adjust.
	(target_current_description): Adjust.
	(set_tdesc_filename_cmd): Adjust.
	(show_tdesc_filename_cmd): Adjust.
	(unset_tdesc_filename_cmd): Adjust.
	(maint_print_c_tdesc_cmd): Adjust.
	(maint_print_xml_tdesc_cmd): Adjust.

Change-Id: Ibfb581490e949c16d59924e2cac633ede5c26c5b
2021-05-07 16:28:56 -04:00
Dimitar Dimitrov
0d315c88a7 sim: Add bfd include path for common testsuite tools
On a host without installed libbfd, this patch fixes the following
"make check-sim" errors for both pru cross target, and native x86_64:

In file included from ../../../binutils/sim/common/sim-basics.h:131,
                 from testsuite/common/bits32m0.c:13:../../../binutils/sim/../include/gdb/callback.h:55:10: fatal error: bfd.h: No such file or directory
   55 | #include "bfd.h"
      |          ^~~~~~~

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2021-05-07 21:02:34 +03:00
Nick Clifton
476654beae Add a generic .bss directive for ELF based targets.
PR 3136
	* config/obj-elf.c (elf_pseudo_table): Add entry for .bss.
	(obj_elf_bss): New function.  Change to the .bss section.
	Support an optional subsection number.
	(obj_elf_change_section): Call obj_elf_section_change_hook.
	(obj_elf_section): Likewise.
	(obj_elf_data): Likewise.
	(obj_elf_text): Likewise.
	(obj_elf_struct): Likewise.
	(obj_elf_subsection): Likewise.
	(obj_elf_previous): Likewise.
	* config/obj-elf.h (obj_elf_bss): Prototype.
	* doc/as.texi (Bss): New node.
2021-05-07 17:08:48 +01:00
Andrew Burgess
8a82de5884 gdb: some int to bool conversion
Change int parameter to bool in remote_notice_new_inferior (remote.c)
and notice_new_inferior (infcmd.c), and update the callers.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* infcmd.c (notice_new_inferior): Change parameter type.
	* inferior.h (notice_new_inferior): Change parameter type.
	* remote.c (remote_notice_new_inferior): Change parameter type to
	bool.  Also update type of local variable to bool.
	(remote_target::update_thread_list): Change type of local variable
	to bool.
	(remote_target::process_stop_reply): Pass bool instead of int to
	remote_notice_new_inferior.
2021-05-07 17:00:25 +01:00
Simon Marchi
bedc473418 gdb: remove reference to current inferior in target_stack::unpush
target_stack::unpush needs to get the target beneath the target being
unpushed to update the m_top field (which keeps the stratum of the
top-most target).  It currently does so using target_ops::beneath, which
uses the target stack of the current inferior.  The target stack of the
current inferior is the same as the `this` in the unpush method.

Avoid this detour and remove this reference to the current inferior by
calling target_ops::find_beneath and passing `this` to find the target
beneath `t` in the target stack that is `this`.

gdb/ChangeLog:

	* target.c (target_stack::unpush): Call target_ops::find_beneath
	to get the target beneath `t`.

Change-Id: If9d9661567c5c16f655d270bd2ec9f1b3aa6dadc
2021-05-07 11:52:51 -04:00
Simon Marchi
27f0a4314a gdb: make target_close check that the target isn't pushed in all inferiors
The target_close function currently checks that the target to be closed
isn't pushed in the current inferior:

    gdb_assert (!current_inferior ()->target_is_pushed (targ));

Normally, a target is closed when its refcount has dropped to 0, due to
not being used in any inferior anymore.  I think it would make sense to
change that assert to not only check in the current inferior, but to
check in all inferiors.  It would be quite bad (and a bug) to close a
target while it's still pushed in one of the non-current inferiors.

gdb/ChangeLog:

	* target.c (target_close): Check in all inferiors that the
	target is not pushed.

Change-Id: I6e37fc3f3476a0593da1e476604642b2de90f1d5
2021-05-07 11:51:39 -04:00
Aaron Merey
1d1669e40f debuginfod-support.c: Use long-lived debuginfod_client
Instead of initializing a new debuginfod_client for each query, store
the first initialized client for the remainder of the GDB session and
use it for every debuginfod query.

In conjunction with upcoming changes to libdebuginfod, using one client
for all queries will avoid latency caused by unneccesarily setting up
TCP connections multiple times.

Tested on Fedora 33 x86_64.

gdb/ChangeLog:

	* debuginfod-support.c (debuginfod_init): Remove.
	(get_debuginfod_client): New function.
2021-05-07 11:37:16 -04:00
Tom Tromey
2698f5ead6 Remove streq_hash in favor of htab_eq_string
Now that libiberty includes htab_eq_string, we can remove the
identical function from gdb.

gdb/ChangeLog
2021-05-07  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (ambiguous_names_p): Use htab_eq_string.
	* utils.c (streq_hash): Remove.
	* utils.h (streq_hash): Don't declare.
	* completer.c (completion_tracker::discard_completions): Update
	comment.
	* ada-lang.c (_initialize_ada_language): Use htab_eq_string.
2021-05-07 09:18:18 -06:00
Simon Marchi
13123da89a gdb: re-format Python files using black 21.4b0
Re-format all Python files using black [1] version 21.4b0.  The goal is
that from now on, we keep all Python files formatted using black.  And
that we never have to discuss formatting during review (for these files
at least) ever again.

One change is needed in gdb.python/py-prettyprint.exp, because it
matches the string representation of an exception, which shows source
code.  So the change in formatting must be replicated in the expected
regexp.

To document our usage of black I plan on adding this to the "GDB Python
Coding Standards" wiki page [2]:

--8<--

All Python source files under the `gdb/` directory must be formatted
using black version 21.4b0.

This specific version can be installed using:

    $ pip3 install 'black == 21.4b0'

All you need to do to re-format files is run `black <file/directory>`,
and black will re-format any Python file it finds in there.  It runs
quite fast, so the simplest is to do:

    $ black gdb/

from the top-level.

If you notice that black produces changes unrelated to your patch, it's
probably because someone forgot to run it before you.  In this case,
don't include unrelated hunks in your patch.  Push an obvious patch
fixing the formatting and rebase your work on top of that.

-->8--

Once this is merged, I plan on setting a up an `ignoreRevsFile`
config so that git-blame ignores this commit, as described here:

  https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame

I also plan on working on a git commit hook (checked in the repo) to
automatically check the formatting of the Python files on commit.

[1] https://pypi.org/project/black/
[2] https://sourceware.org/gdb/wiki/Internals%20GDB-Python-Coding-Standards

gdb/ChangeLog:

	* Re-format all Python files using black.

gdb/testsuite/ChangeLog:

	* Re-format all Python files using black.
	* gdb.python/py-prettyprint.exp (run_lang_tests): Adjust.

Change-Id: I28588a22c2406afd6bc2703774ddfff47cd61919
2021-05-07 10:56:20 -04:00
Marco Barisione
a9b49cbcd5 gdb: add lookup_cmd_exact to simplify a common pattern
In code dealing with commands, there's a pattern repeated a few times of
calling lookup_cmd with some speficic arguments and then using strcmp
on the returned command to check for an exact match.
As a later patch would add a few more similar lines of code, this patch
adds a new lookup_cmd_exact function which simplify this use case.

gdb/ChangeLog:

	* cli/cli-decode.c (lookup_cmd_exact): Add.
	* cli/cli-script.c (do_define_command): Use lookup_cmd_exact.
	(define_prefix_command): Ditto.
	* command.h: Add lookup_cmd_exact.
2021-05-07 15:43:30 +01:00
Cl?ment Chigot
97834047e1 Fix .dwsect generation for XCOFF. Handle .function generated with DWARF on XCOFF.
gas	* config/tc-ppc.c (ppc_function): Update comment for
	fifth argument.
	(ppc_frob_symbol): Remove ppc_last_function check.
	Make sure coff_last_function is reset.
	Correctly set fsize when not provided in .function.
	* testsuite/gas/ppc/aix.exp: New tests.
	* testsuite/gas/ppc/xcoff-function-1-32.d: New test.
	* testsuite/gas/ppc/xcoff-function-1-64.d: New test.
	* testsuite/gas/ppc/xcoff-function-1.s: New test.

bfd	* coff-rs6000.c (xcoff_dwsect_names): Add new DWARF
	sections.
	* coffgen.c (coff_pointerize_aux): Handle C_DWARF.
	(coff_print_symbol): Likewise.
	* libxcoff.h (XCOFF_DWSECT_NBR_NAMES): Update.

gas	* config/obj-coff.c (coff_frob_symbol): Don't skip C_DWARF.
	(coff_adjust_section_syms): Use corrext auxent for C_DWARF.
	(coff_frob_section): Likewise.
	* config/obj-coff.h (SA_GET_SECT_SCNLEN,
	SA_GET_SECT_NRELOC, SA_SET_SECT_SCNLEN,
	SA_SET_SECT_NRELOC) New defines.
	(SET_SECTION_RELOCS): Adjust for C_DWARF.
	* config/tc-ppc.c (ppc_frob_symbol): Don't skip C_DWARF.
	(ppc_adjust_symtab): Reorder C_DWARF symbols.
	* testsuite/gas/ppc/aix.exp: New tests.
	* testsuite/gas/ppc/xcoff-dwsect-2-32.d: New test.
	* testsuite/gas/ppc/xcoff-dwsect-2-64.d: New test.
	* testsuite/gas/ppc/xcoff-dwsect-2.s: New test.

include	* coff/internal.h (C_DWARF): New define.
	* coff/xcoff.h (SSUBTYP_DWLOC, SSUBTYP_DWFRAME,
	SSUBTYP_DWMAC): New defines.
2021-05-07 15:29:49 +01:00
Nick Clifton
3ecc00ec9c Srop readelf's unwind decoder from complaining about x86 binaries.
* readelf.c (no_processor_specific_unwind): New function.
	(process_unwind): Use no_processor_specific_unwind for X86
	targets.
2021-05-07 15:24:14 +01:00