]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
2 years agoUpdated French translation for the gas sub-directory.
Nick Clifton [Fri, 28 Jan 2022 12:16:03 +0000 (12:16 +0000)] 
Updated French translation for the gas sub-directory.

2 years agoSet __ehdr_start rel_from_abs earlier
Alan Modra [Tue, 25 Jan 2022 23:55:24 +0000 (10:25 +1030)] 
Set __ehdr_start rel_from_abs earlier

This is just a tidy, making the __ehdr_start symbol flag tweaks all in
one place.

* ldelf.c (ldelf_before_allocation): Don't set rel_from_abs
for __ehdr_start.
* ldlang.c (lang_symbol_tweaks): Set it here instead.

2 years agoPowerPC64 handling of @tocbase
Alan Modra [Thu, 20 Jan 2022 03:25:53 +0000 (13:55 +1030)] 
PowerPC64 handling of @tocbase

* elf64-ppc.c (ppc64_elf_relocate_section): Warn if the symbol
on R_PPC64_TOC isn't local.

2 years agoUpdate PowerPC64 symtocbase test
Alan Modra [Wed, 19 Jan 2022 13:17:41 +0000 (23:47 +1030)] 
Update PowerPC64 symtocbase test

Using a symbol other than .TOC. with @tocbase is an extension to the
ABI.  It is never valid to use a symbol without a definition in the
binary, and symbols on these expressions cannot be overridden.  Make
this explicit by using ".hidden" in the testcase.

* testsuite/ld-powerpc/symtocbase-1.s: Align data.  Make function
entry symbol hidden.
* testsuite/ld-powerpc/symtocbase-2.s: Likewise.
* testsuite/ld-powerpc/symtocbase.d: Adjust expected output.

2 years agoPR28827, assertion building LLVM 9 on powerpc64le-linux-gnu
Alan Modra [Thu, 27 Jan 2022 23:16:13 +0000 (09:46 +1030)] 
PR28827, assertion building LLVM 9 on powerpc64le-linux-gnu

The assertion is this one in ppc_build_one_stub
  BFD_ASSERT (stub_entry->stub_offset >= stub_entry->group->stub_sec->size);
It is checking that a stub doesn't overwrite the tail of a previous
stub, so not something trivial.

Normally, stub sizing iterates until no stubs are added, detected by
no change in stub section size.  Iteration also continues if no stubs
are added but one or more stubs increases in size, which also can be
detected by a change in stub section size.  But there is a
pathological case where stub section sizing decreases one iteration
then increases the next.  To handle that situation, stub sizing also
stops at more than STUB_SHRINK_ITER (20) iterations when calculated
stub section size is smaller.  The previous larger size is kept for
the actual layout (so that building the stubs, which behaves like
another iteration of stub sizing, will see the stub section sizes
shrink).  The problem with that stopping condition is that it assumes
that stub sizing is only affected by addresses external to the stub
sections, which isn't always true.

This patch fixes that by also keeping larger individual stub_offset
addresses past STUB_SHRINK_ITER.  It also catches a further
pathological case where one stub shrinks and another expands in such a
way that no stub section size change is seen.

PR 28827
* elf64-ppc.c (struct ppc_link_hash_table): Add stub_changed.
(STUB_SHRINK_ITER): Move earlier in file.
(ppc_size_one_stub): Detect any change in stub_offset.  Keep
larger one if past STUB_SHRINK_ITER.
(ppc64_elf_size_stubs): Iterate on stub_changed too.

2 years agoPR28826 x86_64 ld segfaults building xen
Alan Modra [Fri, 28 Jan 2022 03:59:34 +0000 (14:29 +1030)] 
PR28826 x86_64 ld segfaults building xen

Fallout from commit e86fc4a5bc37

PR 28826
* coffgen.c (coff_write_alien_symbol): Init dummy to zeros.

2 years agoPR28753, buffer overflow in read_section_stabs_debugging_info
Alan Modra [Thu, 20 Jan 2022 03:28:38 +0000 (13:58 +1030)] 
PR28753, buffer overflow in read_section_stabs_debugging_info

PR 28753
* rddbg.c (read_section_stabs_debugging_info): Don't read past
end of section when concatentating stab strings.

2 years agoAutomatic date update in version.in
GDB Administrator [Fri, 28 Jan 2022 00:00:25 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agogdb: work around negative DW_AT_data_member_location GCC 11 bug
Simon Marchi [Thu, 27 Jan 2022 22:35:26 +0000 (17:35 -0500)] 
gdb: work around negative DW_AT_data_member_location GCC 11 bug

g++ 11.1.0 has a bug where it will emit a negative
DW_AT_data_member_location in some cases:

    $ cat test.cpp
    #include <memory>

    int
    main()
    {
      std::unique_ptr<int> ptr;
    }
    $ g++ -g test.cpp
    $ llvm-dwarfdump -F a.out
    ...
    0x00000964:       DW_TAG_member
                        DW_AT_name [DW_FORM_strp]   ("_M_head_impl")
                        DW_AT_decl_file [DW_FORM_data1]     ("/usr/include/c++/11.1.0/tuple")
                        DW_AT_decl_line [DW_FORM_data1]     (125)
                        DW_AT_decl_column [DW_FORM_data1]   (0x27)
                        DW_AT_type [DW_FORM_ref4]   (0x0000067a "default_delete<int>")
                        DW_AT_data_member_location [DW_FORM_sdata]  (-1)
    ...

This leads to a GDB crash (when built with ASan, otherwise probably
garbage results), since it tries to read just before (to the left, in
ASan speak) of the value's buffer:

    ==888645==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000c52af at pc 0x7f711b239f4b bp 0x7fff356bd470 sp 0x7fff356bcc18
    READ of size 1 at 0x6020000c52af thread T0
        #0 0x7f711b239f4a in __interceptor_memcpy /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
        #1 0x555c4977efa1 in value_contents_copy_raw /home/simark/src/binutils-gdb/gdb/value.c:1347
        #2 0x555c497909cd in value_primitive_field(value*, long, int, type*) /home/simark/src/binutils-gdb/gdb/value.c:3126
        #3 0x555c478f2eaa in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:333
        #4 0x555c478f63b2 in cp_print_value /home/simark/src/binutils-gdb/gdb/cp-valprint.c:513
        #5 0x555c478f02ca in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:161
        #6 0x555c478f63b2 in cp_print_value /home/simark/src/binutils-gdb/gdb/cp-valprint.c:513
        #7 0x555c478f02ca in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:161
        #8 0x555c478f63b2 in cp_print_value /home/simark/src/binutils-gdb/gdb/cp-valprint.c:513
        #9 0x555c478f02ca in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:161
        #10 0x555c4760d45f in c_value_print_struct /home/simark/src/binutils-gdb/gdb/c-valprint.c:383
        #11 0x555c4760df4c in c_value_print_inner(value*, ui_file*, int, value_print_options const*) /home/simark/src/binutils-gdb/gdb/c-valprint.c:438
        #12 0x555c483ff9a7 in language_defn::value_print_inner(value*, ui_file*, int, value_print_options const*) const /home/simark/src/binutils-gdb/gdb/language.c:632
        #13 0x555c49758b68 in do_val_print /home/simark/src/binutils-gdb/gdb/valprint.c:1048
        #14 0x555c49759b17 in common_val_print(value*, ui_file*, int, value_print_options const*, language_defn const*) /home/simark/src/binutils-gdb/gdb/valprint.c:1151
        #15 0x555c478f2fcb in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:335
        #16 0x555c478f63b2 in cp_print_value /home/simark/src/binutils-gdb/gdb/cp-valprint.c:513
        #17 0x555c478f02ca in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:161
        #18 0x555c4760d45f in c_value_print_struct /home/simark/src/binutils-gdb/gdb/c-valprint.c:383
        #19 0x555c4760df4c in c_value_print_inner(value*, ui_file*, int, value_print_options const*) /home/simark/src/binutils-gdb/gdb/c-valprint.c:438
        #20 0x555c483ff9a7 in language_defn::value_print_inner(value*, ui_file*, int, value_print_options const*) const /home/simark/src/binutils-gdb/gdb/language.c:632
        #21 0x555c49758b68 in do_val_print /home/simark/src/binutils-gdb/gdb/valprint.c:1048
        #22 0x555c49759b17 in common_val_print(value*, ui_file*, int, value_print_options const*, language_defn const*) /home/simark/src/binutils-gdb/gdb/valprint.c:1151
        #23 0x555c478f2fcb in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:335
        #24 0x555c4760d45f in c_value_print_struct /home/simark/src/binutils-gdb/gdb/c-valprint.c:383
        #25 0x555c4760df4c in c_value_print_inner(value*, ui_file*, int, value_print_options const*) /home/simark/src/binutils-gdb/gdb/c-valprint.c:438
        #26 0x555c483ff9a7 in language_defn::value_print_inner(value*, ui_file*, int, value_print_options const*) const /home/simark/src/binutils-gdb/gdb/language.c:632
        #27 0x555c49758b68 in do_val_print /home/simark/src/binutils-gdb/gdb/valprint.c:1048
        #28 0x555c49759b17 in common_val_print(value*, ui_file*, int, value_print_options const*, language_defn const*) /home/simark/src/binutils-gdb/gdb/valprint.c:1151
        #29 0x555c4760f04c in c_value_print(value*, ui_file*, value_print_options const*) /home/simark/src/binutils-gdb/gdb/c-valprint.c:587
        #30 0x555c483ff954 in language_defn::value_print(value*, ui_file*, value_print_options const*) const /home/simark/src/binutils-gdb/gdb/language.c:614
        #31 0x555c49759f61 in value_print(value*, ui_file*, value_print_options const*) /home/simark/src/binutils-gdb/gdb/valprint.c:1189
        #32 0x555c48950f70 in print_formatted /home/simark/src/binutils-gdb/gdb/printcmd.c:337
        #33 0x555c48958eda in print_value(value*, value_print_options const&) /home/simark/src/binutils-gdb/gdb/printcmd.c:1258
        #34 0x555c48959891 in print_command_1 /home/simark/src/binutils-gdb/gdb/printcmd.c:1367
        #35 0x555c4895a3df in print_command /home/simark/src/binutils-gdb/gdb/printcmd.c:1458
        #36 0x555c4767f974 in do_simple_func /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:97
        #37 0x555c47692e25 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:2475
        #38 0x555c4936107e in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:670
        #39 0x555c485f1bff in catch_command_errors /home/simark/src/binutils-gdb/gdb/main.c:523
        #40 0x555c485f249c in execute_cmdargs /home/simark/src/binutils-gdb/gdb/main.c:618
        #41 0x555c485f6677 in captured_main_1 /home/simark/src/binutils-gdb/gdb/main.c:1317
        #42 0x555c485f6c83 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1338
        #43 0x555c485f6d65 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1363
        #44 0x555c46e41ba8 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32
        #45 0x7f71198bcb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
        #46 0x555c46e4197d in _start (/home/simark/build/binutils-gdb-one-target/gdb/gdb+0x77f197d)

    0x6020000c52af is located 1 bytes to the left of 8-byte region [0x6020000c52b0,0x6020000c52b8)
    allocated by thread T0 here:
        #0 0x7f711b2b7459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x555c470acdc9 in xcalloc /home/simark/src/binutils-gdb/gdb/alloc.c:100
        #2 0x555c49b775cd in xzalloc(unsigned long) /home/simark/src/binutils-gdb/gdbsupport/common-utils.cc:29
        #3 0x555c4977bdeb in allocate_value_contents /home/simark/src/binutils-gdb/gdb/value.c:1029
        #4 0x555c4977be25 in allocate_value(type*) /home/simark/src/binutils-gdb/gdb/value.c:1040
        #5 0x555c4979030d in value_primitive_field(value*, long, int, type*) /home/simark/src/binutils-gdb/gdb/value.c:3092
        #6 0x555c478f6280 in cp_print_value /home/simark/src/binutils-gdb/gdb/cp-valprint.c:501
        #7 0x555c478f02ca in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:161
        #8 0x555c478f63b2 in cp_print_value /home/simark/src/binutils-gdb/gdb/cp-valprint.c:513
        #9 0x555c478f02ca in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:161
        #10 0x555c478f63b2 in cp_print_value /home/simark/src/binutils-gdb/gdb/cp-valprint.c:513
        #11 0x555c478f02ca in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:161
        #12 0x555c4760d45f in c_value_print_struct /home/simark/src/binutils-gdb/gdb/c-valprint.c:383
        #13 0x555c4760df4c in c_value_print_inner(value*, ui_file*, int, value_print_options const*) /home/simark/src/binutils-gdb/gdb/c-valprint.c:438
        #14 0x555c483ff9a7 in language_defn::value_print_inner(value*, ui_file*, int, value_print_options const*) const /home/simark/src/binutils-gdb/gdb/language.c:632
        #15 0x555c49758b68 in do_val_print /home/simark/src/binutils-gdb/gdb/valprint.c:1048
        #16 0x555c49759b17 in common_val_print(value*, ui_file*, int, value_print_options const*, language_defn const*) /home/simark/src/binutils-gdb/gdb/valprint.c:1151
        #17 0x555c478f2fcb in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:335
        #18 0x555c478f63b2 in cp_print_value /home/simark/src/binutils-gdb/gdb/cp-valprint.c:513
        #19 0x555c478f02ca in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:161
        #20 0x555c4760d45f in c_value_print_struct /home/simark/src/binutils-gdb/gdb/c-valprint.c:383
        #21 0x555c4760df4c in c_value_print_inner(value*, ui_file*, int, value_print_options const*) /home/simark/src/binutils-gdb/gdb/c-valprint.c:438
        #22 0x555c483ff9a7 in language_defn::value_print_inner(value*, ui_file*, int, value_print_options const*) const /home/simark/src/binutils-gdb/gdb/language.c:632
        #23 0x555c49758b68 in do_val_print /home/simark/src/binutils-gdb/gdb/valprint.c:1048
        #24 0x555c49759b17 in common_val_print(value*, ui_file*, int, value_print_options const*, language_defn const*) /home/simark/src/binutils-gdb/gdb/valprint.c:1151
        #25 0x555c478f2fcb in cp_print_value_fields(value*, ui_file*, int, value_print_options const*, type**, int) /home/simark/src/binutils-gdb/gdb/cp-valprint.c:335
        #26 0x555c4760d45f in c_value_print_struct /home/simark/src/binutils-gdb/gdb/c-valprint.c:383
        #27 0x555c4760df4c in c_value_print_inner(value*, ui_file*, int, value_print_options const*) /home/simark/src/binutils-gdb/gdb/c-valprint.c:438
        #28 0x555c483ff9a7 in language_defn::value_print_inner(value*, ui_file*, int, value_print_options const*) const /home/simark/src/binutils-gdb/gdb/language.c:632
        #29 0x555c49758b68 in do_val_print /home/simark/src/binutils-gdb/gdb/valprint.c:1048

Since there are some binaries with this in the wild, I think it would be
useful for GDB to work around this.  I did the obvious simple thing, if
the DW_AT_data_member_location's value is -1, replace it with 0.  I
added a producer check to only apply this fixup for GCC 11.  The idea is
that if some other compiler ever uses a DW_AT_data_member_location value
of -1 by mistake, we don't know (before analyzing the bug at least) if
they did mean 0 or some other value.  So I wouldn't want to apply the
fixup in that case.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28063
Change-Id: Ieef3459b0b9bbce8bdad838ba83b4b64e7269d42

2 years agoFix GDB internal error by using text (instead of data) section offset
Kevin Buettner [Tue, 25 Jan 2022 21:45:16 +0000 (14:45 -0700)] 
Fix GDB internal error by using text (instead of data) section offset

Fedora Rawhide is now using gcc-12.0.  As part of updating to the
gcc-12.0 package set, Rawhide is also now using a version of libgcc_s
which lacks a .data section.  This causes gdb to fail in the following
fashion while debugging a program (such as gdb) which uses libgcc_s:

    (top-gdb) run
    Starting program: rawhide-master/bld/gdb/gdb
    ...
    objfiles.h:467: internal-error: sect_index_data not initialized
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    ...

I snipped the backtrace from the above output.  Instead, here's a
portion of a backtrace obtained using GDB's backtrace command.
(Obviously, in order to obtain it, I used a GDB which has been patched
with this commit.)

    #0  internal_error (
file=0xc6a508 "gdb/objfiles.h", line=467,
fmt=0xc6a4e8 "sect_index_data not initialized")
at gdbsupport/errors.cc:51
    #1  0x00000000005f9651 in objfile::data_section_offset (this=0x4fa48f0)
at gdb/objfiles.h:467
    #2  0x000000000097c5f8 in relocate_address (address=0x17244, objfile=0x4fa48f0)
at gdb/stap-probe.c:1333
    #3  0x000000000097c630 in stap_probe::get_relocated_address (this=0xa1a17a0,
objfile=0x4fa48f0)
at gdb/stap-probe.c:1341
    #4  0x00000000004d7025 in create_exception_master_breakpoint_probe (
objfile=0x4fa48f0)
at gdb/breakpoint.c:3505
    #5  0x00000000004d7426 in create_exception_master_breakpoint ()
at gdb/breakpoint.c:3575
    #6  0x00000000004efcc1 in breakpoint_re_set ()
at gdb/breakpoint.c:13407
    #7  0x0000000000956998 in solib_add (pattern=0x0, from_tty=0, readsyms=1)
at gdb/solib.c:1001
    #8  0x00000000009576a8 in handle_solib_event ()
at gdb/solib.c:1269
    ...

The function 'relocate_address' in gdb/stap-probe.c attempts to do
its "relocation" by using objfile->data_section_offset().  That
method, data_section_offset() is defined as follows in objfiles.h:

  CORE_ADDR data_section_offset () const
  {
    return section_offsets[SECT_OFF_DATA (this)];
  }

The internal error occurs when the SECT_OFF_DATA macro finds that the
'sect_index_data' field is -1:

    #define SECT_OFF_DATA(objfile) \
 ((objfile->sect_index_data == -1) \
  ? (internal_error (__FILE__, __LINE__, \
     _("sect_index_data not initialized")), -1) \
  : objfile->sect_index_data)

relocate_address() is obtaining the section offset in order to compute
a relocated address.  For some ABIs, such as the System V ABI, the
section offsets will all be the same.  So for those ABIs, it doesn't
matter which offset is used.  However, other ABIs, such as the FDPIC
ABI, will have different offsets for the various sections.  Thus, for
those ABIs, it is vital that this and other relocation code use the
correct offset.

In stap_probe::get_relocated_address, the address to which to add the
offset (thus forming the relocated address) is obtained via
this->get_address (); get_address is a getter for m_address in
probe.h.  It's documented/defined as follows (also in probe.h):

  /* The address where the probe is inserted, relative to
     SECT_OFF_TEXT.  */
  CORE_ADDR m_address;

(Thanks to Tom Tromey for this observation.)

So, based on this, the current use of data_section_offset /
SECT_OFF_DATA is wrong.  This relocation code should have been using
text_section_offset / SECT_OFF_TEXT all along.  That being the
case, I've adjusted the stap-probe.c relocation code accordingly.

Searching the sources turned up one other use of data_section_offset,
in gdb/dtrace-probe.c, so I've updated that code as well.  The same
reasoning presented above applies to this case too.

Summary:

* gdb/dtrace-probe.c (dtrace_probe::get_relocated_address):
Use method text_section_offset instead of data_section_offset.
* gdb/stap-probe.c (relocate_address): Likewise.

2 years agogdb, remote, btrace: move switch_to_thread call right before xfer call
Markus Metzger [Thu, 25 Nov 2021 14:22:24 +0000 (15:22 +0100)] 
gdb, remote, btrace: move switch_to_thread call right before xfer call

In remote_target::remote_btrace_maybe_reopen, we switch to the currently
iterated thread in order to set inferior_ptid for a subsequent xfer.

Move the switch_to_thread call directly before the target_read_stralloc
call to clarify why we need to switch threads.

2 years agogdb, gdbserver: update thread identifier in enable_btrace target method
Markus Metzger [Thu, 25 Nov 2021 14:15:52 +0000 (15:15 +0100)] 
gdb, gdbserver: update thread identifier in enable_btrace target method

The enable_btrace target method takes a ptid_t to identify the thread on
which tracing shall be enabled.

Change this to thread_info * to avoid translating back and forth between
the two.  This will be used in a subsequent patch.

2 years agogdb, btrace: switch threads in remote_btrace_maybe_reopen()
Markus Metzger [Thu, 25 Nov 2021 06:33:20 +0000 (07:33 +0100)] 
gdb, btrace: switch threads in remote_btrace_maybe_reopen()

In remote_btrace_maybe_reopen() we iterate over threads and use
set_general_thread() to set the thread from which to transfer the btrace
configuration.

This sets the remote general thread but does not affect inferior_ptid.  On
the xfer request later on, remote_target::xfer_partial() again sets the
remote general thread to inferior_ptid, overwriting what
remote_btrace_maybe_reopen() had done.

In one case, this led to inferior_ptid being null_ptid when we tried to
enable tracing on a newly created thread inside a newly created process
during attach.

This, in turn, led to find_inferior_pid() asserting when we iterated over
threads in record_btrace_is_replaying(), which was called from
record_btrace_target::xfer_partial() when reading the btrace configuration
of the new thread to check whether it was already being recorded.

The bug was exposed by

    0618ae41497 gdb: optimize all_matching_threads_iterator

and found by

    FAIL: gdb.btrace/enable-new-thread.exp: ... (GDB internal error)

Use switch_to_thread() in remote_btrace_maybe_reopen().

2 years agogdb, btrace: rename record_btrace_enable_warn()
Markus Metzger [Tue, 23 Nov 2021 13:59:47 +0000 (14:59 +0100)] 
gdb, btrace: rename record_btrace_enable_warn()

We use record_btrace_enable_warn() as the new-thread observer callback.
It is not used in other contexts.

Rename it to record_btrace_on_new_thread() to make its role more clear.

2 years agoUpdated Swedish translation for the binutils subdirectory
Nick Clifton [Thu, 27 Jan 2022 11:21:00 +0000 (11:21 +0000)] 
Updated Swedish translation for the binutils subdirectory

2 years agoAutomatic date update in version.in
GDB Administrator [Thu, 27 Jan 2022 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agogdb/python: handle non utf-8 characters when source highlighting
Andrew Burgess [Fri, 26 Nov 2021 13:15:28 +0000 (13:15 +0000)] 
gdb/python: handle non utf-8 characters when source highlighting

This commit adds support for source files that contain non utf-8
characters when performing source styling using the Python pygments
package.  This does not change the behaviour of GDB when the GNU
Source Highlight library is used.

For the following problem description, assume that either GDB is built
without GNU Source Highlight support, of that this has been disabled
using 'maintenance set gnu-source-highlight enabled off'.

The initial problem reported was that a source file containing non
utf-8 characters would cause GDB to print a Python exception, and then
display the source without styling, e.g.:

  Python Exception <class 'UnicodeDecodeError'>: 'utf-8' codec can't decode byte 0xc0 in position 142: invalid start byte
  /* Source code here, without styling...  */

Further, as the user steps through different source files, each time
the problematic source file was evicted from the source cache, and
then later reloaded, the exception would be printed again.

Finally, this problem is only present when using Python 3, this issue
is not present for Python 2.

What makes this especially frustrating is that GDB can clearly print
the source file contents, they're right there...  If we disable
styling completely, or make use of the GNU Source Highlight library,
then everything is fine.  So why is there an error when we try to
apply styling using Python?

The problem is the use of PyString_FromString (which is an alias for
PyUnicode_FromString in Python 3), this function converts a C string
into a either a Unicode object (Py3) or a str object (Py2).  For
Python 2 there is no unicode encoding performed during this function
call, but for Python 3 the input is assumed to be a uft-8 encoding
string for the purpose of the conversion.  And here of course, is the
problem, if the source file contains non utf-8 characters, then it
should not be treated as utf-8, but that's what we do, and that's why
we get an error.

My first thought when looking at this was to spot when the
PyString_FromString call failed with a UnicodeDecodeError and silently
ignore the error.  This would mean that GDB would print the source
without styling, but would also avoid the annoying exception message.

However, I also make use of `pygmentize`, a command line wrapper
around the Python pygments module, which I use to apply syntax
highlighting in the output of `less`.  And this command line wrapper
is quite happy to syntax highlight my source file that contains non
utf-8 characters, so it feels like the problem should be solvable.

It turns out that inside the pygments module there is already support
for guessing the encoding of the incoming file content, if the
incoming content is not already a Unicode string.  This is what
happens for Python 2 where the incoming content is of `str` type.

We could try and make GDB smarter when it comes to converting C
strings into Python Unicode objects; this would probably require us to
just try a couple of different encoding schemes rather than just
giving up after utf-8.

However, I figure, why bother?  The pygments module already does this
for us, and the colorize API is not part of the documented external
API of GDB.  So, why not just change the colorize API, instead of the
content being a Unicode string (for Python 3), lets just make the
content be a bytes object.  The pygments module can then take
responsibility for guessing the encoding.

So, currently, the colorize API receives a unicode object, and returns
a unicode object.  I propose that the colorize API receive a bytes
object, and return a bytes object.

2 years agoRemove global wrap_here function
Tom Tromey [Fri, 31 Dec 2021 22:04:58 +0000 (15:04 -0700)] 
Remove global wrap_here function

This removes the global wrap_here function, so that future calls
cannot be introduced.  Instead, all callers must use the method on the
appropriate ui_file.

This temporarily moves the implementation of this method to utils.c.
This will change once the remaining patches to untangle the pager have
been written.

2 years agoAlways call the wrap_here method
Tom Tromey [Thu, 30 Dec 2021 17:29:03 +0000 (10:29 -0700)] 
Always call the wrap_here method

This changes all existing calls to wrap_here to call the method on the
appropriate ui_file instead.  The choice of ui_file is determined by
context.

2 years agoAdd ui_file::wrap_here
Tom Tromey [Thu, 30 Dec 2021 17:23:18 +0000 (10:23 -0700)] 
Add ui_file::wrap_here

Right now, wrap_here is a global function.  In the long run, we'd like
output streams to be relatively self-contained objects, and having a
global function like this is counter to that goal.  Also, existing
code freely mixes writes to some parameterized stream with calls to
wrap_here -- but wrap_here only really affects gdb_stdout, so this is
also incoherent.

This step is a patch toward making wrap_here more sane.  It adds a
wrap_here method to ui_file and changes ui_out implementations to use
it.

2 years agoConvert wrap_here to use integer parameter
Tom Tromey [Thu, 30 Dec 2021 16:46:02 +0000 (09:46 -0700)] 
Convert wrap_here to use integer parameter

I think it only really makes sense to call wrap_here with an argument
consisting solely of spaces.  Given this, it seemed better to me that
the argument be an int, rather than a string.  This patch is the
result.  Much of it was written by a script.

2 years agogdb/python: improve the auto help text for gdb.Parameter
Andrew Burgess [Fri, 7 Jan 2022 16:48:49 +0000 (16:48 +0000)] 
gdb/python: improve the auto help text for gdb.Parameter

This commit attempts to improve the help text that is generated for
gdb.Parameter objects when the user fails to provide their own
documentation.

Documentation for a gdb.Parameter is currently pulled from two
sources: the class documentation string, and the set_doc/show_doc
class attributes.  Thus, a fully documented parameter might look like
this:

  class Param_All (gdb.Parameter):
     """This is the class documentation string."""

     show_doc = "Show the state of this parameter"
     set_doc = "Set the state of this parameter"

     def get_set_string (self):
        val = "on"
        if (self.value == False):
           val = "off"
        return "Test Parameter has been set to " + val

     def __init__ (self, name):
        super (Param_All, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_BOOLEAN)
        self._value = True

  Param_All ('param-all')

Then in GDB we see this:

  (gdb) help set param-all
  Set the state of this parameter
  This is the class documentation string.

Which is fine.  But, if the user skips both of the documentation parts
like this:

  class Param_None (gdb.Parameter):

     def get_set_string (self):
        val = "on"
        if (self.value == False):
           val = "off"
        return "Test Parameter has been set to " + val

     def __init__ (self, name):
        super (Param_None, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_BOOLEAN)
        self._value = True

  Param_None ('param-none')

Now in GDB we see this:

  (gdb) help set param-none
  This command is not documented.
  This command is not documented.

That's not great, the duplicated text looks a bit weird.  If we drop
different parts we get different results.  Here's what we get if the
user drops the set_doc and show_doc attributes:

  (gdb) help set param-doc
  This command is not documented.
  This is the class documentation string.

That kind of sucks, we say it's undocumented, then proceed to print
the documentation.  Finally, if we drop the class documentation but
keep the set_doc and show_doc:

  (gdb) help set param-set-show
  Set the state of this parameter
  This command is not documented.

That seems OK.

So, I think there's room for improvement.

With this patch, for the four cases above we now see this:

  # All values provided by the user, no change in this case:
  (gdb) help set param-all
  Set the state of this parameter
  This is the class documentation string.

  # Nothing provided by the user, the first string is now different:
  (gdb) help set param-none
  Set the current value of 'param-none'.
  This command is not documented.

  # Only the class documentation is provided, the first string is
  # changed as in the previous case:
  (gdb) help set param-doc
  Set the current value of 'param-doc'.
  This is the class documentation string.

  # Only the set_doc and show_doc are provided, this case is unchanged
  # from before the patch:
  (gdb) help set param-set-show
  Set the state of this parameter
  This command is not documented.

The one place where this change might be considered a negative is when
dealing with prefix commands.  If we create a prefix command but don't
supply the set_doc / show_doc strings, then this is what we saw before
my patch:

  (gdb) python Param_None ('print param-none')
  (gdb) help set print
  set print, set pr, set p
  Generic command for setting how things print.

  List of set print subcommands:

  ... snip ...
  set print param-none -- This command is not documented.
  ... snip ...

And after my patch:

  (gdb) python Param_None ('print param-none')
  (gdb) help set print
  set print, set pr, set p
  Generic command for setting how things print.

  List of set print subcommands:

  ... snip ...
  set print param-none -- Set the current value of 'print param-none'.
  ... snip ...

This seems slightly less helpful than before, but I don't think its
terrible.

Additionally, I've changed what we print when the get_show_string
method is not provided in Python.

Back when gdb.Parameter was first added to GDB, we didn't provide a
show function when registering the internal command object within
GDB.  As a result, GDB would make use of its "magic" mangling of the
show_doc string to create a sentence that would display the current
value (see deprecated_show_value_hack in cli/cli-setshow.c).

However, when we added support for the get_show_string method to
gdb.Parameter, there was an attempt to maintain backward compatibility
by displaying the show_doc string with the current value appended, see
get_show_value in py-param.c.  Unfortunately, this isn't anywhere
close to what deprecated_show_value_hack does, and the results are
pretty poor, for example, this is GDB before my patch:

  (gdb) show param-none
  This command is not documented. off

I think we can all agree that this is pretty bad.

After my patch, we how show this:

  (gdb) show param-none
  The current value of 'param-none' is "off".

Which at least is a real sentence, even if it's not very informative.

This patch does change the way that the Python API behaves slightly,
but only in the cases when the user has missed providing GDB with some
information.  In most cases I think the new behaviour is a lot better,
there's the one case (noted above) which is a bit iffy, but I think is
still OK.

I've updated the existing gdb.python/py-parameter.exp test to cover
the modified behaviour.

Finally, I've updated the documentation to (I hope) make it clearer
how the various bits of help text come together.

2 years agogdb/python: add gdb.history_count function
Andrew Burgess [Mon, 24 Jan 2022 15:19:43 +0000 (15:19 +0000)] 
gdb/python: add gdb.history_count function

Add a new function gdb.history_count to the Python api, this function
returns an integer, the number of items in GDB's value history.

This is useful if you want to pull items from the history by their
absolute number, for example, if you wanted to show a complete history
list.  Previously we could figure out how many items are in the
history list by trying to fetch the items, and then catching the
exception when the item is not available, but having this function
seems nicer.

2 years agoRemove unused declaration
Tom Tromey [Wed, 26 Jan 2022 21:26:44 +0000 (14:26 -0700)] 
Remove unused declaration

This removes an unused declaration from top.h.  This type is not
defined anywhere.

2 years agogdb: convert maintenance target-async and target-non-stop settings to callbacks
Simon Marchi [Thu, 25 Nov 2021 03:11:58 +0000 (22:11 -0500)] 
gdb: convert maintenance target-async and target-non-stop settings to callbacks

This simplifies things a bit, as we don't need two variables and think
about reverting target_async_permitted_1 and target_non_stop_enabled_1
values if we can't change the setting.

Change-Id: I36acab045dacf02ae1988486cfdb27c1dff309f6

2 years agoReference array of structs instead of first member during memcpy
Keith Seitz [Wed, 26 Jan 2022 16:56:18 +0000 (08:56 -0800)] 
Reference array of structs instead of first member during memcpy

aarch64-tdep.c defines the following macro:

#define MEM_ALLOC(MEMS, LENGTH, RECORD_BUF) \
        do  \
          { \
            unsigned int mem_len = LENGTH; \
            if (mem_len) \
              { \
                MEMS =  XNEWVEC (struct aarch64_mem_r, mem_len);  \
                memcpy(&MEMS->len, &RECORD_BUF[0], \
                       sizeof(struct aarch64_mem_r) * LENGTH); \
              } \
          } \
          while (0)

This is simlpy allocating a new array and copying it. However, for
the destination address, it is actually copying into the first member
of the first element of the array (`&MEMS->len"). This elicits a
warning with GCC 12:

../../binutils-gdb/gdb/aarch64-tdep.c: In function ‘int aarch64_process_record(gdbarch*, regcache*, CORE_ADDR)’:
../../binutils-gdb/gdb/aarch64-tdep.c:3711:23: error: writing 16 bytes into a region of size 8 [-Werror=stringop-overflow=]
 3711 |                 memcpy(&MEMS->len, &RECORD_BUF[0], \
      |                       ^
../../binutils-gdb/gdb/aarch64-tdep.c:4394:3: note: in expansion of macro ‘MEM_ALLOC’
 4394 |   MEM_ALLOC (aarch64_insn_r->aarch64_mems, aarch64_insn_r->mem_rec_count,
      |   ^~~~~~~~~
../../binutils-gdb/gdb/aarch64-tdep.c:3721:12: note: destination object ‘aarch64_mem_r::len’ of size 8
 3721 |   uint64_t len;    /* Record length.  */
      |            ^~~

The simple fix is to reference the array, `MEMS' as the destination of the copy.

Tested by rebuilding.

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Tue Jan 25 08:28:32 2022 -0800
#
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Changes to be committed:
# modified:   aarch64-tdep.c
#

2 years agogdb: add string_file::release method
Simon Marchi [Tue, 25 Jan 2022 01:00:46 +0000 (20:00 -0500)] 
gdb: add string_file::release method

A common pattern for string_file is to want to move out the internal
string buffer, because it is the result of the computation that we want
to return.  It is the reason why string_file::string returns a non-const
reference, as explained in the comment.  I think it would make sense to
have a dedicated method for that instead and make string_file::string
return a const reference.

This allows removing the explicit std::move in the typical case.  Note
that compile_program::compute was missing a move, meaning that the
resulting string was copied.  With the new version, it's not possible to
forget to move.

Change-Id: Ieaefa35b73daa7930b2f3a26988b6e3b4121bb79

2 years agoAdd a way to temporarily set a gdb parameter from Python
Tom Tromey [Tue, 4 Jan 2022 18:00:52 +0000 (11:00 -0700)] 
Add a way to temporarily set a gdb parameter from Python

It's sometimes useful to temporarily set some gdb parameter from
Python.  Now that the 'endian' crash is fixed, and now that the
current language is no longer captured by the Python layer, it seems
reasonable to add a helper function for this situation.

This adds a new gdb.with_parameter function.  This creates a context
manager which temporarily sets some parameter to a specified value.
The old value is restored when the context is exited.  This is most
useful with the Python "with" statement:

   with gdb.with_parameter('language', 'ada'):
      ... do Ada stuff

This also adds a simple function to set a parameter,
gdb.set_parameter, as suggested by Andrew.

This is PR python/10790.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=10790

2 years agoFix another crash with gdb parameters in Python
Tom Tromey [Tue, 4 Jan 2022 15:52:40 +0000 (08:52 -0700)] 
Fix another crash with gdb parameters in Python

While looking into the language-capturing issue, I found another way
to crash gdb using parameters from Python:

(gdb) python print(gdb.parameter('endian'))

(This is related to PR python/12188, though this patch isn't going to
fix what that bug is really about.)

The problem here is that the global variable that underlies the
"endian" parameter is initialized to NULL.  However, that's not a
valid value for an "enum" set/show parameter.

My understanding is that, in gdb, an "enum" parameter's underlying
variable must have a value that is "==" (not just strcmp-equal) to one
of the values coming from the enum array.  This invariant is relied on
in various places.

I started this patch by fixing the problem with "endian".  Then I
added some assertions to add_setshow_enum_cmd to try to catch other
problems of the same type.

This patch fixes all the problems that I found.  I also looked at all
the calls to add_setshow_enum_cmd to ensure that they were all
included in the gdb I tested.  I think they are: there are no calls in
nat-* files, or in remote-sim.c; and I was trying a build with all
targets, Python, and Guile enabled.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=12188

2 years agoChange how Python architecture and language are handled
Tom Tromey [Tue, 4 Jan 2022 15:02:24 +0000 (08:02 -0700)] 
Change how Python architecture and language are handled

Currently, gdb's Python layer captures the current architecture and
language when "entering" Python code.  This has some undesirable
effects, and so this series changes how this is handled.

First, there is code like this:

  gdbpy_enter enter_py (python_gdbarch, python_language);

This is incorrect, because both of these are NULL when not otherwise
assigned.  This can cause crashes in some cases -- I've added one to
the test suite.  (Note that this crasher is just an example, other
ones along the same lines are possible.)

Second, when the language is captured in this way, it means that
Python code cannot affect the current language for its own purposes.
It's reasonable to want to write code like this:

    gdb.execute('set language mumble')
    ... stuff using the current language
    gdb.execute('set language previous-value')

However, this won't actually work, because the language is captured on
entry.  I've added a test to show this as well.

This patch changes gdb to try to avoid capturing the current values.
The Python concept of the current gdbarch is only set in those few
cases where a non-default value is computed or needed; and the
language is not captured at all -- instead, in the cases where it's
required, the current language is temporarily changed.

2 years agobfd: Make bfd.stamp depend on source bfd.texi
H.J. Lu [Tue, 25 Jan 2022 17:08:43 +0000 (09:08 -0800)] 
bfd: Make bfd.stamp depend on source bfd.texi

Make bfd.stamp depend on source bfd.texi to avoid regenerating
doc/bfd.info for each make run.

PR binutils/28807
* Makefile.in: Regenerate.
* doc/local.mk (%D%/bfd.stamp): Depend on $(srcdir)/%D%/bfd.texi.

2 years agold: Rewrite lang_size_relro_segment_1
H.J. Lu [Fri, 14 Jan 2022 21:48:36 +0000 (13:48 -0800)] 
ld: Rewrite lang_size_relro_segment_1

1. Compute the desired PT_GNU_RELRO segment base and find the maximum
section alignment of sections starting from the PT_GNU_RELRO segment.
2. Find the first preceding load section.
3. Don't add the 1-page gap between the first preceding load section and
the relro segment if the maximum page size >= the maximum section
alignment.  Align the PT_GNU_RELRO segment first.  Subtract the maximum
page size if therer is still a 1-page gap.

PR ld/28743
PR ld/28819
* ldlang.c (lang_size_relro_segment_1): Rewrite.
* testsuite/ld-x86-64/pr28743-1.d: New file.
* testsuite/ld-x86-64/pr28743-1.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr28743-1.

2 years agogdb/testsuite: Ensure constant test name in gdb.base/break-interp.exp
Lancelot SIX [Wed, 19 Jan 2022 10:44:06 +0000 (05:44 -0500)] 
gdb/testsuite: Ensure constant test name in gdb.base/break-interp.exp

When running the testsuite, I have lines similar to the following in the
gdb.sum file:

~~~
PASS: gdb.base/break-interp.exp: ldprelink=NO: ldsepdebug=NO: first backtrace: p /x 0x7f283d2f0fd1
...
PASS: gdb.base/break-interp.exp: ldprelink=NO: ldsepdebug=NO: binprelink=NO: binsepdebug=NO: binpie=NO: INNER: first backtrace: p /x 0x7f00de0317a5
...
~~~

The address part of the command might change between execution of the
test, which adds noise to a diff between two .sum files.

This patch changes to test name to "p /x $pc" in order to have constant
test name.

Tested on x86_64-Linux.

Change-Id: I973c1237a084dd6d424276443cbf0920533c9a21

2 years agoAutomatic date update in version.in
GDB Administrator [Wed, 26 Jan 2022 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agoAlways print the "host libthread-db" message to stdout
Tom Tromey [Thu, 30 Dec 2021 19:13:52 +0000 (12:13 -0700)] 
Always print the "host libthread-db" message to stdout

linux-thread-db.c has a bit of unusual code that unconditionally
prints a message, but decides whether to print to gdb_stdout or
gdb_stdlog based on a debug flag.  It seems better to me to simply
always print this; and this is the only spot in gdb where we
conditionally pass gdb_stdout to one of the f*_unfiltered functions.

2 years agoReduce explicit use of gdb_stdout
Tom Tromey [Fri, 31 Dec 2021 00:31:41 +0000 (17:31 -0700)] 
Reduce explicit use of gdb_stdout

In an earlier version of the pager rewrite series, it was important to
audit unfiltered output calls to see which were truly necessary.

This is no longer necessary, but it still seems like a decent cleanup
to change calls to avoid explicitly passing gdb_stdout.  That is,
rather than using something like fprintf_unfiltered with gdb_stdout,
the code ought to use plain printf_unfiltered instead.

This patch makes this change.  I went ahead and converted all the
_filtered calls I could find, as well, for the same clarity.

2 years agoSent timing stats to gdb_stdlog
Tom Tromey [Wed, 29 Dec 2021 21:16:02 +0000 (14:16 -0700)] 
Sent timing stats to gdb_stdlog

This changes the time / space / symtab per-command statistics code to
send its output to gdb_stdlog rather than gdb_stdout.  This seems
slightly more correct to me.

2 years agoSend some error output to gdb_stderr
Tom Tromey [Wed, 29 Dec 2021 19:50:25 +0000 (12:50 -0700)] 
Send some error output to gdb_stderr

This changes some code to send some error messages to gdb_stderr
rather than gdb_stdout.

2 years agoFix a probem building the binutils on SPARC/amd64
Klaus Ziegler [Tue, 25 Jan 2022 17:33:03 +0000 (17:33 +0000)] 
Fix a probem building the binutils on SPARC/amd64

PR 28816
* elf/common.h (AT_SUN_HWCAP): Make definition conditional.

2 years agobfd: Regenerate Makefile.in
H.J. Lu [Tue, 25 Jan 2022 16:54:36 +0000 (08:54 -0800)] 
bfd: Regenerate Makefile.in

* Makefile.in: Regenerate.

2 years agogold: drop old cygnus install hack
Mike Frysinger [Sun, 23 Jan 2022 17:53:22 +0000 (12:53 -0500)] 
gold: drop old cygnus install hack

The gold subdir doesn't actually have a manual, so this hack doesn't
do anything.  Plus the automake cygnus option was removed years ago
by Simon in d0ac1c44885daf68f631befa37e ("Bump to autoconf 2.69 and
automake 1.15.1").  So delete it here.

2 years agogas: drop old cygnus install hack
Mike Frysinger [Sun, 23 Jan 2022 17:44:24 +0000 (12:44 -0500)] 
gas: drop old cygnus install hack

This was needed when gas was using the automake cygnus option, but
this was removed years ago by Simon in d0ac1c44885daf68f631befa37e
("Bump to autoconf 2.69 and automake 1.15.1").  So delete it here.
The info pages are already & still installed by default w/out it.

2 years agoAutomatic date update in version.in
GDB Administrator [Tue, 25 Jan 2022 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agobfd: Update doc/local.mk
H.J. Lu [Mon, 24 Jan 2022 15:39:44 +0000 (07:39 -0800)] 
bfd: Update doc/local.mk

PR binutils/28807
* Makefile.in: Regenerate.
* doc/local.mk (AM_MAKEINFOFLAGS): Add -I "$(srcdir)/%D%" -I %D%.
(TEXI2DVI): New.
(%D%/bfd.texi): Removed.
(doc/bfd/index.html): Remove -I$(srcdir).  Replace bfd.texi with
%D%/bfd.texi.

2 years agobfd/doc: Fix racy build failure from missing mkdir
Roland McGrath [Mon, 24 Jan 2022 20:38:50 +0000 (12:38 -0800)] 
bfd/doc: Fix racy build failure from missing mkdir

bfd/
* doc/local.mk (%D%/bfdver.texi): Add mkdir command.

2 years agoFix a proble building the libiberty library with gcc-12.
Martin Sebor [Mon, 24 Jan 2022 17:56:23 +0000 (17:56 +0000)] 
Fix a proble building the libiberty library with gcc-12.

PR 28779
* regex.c: Suppress -Wuse-after-free.

2 years agogdb/doc: improve description for Window.click on Python TUI windows
Andrew Burgess [Mon, 24 Jan 2022 10:33:23 +0000 (10:33 +0000)] 
gdb/doc: improve description for Window.click on Python TUI windows

The description of the Window.click method doesn't mention where the
coordinates are anchored (it's the top left corner).

This minor tweak just mentions this point.

2 years agoUpdate Bulgarian, French, Romaniam and Ukranian translation for some of the sub-direc...
Nick Clifton [Mon, 24 Jan 2022 14:22:49 +0000 (14:22 +0000)] 
Update Bulgarian, French, Romaniam and Ukranian translation for some of the sub-directories

2 years agoAutomatic date update in version.in
GDB Administrator [Mon, 24 Jan 2022 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agoSimplify some Rust expression-evaluation code
Tom Tromey [Sun, 23 Jan 2022 19:48:38 +0000 (12:48 -0700)] 
Simplify some Rust expression-evaluation code

A few Rust operations do a bit of work in their 'evaluate' functions
and then call another function -- but are also the only caller.  This
patch simplifies this code by removing the extra layer.

Tested on x86-64 Fedora 34.  I'm checking this in.

2 years agobfd: Partially revert commit 0e3839bde6f
H.J. Lu [Sun, 23 Jan 2022 18:40:46 +0000 (10:40 -0800)] 
bfd: Partially revert commit 0e3839bde6f

Partially revert

commit 0e3839bde6f93e1e3eefce815be3636e3d81054d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Jan 23 07:29:27 2022 -0800

    bfd: Properly install library and header files

PR binutils/28807
* Makefile.am: Revert bfdlib_LTLIBRARIES and bfdinclude_HEADERS
changes.
* Makefile.in: Regenerate.

2 years agobfd: Properly install library and header files
H.J. Lu [Sun, 23 Jan 2022 15:29:27 +0000 (07:29 -0800)] 
bfd: Properly install library and header files

Rename bfdlib_LTLIBRARIES and bfdinclude_HEADERS to lib_LTLIBRARIES and
include_HEADERS to fix the missing installed library and header files in
bfd caused by

commit bd32be01c997f686ab0b53f0640eaa0aeb61fbd3
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Fri Dec 3 00:23:20 2021 -0500

    bfd: merge doc subdir up a level

PR binutils/28807
* Makefile.am (bfdlib_LTLIBRARIES): Renamed to ...
(lib_LTLIBRARIES): This.
(bfdinclude_HEADERS): Renamed to ...
(include_HEADERS): This.
* Makefile.in: Regenerate.
* doc/local.mk (install): Removed.

2 years agoRegenerate Makefile.in files with automake 1.15.1
H.J. Lu [Sun, 23 Jan 2022 14:59:20 +0000 (06:59 -0800)] 
Regenerate Makefile.in files with automake 1.15.1

Regenerate Makefile.in files with the unmodified automake 1.15.1 to
remove

runstatedir = @runstatedir@

bfd/

* Makefile.in: Regenerate.

binutils/

* Makefile.in: Regenerate.

gas/

* Makefile.in: Regenerate.

gold/

* Makefile.in: Regenerate.
* testsuite/Makefile.in: Likewise.

gprof/

* Makefile.in: Regenerate.

ld/

* Makefile.in: Regenerate.

opcodes/

* Makefile.in: Regenerate.

2 years agoRegenerate configure files with autoconf 2.69
H.J. Lu [Sun, 23 Jan 2022 13:27:01 +0000 (05:27 -0800)] 
Regenerate configure files with autoconf 2.69

Regenerate configure files with the unmodified autoconf 2.69 to remove

  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]

bfd/

* configure: Regenerate.

binutils/

* configure: Regenerate.

gas/

* configure: Regenerate.

gold/

* configure: Regenerate.

gprof/

* configure: Regenerate.

ld/

* configure: Regenerate.

opcodes/

* configure: Regenerate.

2 years agoAutomatic date update in version.in
GDB Administrator [Sun, 23 Jan 2022 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agobfd: merge doc subdir up a level
Mike Frysinger [Fri, 3 Dec 2021 05:23:20 +0000 (00:23 -0500)] 
bfd: merge doc subdir up a level

This avoids a recursive make into the doc subdir and speeds up the
build slightly.  It also allows for more parallelism.

2 years agobfd: rename core.texi to corefile.texi
Mike Frysinger [Mon, 20 Dec 2021 07:05:31 +0000 (02:05 -0500)] 
bfd: rename core.texi to corefile.texi

This is a generated file name from a correspondingly named C file.
Rename it to avoid unique build rules since there's no difference
to the generated manual.

2 years agobfd: replace doc header generation with pattern rules
Mike Frysinger [Mon, 20 Dec 2021 06:02:19 +0000 (01:02 -0500)] 
bfd: replace doc header generation with pattern rules

This unifies boilerplate rules for most files with pattern rules.

2 years agoAllow inferring tmp_prefix from the dll name from a def file.
Martin Storsj? [Sat, 22 Jan 2022 14:31:22 +0000 (14:31 +0000)] 
Allow inferring tmp_prefix from the dll name from a def file.

2 years agoAdjust default page sizes for haiku arm.
Alexander von Gluck IV [Sat, 22 Jan 2022 14:18:34 +0000 (14:18 +0000)] 
Adjust default page sizes for haiku arm.

* configure.tgt (arm-haiku): Fix typo.
* emulparams/armelf_haiku.su (MAXPAGESIZE): Use the default value.
(COMMONPAGESIZE): Likewise.

2 years agoUpdate release makeing script with new release numbers
Nick Clifton [Sat, 22 Jan 2022 13:26:54 +0000 (13:26 +0000)] 
Update release makeing script with new release numbers

2 years agoChange version number to 2.38.50 and regenerate files
Nick Clifton [Sat, 22 Jan 2022 12:39:28 +0000 (12:39 +0000)] 
Change version number to 2.38.50 and regenerate files

2 years agoAdd markers for 2.38 branch
Nick Clifton [Sat, 22 Jan 2022 12:08:55 +0000 (12:08 +0000)] 
Add markers for 2.38 branch

2 years agoRISC-V: create new frag after alignment.
Lifang Xia [Thu, 20 Jan 2022 02:42:55 +0000 (10:42 +0800)] 
RISC-V: create new frag after alignment.

PR 28793:

The alignment may be removed in linker. We need to create new frag after
alignment to prevent the assembler from computing static offsets.

gas/
* config/tc-riscv.c (riscv_frag_align_code): Create new frag.

2 years agoAutomatic date update in version.in
GDB Administrator [Sat, 22 Jan 2022 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agogdb: include gdbsupport/buildargv.h in ser-mingw.c
Simon Marchi [Fri, 21 Jan 2022 16:33:29 +0000 (11:33 -0500)] 
gdb: include gdbsupport/buildargv.h in ser-mingw.c

Fixes:

      CXX    ser-mingw.o
    /home/simark/src/binutils-gdb/gdb/ser-mingw.c: In function ‘int pipe_windows_open(serial*, const char*)’:
    /home/simark/src/binutils-gdb/gdb/ser-mingw.c:870:3: error: ‘gdb_argv’ was not declared in this scope
      870 |   gdb_argv argv (name);
          |   ^~~~~~~~

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28802
Change-Id: I7f3e8ec5f9ca8582d587545fdf6b69901259f199

2 years agoUpdated Serbian translation for the ld sub-directory
Nick Clifton [Fri, 21 Jan 2022 15:42:18 +0000 (15:42 +0000)] 
Updated Serbian translation for the ld sub-directory

2 years agogdb/doc: fill in two missing @r
Andrew Burgess [Fri, 21 Jan 2022 12:49:48 +0000 (12:49 +0000)] 
gdb/doc: fill in two missing @r

I noticed two places in the docs where we appear to be missing @r.
makeinfo seems to do the correct things despite these being
missing (at least, I couldn't see any difference in the pdf or info
output), but it doesn't hurt to have the @r in place.

2 years agodrop old unused stamp-h.in file
Mike Frysinger [Fri, 21 Jan 2022 04:09:42 +0000 (23:09 -0500)] 
drop old unused stamp-h.in file

This was needed by ancient versions of automake, but that hasn't been
the case since at least automake-1.5, so punt this from the tree.

2 years agogdbsupport/gdb_regex.cc: replace defs.h include with common-defs.h
Simon Marchi [Fri, 21 Jan 2022 03:57:11 +0000 (22:57 -0500)] 
gdbsupport/gdb_regex.cc: replace defs.h include with common-defs.h

This was forgotten when gdb_regex was moved from gdb to gdbsupport.

Change-Id: I73b446f71861cabbf7afdb7408ef9d59fa64b804

2 years agoAutomatic date update in version.in
GDB Administrator [Fri, 21 Jan 2022 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agoAvoid bad breakpoints with --gc-sections
Tom Tromey [Thu, 13 Jan 2022 16:48:18 +0000 (09:48 -0700)] 
Avoid bad breakpoints with --gc-sections

We found a case where --gc-sections can cause gdb to set an invalid
breakpoint.  In the included test case, gdb will set a breakpoint with
two locations, one of which is 0x0.

The code in lnp_state_machine::check_line_address is intended to
filter out this sort of problem, but in this case, the entire CU is
empty, causing unrelocated_lowpc==0x0 -- which circumvents the check.

It seems to me that if a CU is empty like this, then it is ok to
simply ignore the line table, as there won't be any locations anyway.

2 years agoAutomatic date update in version.in
GDB Administrator [Thu, 20 Jan 2022 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agoAdd `set print array-indexes' tests for C/C++ arrays
Maciej W. Rozycki [Wed, 19 Jan 2022 21:55:10 +0000 (21:55 +0000)] 
Add `set print array-indexes' tests for C/C++ arrays

Add `set print array-indexes' tests for C/C++ arrays, complementing one
for Fortran arrays.

2 years agoRespect `set print array-indexes' with Fortran arrays
Maciej W. Rozycki [Wed, 19 Jan 2022 21:55:10 +0000 (21:55 +0000)] 
Respect `set print array-indexes' with Fortran arrays

Add `set print array-indexes' handling for Fortran arrays.  Currently
the setting is ignored and indices are never shown.

Keep track of the most recent index handled so that any outstanding
repeated elements printed when the limit set by `set print elements' is
hit have the correct index shown.

Output now looks like:

(gdb) set print array-indexes on
(gdb) print array_1d
$1 = ((-2) = 1, (-1) = 1, (0) = 1, (1) = 1, (2) = 1)
(gdb) set print repeats 4
(gdb) set print elements 12
(gdb) print array_2d
$2 = ((-2) = ((-2) = 2, <repeats 5 times>) (-1) = ((-2) = 2, <repeats 5 times>) (0) = ((-2) = 2, (-1) = 2, ...) ...)
(gdb)

for a 5-element vector and a 5 by 5 array filled with the value of 2.

2 years agoAdd `set print repeats' tests for C/C++ arrays
Maciej W. Rozycki [Wed, 19 Jan 2022 21:55:10 +0000 (21:55 +0000)] 
Add `set print repeats' tests for C/C++ arrays

Add `set print repeats' tests for C/C++ arrays, complementing one for
Fortran arrays and covering the different interpretation of the `set
print elements' setting in particular where the per-dimension count of
the elements handled is matched against the trigger rather than the
total element count as with Fortran arrays.

2 years agoRespect `set print repeats' with Fortran arrays
Maciej W. Rozycki [Wed, 19 Jan 2022 21:55:10 +0000 (21:55 +0000)] 
Respect `set print repeats' with Fortran arrays

Implement `set print repeats' handling for Fortran arrays.  Currently
the setting is ignored and always treated as if no limit was set.

Unlike the generic array walker implemented decades ago the Fortran one
is a proper C++ class.  Rather than trying to mimic the old walker then,
which turned out a bit of a challenge where interacting with the `set
print elements' setting, write it entirely from scratch, by adding an
extra specialization handler method for processing dimensions other than
the innermost one and letting the specialization class call the `walk_1'
method from the handler as it sees fit.  This way repeats can be tracked
and the next inner dimension recursed into as a need arises only, or
unconditionally in the base class.

Keep track of the dimension number being handled in the class rather as
a parameter to the walker so that it does not have to be passed across
by the specialization class.

Use per-dimension element count tracking, needed to terminate processing
early when the limit set by `set print elements' is hit.  This requires
extra care too where the limit triggers exactly where another element
that is a subarray begins.  In that case rather than recursing we need
to terminate processing or lone `(...)' would be printed.  Additionally
if the skipped element is the last one in the current dimension we need
to print `...' by hand, because `continue_walking' won't print it at the
upper level, because it can see the last element has already been taken
care of.

Preserve the existing semantics of `set print elements' where the total
count of the elements handled is matched against the trigger level which
is unlike with the C/C++ array printer where the per-dimension element
count is used instead.

Output now looks like:

(gdb) set print repeats 4
(gdb) print array_2d
$1 = ((2, <repeats 5 times>) <repeats 5 times>)
(gdb) set print elements 12
(gdb) print array_2d
$2 = ((2, <repeats 5 times>) (2, <repeats 5 times>) (2, 2, ...) ...)
(gdb)

for a 5 by 5 array filled with the value of 2.

Amend existing test cases accordingly that rely on the current incorrect
behavior and explicitly request that there be no limit for printing
repeated elements there.

Add suitable test cases as well covering sliced arrays in particular.

Co-Authored-By: Andrew Burgess <andrew.burgess@embecosm.com>
2 years agofbsd-nat: Add include for gdb_argv.
John Baldwin [Wed, 19 Jan 2022 16:30:38 +0000 (08:30 -0800)] 
fbsd-nat: Add include for gdb_argv.

2 years agoPowerPC64 DT_RELR ELFv1
Alan Modra [Wed, 19 Jan 2022 02:49:51 +0000 (13:19 +1030)] 
PowerPC64 DT_RELR ELFv1

More fun with R_PPC64_NONE found in .opd.  Fixed by the
allocate_dynrelocs and ppc64_elf_size_dynamic_sections changes, and
since we are doing ifunc, opd and SYMBOL_REFERENCES_LOCAL tests later,
don't duplicate that work in check_relocs.

* elf64-ppc.c (ppc64_elf_check_relocs): Remove opd and ifunc
conditions for rel_count.
(dec_dynrel_count): Likewise.
(allocate_dynrelocs): Test for opd and ifunc when allocating
relative relocs.
(ppc64_elf_size_dynamic_sections): Likewise.

2 years agoPowerPC64 DT_RELR local PLT
Alan Modra [Wed, 19 Jan 2022 02:58:04 +0000 (13:28 +1030)] 
PowerPC64 DT_RELR local PLT

Similarly to the local GOT case.

* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Don't allocate
space for PLT relocs against local syms when enable_dt_relr.

2 years agoPowerPC64 DT_RELR local GOT
Alan Modra [Wed, 19 Jan 2022 00:23:53 +0000 (10:53 +1030)] 
PowerPC64 DT_RELR local GOT

Fixes another case where we end up with superfluous R_PPC64_NONE.

* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Don't allocate
space for GOT relocs against non-TLS local syms when enable_dt_relr.
(ppc64_elf_layout_multitoc): Likewise.

2 years agoAutomatic date update in version.in
GDB Administrator [Wed, 19 Jan 2022 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agoRe: PowerPC64 DT_RELR
Alan Modra [Tue, 18 Jan 2022 23:05:00 +0000 (09:35 +1030)] 
Re: PowerPC64 DT_RELR

HJ: "There are 238 R_PPC64_NONEs in libc.so.6 alone."
Indeed, let's make them go away.  I had the SYMBOL_REFERENCES_LOCAL
test in the wrong place.  check_relocs is too early to know whether a
symbol is dynamic in a shared library.  Lots of glibc symbols are made
local by version script, but that doesn't happen until
size_dynamic_sections.

* elf64-ppc.c (ppc64_elf_check_relocs): Don't count relative relocs
here depending on SYMBOL_REFERENCES_LOCAL.
(dec_dynrel_count): Likewise.
(allocate_dynrelocs): Do so here instead.

2 years agoFix the remote-sim.c build
Tom Tromey [Tue, 18 Jan 2022 21:12:23 +0000 (14:12 -0700)] 
Fix the remote-sim.c build

My earlier patch to move gdb_argv broke the remote-sim.c build.  This
patch fixes the bug.  I'm checking it in.

2 years agogdbserver: introduce remote_debug_printf
Simon Marchi [Mon, 17 Jan 2022 02:16:02 +0000 (21:16 -0500)] 
gdbserver: introduce remote_debug_printf

Add remote_debug_printf, and use it for all debug messages controlled by
remote_debug.

Change remote_debug to be a bool, which is trivial in this case.

Change-Id: I90de13cb892faec3830047b571661822b126d6e8

2 years agogdbserver: introduce threads_debug_printf, THREADS_SCOPED_DEBUG_ENTER_EXIT
Simon Marchi [Mon, 17 Jan 2022 02:27:58 +0000 (21:27 -0500)] 
gdbserver: introduce threads_debug_printf, THREADS_SCOPED_DEBUG_ENTER_EXIT

Add the threads_debug_printf and THREADS_SCOPED_DEBUG_ENTER_EXIT, which
use the logging infrastructure from gdbsupport/common-debug.h.  Replace
all debug_print uses that are predicated by debug_threads with
threads_dethreads_debug_printf.  Replace uses of the debug_enter and
debug_exit macros with THREADS_SCOPED_DEBUG_ENTER_EXIT, which serves
essentially the same purpose, but allows showing what comes between the
enter and the exit in an indented form.

Note that "threads" debug is currently used for a bit of everything in
GDBserver, not only threads related stuff.  It should ideally be cleaned
up and separated logically as is done in GDB, but that's out of the
scope of this patch.

Change-Id: I2d4546464462cb4c16f7f1168c5cec5a89f2289a

2 years agogdbserver: turn debug_threads into a boolean
Simon Marchi [Mon, 17 Jan 2022 02:21:24 +0000 (21:21 -0500)] 
gdbserver: turn debug_threads into a boolean

debug_threads is always used as a boolean.  Except in ax.cc and
tracepoint.cc.  These files have their own macros that use
debug_threads, and have a concept of verbosity level.  But they both
have a single level, so it's just a boolean in the end.

Remove this concept of level.  If we ever want to re-introduce it, I
think it will be better implemented in a more common location.

Change debug_threads to bool and adjust some users that were treating it
as an int.

Change-Id: I137f596eaf763a08c977dd74417969cedfee9ecf

2 years agoSimplify Ada catchpoints
Tom Tromey [Thu, 13 Jan 2022 01:11:53 +0000 (18:11 -0700)] 
Simplify Ada catchpoints

All the Ada catchpoints use the same breakpoint_ops contents, because
the catchpoint itself records its kind.  This patch simplifies the
code by removing the redundant ops structures.

2 years agoMove "catch exec" to a new file
Tom Tromey [Wed, 12 Jan 2022 23:13:23 +0000 (16:13 -0700)] 
Move "catch exec" to a new file

The "catch exec" code is reasonably self-contained, and so this patch
moves it out of breakpoint.c (the second largest source file in gdb)
and into a new file, break-catch-exec.c.

2 years agoMove "catch fork" to a new file
Tom Tromey [Wed, 12 Jan 2022 23:03:33 +0000 (16:03 -0700)] 
Move "catch fork" to a new file

The "catch fork" code is reasonably self-contained, and so this patch
moves it out of breakpoint.c (the second largest source file in gdb)
and into a new file, break-catch-fork.c.

2 years agoUnify "catch fork" and "catch vfork"
Tom Tromey [Wed, 12 Jan 2022 22:55:50 +0000 (15:55 -0700)] 
Unify "catch fork" and "catch vfork"

I noticed that "catch fork" and "catch vfork" are nearly identical.
This patch simplifies the code by unifying these two cases.

2 years agoMove gdb_regex to gdbsupport
Tom Tromey [Sat, 1 Jan 2022 18:31:47 +0000 (11:31 -0700)] 
Move gdb_regex to gdbsupport

This moves the gdb_regex convenience class to gdbsupport.

2 years agoIntroduce gdb-hashtab module in gdbsupport
Tom Tromey [Tue, 21 Dec 2021 23:48:38 +0000 (16:48 -0700)] 
Introduce gdb-hashtab module in gdbsupport

gdb has some extensions and helpers for working with the libiberty
hash table.  This patch consolidates these and moves them to
gdbsupport.

2 years agoMove gdb obstack code to gdbsupport
Tom Tromey [Tue, 21 Dec 2021 23:38:32 +0000 (16:38 -0700)] 
Move gdb obstack code to gdbsupport

This moves the gdb-specific obstack code -- both extensions like
obconcat and obstack_strdup, and things like auto_obstack -- to
gdbsupport.

2 years agoMove gdb_argv to gdbsupport
Tom Tromey [Wed, 26 Feb 2020 01:14:19 +0000 (18:14 -0700)] 
Move gdb_argv to gdbsupport

This moves the gdb_argv class to a new header in gdbsupport.

2 years agoSimplify event_location_probe
Tom Tromey [Fri, 14 Jan 2022 16:06:11 +0000 (09:06 -0700)] 
Simplify event_location_probe

event_location_probe currently stores two strings, but really only
needs one.  This patch simplifies it and removes some unnecessary
copies as well.

2 years agoUse std::string in event_location
Tom Tromey [Fri, 14 Jan 2022 15:53:35 +0000 (08:53 -0700)] 
Use std::string in event_location

This changes event_location to use std::string, removing some manual
memory management, and an unnecessary string copy.

2 years agoSplit event_location into subclasses
Tom Tromey [Fri, 14 Jan 2022 15:29:42 +0000 (08:29 -0700)] 
Split event_location into subclasses

event_location uses the old C-style discriminated union approach.
However, it's better to use subclassing, as this makes the code
clearer and removes some chances for error.  This also enables future
cleanups to avoid manual memory management and copies.

2 years agoRemove EL_* macros from location.c
Tom Tromey [Fri, 14 Jan 2022 14:33:33 +0000 (07:33 -0700)] 
Remove EL_* macros from location.c

This patch removes the old-style EL_* macros from location.c.  This
cleans up the code by itself, IMO, but also enables further cleanups
in subsequent patches.

2 years agoBoolify explicit_to_string_internal
Tom Tromey [Fri, 14 Jan 2022 14:26:12 +0000 (07:26 -0700)] 
Boolify explicit_to_string_internal

This changes explicit_to_string_internal to use 'bool' rather than
'int'.