]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
11 months agoAdd extra linker warning message about discrepancies between normal and common symbols.
Nick Clifton [Wed, 7 Jun 2023 13:30:13 +0000 (14:30 +0100)] 
Add extra linker warning message about discrepancies between normal and common symbols.

  PR 30499
  bfd * elflink.c (elf_link_add_object_symbols): Add a message indicating that alignment and size discrepancies between the definition of common symbols and normal symbols are serious and should be investigated.
  ld  * testsuite/ld-elfcomm/elfcomm.exp: Update regexps to match new output from the linker.

11 months ago[gdb/tui] Factor out border-mode help text
Tom de Vries [Wed, 7 Jun 2023 13:10:01 +0000 (15:10 +0200)] 
[gdb/tui] Factor out border-mode help text

I noticed that the help texts for tui border-mode and tui active-border-mode
are similar.

Factor out the common part into macro HELP_ATTRIBUTE_MODE.

Tested on x86_64-linux.

11 months ago[gdb/cli] Handle pending ^C after rl_callback_read_char for readline 7
Tom de Vries [Wed, 7 Jun 2023 12:57:40 +0000 (14:57 +0200)] 
[gdb/cli] Handle pending ^C after rl_callback_read_char for readline 7

In commit faf01aee1d0 ("[gdb] Handle pending ^C after rl_callback_read_char")
we handled a problem (described in detail in that commit) for readline >= 8
using public readline functions rl_pending_signal and rl_check_signals.

For readline 7 (note that we require at least readline 7 so there's no need to
worry about readline 6), there was no fix though, because rl_check_signals was
not available.

Fix this by instead using the private readline function _rl_signal_handler.

There is precedent for using private readline variables and functions, but
it's something we want to get rid of (PR build/10723).  Nevertheless, I think
we can allow this specific instance because it's not used when building
against readline >= 8.

[ In the meanwhile, a fix was committed in the devel branch of the readline
repo, contained in commit 8d0c439 ("rollup of changes since readline-8.2"),
first proposed here (
https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00008.html ). ]

Tested on x86_64-linux, against system readline 7.0 on openSUSE Leap 15.4.

PR cli/27813
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27813

11 months agoFix PR30369 regression on aarch64/arm (PR30506)
Tom de Vries [Tue, 16 May 2023 16:00:51 +0000 (17:00 +0100)] 
Fix PR30369 regression on aarch64/arm (PR30506)

The gdb.dwarf2/dw2-prologue-end-2.exp test was failing for both AArch64 and
Arm.

As Tom pointed out here (https://inbox.sourceware.org/gdb-patches/6663707c-4297-c2f2-a0bd-f3e84fc62aad@suse.de/),
there are issues with both the prologue skipper for AArch64 and Arm and an
incorrect assumption by the testcase.

This patch fixes both of AArch64's and Arm's prologue skippers to not skip past
the end of a function.  It also incorporates a fix to the testcase so it
doesn't assume the prologue skipper will stop at the first instruction of the
functions/labels.

Regression-tested on aarch64-linux/arm-linux Ubuntu 20.04/22.04 and
x86_64-linux Ubuntu 20.04.

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

Co-Authored-By: Tom de Vries <tdevries@suse.de>
Co-Authored-By: Luis Machado <luis.machado@arm.com>
11 months ago[gdb/testsuite] Add missing wait in gdb.python/tui-window-disabled.exp
Tom de Vries [Wed, 7 Jun 2023 09:36:19 +0000 (11:36 +0200)] 
[gdb/testsuite] Add missing wait in gdb.python/tui-window-disabled.exp

While working on PR tui/30526, I noticed a bug in test-case
gdb.python/tui-window-disabled.exp.

Here we send "tui enable" to gdb, but don't wait for it to arrive before
checking for a window box:
...
    send_gdb "tui enable\n"
    Term::check_box "check for python window" 0 0 80 16
...

Fix this by waiting for the prompt to be issued in TUI before doing the check.

Tested on x86_64-linux.

11 months ago[gdb/testsuite] Fix two typos in gdb.python/tui-window-disabled.exp
Tom de Vries [Wed, 7 Jun 2023 09:36:19 +0000 (11:36 +0200)] 
[gdb/testsuite] Fix two typos in gdb.python/tui-window-disabled.exp

Fix two typos in test-case gdb.python/tui-window-disabled.exp.

11 months ago[gdb/testsuite] Handle output after prompt in gdb.threads/step-N-all-progress.exp
Tom de Vries [Wed, 7 Jun 2023 09:36:19 +0000 (11:36 +0200)] 
[gdb/testsuite] Handle output after prompt in gdb.threads/step-N-all-progress.exp

Using "taskset -c 0" I run into this timeout:
...
(gdb) PASS: gdb.threads/step-N-all-progress.exp: non-stop=on: \
  target-non-stop=on: continue to breakpoint: break here
next 3^M
[New Thread 0x7ffff7dbd6c0 (LWP 10202)]^M
50        return 0;^M
(gdb) [Thread 0x7ffff7dbd6c0 (LWP 10202) exited]^M
FAIL: gdb.threads/step-N-all-progress.exp: non-stop=on: target-non-stop=on: \
  next 3 (timeout)
...

The problem is that this test:
...
    gdb_test "next 3" "return 0;"
...
expects no output after the prompt.

Fix this by using -no-prompt-anchor.

Tested on x86_64-linux.

11 months agold-elf/eh5 remove xfail hppa64
Alan Modra [Wed, 7 Jun 2023 07:58:22 +0000 (17:28 +0930)] 
ld-elf/eh5 remove xfail hppa64

Commit cb81e84c72 resulted in an xpass for hppa64-hp-hpux11, but the
test still fails on hpp64-linux.  Let's make it pass for hppa64-linux
too, by accepting pcrel sdata8 encoding in the augmentation data.

11 months agoFix gdb.base/memtag.exp failure
Luis Machado [Tue, 6 Jun 2023 09:57:59 +0000 (10:57 +0100)] 
Fix gdb.base/memtag.exp failure

While running this test on an emulator, I noticed we're failing to match the
output message when "memory-tag check" is issued with no arguments.  That's
because I coded the message using "error" and missed a period at the end.  Other
similar messages are issued with error_no_arg.

This patch changes that call to use error_no_arg.

Tested on aarch64-linux Ubuntu 20.04/22.04.

11 months ago_bfd_free_cached_info
Alan Modra [Wed, 7 Jun 2023 04:46:06 +0000 (14:16 +0930)] 
_bfd_free_cached_info

doc/bfdint.texi and comments in the aout and som code about this
function are just wrong, and its name is not very apt.  Better would
be _bfd_mostly_destroy, and we certainly should not be saying anything
about the possibility of later recreating anything lost by this
function.  What's more, if _bfd_free_cached_info is called when
creating an archive map to reduce memory usage by throwing away
symbols, the target _close_and_cleanup function won't have access to
tdata or section bfd_user_data to tidy memory.  This means most of the
target _close_and_cleanup function won't do anything, and therefore
sometimes will result in memory leaks.

This patch fixes the documentation problems and moves most of the
target _close_and_cleanup code to target _bfd_free_cached_info.
Another notable change is that bfd_generic_bfd_free_cached_info is now
defined as _bfd_free_cached_info rather than _bfd_bool_bfd_true,
ie. the default now frees objalloc memory.

11 months agoMemory leaks in bfd/vms-lib.c
Alan Modra [Wed, 7 Jun 2023 01:23:36 +0000 (10:53 +0930)] 
Memory leaks in bfd/vms-lib.c

* vms-lib.c (vms_lib_read_index): Free malloc'd memory on error
return paths.
(vms_write_index, _bfd_vms_lib_write_archive_contents): Likewise.

11 months agobfd/elf.c strtab memory leak
Alan Modra [Wed, 7 Jun 2023 00:11:57 +0000 (09:41 +0930)] 
bfd/elf.c strtab memory leak

* elf.c (_bfd_elf_compute_section_file_positions): Free strtab
on set_group_contents failure return path.

11 months agoobjcopy memory leaks after errors
Alan Modra [Tue, 6 Jun 2023 00:20:56 +0000 (09:50 +0930)] 
objcopy memory leaks after errors

These aren't important at all, but tidy them in case they obscure
other more important leaks.

* objcopy (copy_file): Close input bfd after errors.

11 months agoAutomatic date update in version.in
GDB Administrator [Wed, 7 Jun 2023 00:00:47 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agolibsframe: fix cosmetic issues and typos
Indu Bhagat [Tue, 6 Jun 2023 17:50:07 +0000 (10:50 -0700)] 
libsframe: fix cosmetic issues and typos

include/
* sframe-api.h (sframe_decoder_get_num_fidx): Use extern.
libsframe/
* sframe-dump.c (dump_sframe_func_with_fres): Fix line length.
* sframe.c (sframe_frame_row_entry_copy): Likewise.
(sframe_decode_fre_start_address): Use the intended type uint32_t.

11 months agoRe: loongarch readelf support
Alan Modra [Tue, 6 Jun 2023 10:26:56 +0000 (19:56 +0930)] 
Re: loongarch readelf support

Commit 89c70cd358b8 apparently results in a bogus "value may be used
uninitialized" warning with some combination of compiler and
optimisation options.

* readelf.c (target_specific_reloc_handling): Init value.

11 months agoAutomatic date update in version.in
GDB Administrator [Tue, 6 Jun 2023 00:01:04 +0000 (00:01 +0000)] 
Automatic date update in version.in

11 months agolibsframe: avoid unnecessary type casts
Indu Bhagat [Mon, 5 Jun 2023 21:16:02 +0000 (14:16 -0700)] 
libsframe: avoid unnecessary type casts

Change the data type of some of the members of the sframe_decoder_ctx
and sframe_encoder_ctx data structures to use the applicable data types
explicitly. Current implementation in libsframe does type casts, which
seem unnecessary.

libsframe/
* libsframe/sframe-impl.h (struct sframe_decoder_ctx): Use
applicable data type explicitly.
(struct sframe_encoder_ctx): Likewise. Use same style of
comments consistently.
* libsframe/sframe.c (struct sf_fde_tbl): Define without
typedef.
(struct sf_fre_tbl): Likewise.
(sframe_decode): Remove unnecessary type casts.
(sframe_encoder_get_funcdesc_at_index): Likewise.
(sframe_encoder_add_fre): Likewise.
(sframe_encoder_add_funcdesc): Likewise.
(sframe_sort_funcdesc): Likewise.
(sframe_encoder_write_sframe): Likewise.

11 months agoELF: Add "#pass" to ld-elf/pr30508.d
H.J. Lu [Mon, 5 Jun 2023 16:32:12 +0000 (09:32 -0700)] 
ELF: Add "#pass" to ld-elf/pr30508.d

Add "#pass" to ld-elf/pr30508.d to allow extra segments.

PR binutils/30508
* testsuite/ld-elf/pr30508.d: Add "#pass".

11 months agoUse unrelocated_addr in dwarf2_fde
Tom Tromey [Mon, 24 Apr 2023 14:23:46 +0000 (08:23 -0600)] 
Use unrelocated_addr in dwarf2_fde

This changes dwarf2_fde to use the unrelocated_addr type.  This
pointed out a latent bug in dwarf2_frame_cache, where a relocated
address is compared to an unrelocated address.

11 months agoUse local "text offset" variable in dwarf2_frame_cache
Tom Tromey [Mon, 24 Apr 2023 14:21:49 +0000 (08:21 -0600)] 
Use local "text offset" variable in dwarf2_frame_cache

A few spots in dwarf2_frame_cache use:

    cache->per_objfile->objfile->text_section_offset ()

... and a subsequent patch will add more, so move this into a local
variable.

11 months agoConstify dwarf2_cie::augmentation
Tom Tromey [Fri, 21 Apr 2023 19:24:01 +0000 (13:24 -0600)] 
Constify dwarf2_cie::augmentation

I noticed that dwarf2_cie::augmentation could be 'const'.

11 months agoUse "unrelocated" terminology in linetable_entry
Tom Tromey [Fri, 21 Apr 2023 15:36:54 +0000 (09:36 -0600)] 
Use "unrelocated" terminology in linetable_entry

I forgot to convert struct linetable_entry to use the "unrelocated"
(as opposed to "raw") terminology.  This patch corrects the oversight.

11 months agoFix comment in address_class
Tom Tromey [Fri, 21 Apr 2023 15:33:08 +0000 (09:33 -0600)] 
Fix comment in address_class

enum address_class has a stale comment referring to
MSYMBOL_VALUE_RAW_ADDRESS, which no longer exists.  This patch updates
the comment.

11 months agoUse unrelocated_addr in dwarf_decode_lines
Tom Tromey [Thu, 20 Apr 2023 19:31:23 +0000 (13:31 -0600)] 
Use unrelocated_addr in dwarf_decode_lines

This changes dwarf_decode_lines to accept an unrelocated_addr and
fixes up the fallout.

11 months agoUse unrelocated_addr in the DWARF reader
Tom Tromey [Thu, 20 Apr 2023 12:32:26 +0000 (06:32 -0600)] 
Use unrelocated_addr in the DWARF reader

This changes various spots in the DWARF reader to use
unrelocated_addr.

11 months agoMove unrelocated_addr to common-types.h
Tom Tromey [Wed, 19 Apr 2023 19:36:56 +0000 (13:36 -0600)] 
Move unrelocated_addr to common-types.h

unrelocated_addr is currently defined in symtab.h, but in order to
avoid having to include that in more places, I wanted to move the type
elsewhere.  I considered defs.h, but it seemed reasonable to have it
next to CORE_ADDR, which is what this patch does.

11 months agoMinor cleanup in loclist_describe_location
Tom Tromey [Thu, 20 Apr 2023 12:33:12 +0000 (06:33 -0600)] 
Minor cleanup in loclist_describe_location

loclist_describe_location already has a per_objfile local variable, so
use it consistently.

11 months agoRemove baseaddr parameter from dwarf2_record_block_ranges
Tom Tromey [Wed, 19 Apr 2023 19:21:51 +0000 (13:21 -0600)] 
Remove baseaddr parameter from dwarf2_record_block_ranges

dwarf2_record_block_ranges is only ever called with the text section
offset, so this patch removes the parameter entirely.  This makes a
subsequent patch a little simpler.

11 months agoELF: Don't warn an empty PT_LOAD with the program headers
H.J. Lu [Fri, 2 Jun 2023 18:54:21 +0000 (11:54 -0700)] 
ELF: Don't warn an empty PT_LOAD with the program headers

When rewriting the program headers, don't warn an empty PT_LOAD with the
program headers.

bfd/

PR binutils/30508
* elf.c (rewrite_elf_program_header): Don't warn if an empty
PT_LOAD contains the program headers.

ld/

PR binutils/30508
* testsuite/ld-elf/pr30508.d: New file.
* testsuite/ld-elf/pr30508.s: Likewise.

11 months agogdb: building inferior strings from within GDB
Andrew Burgess [Tue, 13 Jul 2021 18:44:27 +0000 (14:44 -0400)] 
gdb: building inferior strings from within GDB

History Of This Patch
=====================

This commit aims to address PR gdb/21699.  There have now been a
couple of attempts to fix this issue.  Simon originally posted two
patches back in 2021:

  https://sourceware.org/pipermail/gdb-patches/2021-July/180894.html
  https://sourceware.org/pipermail/gdb-patches/2021-July/180896.html

Before Pedro then posted a version of his own:

  https://sourceware.org/pipermail/gdb-patches/2021-July/180970.html

After this the conversation halted.  Then in 2023 I (Andrew) also took
a look at this bug and posted two versions:

  https://sourceware.org/pipermail/gdb-patches/2023-April/198570.html
  https://sourceware.org/pipermail/gdb-patches/2023-April/198680.html

The approach taken in my first patch was pretty similar to what Simon
originally posted back in 2021.  My second attempt was only a slight
variation on the first.

Pedro then pointed out his older patch, and so we arrive at this
patch.  The GDB changes here are mostly Pedro's work, but updated by
me (Andrew), any mistakes are mine.

The tests here are a combinations of everyone's work, and the commit
message is new, but copies bits from everyone's earlier work.

Problem Description
===================

Bug PR gdb/21699 makes the observation that using $_as_string with
GDB's printf can cause GDB to print unexpected data from the
inferior.  The reproducer is pretty simple:

  #include <stddef.h>
  static char arena[100];

  /* Override malloc() so value_coerce_to_target() gets a known
     pointer, and we know we"ll see an error if $_as_string() gives
     a string that isn't null terminated. */
  void
  *malloc (size_t size)
  {
      memset (arena, 'x', sizeof (arena));
      if (size > sizeof (arena))
          return NULL;
      return arena;
  }

  int
  main ()
  {
    return 0;
  }

And then in a GDB session:

  $ gdb -q test
  Reading symbols from /tmp/test...
  (gdb) start
  Temporary breakpoint 1 at 0x4004c8: file test.c, line 17.
  Starting program: /tmp/test

  Temporary breakpoint 1, main () at test.c:17
  17        return 0;
  (gdb) printf "%s\n", $_as_string("hello")
  "hello"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  (gdb) quit

The problem above is caused by how value_cstring is used within
py-value.c, but once we understand the issue then it turns out that
value_cstring is used in an unexpected way in many places within GDB.

Within py-value.c we have a null-terminated C-style string.  We then
pass a pointer to this string, along with the length of this
string (so not including the null-character) to value_cstring.

In value_cstring GDB allocates an array value of the given character
type, and copies in requested number of characters.  However
value_cstring does not add a null-character of its own.  This means
that the value created by calling value_cstring is only
null-terminated if the null-character is included in the passed in
length.  In py-value.c this is not the case, and indeed, in most uses
of value_cstring, this is not the case.

When GDB tries to print one of these strings the value contents are
pushed to the inferior, and then read back as a C-style string, that
is, GDB reads inferior memory until it finds a null-terminator.  For
the py-value.c case, no null-terminator is pushed into the inferior,
so GDB will continue reading inferior memory until a null-terminator
is found, with unpredictable results.

Patch Description
=================

The first thing this patch does is better define what the arguments
for the two function value_cstring and value_string should represent.
The comments in the header file are updated to describe whether the
length argument should, or should not, include a null-character.
Also, the data argument is changed to type gdb_byte.  The functions as
they currently exist will handle wide-characters, in which case more
than one 'char' would be needed for each character.  As such using
gdb_byte seems to make more sense.

To avoid adding casts throughout GDB, I've also added an overload that
still takes a 'char *', but asserts that the character type being used
is of size '1'.

The value_cstring function is now responsible for adding a null
character at the end of the string value it creates.

However, once we start looking at how value_cstring is used, we
realise there's another, related, problem.  Not every language's
strings are null terminated.  Fortran and Ada strings, for example,
are just an array of characters, GDB already has the function
value_string which can be used to create such values.

Consider this example using current GDB:

  (gdb) set language ada
  (gdb) p $_gdb_setting("arch")
  $1 = (97, 117, 116, 111)
  (gdb) ptype $
  type = array (1 .. 4) of char
  (gdb) p $_gdb_maint_setting("test-settings string")
  $2 = (0)
  (gdb) ptype $
  type = array (1 .. 1) of char

This shows two problems, first, the $_gdb_setting and
$_gdb_maint_setting functions are calling value_cstring using the
builtin_char character, rather than a language appropriate type.  In
the first call, the 'arch' case, the value_cstring call doesn't
include the null character, so the returned array only contains the
expected characters.  But, in the $_gdb_maint_setting example we do
end up including the null-character, even though this is not expected
for Ada strings.

This commit adds a new language method language_defn::value_string,
this function takes a pointer and length and creates a language
appropriate value that represents the string.  For C, C++, etc this
will be a null-terminated string (by calling value_cstring), and for
Fortran and Ada this can be a bounded array of characters with no null
terminator.  Additionally, this new language_defn::value_string
function is responsible for selecting a language appropriate character
type.

After this commit the only calls to value_cstring are from the C
expression evaluator and from the default language_defn::value_string.

And the only calls to value_string are from Fortan, Ada, and ObjectC
related code.

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

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Co-Authored-By: Pedro Alves <pedro@palves.net>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
11 months ago[gdb] Fix grammar in comments and docs
Tom de Vries [Mon, 5 Jun 2023 10:53:15 +0000 (12:53 +0200)] 
[gdb] Fix grammar in comments and docs

Fix grammar in some comments and docs:
- machines that doesn't -> machines that don't
- its a -> it's a
- its the -> it's the
- if does its not -> if it does it's not
- one more instructions if doesn't match ->
  one more instruction if it doesn't match
- it's own -> its own
- it's first -> its first
- it's pointer -> its pointer

I also came across "it's performance" in gdb/stubs/*-stub.c in the HP public
domain notice, I've left that alone.

Tested on x86_64-linux.

11 months ago[gdb] Fix more typos
Tom de Vries [Mon, 5 Jun 2023 10:53:15 +0000 (12:53 +0200)] 
[gdb] Fix more typos

Fix some more typos:
- distinquish -> distinguish
- actualy -> actually
- singe -> single
- frash -> frame
- chid -> child
- dissassembler -> disassembler
- uninitalized -> uninitialized
- precontidion -> precondition
- regsiters -> registers
- marge -> merge
- sate -> state
- garanteed -> guaranteed
- explictly -> explicitly
- prefices (nonstandard plural) -> prefixes
- bondary -> boundary
- formated -> formatted
- ithe -> the
- arrav -> array
- coresponding -> corresponding
- owend -> owned
- fials -> fails
- diasm -> disasm
- ture -> true
- tpye -> type

There's one code change, the name of macro SIG_CODE_BONDARY_FAULT changed to
SIG_CODE_BOUNDARY_FAULT.

Tested on x86_64-linux.

11 months agobfd_error_on_input messages
Alan Modra [Mon, 5 Jun 2023 06:55:16 +0000 (16:25 +0930)] 
bfd_error_on_input messages

bfd_errmsg uses asprintf for bfd_error_on_input, which means we
currently leak memory.  Keep a static pointer to the message and free
it in various places to minimise the leaks.
bfd_set_input_error (NULL, bfd_error_no_error) is a way to free up the
last string if that matters.

* bfd.c (input_error_msg): New static var.
(bfd_set_input_error): Free it here..
(bfd_init): ..and here..
(bfd_errmsg): ..and here.  Use it for asprintf output.

11 months agoYet another ecoff fuzzed object fix
Alan Modra [Mon, 5 Jun 2023 06:51:25 +0000 (16:21 +0930)] 
Yet another ecoff fuzzed object fix

* ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check fdr_ptr
csym against remaining space for symbols.  Error on out of bounds
fdr_ptr fields.

11 months agoMIPS: sync oprand char usage between mips and micromips
YunQiang Su [Wed, 26 Apr 2023 10:16:40 +0000 (18:16 +0800)] 
MIPS: sync oprand char usage between mips and micromips

We should try our best to make mips32 using the same
oprand char with micromips. So for mips32, we use:

  ^  is added for 5bit sa oprand for some new DSPr2 instructions:
APPEND, PREPEND, PRECR_SRA[_R].PH.W
the LSB bit is 11, like RD.
  +t is removed for coprocessor 0 destination register.
'E' does the samething.
  +t is now used for RX oprand for MFTR/MTTR (MT ASE)
  ?  is added for sel oprand for MFTR/MTTR (MT ASE)
For mips32, the position of sel in MFTR/MTTR is same with mfc0 etc,
while for micromips, they are different.

We also add an extesion format of cftc2/cttc2/mftc2/mfthc2/mttc2/mtthc2:
concatenating rs with rx as the index of control or data.

11 months agoMIPS: add MT ASE support for micromips32
YunQiang Su [Wed, 26 Apr 2023 10:16:39 +0000 (18:16 +0800)] 
MIPS: add MT ASE support for micromips32

These instructions are descripted in MD00768.

MIPS® Architecture for Programmers
Volume IV-f: The MIPS® MT Module for
the microMIPS32â„¢ Architecture

Document Number: MD00768
Revision 1.12
July 16, 2013

https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00768-1C-microMIPS32MT-AFP-01.12.pdf

11 months agoRevert "MIPS: add MT ASE support for micromips32"
YunQiang Su [Mon, 5 Jun 2023 03:10:23 +0000 (11:10 +0800)] 
Revert "MIPS: add MT ASE support for micromips32"

This reverts commit 783a5f46b0583e9ed3a63acd3361009f46de5c17.

11 months agoMIPS: add MT ASE support for micromips32
YunQiang Su [Tue, 25 Apr 2023 06:56:26 +0000 (14:56 +0800)] 
MIPS: add MT ASE support for micromips32

These instructions are descripted in MD00768.

MIPS® Architecture for Programmers
Volume IV-f: The MIPS® MT Module for
the microMIPS32â„¢ Architecture

Document Number: MD00768
Revision 1.12
July 16, 2013

https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00768-1C-microMIPS32MT-AFP-01.12.pdf

11 months agoMIPS: fix some ld testcases with compiler
YunQiang Su [Tue, 16 May 2023 01:46:46 +0000 (09:46 +0800)] 
MIPS: fix some ld testcases with compiler

1. config/default.exp:
use -mabi=32 not for -gnuabi64
xfail_from_runlist: remove an element and mark it xfail.
2. ld-elf/indirect.exp: xfail
indirect5a indirect5b indirect6a indirect6b
indirect5c indirect5d indirect6c indirect6d
3. ld-elf/pr23658-2: mips output is not common
4. ld-elf/shared.exp: non-run on mips: Build libpr16496b.so
5. ld-elfvers/vers.exp:
xfail vers4, vers4b
no-run on mips: vers24a, vers24b, vers24c
6. ld-gc/gc.exp: add -KPIC into asflags for pr13683, pr14265, pr19161
7. ld-mips-elf/mips-elf.exp:
use noarch for mips16-local-stubs-1, since it use -mips4
8. ld-plugin/lto.exp:
no-run on mips/linux: PR ld/12982
add -KPIC into asflags for lto-3r, lto-5r, PR ld/19317 (2)
xfail PR ld/15323 (4), PR ld/19317 (3)
9. ld-plugin/plugin.exp: xfail
plugin claimfile lost symbol
plugin claimfile replace symbol
plugin claimfile replace symbol
plugin claimfile lost symbol with source
plugin claimfile replace symbol with source
plugin claimfile resolve symbol with source
plugin 2 with source lib
load plugin 2 with source
plugin 3 with source lib
load plugin 3 with source
11. ld-selective/selective.exp: add -fno-PIC, which is needed for -mno-abicalls
12. ld-shared/shared.exp: xfail shared (non PIC), shared (PIC main, non PIC so)

11 months agoMIPS: fix -gnuabi64 testsuite
YunQiang Su [Wed, 10 May 2023 13:22:41 +0000 (21:22 +0800)] 
MIPS: fix -gnuabi64 testsuite

Test on:
mips64-linux-gnuabi64
mips64el-linux-gnuabi64
mipsisa64-linux-gnuabi64
mipsisa64el-linux-gnuabi64
mipsisa64r2-linux-gnuabi64
mipsisa64r2el-linux-gnuabi64
mipsisa64r6-linux-gnuabi64
mipsisa64r6el-linux-gnuabi64

11 months agoMIPS: fix r6 testsuites
YunQiang Su [Wed, 10 May 2023 07:50:19 +0000 (15:50 +0800)] 
MIPS: fix r6 testsuites

Introduce
run_dump_test_o32l
run_dump_test_n32l
run_dump_test_n64l
Which use `-march=from-abi` for pre-R6 testcases,
like micromips/mips16e etc.

For cases doesn't use run_dump_test_*, we use
-mips32r2 for micromips32
-mips1 for mips16-32
-march=from-abi for testcases to o32/n32/n64 both/all.

Replace `addi` with `addiu` for some cases for both r6 and pre-R6.

Introduce some new testcases for r6 with FPXX/FP64.
Introduce new testcase: comdat-reloc-r6.

Skip `default` in mips_arch_list_matching if triple is mipsisa*, due to:
  1)it will cannot match mipsr6@*.d: since mips32rN/mips64rN
    will always be used, it won't be a problem.
  2)some test think -march=mips64rN will alway true for mipsisa64rN,
    which is not true now.

This patch fix testsuite for all r6-default gnu triples:
  mipsisa32r6-linux-gnu
  mipsisa32r6el-linux-gnu
  mips-img-linux-gnu
  mipsel-img-linux-gnu
  mipsisa64r6-linux-gnu
  mipsisa64r6el-linux-gnu

11 months agoMIPS: default r6 if vendor is img
YunQiang Su [Wed, 10 May 2023 10:07:23 +0000 (18:07 +0800)] 
MIPS: default r6 if vendor is img

This behavior is used by downstream toolchain since 2014.
We also set the default ABI for mips*-img-elf to O32.
The previous value is NO_ABI, which is not good default ABI.

We don't support mips64*-img* due to GCC doesn't support it,
and We believe that the multilib should be used for this case.

11 months agoMIPS: gas: alter 64 or 32 for mipsisa triples if march is implicit
YunQiang Su [Sat, 6 May 2023 08:26:13 +0000 (16:26 +0800)] 
MIPS: gas: alter 64 or 32 for mipsisa triples if march is implicit

When configure with triples mipsisa[32,64]rN[el,], the march value
is pinned to a fix value if not given explicitly. for example
   1) mipsisa32r6-linux-gnu -n32 xx.s will complains that:
      -march=mips32r6 is not compatible with the selected ABI
   2) mipsisa64r2el-linux-gnu -o32 generates objects with 64bit CPU:
      ELF 32-bit LSB relocatable, MIPS, MIPS64 rel2 version 1 (SYSV)
They are not good default behaviors: Let's alter the CPU info

Since we are using these triples as a regular linux distributions,
let's alter march according to ABI.

11 months agoAutomatic date update in version.in
GDB Administrator [Mon, 5 Jun 2023 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agoAutomatic date update in version.in
GDB Administrator [Sun, 4 Jun 2023 00:00:34 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months ago[gdb] Fix typos
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb] Fix typos

Fix a few typos:
- implemention -> implementation
- convertion(s) -> conversion(s)
- backlashes -> backslashes
- signoring -> ignoring
- (un)ambigious -> (un)ambiguous
- occured -> occurred
- hidding -> hiding
- temporarilly -> temporarily
- immediatelly -> immediately
- sillyness -> silliness
- similiar -> similar
- porkuser -> pokeuser
- thats -> that
- alway -> always
- supercede -> supersede
- accomodate -> accommodate
- aquire -> acquire
- priveleged -> privileged
- priviliged -> privileged
- priviledges -> privileges
- privilige -> privilege
- recieve -> receive
- (p)refered -> (p)referred
- succesfully -> successfully
- successfuly -> successfully
- responsability -> responsibility
- wether -> whether
- wich -> which
- disasbleable -> disableable
- descriminant -> discriminant
- construcstor -> constructor
- underlaying -> underlying
- underyling -> underlying
- structureal -> structural
- appearences -> appearances
- terciarily -> tertiarily
- resgisters -> registers
- reacheable -> reachable
- likelyhood -> likelihood
- intepreter -> interpreter
- disassemly -> disassembly
- covnersion -> conversion
- conviently -> conveniently
- atttribute -> attribute
- struction -> struct
- resonable -> reasonable
- popupated -> populated
- namespaxe -> namespace
- intialize -> initialize
- identifer(s) -> identifier(s)
- expection -> exception
- exectuted -> executed
- dungerous -> dangerous
- dissapear -> disappear
- completly -> completely
- (inter)changable -> (inter)changeable
- beakpoint -> breakpoint
- automativ -> automatic
- alocating -> allocating
- agressive -> aggressive
- writting -> writing
- reguires -> requires
- registed -> registered
- recuding -> reducing
- opeartor -> operator
- ommitted -> omitted
- modifing -> modifying
- intances -> instances
- imbedded -> embedded
- gdbaarch -> gdbarch
- exection -> execution
- direcive -> directive
- demanged -> demangled
- decidely -> decidedly
- argments -> arguments
- agrument -> argument
- amespace -> namespace
- targtet -> target
- supress(ed) -> suppress(ed)
- startum -> stratum
- squence -> sequence
- prompty -> prompt
- overlow -> overflow
- memember -> member
- languge -> language
- geneate -> generate
- funcion -> function
- exising -> existing
- dinking -> syncing
- destroh -> destroy
- clenaed -> cleaned
- changep -> changedp (name of variable)
- arround -> around
- aproach -> approach
- whould -> would
- symobl -> symbol
- recuse -> recurse
- outter -> outer
- freeds -> frees
- contex -> context

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/tdep] Fix typo in debug message
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb/tdep] Fix typo in debug message

In microblaze_analyze_prologue in gdb/microblaze-tdep.c I came across:
...
  microblaze_debug ("got addi r1,r1,%d; contnuing\n", imm);
...

Fix this by using "continuing".

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/python] Fix doc string of valpy_const_value
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb/python] Fix doc string of valpy_const_value

In gdb/python/py-value.c, in the value_object_methods array I noticed:
...
  { "const_value", valpy_const_value, METH_NOARGS,
    "Return a 'const' qualied version of the same value." },
...

Fix the qualied -> qualified typo.

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/guile] Fix doc string for value-optimized-out?
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb/guile] Fix doc string for value-optimized-out?

In gdb/guile/scm-value.c, I noticed in the value_functions array initializer:
...
  { "value-optimized-out?", 1, 0, 0,
    as_a_scm_t_subr (gdbscm_value_optimized_out_p),
    "\
Return #t if the value has been optimizd out." },
...
There's a typo in the doc string.

Fix this by using "optimized".

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/tui] Fix help text of show tui tab-width
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb/tui] Fix help text of show tui tab-width

I noticed:
...
(gdb) help show tui tab-width
Show the tab witdh, in characters, for the TUI.
This variable controls how many spaces are used to display a tab character.
...
a typo: "witdh".

Fix this by using "width" instead.

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/cli] Fix help text of maint info target-sections
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb/cli] Fix help text of maint info target-sections

I noticed a typo:
...
(gdb) help maint info target-sections
List GDB's internal section table.

Print the current targets section list.  This is a sub-set of all
sections, from all objects currently loaded.  Usually the ALLOC
sectoins.
...

Fix this by using "sections".

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/cli] Fix help text of maint set ignore-prologue-end-flag
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb/cli] Fix help text of maint set ignore-prologue-end-flag

I noticed here:
...
(gdb) help maint set ignore-prologue-end-flag
Set if the PROLOGUE-END flag is ignored.
The PROLOGUE-END flag from the line-table entries is used to place \
  breakpoints past the prologue of functions.  Disabeling its use use forces \
  the use of prologue scanners.
...
a typo in "Disabeling" and accidental word repetition "use use".

Fix by replacing with "Disabling" and "use".

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/compile] Fix typo in debug message
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb/compile] Fix typo in debug message

In compile_object_load in gdb/compile/compile-object-load.c I came across:
...
"Connectiong ELF symbol \"%s\" to the .toc section (%s)\n",
...

Fix this typo by using "Connecting" instead.

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdbserver] Fix typo in debug message
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdbserver] Fix typo in debug message

I noticed in emit_ops_insns in gdbserver/linux-aarch64-low.cc:
...
  threads_debug_printf ("Adding %d instrucions at %s",
...

Fix the typo by using "instructions" instead.

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/ada] Fix argument name misspelling
Tom de Vries [Sat, 3 Jun 2023 20:43:57 +0000 (22:43 +0200)] 
[gdb/ada] Fix argument name misspelling

Two functions use the argument name bounds_prefered_p.

This misspells "preferred".

Fix this by using bounds_preferred_p instead.

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months agoRe: loongarch readelf support
Alan Modra [Sat, 3 Jun 2023 07:46:04 +0000 (17:16 +0930)] 
Re: loongarch readelf support

Another segfault.

* readelf.c (target_specific_reloc_handling): Sanity check
loongarch reloc r_offset.

11 months agoRe: More ecoff sanity checks
Alan Modra [Sat, 3 Jun 2023 03:09:06 +0000 (12:39 +0930)] 
Re: More ecoff sanity checks

Yet another fuzzer fix.

* ecoff.c (ecoff_slurp_symbolic_header <FIX>): Zero counts when
associated pointer is zero.
(_bfd_ecoff_slurp_symbolic_info): Remove now unnecessary check.

11 months agoAutomatic date update in version.in
GDB Administrator [Sat, 3 Jun 2023 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months ago[AArch64] Fix architecture debug version constant thinkos
Luis Machado [Thu, 1 Jun 2023 16:41:37 +0000 (17:41 +0100)] 
[AArch64] Fix architecture debug version constant thinkos

Caught this during emulator testing.

Fix the constants. They should be 0xa and 0xb as opposed to 0x10 and
0x11.  There was a thinko while defining them.

Obvious enough.

Tested on aarch64-linux Ubuntu 20.04/22.04.

11 months agoRe: bfd_close and target free_cached_memory
Alan Modra [Thu, 1 Jun 2023 23:30:41 +0000 (09:00 +0930)] 
Re: bfd_close and target free_cached_memory

_bfd_delete_bfd can be called early, before the target xvec is set up.

* opncls.c (_bfd_delete_bfd): Don't segfault on NULL xvec.

11 months agoRe: More ecoff sanity checks
Alan Modra [Thu, 1 Jun 2023 22:51:36 +0000 (08:21 +0930)] 
Re: More ecoff sanity checks

Another fix for fuzzed object files, exhibiting as a segfault in
nm.c filter_symbols when accessing a symbol name.

* ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check
fdr_ptr->issBase, and tighten sym.iss check.

11 months agoloongarch readelf support
Alan Modra [Thu, 1 Jun 2023 14:01:47 +0000 (23:31 +0930)] 
loongarch readelf support

This fixes two buffer overflows found by fuzzers.

* readelf.c (target_specific_reloc_handling): Sanity check
loongarch reloc symbol index.  Don't apply reloc after errors.
Reduce translation work of "invalid symbol index" error message.

11 months agoMinor objcopy optimisation for copy_relocations_in_section
Alan Modra [Thu, 1 Jun 2023 07:30:53 +0000 (17:00 +0930)] 
Minor objcopy optimisation for copy_relocations_in_section

* objcopy (copy_relocations_in_section): Don't read the relocs
for STRIP_ALL if keep_specific_htab is empty.

11 months agoAutomatic date update in version.in
GDB Administrator [Fri, 2 Jun 2023 00:01:12 +0000 (00:01 +0000)] 
Automatic date update in version.in

11 months agolibsframe: avoid using magic number
Indu Bhagat [Thu, 1 Jun 2023 16:41:04 +0000 (09:41 -0700)] 
libsframe: avoid using magic number

Define a new constant for the maximum number of stack offsets handled in
libsframe, and use it.  Note that the SFrame format does not define such
a constant (limit).  This is an implmentation-defined constant in
libsframe.

include/
* sframe-api.h (MAX_NUM_STACK_OFFSETS): New definition.
libsframe/
* sframe.c (sframe_fre_sanity_check_p): Use it.

11 months agolibsframe: minor fixups in flip_fre related functions
Indu Bhagat [Thu, 1 Jun 2023 05:55:41 +0000 (22:55 -0700)] 
libsframe: minor fixups in flip_fre related functions

libsframe/
* sframe.c (flip_fre_start_address): Remove unnecessary type
cast.  Use uint16_t instead of unsigned short.
(flip_fre_stack_offsets): Likewise.

11 months agoRISC-V: PR30449, Add lga assembler macro support.
Jim Wilson [Thu, 1 Jun 2023 04:10:16 +0000 (12:10 +0800)] 
RISC-V: PR30449, Add lga assembler macro support.

Originally discussion, https://github.com/riscv/riscv-isa-manual/pull/539

Added new load address pseudo instruction which is always expanded to GOT
access, no matter the .option rvc is set or not.

gas/
PR 30449
* config/tc-riscv.c (macro): Add M_LGA support.
* testsuite/gas/riscv/la-variants.d: New.
* testsuite/gas/riscv/la-variants.s: New.
include/
PR 30449
* opcode/riscv.h (M_LGA): New.
opcodes/
PR 30449
* riscv-opc.c (riscv_opcodes): Add lga support.

11 months ago[PR ld/22263][PR ld/24676] RISC-V: Avoid spurious R_RISCV_NONE for TLS GD/IE.
Nelson Chu [Fri, 26 May 2023 10:05:34 +0000 (18:05 +0800)] 
[PR ld/22263][PR ld/24676] RISC-V: Avoid spurious R_RISCV_NONE for TLS GD/IE.

For TLS GD/IE, add the same condition with the relocate_section in the
allocate_dynrelocs, to make sure we won't reserve redundant spaces
for dynamic relocations since the conservative estimatation.

After applying this patch, ld seems no longer generate the spurious
R_RISCV_NONE for pr22263-1 test, and the test in pr24676.

bfd/
PR ld/22263
PR ld/24676
* elfnn-riscv.c (RISCV_TLS_GD_IE_NEED_DYN_RELOC): New defined.
Set NEED_RELOC to true if TLS GD/IE needs dynamic relocations,
and INDX will be the dynamic index.
(allocate_dynrelocs): Don't reserve extra spaces in the rela.got
if RISCV_TLS_GD_IE_NEED_DYN_RELOC set need_reloc to false.  This
condition needs to be same as relocate_section.
(relocate_section): Likewise, use the same condition as
allocate_dynrelocs.

11 months agoHarden PowerPC64 OPD handling against fuzzers
Alan Modra [Wed, 31 May 2023 05:41:34 +0000 (15:11 +0930)] 
Harden PowerPC64 OPD handling against fuzzers

PowerPC64 ELFv1 object files should have at most one .opd section, and
OPD handling in elf64-ppc.c makes use of this fact by caching some
.opd section info in the per-object bfd.tdata.  This was done to avoid
another word in the target specific section data.  Of course, fuzzers
don't respect the ABI, and even non-malicious users can accidentally
create multiple .opd sections.  So it is better to avoid possible
buffer overflows and other confusion when OPD handling for a second
.opd section references data for the first .opd section, by keeping
the data per-section.

The patch also fixes a memory leak, and a corner case where I think we
could hit an assertion in opd_entry_value or read out of bounds in
ppc64_elf_branch_reloc doing a final link producing non-ppc64 output.
(It's a really rare corner case because not only would you need to be
linking ppc64 objects to non-ppc64 output, you'd also need a branch
reloc symbol to be defined in a .opd section of a non-ppc64 input.)

* elf64-ppc.c (is_ppc64_elf): Move earlier in file.
(ppc64_elf_branch_reloc): Check symbol bfd before accessing
ppc64 elf specific data structures.
(struct ppc64_elf_obj_tdata): Move opd union..
(struct _ppc64_elf_section_data): ..to here.
(ppc64_elf_before_check_relocs): Allow for opd sec_type
already set to sec_opd.
(ppc64_elf_check_relocs): Only set sec_type to sec_toc when
unset.  Error for unexpected toc relocs.
(opd_entry_value): Return -1 when non-ppc64 rather than
asserting.  Check and set sec_type too.  Adjust for changed
location of contents and relocs.
(ppc64_elf_relocate_section): Adjust for changed location of
cached .opd relocs.
(ppc64_elf_free_cached_info): New function.
(bfd_elf64_bfd_free_cached_info): Define.

11 months agobfd_close and target free_cached_memory
Alan Modra [Wed, 31 May 2023 11:47:48 +0000 (21:17 +0930)] 
bfd_close and target free_cached_memory

bfd_free_cached_info is used in just one place in archive.c, which
means most times we reach bfd_close the function isn't called.  On the
other hand, if bfd_free_cached_info is called we can't do much on the
bfd since it loses all its obj_alloc memory.  This restricts what can
be done in a target _close_and_cleanup.  In particular you can't look
at sections, which leads to duplication of code in target
close_and_cleanup and free_cached_info, eg. elfnn-aarch64.c.

* opncls.c (_bfd_delete_bfd): Call bfd_free_cached_info.
* elfnn-aarch64.c (elfNN_aarch64_close_and_cleanup): Delete.
(bfd_elfNN_close_and_cleanup): Don't define.
* som.c (som_bfd_free_cached_info): Don't call
_bfd_generic_close_and_cleanup here.
(som_close_and_cleanup): Define as _bfd_generic_close_and_cleanup.

11 months agosection_by_target_index memory leak
Alan Modra [Tue, 30 May 2023 10:35:38 +0000 (20:05 +0930)] 
section_by_target_index memory leak

The rs6000 backend can call coff_section_from_bfd_index from its
object_p function via coff_set_alignment_hook.  If the object doesn't
match, or another target matches too, then the hash table needs to be
freed via a cleanup.

* coffgen.c (coff_object_cleanup): New function.
(coff_real_object_p): Return coff_object_cleanup, and call on
failure path.  Move declaration to..
* libcoff-in.h: ..here.
(coff_object_cleanup): Declare.
* coff-stgo32.c (go32exe_cleanup): Call coff_object_cleanup.
(go32exe_check_format): Adjust assertion.
* libcoff.h: Regenerate.

11 months agoRemove BFD_FAIL in cpu-sh.c
Alan Modra [Tue, 30 May 2023 10:16:24 +0000 (19:46 +0930)] 
Remove BFD_FAIL in cpu-sh.c

The assertions in cpu-sh.c can be triggered by passing bogus values
in disassemble_info.mach.  This doesn't cause any bfd misbehaviour.

* cpu-sh.c (sh_get_arch_from_bfd_mach): Remove BFD_FAIL.
(sh_get_arch_up_from_bfd_mach): Likewise.

11 months agoAutomatic date update in version.in
GDB Administrator [Thu, 1 Jun 2023 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agogprofng: Fix -Wsign-compare warning
Vladimir Mezentsev [Fri, 26 May 2023 02:06:52 +0000 (19:06 -0700)] 
gprofng: Fix -Wsign-compare warning

gprofng/ChangeLog
2023-05-25  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/30490
* src/LoadObject.cc: Fix -Wsign-compare warning.

11 months agogprofng: 29470 The test suite should be made more flexible
Vladimir Mezentsev [Fri, 26 May 2023 00:54:53 +0000 (17:54 -0700)] 
gprofng: 29470 The test suite should be made more flexible

I add two new targets (check-extra, check-install) for gprofng testing:
  `make check` runs sanity testing for gprofng and takes ~30 secunds.
  `make check-extra` runs all gprofng tests and takes ~20 minutus.
  `make check-install` runs all gprofng tests and uses gprofng installation.

On aarch64, there are unwind problems in libgp-collector.so.
I set ACCT_FILTER to temporarily ignore problematic functions.

gprofng/ChangeLog
2023-05-25  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/29470
* Makefile.am: Add check-extra, check-install.
* Makefile.in: Rebuild
* testsuite/config/default.exp: Set the GPROFNG variable.
* testsuite/gprofng.display/display.exp: Updated the test list.
* testsuite/gprofng.display/jsynprog/Intface.java: Correct copyright.
* testsuite/gprofng.display/jsynprog/Launcher.java: Likewise.
* testsuite/gprofng.display/jsynprog/Makefile: Likewise.
* testsuite/gprofng.display/jsynprog/Routine.java: Likewise.
* testsuite/gprofng.display/jsynprog/Sub_Routine.java: Likewise.
* testsuite/gprofng.display/jsynprog/cloop.cc: Likewise.
* testsuite/gprofng.display/jsynprog/jsynprog.h: Likewise.
* testsuite/gprofng.display/jsynprog/jsynprog.java: Correct copyright.
Add the -j option to run the selected functions.
* testsuite/gprofng.display/synprog/check_results.pl:
Remove unused environment variable.
* testsuite/gprofng.display/synprog/synprog.c: Updated DEFAULT_COMMAND.
* testsuite/lib/Makefile.skel: Apply $(ACCT_FILTER).
* testsuite/lib/acct.pm: Ignore errors when $(ACCT_FILTER) is set.
* testsuite/lib/display-lib.exp: Add TARGET_FLAGS in make_args.

11 months agoImprove MI -dprintf-insert documentation
Tom Tromey [Wed, 31 May 2023 14:26:37 +0000 (08:26 -0600)] 
Improve MI -dprintf-insert documentation

I found the documentation for -dprintf-insert a bit unclear.  It
didn't mention the possibility of multiple arguments, and I also
noticed that it implied that the format parameter is optional, which
it is not.

While looking into this I also noticed a few comments in the
implementation that could also be improved.

Then, I noticed a repeated call to strlen in a loop condition, so I
fixed this up as well.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
11 months agoPass correct name to @value in gdb.texinfo
Tom Tromey [Wed, 31 May 2023 14:28:01 +0000 (08:28 -0600)] 
Pass correct name to @value in gdb.texinfo

I noticed a couple instance of this warning when rebuilding the gdb
info files:

    warning: undefined flag: GDB

The problem is that the wrong argument was passed to @value.  This
patch fixes the problem.

11 months ago[gdb/testsuite] Fix gdb.tui/wrap-line.exp with --disable-tui
Tom de Vries [Wed, 31 May 2023 13:31:15 +0000 (15:31 +0200)] 
[gdb/testsuite] Fix gdb.tui/wrap-line.exp with --disable-tui

When running the test-case gdb.tui/wrap-line.exp with a build configured with
--disable-tui, we run into:
...
(gdb) PASS: gdb.tui/wrap-line.exp: width-hard-coded: set width 50
tui new-layout command-layout cmd 1^M
Undefined command: "tui".  Try "help".^M
(gdb) ERROR: Undefined command "tui new-layout command-layout cmd 1".
...

Fix this by guarding the command with allow_tui_tests.

Tested on x86_64-linux.

11 months ago[gdb/testsuite] Fix gdb.tui/pr30056.exp for native-extended-gdbserver
Tom de Vries [Wed, 31 May 2023 13:06:40 +0000 (15:06 +0200)] 
[gdb/testsuite] Fix gdb.tui/pr30056.exp for native-extended-gdbserver

When running test-case gdb.tui/pr30056.exp with target board
native-extended-gdbserver, I run into:
...
Quit^[[K^M^[[B(gdb) PASS: gdb.tui/pr30056.exp: Control-C
Remote debugging from host ::1, port 38810^M
^M(failed reverse-i-search)`xyz': ^M(gdb) target extended-remote \
  localhost:2346^[[7GWARNING: Timed out waiting for EOF in server after \
  monitor exit
...

This is due to the fact that ^C doesn't abort the reverse-i-search.  This
appears to be due to a readline problem.  A PR is open about this: PR
cli/30498.

Add a KFAIL for the PR, and ensure that the isearch is aborted by using ^G,
such that we have a responsive prompt to handle the "monitor exit" command
that native-extended-gdbserver issues.

Tested on x86_64-linux.

11 months agope/coff - add support for base64 encoded long section names
Tristan Gingold [Wed, 31 May 2023 10:20:55 +0000 (11:20 +0100)] 
pe/coff - add support for base64 encoded long section names

  PR 30444
  * coffcode.h (coff_write_object_contents): Handle base64 encoding on PE.  Also check for too large string table.
  * coffgen.c (extract_long_section_name): New function extracted from ... (make_a_section_from_file): ... here.  Add support for base64 long section names. (decode_base64): New function.

11 months agoFix printf formating issues in elfxx-loongarch64.c
Nick Clifton [Wed, 31 May 2023 09:21:40 +0000 (10:21 +0100)] 
Fix printf formating issues in elfxx-loongarch64.c

11 months agopython, btrace: Fix some small formatting issues.
Felix Willgerodt [Mon, 3 Apr 2023 14:13:49 +0000 (16:13 +0200)] 
python, btrace: Fix some small formatting issues.

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months ago[gdb/tui] Fix fingerprint for cmd-only layout
Tom de Vries [Wed, 31 May 2023 05:39:31 +0000 (07:39 +0200)] 
[gdb/tui] Fix fingerprint for cmd-only layout

I added a cmd-only layout:
...
(gdb) tui new-layout cmd cmd 1
...
and set it:
...
(gdb) layout cmd
...
which gave me the expect result: only the cmd window in the screen.

However, after going back to layout src:
...
(gdb) layout src
...
I got a source window with only one line in it, and the cmd window taking most
of the screen.

I traced this back to tui_set_layout, where for both the old and the new
layout the fingerprint of the cmd window in the layout is taken.  If the
fingerprint is the same, an effort will be done to preserve the command
window size.

The fingerprint is "VC" for both the old (cmd) and new (src) layouts, which
explains the behaviour.

I think this is essentially a bug in the finger print calculation, and it
should be "C" for the cmd layout.

Fix this by not adding a V or H in the fingerprint if the list size is one.

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
11 months agoAutomatic date update in version.in
GDB Administrator [Wed, 31 May 2023 00:00:47 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agogdb: add support for %V to printf command
Andrew Burgess [Thu, 23 Mar 2023 12:12:38 +0000 (12:12 +0000)] 
gdb: add support for %V to printf command

This commit adds a new format for the printf and dprintf commands:
'%V'.  This new format takes any GDB expression and formats it as a
string, just as GDB would for a 'print' command, e.g.:

  (gdb) print a1
  $a = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}
  (gdb) printf "%V\n", a1
  {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}
  (gdb)

It is also possible to pass the same options to %V as you might pass
to the print command, e.g.:

  (gdb) print -elements 3 -- a1
  $4 = {2, 4, 6...}
  (gdb) printf "%V[-elements 3]\n", a1
  {2, 4, 6...}
  (gdb)

This new feature would effectively replace an existing feature of GDB,
the $_as_string builtin convenience function.  However, the
$_as_string function has a few problems which this new feature solves:

1. $_as_string doesn't currently work when the inferior is not
running, e.g:

  (gdb) printf "%s", $_as_string(a1)
  You can't do that without a process to debug.
  (gdb)

The reason for this is that $_as_string returns a value object with
string type.  When we try to print this we call value_as_address,
which ends up trying to push the string into the inferior's address
space.

Clearly we could solve this problem, the string data exists in GDB, so
there's no reason why we have to push it into the inferior, but this
is an existing problem that would need solving.

2. $_as_string suffers from the fact that C degrades arrays to
pointers, e.g.:

  (gdb) printf "%s\n", $_as_string(a1)
  0x404260 <a1>
  (gdb)

The implementation of $_as_string is passed a gdb.Value object that is
a pointer, it doesn't understand that it's actually an array.  Solving
this would be harder than issue #1 I think.  The whole array to
pointer transformation is part of our expression evaluation.  And in
most cases this is exactly what we want.  It's not clear to me how
we'd (easily) tell GDB that we didn't want this reduction in _some_
cases.  But I'm sure this is solvable if we really wanted to.

3. $_as_string is a gdb.Function sub-class, and as such is passed
gdb.Value objects.  There's no super convenient way to pass formatting
options to $_as_string.  By this I mean that the new %V feature
supports print formatting options.  Ideally, we might want to add this
feature to $_as_string, we might imagine it working something like:

  (gdb) printf "%s\n", $_as_string(a1,
                                   elements = 3,
                                   array_indexes = True)

where the first item is the value to print, while the remaining
options are the print formatting options.  However, this relies on
Python calling syntax, which isn't something that convenience
functions handle.  We could possibly rely on strictly positional
arguments, like:

  (gdb) printf "%s\n", $_as_string(a1, 3, 1)

But that's clearly terrible as there's far more print formatting
options, and if you needed to set the 9th option you'd need to fill in
all the previous options.

And right now, the only way to pass these options to a gdb.Function is
to have GDB first convert them all into gdb.Value objects, which is
really overkill for what we want.

The new %V format solves all these problems: the string is computed
and printed entirely on the GDB side, we are able to print arrays as
actual arrays rather than pointers, and we can pass named format
arguments.

Finally, the $_as_string is sold in the manual as allowing users to
print the string representation of flag enums, so given:

  enum flags
    {
      FLAG_A = (1 << 0),
      FLAG_B = (1 << 1),
      FLAG_C = (1 << 1)
    };

  enum flags ff = FLAG_B;

We can:

  (gdb) printf "%s\n", $_as_string(ff)
  FLAG_B

This works just fine with %V too:

  (gdb) printf "%V\n", ff
  FLAG_B

So all functionality of $_as_string is replaced by %V.  I'm not
proposing to remove $_as_string, there might be users currently
depending on it, but I am proposing that we don't push $_as_string in
the documentation.

As %V is a feature of printf, GDB's dprintf breakpoints naturally gain
access to this feature too.  dprintf breakpoints can be operated in
three different styles 'gdb' (use GDB's printf), 'call' (call a
function in the inferior), or 'agent' (perform the dprintf on the
remote).

The use of '%V' will work just fine when dprintf-style is 'gdb'.

When dprintf-style is 'call' the format string and arguments are
passed to an inferior function (printf by default).  In this case GDB
doesn't prevent use of '%V', but the documentation makes it clear that
support for '%V' will depend on the inferior function being called.

I chose this approach because the current implementation doesn't place
any restrictions on the format string when operating in 'call' style.
That is, the user might already be calling a function that supports
custom print format specifiers (maybe including '%V') so, I claim, it
would be wrong to block use of '%V' in this case.  The documentation
does make it clear that users shouldn't expect this to "just work"
though.

When dprintf-style is 'agent' then GDB does no support the use of
'%V' (right now).  This is handled at the point when GDB tries to
process the format string and send the dprintf command to the remote,
here's an example:

  Reading symbols from /tmp/hello.x...
  (gdb) dprintf call_me, "%V", a1
  Dprintf 1 at 0x401152: file /tmp/hello.c, line 8.
  (gdb) set sysroot /
  (gdb) target remote | gdbserver --once - /tmp/hello.x
  Remote debugging using | gdbserver --once - /tmp/hello.x
  stdin/stdout redirected
  Process /tmp/hello.x created; pid = 3088822
  Remote debugging using stdio
  Reading symbols from /lib64/ld-linux-x86-64.so.2...
  (No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
  0x00007ffff7fd3110 in _start () from /lib64/ld-linux-x86-64.so.2
  (gdb) set dprintf-style agent
  (gdb) c
  Continuing.
  Unrecognized format specifier 'V' in printf
  Command aborted.
  (gdb)

This is exactly how GDB would handle any other invalid format
specifier, for example:

  Reading symbols from /tmp/hello.x...
  (gdb) dprintf call_me, "%Q", a1
  Dprintf 1 at 0x401152: file /tmp/hello.c, line 8.
  (gdb) set sysroot /
  (gdb) target remote | gdbserver --once - /tmp/hello.x
  Remote debugging using | gdbserver --once - /tmp/hello.x
  stdin/stdout redirected
  Process /tmp/hello.x created; pid = 3089193
  Remote debugging using stdio
  Reading symbols from /lib64/ld-linux-x86-64.so.2...
  (No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
  0x00007ffff7fd3110 in _start () from /lib64/ld-linux-x86-64.so.2
  (gdb) set dprintf-style agent
  (gdb) c
  Continuing.
  Unrecognized format specifier 'Q' in printf
  Command aborted.
  (gdb)

The error message isn't the greatest, but improving that can be put
off for another day I hope.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Acked-By: Simon Marchi <simon.marchi@efficios.com>
11 months agogdb: add interp::on_memory_changed method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_memory_changed method

Same idea as previous patches, but for memory_changed.

Change-Id: Ic19f20c24d8a6431d4a89c5625e8ef4898f76e82

11 months agogdb: add interp::on_param_changed method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_param_changed method

Same idea as previous patches, but for command_param_changed.

Change-Id: I7c2196343423360da05f016f8ffa871c064092bb

11 months agogdb: add interp::on_breakpoint_modified method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_breakpoint_modified method

Same idea as previous patches, but for breakpoint_modified.

Change-Id: I4f0a9edea912de431e32451d74224b2022a7c328

11 months agogdb: add interp::on_breakpoint_deleted method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_breakpoint_deleted method

Same idea as previous patches, but for breakpoint_deleted.

Change-Id: I59c231ce963491bb1eee1432ee1090138f09e19c

11 months agogdb: add interp::on_breakpoint_created method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_breakpoint_created method

Same idea as previous patches, but for breakpoint_created.

Change-Id: I614113c924edc243590018b8fb3bf69cb62215ef

11 months agogdb: add interp::on_tsv_modified method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_tsv_modified method

Same idea as previous patches, but for tsv_modified.

Change-Id: I55454a2386d5450040b3a353909b26f389a43682

11 months agogdb: add interp::on_tsv_deleted method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_tsv_deleted method

Same idea as previous patches, but for tsv_deleted.

Change-Id: I71b0502b493da7b6e293bee02aeca98de83d4b75

11 months agogdb: add interp::on_tsv_created method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_tsv_created method

Same idea as previous patches, but for tsv_created.

Change-Id: I9c30ecfdbd78ca015d613f43a0c0aef6c7eb32b5

11 months agogdb: add interp::on_traceframe_changed method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_traceframe_changed method

Same idea as previous patches, but for traceframe_changed.

Change-Id: Ia473f07d70d57b30aca0094d0e0585d7e0d95637

11 months agogdb: add interp::on_about_to_proceed method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_about_to_proceed method

Same idea as previous patches, but for about_to_proceed.  We only need
(and want, as far as the mi_interp implementation is concerned) to
notify the interpreter that caused the proceed.

Change-Id: Id259bca10dbc3d43d46607ff7b95243a9cbe2f89

11 months agogdb: add interp::on_solib_unloaded method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_solib_unloaded method

Same idea as previous patches, but for solib_unloaded.

Change-Id: Iad847de93f0b38b5c90679a173d3beeaed7af6c5

11 months agogdb: add interp::on_solib_loaded method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_solib_loaded method

Same idea as previous patches, but for solib_loaded

Change-Id: I85edb0a4b377f4b2c39ffccf31cb75f38bae0f55

11 months agogdb: add interp::on_target_resumed method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_target_resumed method

Same idea as previous patches, but for target_resumed.

Change-Id: I66fa28d1d41a1f3c4fb0d6a470137d493eac3c8c

11 months agogdb: add interp::on_record_changed method
Simon Marchi [Fri, 21 Apr 2023 13:45:30 +0000 (09:45 -0400)] 
gdb: add interp::on_record_changed method

Same idea as previous patches, but for record_changed

Change-Id: I5eeeacd703af8401c315060514c94e8e6439cc40