platform/upstream/binutils.git
8 months agosim: warnings: enable -Wduplicated-cond
Mike Frysinger [Thu, 21 Dec 2023 05:02:03 +0000 (00:02 -0500)]
sim: warnings: enable -Wduplicated-cond

8 months agosim: mn10300: fix LAST_TIMER_REG typo
Mike Frysinger [Thu, 21 Dec 2023 05:00:49 +0000 (00:00 -0500)]
sim: mn10300: fix LAST_TIMER_REG typo

The compiler pointed out that we're testing LAST_TIMER_REG and
LAST_COUNTER which are the same value ... and that's because we
set LAST_TIMER_REG to the wrong register.  Fix the typo.

8 months agosim: bfin: clean up astat reg name decode a little
Mike Frysinger [Thu, 21 Dec 2023 04:59:28 +0000 (23:59 -0500)]
sim: bfin: clean up astat reg name decode a little

The compiler pointed out we checked AZ twice.  Sort by name to avoid
that in the future, and to make it clearer that we have coverage of
all the bits.  And add the bits we were missing.

The order here doesn't matter as it's just turning a pointer into a
human readable string when store tracing is enabled.

8 months agosim: common: delete unused scache in some mloop paths
Mike Frysinger [Tue, 19 Dec 2023 10:47:32 +0000 (05:47 -0500)]
sim: common: delete unused scache in some mloop paths

The scache vars aren't used by ports in the pbb & fast codepaths,
nor are they documented as inputs to the callbacks, so delete them
to avoid unused variable compiler warnings.

8 months agosim: cgen: unify the genmloop logic a bit
Mike Frysinger [Wed, 20 Dec 2023 00:54:13 +0000 (19:54 -0500)]
sim: cgen: unify the genmloop logic a bit

Pull out the common parts of the genmloop invocation into the common
code.  This will make it easier to add more, and make the per-port
differences a little more obvious.

8 months agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Dec 2023 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

8 months agogprofng: 31169 Source code locations can not be found in a C++ application
Vladimir Mezentsev [Tue, 19 Dec 2023 05:04:57 +0000 (21:04 -0800)]
gprofng: 31169 Source code locations can not be found in a C++ application

gprofng incorrectly reads the form of the DW_FORM_ref_addr attribute for DWARF
Version 3 or later.
From DWARF specification:
  References that use the attribute form DW_FORM_ref_addr are specified to
  be four bytes in the DWARF 32-bit format and eight bytes in the DWARF
  64-bit format, while DWARF Version 2 specifies that such references have
  the same size as an address on the target system.

2023-12-18  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/31169
* src/DwarfLib.cc: Fix the reader for DW_FORM_ref_addr.

8 months agoFix handling of vanishing threads that were stepping/stopping
Pedro Alves [Fri, 1 Dec 2023 17:45:21 +0000 (17:45 +0000)]
Fix handling of vanishing threads that were stepping/stopping

Downstream, AMD is carrying a testcase
(gdb.rocm/continue-over-kernel-exit.exp) that exposes a couple issues
with the amd-dbgapi target's handling of exited threads.  The test
can't be added upstream yet, unfortunately, due to dependency on DWARF
extensions that can't be upstreamed yet.  However, it can be found on
the mailing list on the same series as this patch.

The test spawns a kernel with a number of waves.  The waves do nothing
but exit.  There is a breakpoint on the s_endpgm instruction.  Once
that breakpoint is hit, the test issues a "continue" command.  We
should see one breakpoint hit per wave, and then the whole program
exiting.  We do see that, however we also see this:

 [New AMDGPU Wave ?:?:?:1 (?,?,?)/?]
 [AMDGPU Wave ?:?:?:1 (?,?,?)/? exited]
 *repeat for other waves*
 ...
 [Thread 0x7ffff626f640 (LWP 3048491) exited]
 [Thread 0x7fffeb7ff640 (LWP 3048488) exited]
 [Inferior 1 (process 3048475) exited normally]

That "New AMDGPU Wave" output comes from infrun.c itself adding the
thread to the GDB thread list, because it got an event for a thread
not on the thread list yet.  The output shows "?"s instead of proper
coordinates, because the event was a TARGET_WAITKIND_THREAD_EXITED,
i.e., the wave was already gone when infrun.c added the thread to the
thread list.

That shouldn't ever happen for the amd-dbgapi target, threads should
only ever be added by the backend.

Note "New AMDGPU Wave ?:?:?:1" is for wave 1.  What happened was that
wave 1 terminated previously, and a previous call to
amd_dbgapi_target::update_thread_list() noticed the wave had vanished
and removed it from the GDB thread list.  However, because the wave
was stepping when it terminated (due to the displaced step over the
s_endpgm) instruction, it is guaranteed that the amd-dbgapi library
queues a WAVE_COMMAND_TERMINATED event for the exit.

When we process that WAVE_COMMAND_TERMINATED event, in
amd-dbgapi-target.c:process_one_event, we return it to the core as a
TARGET_WAITKIND_THREAD_EXITED event:

 static void
 process_one_event (amd_dbgapi_event_id_t event_id,
    amd_dbgapi_event_kind_t event_kind)
 {
 ...
 if (status == AMD_DBGAPI_STATUS_ERROR_INVALID_WAVE_ID
     && event_kind == AMD_DBGAPI_EVENT_KIND_WAVE_COMMAND_TERMINATED)
   ws.set_thread_exited (0);
 ...
 }

Recall the wave is already gone from the GDB thread list.  So when GDB
sees that TARGET_WAITKIND_THREAD_EXITED event for a thread it doesn't
know about, it adds the thread to the thread list, resulting in that:

 [New AMDGPU Wave ?:?:?:1 (?,?,?)/?]

and then, because it was a TARGET_WAITKIND_THREAD_EXITED event, GDB
marks the thread exited right afterwards:

 [AMDGPU Wave ?:?:?:1 (?,?,?)/? exited]

The fix is to make amd_dbgapi_target::update_thread_list() _not_
delete vanishing waves iff they were stepping or in progress of being
stopped.  These two cases are the ones dbgapi guarantees will result
in a WAVE_COMMAND_TERMINATED event if the wave terminates:

  /**
   * A command for a wave was not able to complete because the wave has
   * terminated.
   *
   * Commands that can result in this event are ::amd_dbgapi_wave_stop and
   * ::amd_dbgapi_wave_resume in single step mode.  Since the wave terminated
   * before stopping, this event will be reported instead of
   * ::AMD_DBGAPI_EVENT_KIND_WAVE_STOP.
   *
   * The wave that terminated is available by the ::AMD_DBGAPI_EVENT_INFO_WAVE
   * query.  However, the wave will be invalid since it has already terminated.
   * It is the client's responsibility to know what command was being performed
   * and was unable to complete due to the wave terminating.
   */
  AMD_DBGAPI_EVENT_KIND_WAVE_COMMAND_TERMINATED = 2,

As the comment says, it's GDB's responsability to know whether the
wave was stepping or being stopped.  Since we now have a wave_info map
with one entry for each wave, that seems like the place to store that
information.  However, I still decided to put all the coordinate
information in its own structure.  I.e., basically renamed the
existing wave_info to wave_coordinates, and then added a new wave_info
structure that holds the new state, plus a wave_coordinates object.
This seemed cleaner as there are places where we only need to
instantiate a wave_coordinates object.

There's an extra twist.  The testcase also exercises stopping at a new
kernel right after the first kernel fully exits.  In that scenario, we
were hitting this assertion after the first kernel fully exits and the
hit of the breakpoint at the second kernel is handled:

 [amd-dbgapi] process_event_queue: Pulled event from dbgapi: event_id.handle = 26, event_kind = WAVE_STOP
 [amd-dbgapi-lib] suspending queue_3, queue_2, queue_1 (refresh wave list)
 ../../src/gdb/amd-dbgapi-target.c:1625: internal-error: amd_dbgapi_thread_deleted: Assertion `it != info->wave_info_map.end ()' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.

This is the exact same problem as above, just a different
manifestation.  In this scenario, we end up in update_thread_list
successfully deleting the exited thread (because it was no longer the
current thread) that was incorrectly added by infrun.c.  Because it
was added by infrun.c and not by amd-dbgapi-target.c:add_gpu_thread,
it doesn't have an entry in the wave_info map, so
amd_dbgapi_thread_deleted trips on this assertion:

      gdb_assert (it != info->wave_info_map.end ());

here:

  ...
  -> stop_all_threads
   -> update_thread_list
    -> target_update_thread_list
     -> amd_dbgapi_target::update_thread_list
      -> thread_db_target::update_thread_list
       -> linux_nat_target::update_thread_list
-> delete_exited_threads
 -> delete_thread
  -> delete_thread_1
   -> gdb::observers::observable<thread_info*>::notify
    -> amd_dbgapi_thread_deleted
     -> internal_error_loc

The testcase thus tries both running to exit after the first kernel
exits, and running to a breakpoint in a second kernel after the first
kernel exits.

Approved-By: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Change-Id: I43a66f060c35aad1fe0d9ff022ce2afd0537f028

8 months agoFix thread target ID of exited waves
Pedro Alves [Fri, 17 Nov 2023 12:41:36 +0000 (12:41 +0000)]
Fix thread target ID of exited waves

Currently, if you step over kernel exit, you see:

 stepi
 [AMDGPU Wave ?:?:?:1 (?,?,?)/? exited]
 Command aborted, thread exited.
 (gdb)

Those '?' are because the thread/wave is already gone by the time GDB
prints the "exited" notification, we can't ask dbgapi for any info
about the wave anymore.

This commit fixes it by caching the wave's coordinates as soon as GDB
sees the wave for the first time, and making
amd_dbgapi_target::pid_to_str use the cached info.

At first I thought of clearing the wave_info object from a
thread_exited observer.  However, that is too soon, resulting in this:

 (gdb) si
 [AMDGPU Wave 1:4:1:1 (0,0,0)/0 exited]
 Command aborted, thread exited.
 (gdb) thread
 [Current thread is 6 (AMDGPU Wave ?:?:?:0 (?,?,?)/?) (exited)]

We need instead to clear the wave info when the thread is ultimately
deleted, so we get:

 (gdb) si
 [AMDGPU Wave 1:4:1:1 (0,0,0)/0 exited]
 Command aborted, thread exited.
 (gdb) thread
 [Current thread is 6 (AMDGPU Wave 1:4:1:1 (0,0,0)/0) (exited)]

And for that, we need a new thread_deleted observable.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Approved-By: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Change-Id: I6c3e22541f051e1205f75eb657b04dc15e547580

8 months agoStep over thread exit, always delete the thread non-silently
Pedro Alves [Fri, 17 Nov 2023 21:45:06 +0000 (21:45 +0000)]
Step over thread exit, always delete the thread non-silently

With AMD GPU debugging, I noticed that when stepping over a breakpoint
placed on top of the s_endpgm instruction inline (displaced=off), GDB
would behave differently -- it wouldn't print the wave exit.  E.g:

With displaced stepping, or no breakpoint at all:

 stepi
 [AMDGPU Wave 1:4:1:1 (0,0,0)/0 exited]
 Command aborted, thread exited.
 (gdb)

With inline stepping:

 stepi
 Command aborted, thread exited.
 (gdb)

In the cases we see the "exited" notification, handle_thread_exit is
what first called delete_thread on the exiting thread, which is
non-silent.

With inline stepping, however, handle_thread_exit ends up in
update_thread_list (via restart_threads) before any delete_thread
call.  Thus, amd_dbgapi_target::update_thread_list notices that the
wave is gone and deletes it with delete_thread_silent.

This commit fixes it, by making handle_thread_exited call
set_thread_exited (with the default silent=false) early, which emits
the user-visible notification.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I22ab3145e18d07c99dace45576307b9f9d5d966f

8 months agodisplaced_step_finish: Don't fetch the regcache of exited threads
Pedro Alves [Fri, 1 Dec 2023 13:31:00 +0000 (13:31 +0000)]
displaced_step_finish: Don't fetch the regcache of exited threads

displaced_step_finish can be called with event_status.kind ==
TARGET_WAITKIND_THREAD_EXITED, and in that case it is not possible to
get at the already-exited thread's registers.

This patch moves the get_thread_regcache calls to branches that
actually need it, where we know the thread is still alive.

It also adds an assertion to get_thread_regcache, to help catching
these broken cases sooner.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I63b5eacb3e02a538fc5087c270d8025adfda88c3

8 months agoEnsure selected thread after thread exit stop
Pedro Alves [Mon, 20 Nov 2023 17:49:08 +0000 (17:49 +0000)]
Ensure selected thread after thread exit stop

While making step over thread exit work properly on AMDGPU, I noticed
that if there's a breakpoint on top of the exit syscall, and,
displaced stepping is off, then when GDB reports "Command aborted,
thread exited.", GDB also switches focus to a random thread, instead
of leaving the exited thread as selected:

 (gdb) thread
 [Current thread is 6, lane 0 (AMDGPU Lane 1:4:1:1/0 (0,0,0)[0,0,0])]
 (gdb) si
 Command aborted, thread exited.
 (gdb) thread
 [Current thread is 5 (Thread 0x7ffff626f640 (LWP 3248392))]
 (gdb)

The previous patch extended gdb.threads/step-over-thread-exit.exp to
exercise this on GNU/Linux (on the CPU side), and there, after that
"si", we always end up with the exiting thread as selected even
without this fix, but that's just a concidence, there's a code path
that happens to select the exiting thread for an unrelated reason.

This commit add the explict switch, fixing the latent problem for
GNU/Linux, and the actual problem on AMDGPU.  I wrote a gdb.rocm/
testcase for this, but it can't be upstreamed yet, until more pieces
of the DWARF machinery are upstream as well.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I6ff57a79514ac0142bba35c749fe83d53d9e4e51

8 months agogdb.threads/step-over-thread-exit.exp improvements
Pedro Alves [Tue, 21 Nov 2023 12:23:11 +0000 (12:23 +0000)]
gdb.threads/step-over-thread-exit.exp improvements

This commit makes the following improvements to
gdb.threads/step-over-thread-exit.exp:

- Add a third axis to stepping over the breakpoint with displaced vs
  inline stepping -- also test with no breakpoint at all.

- Check that when GDB reports "Command aborted, thread exited.", the
  selected thread is the thread that exited.  This is always true
  currently on GNU/Linux by coincidence, but a similar testcase on AMD
  GPU exposed a problem here.  Better make the testcase catch any
  potential regression.

- Fixes a race that Simon ran into with GDBserver testing.

    (gdb) next
    [New Thread 2143071.2143438]

    Thread 3 "step-over-threa" hit Breakpoint 2, 0x000055555555524e in my_exit_syscall () at .../testsuite/lib/my-syscalls.S:74
    74      SYSCALL (my_exit, __NR_exit)
    (gdb) FAIL: gdb.threads/step-over-thread-exit.exp: displaced-stepping=auto: non-stop=on: target-non-stop=on: schedlock=off: cmd=next: ns_stop_all=0: command aborts when thread exits

  I was not able to reproduce it, but I believe that what happens is
  the following:

  Once we continue, the thread 2 exits, and the main thread thus
  unblocks from its pthread_join, and spawns a new thread.  That new
  thread may hit the breakpoint at my_exit_syscall very quickly.  GDB
  could then see/process that breakpoint event before the thread exit
  event for the thread we care about, which would result in the
  failure seen above.

  The fix here is to not loop and start a new thread at all in the
  scenario where the race can happen.  We only need to loop and spawn
  new threads when testing with "cmd=continue" and schedlock off, in
  which case GDB doesn't abort the command when the thread exits.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I90c95c32f00630a3f682b1541c23aff52451f9b6

8 months agoFix bug in previous remote unique_ptr change
Pedro Alves [Wed, 20 Dec 2023 20:11:23 +0000 (20:11 +0000)]
Fix bug in previous remote unique_ptr change

By inspection, I noticed that the previous patch went too far, here:

 @@ -7705,7 +7713,8 @@ remote_target::discard_pending_stop_replies (struct inferior *inf)
    if (rs->remote_desc == NULL)
      return;

 -  reply = (struct stop_reply *) rns->pending_event[notif_client_stop.id];
 +  stop_reply_up reply
 +    = as_stop_reply_up (std::move (rns->pending_event[notif_client_stop.id]));

    /* Discard the in-flight notification.  */
    if (reply != NULL && reply->ptid.pid () == inf->pid)

That is always moving the stop reply from pending_event, when we only
really want to peek into it.  The code further below that even says:

  /* Discard the in-flight notification.  */
  if (reply != NULL && reply->ptid.pid () == inf->pid)
    {
      /* Leave the notification pending, since the server expects that
 we acknowledge it with vStopped.  But clear its contents, so
 that later on when we acknowledge it, we also discard it.  */

This commit reverts that hunk back, adjusted to use unique_ptr::get().

Change-Id: Ifc809d1a8225150a4656889f056d51267100ee24

8 months agoComplete use of unique_ptr with notif_event and stop_reply
Pedro Alves [Thu, 9 Nov 2023 21:22:15 +0000 (21:22 +0000)]
Complete use of unique_ptr with notif_event and stop_reply

We already use unique_ptr with notif_event and stop_reply in some
places around the remote target, but not fully.  There are several
code paths that still use raw pointers.  This commit makes all of the
ownership of these objects tracked by unique pointers, making the
lifetime flow much more obvious, IMHO.

I notice that it fixes a leak -- in remote_notif_stop_ack, We weren't
destroying the stop_reply object if it was of TARGET_WAITKIND_IGNORE
kind.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: Id81daf39653d8792c8795b2a145772176bfae77c

8 months agoMake cached_reg_t own its data
Pedro Alves [Thu, 9 Nov 2023 20:44:12 +0000 (20:44 +0000)]
Make cached_reg_t own its data

struct cached_reg_t owns its data buffer, but currently that is
managed manually.  Convert it to use a unique_xmalloc_ptr.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I05a107098b717299e76de76aaba00d7fbaeac77b

8 months agogdb: remove stale comment and ctor in gdbarch_info
Simon Marchi [Wed, 20 Dec 2023 15:36:14 +0000 (15:36 +0000)]
gdb: remove stale comment and ctor in gdbarch_info

tdesc_data is not part of a union, since commit 4f3681cc3361 ("Fix thread's
gdbarch when SVE vector length changes").  Remove the stale comment and
constructor.

Change-Id: Ie895ce36614930e8bd9c4967174c8bf1b321c503

8 months agos390: Add suffix to conditional branch instruction descriptions
Jens Remus [Wed, 20 Dec 2023 10:34:48 +0000 (11:34 +0100)]
s390: Add suffix to conditional branch instruction descriptions

Suffix the instruction description of conditional branch extended
mnemonics with their condition (e.g. "on A high"). This complements
the optional printing of instruction descriptions as comments in the
disassembly.

Due to the added text the maximum description length is increased from
80 to 128 characters (including the trailing '\0' character).

opcodes/
* s390-mkopc.c: Add suffix to conditional branch extended
  mnemonic instruction descriptions.

gas/
* testsuite/gas/s390/zarch-insndesc.s: Add test cases for
  printing of suffixed instruction description of conditional
  branch extended mnemonics.
* testsuite/gas/s390/zarch-insndesc.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
8 months agos390: Optionally print instruction description in disassembly
Jens Remus [Wed, 20 Dec 2023 10:34:15 +0000 (11:34 +0100)]
s390: Optionally print instruction description in disassembly

Print instruction description as comment in disassembly with s390
architecture specific option "insndesc":

- For objdump it can be enabled with option "-M insndesc"
- In gdb it can be enabled with "set disassembler-options insndesc"

Since comments are not column aligned the output can enhanced for
readability by postprocessing using a filter such as "expand":

... | expand -t 8,16,24,32,40,80

Or when using in combination with objdump option --visualize-jumps:

... | expand | sed -e 's/ *#/\t#/' | expand -t 1,80

Note that the instruction descriptions add about 128 KB to s390-opc.o:

s390-opc.o without instruction descriptions: 216368 bytes
s390-opc.o with instruction descriptions   : 348432 bytes

binutils/
* NEWS: Mention new s390-specific disassembler option
  "insndesc".

include/
* opcode/s390.h (struct s390_opcode): Add field to hold
  instruction description.

opcodes/
* s390-mkopc.c: Copy instruction description from s390-opc.txt
  into generated operation code table s390-opc.tab.
* s390-opc.c (s390_opformats): Provide NULL as description in
  .insn pseudo-mnemonics opcode table.
* s390-dis.c: Add s390-specific disassembler option "insndesc"
  and optionally print the instruction description as comment in
  the disassembly when it is specified.

gas/
* testsuite/gas/s390/s390.exp: Add new test disassembly test
  case "zarch-insndesc".
* testsuite/gas/s390/zarch-insndesc.s: New test case for s390-
  specific disassembler option "insndesc".
* testsuite/gas/s390/zarch-insndesc.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
8 months agos390: Use safe string functions and length macros in s390-mkopc
Jens Remus [Wed, 20 Dec 2023 10:17:39 +0000 (11:17 +0100)]
s390: Use safe string functions and length macros in s390-mkopc

Use strncpy() and snprintf() instead of strcpy() and strcat(). Define
and use macros for string lengths, such as mnemonic, instruction
format, and instruction description.

This is a mechanical change, although some buffers have increased in
length by one character. This has been confirmed by verifying that the
generated opcode/s390-opc.tab is unchanged.

opcodes/
* s390-mkopc.c: Use strncpy() and strncat().

Suggested-by: Nick Clifton <nickc@redhat.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
8 months agos390: Enhance error handling in s390-mkopc
Jens Remus [Wed, 20 Dec 2023 10:17:11 +0000 (11:17 +0100)]
s390: Enhance error handling in s390-mkopc

When the s390-mkopc utility detects an error it prints an error message
to strerr and either continues processing or exists with a non-zero
return code. If it continues without detecting any further error the
final return code was zero, potentially hiding the detected error.

Introduce a global variable to hold the final return code and initialize
it to EXIT_SUCCESS. Introduce a helper function print_error() that
prints an error message to stderr and sets the final return code to
EXIT_FAILURE. Use it to print all error messages. Return the final
return code at the end of the processing.

While at it enhance error messages to state more clearly which mnemonic
an error was detected for. Also continue processing for cases where
subsequent mnemonics can be processed.

opcodes/
* s390-mkopc.c: Enhance error handling. Return EXIT_FAILURE
  in case of an error, otherwise EXIT_SUCCESS.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
8 months agos390: Provide IBM z16 (arch14) instruction descriptions
Jens Remus [Wed, 20 Dec 2023 10:16:38 +0000 (11:16 +0100)]
s390: Provide IBM z16 (arch14) instruction descriptions

Provide descriptions for instructions introduced with commit ba2b480f103
("IBM Z: Implement instruction set extensions"). This complements commit
69341966def ("IBM zSystems: Add support for z16 as CPU name."). Use
instruction names from IBM z/Architecture Principles of Operation [1] as
instruction description.

[1]: IBM z/Architecture Principles of Operation, SA22-7832-13, IBM z16,
     https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf

opcodes/
* s390-opc.txt: Add descriptions for IBM z16 (arch14)
  instructions.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
8 months agos390: Align letter case of instruction descriptions
Jens Remus [Wed, 20 Dec 2023 10:16:08 +0000 (11:16 +0100)]
s390: Align letter case of instruction descriptions

Change the bitwise operations names "and" and "or" to lower case. Change
the register name abbreviations "FPR", "GR", and "VR" to upper case.

opcodes/
* s390-opc.txt: Align letter case of instruction descriptions.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
8 months agos390: Fix build when using EXEEXT_FOR_BUILD
Jens Remus [Wed, 20 Dec 2023 10:14:47 +0000 (11:14 +0100)]
s390: Fix build when using EXEEXT_FOR_BUILD

Suffix the s390-mkopc build utility executable file name with
EXEEXT_FOR_BUILD. Otherwise it cannot be located when building with
EXEEXT_FOR_BUILD. Use pattern used for other architecture build
utilities and compile and link s390-mkopc in two steps.

While at it also specify the dependencies of s390-mkopc.c.

opcodes/
* Makefile.am: Add target to build s390-mkopc.o. Correct
  target to build s390-mkopc$(EXEEXT_FOR_BUILD).
* Makefile.in: Regenerate.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
8 months agosim: frv: enable warnings in memory.c
Mike Frysinger [Tue, 19 Dec 2023 11:49:41 +0000 (06:49 -0500)]
sim: frv: enable warnings in memory.c

Fix one minor pointer-sign warning to enable warnings in general
for this file.  Reading the data as signed and then returning it
as unsigned should be functionally the same in this case.

8 months agoAutomatic date update in version.in
GDB Administrator [Wed, 20 Dec 2023 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in

8 months agoRe: PR31145, potential memory leak in binutils/ld
Alan Modra [Tue, 19 Dec 2023 21:59:12 +0000 (08:29 +1030)]
Re: PR31145, potential memory leak in binutils/ld

Revert most of this patch, it isn't correct to free the BFD_IN_MEMORY
iostream in io_reinit.

PR 31145
* format.c (io_reinit): Revert last change.  Comment.
* opncls.c (_bfd_delete_bfd): Likewise.

8 months agogdb: use put_frame_register instead of put_frame_register_bytes in pseudo_to_concat_raw
Simon Marchi [Mon, 18 Dec 2023 20:02:47 +0000 (15:02 -0500)]
gdb: use put_frame_register instead of put_frame_register_bytes in pseudo_to_concat_raw

Here, we write single complete registers, we don't need the
functionality of put_frame_register_bytes, use put_frame_register
instead.

Change-Id: I987867a27249db4f792a694b47ecb21c44f64d08
Approved-By: Tom Tromey <tom@tromey.com>
8 months agogdb: remove stale comment in value_assign
Simon Marchi [Mon, 18 Dec 2023 20:02:46 +0000 (15:02 -0500)]
gdb: remove stale comment in value_assign

This comment is no longer relevant, put_frame_register_bytes now accepts
the "next frame".

Change-Id: I077933a03f8bdb886f8ba10a98d1202a38bce0a9
Approved-By: Tom Tromey <tom@tromey.com>
8 months agoaarch64: Add FEAT_ITE support
Andrea Corallo [Tue, 10 Oct 2023 15:37:11 +0000 (16:37 +0100)]
aarch64: Add FEAT_ITE support

This patch add support for FEAT_ITE "Instrumentation Extension" adding
the "trcit" instruction.

This is enabled by the +ite march flag.

8 months agoaarch64: Add FEAT_ECBHB support
Andrea Corallo [Tue, 12 Sep 2023 10:23:52 +0000 (11:23 +0100)]
aarch64: Add FEAT_ECBHB support

This patch add support for FEAT_ECBHB "Exploitative control using
branch history information" adding the "clrbhb" instruction.  AFAIU
the same alias was originally added as "clearbhb" before the
architecture was finalized (Mandatory v8.9-a/v9.4-a; Optional
v8.0-a+/v9.0-a+).

8 months agoaarch64: Add FEAT_SPECRES2 support
Andrea Corallo [Wed, 6 Sep 2023 14:52:45 +0000 (15:52 +0100)]
aarch64: Add FEAT_SPECRES2 support

This patch add supports for FEAT_SPECRES2 "Enhanced speculation
restriction instructions" adding the "cosp" instruction.

This is mandatory v8.9-a/v9.4-a and optional v8.0-a+/v9.0-a+.  It is
enabled by the +predres2 march flag.

8 months agogdb: register frame_destroyed function for amd64 gdbarch
Guinevere Larsen [Wed, 1 Nov 2023 16:29:22 +0000 (17:29 +0100)]
gdb: register frame_destroyed function for amd64 gdbarch

gdbarches usually register functions to check when a frame is destroyed
which is used with software watchpoints, since the expression of the
watchpoint is no longer vlaid at this point.  On amd64, this wasn't done
anymore because GCC started using CFA for variable locations instead.

However, clang doesn't use the CFA and instead relies on specifying when
an epilogue has started, meaning software watchpoints get a spurious hit
when a frame is destroyed. This patch re-adds the code to register the
function that detects when a frame is destroyed, but only uses this when
the producer is LLVM, so gcc code isn't affected. The logic that
identifies the epilogue has been factored out into the new function
amd64_stack_frame_destroyed_p_1, so the frame sniffer can call it
directly, and its behavior isn't changed.

This can also remove the XFAIL added to gdb.python/pq-watchpoint tests
that handled this exact flaw in clang.

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
8 months agosim: common: delete unused argbuf in generated mloop code
Mike Frysinger [Tue, 19 Dec 2023 11:54:13 +0000 (06:54 -0500)]
sim: common: delete unused argbuf in generated mloop code

This function only uses prev_abuf, not abuf, and doesn't inline code
from the various ports on the fly, so abuf will never be used.

8 months agosim: v850: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:17:32 +0000 (22:17 -0500)]
sim: v850: fix -Wunused-variable warnings

8 months agosim: sh: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:50:22 +0000 (22:50 -0500)]
sim: sh: fix -Wunused-variable warnings

8 months agosim: moxie: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:12:20 +0000 (22:12 -0500)]
sim: moxie: fix -Wunused-variable warnings

8 months agosim: msp430: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:22:35 +0000 (22:22 -0500)]
sim: msp430: fix -Wunused-variable warnings

8 months agosim: mn10300: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:11:32 +0000 (22:11 -0500)]
sim: mn10300: fix -Wunused-variable warnings

8 months agosim: mips: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:49:23 +0000 (22:49 -0500)]
sim: mips: fix -Wunused-variable warnings

8 months agosim: microblaze: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:44:27 +0000 (22:44 -0500)]
sim: microblaze: fix -Wunused-variable warnings

8 months agosim: mcore: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:20:48 +0000 (22:20 -0500)]
sim: mcore: fix -Wunused-variable warnings

8 months agosim: m32r: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:25:10 +0000 (22:25 -0500)]
sim: m32r: fix -Wunused-variable warnings

8 months agosim: lm32: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:10:00 +0000 (22:10 -0500)]
sim: lm32: fix -Wunused-variable warnings

8 months agosim: iq2000: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 05:13:17 +0000 (00:13 -0500)]
sim: iq2000: fix -Wunused-variable warnings

8 months agosim: h8300: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:15:03 +0000 (22:15 -0500)]
sim: h8300: fix -Wunused-variable warnings

8 months agosim: ft32: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:41:50 +0000 (22:41 -0500)]
sim: ft32: fix -Wunused-variable warnings

8 months agosim: frv: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 05:15:58 +0000 (00:15 -0500)]
sim: frv: fix -Wunused-variable warnings

8 months agosim: erc32: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:19:25 +0000 (22:19 -0500)]
sim: erc32: fix -Wunused-variable warnings

8 months agosim: cris: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 03:09:52 +0000 (22:09 -0500)]
sim: cris: fix -Wunused-variable warnings

8 months agosim: cr16: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 02:47:20 +0000 (21:47 -0500)]
sim: cr16: fix -Wunused-variable warnings

8 months agosim: bpf: fix -Wunused-variable warnings
Mike Frysinger [Sat, 16 Dec 2023 02:47:06 +0000 (21:47 -0500)]
sim: bpf: fix -Wunused-variable warnings

8 months agosim: bfin: fix -Wunused-variable warnings
Mike Frysinger [Wed, 6 Dec 2023 13:40:08 +0000 (06:40 -0700)]
sim: bfin: fix -Wunused-variable warnings

8 months agosim: aarch64: fix -Wunused-variable warnings
Mike Frysinger [Wed, 6 Dec 2023 13:39:56 +0000 (06:39 -0700)]
sim: aarch64: fix -Wunused-variable warnings

8 months agosim: common: fix -Wunused-variable warnings
Mike Frysinger [Wed, 6 Dec 2023 13:39:49 +0000 (06:39 -0700)]
sim: common: fix -Wunused-variable warnings

8 months agocpu: cris: drop some unused vars
Mike Frysinger [Tue, 19 Dec 2023 02:43:07 +0000 (21:43 -0500)]
cpu: cris: drop some unused vars

These fix unused variable warnings in the generated sim.

8 months agox86: Remove the restriction for size of the mask register in AVX10
Haochen Jiang [Tue, 19 Dec 2023 08:35:00 +0000 (16:35 +0800)]
x86: Remove the restriction for size of the mask register in AVX10

Since AVX10.1/256 will also allow 64 bit mask register, we will
remove the restriction for size of the mask register in AVX10.

gas/ChangeLog:

* config/tc-i386.c (VSZ128, VSZ256, VSZ512): New.
(VEX_check_encoding): Remove opcode_modifier check for vsz.
* testsuite/gas/i386/avx10-vsz.l: Remove testcases for mask
registers since they are not needed.
* testsuite/gas/i386/avx10-vsz.s: Ditto.

opcodes/ChangeLog:

* i386-gen.c: Remove Vsz.
* i386-opc.h: Ditto.
* i386-opc.tbl: Remove kvsz.
* i386-tbl.h: Regenerated.

8 months agoLoongArch: Allow la.got -> la.pcrel relaxation for shared object
Xi Ruoyao [Tue, 5 Dec 2023 19:05:47 +0000 (03:05 +0800)]
LoongArch: Allow la.got -> la.pcrel relaxation for shared object

Even in shared objects, la.got -> la.pcrel relaxation can still be
performed for symbols with hidden visibility. For example, if a.c is:

    extern int x;
    int f() { return x++; }

and b.c is:

    int x = 114514;

If compiling and linking with:

    gcc -shared -fPIC -O2 -fvisibility=hidden a.c b.c

Then the la.got in a.o should be relaxed to la.pcrel, and the resulted f
should be like:

    pcaddi  $t0, x
    ldptr.w $a0, $t0, 0
    addi.w  $t1, $a0, 1
    stptr.w $t1, $t0, 0
    ret

Remove bfd_link_executable from the condition of la.got -> la.pcrel
relaxation so this will really happen.  The SYMBOL_REFERENCES_LOCAL
check is enough not to wrongly relax preemptable symbols (for e.g.
when -fvisibility=hidden is not used).

Note that on x86_64 this is also relaxed and the produced code is like:

    lea x(%rip), %rdx
    mov (%rdx), %rax
    lea 1(%rax), %ecx
    mov %ecx, (%rdx)
    ret

Tested by running ld test suite, bootstrapping and regtesting GCC with
the patched ld, and building and testing Glibc with the patched ld.  No
regression is observed.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
8 months agoYet another fix for mcore-sim (rotli)
Jeff Law [Tue, 19 Dec 2023 05:04:25 +0000 (22:04 -0700)]
Yet another fix for mcore-sim (rotli)

This came up testing the CRC optimization work from Mariam@RAU.
Basically to optimize some CRC loops into table lookups or carryless
multiplies, we may need to do a bit reflection, which on the mcore
processor is done using a rotate instruction.

Unfortunately the simulator implementation of rotates has the exact same
problem as we saw with right shifts.  The input value may have been sign
extended from 32 to 64 bits.  When we rotate the extended value, we get
those sign extension bits and thus the wrong result.

The fix is the same.  Rather than using a "long", use a uint32_t for the
type of the temporary.  This fixes a handful of tests in the GCC testsuite:

8 months agoAutomatic date update in version.in
GDB Administrator [Tue, 19 Dec 2023 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

8 months agogettext: disable install, docs targets, libasprintf, threads
Arsen Arsenović [Thu, 16 Nov 2023 22:50:30 +0000 (23:50 +0100)]
gettext: disable install, docs targets, libasprintf, threads

This fixes issues reported by David Edelsohn <dje.gcc@gmail.com>, and by
Eric Gallager <egallager@gcc.gnu.org>.

ChangeLog:

* Makefile.def (gettext): Disable (via missing)
{install-,}{pdf,html,info,dvi} and TAGS targets.  Set no_install
to true.  Add --disable-threads --disable-libasprintf.
* Makefile.in: Regenerate.

8 months agold: Print 0 size in B and not in GB
Torbjörn SVENSSON [Sun, 17 Dec 2023 21:16:08 +0000 (22:16 +0100)]
ld: Print 0 size in B and not in GB

When using --print-memory-usage, the printed size can be zero and in
that case, the unit should be B and not GB.

ld/
* ldlang.c (lang_print_memory_size) Print 0 B instead of 0 GB.
* testsuite/ld-scripts/print-memory-usage-1.l: Validate emplty region.
* testsuite/ld-scripts/print-memory-usage-1.t: Define empty region.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
8 months agoPR31162, Memory Leak in ldwrite.c
Alan Modra [Fri, 15 Dec 2023 09:49:46 +0000 (20:19 +1030)]
PR31162, Memory Leak in ldwrite.c

This isn't a particularly worrying memory leak, but fix it anyway.

PR 31162
* ldwrite.c (build_link_order): Use bfd_alloc rather than xmalloc.
Add %E to error messages.

8 months agogdb/testsuite: another attempt to fix gdb.threads/thread-specific-bp.exp
Andrew Burgess [Sat, 2 Dec 2023 10:08:10 +0000 (10:08 +0000)]
gdb/testsuite: another attempt to fix gdb.threads/thread-specific-bp.exp

The gdb.threads/thread-specific-bp.exp test has been a little
problematic, see commits:

  commit 89702edd933a5595557bcd9cc4a0dcc3262226d4
  Date:   Thu Mar 9 12:31:26 2023 +0100

      [gdb/testsuite] Fix gdb.threads/thread-specific-bp.exp on native-gdbserver

and

  commit 2e5843d87c4050bf1109921481fb29e1c470827f
  Date:   Fri Nov 19 14:33:39 2021 +0100

      [gdb/testsuite] Fix gdb.threads/thread-specific-bp.exp

But I recently saw a test failure for that test, which looked like
this:

  ...
  (gdb) PASS: gdb.threads/thread-specific-bp.exp: non_stop=on: thread 1 selected
  continue -a
  Continuing.

  Thread 1 "thread-specific" hit Breakpoint 4, end () at /tmp/binutils-gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.threads/thread-specific-bp.c:29
  29      }
  (gdb) [Thread 0x7ffff7c5c700 (LWP 1552086) exited]
  Thread-specific breakpoint 3 deleted - thread 2 no longer in the thread list.
  FAIL: gdb.threads/thread-specific-bp.exp: non_stop=on: continue to end (timeout)
  ...

This only crops up (for me) when running on a loaded machine, and
still only occurs sometimes.  I've had to leave the test running in a
loop for 10+ minutes sometimes in order to see the failure.

The problem is that we use gdb_test_multiple to try and match two
patterns:

  (1) The 'Thread-specific breakpoint 3 deleted ....' message, and
  (2) The GDB prompt.

As written in the test, we understand that these patterns can occur in
any order, and we have a flag for each pattern.  Once both patterns
have been seen then we PASS the test.

The problem is that once expect has matched a pattern, everything up
to, and including the matched text is discarded from the input
buffer.  Thus, if the input buffer contains:

  <PATTERN 2><PATTERN 1>

Then expect will first try to match <PATTERN 1>, which succeeds, and
then expect discards the entire input buffer up to the end of the
<PATTERN 1>.  As a result, we will never spot <PATTERN 2>.

Obviously we can't just reorder the patterns within the
gdb_test_multiple, as the output can legitimately (and most often
does) occur in the other order, in which case the test would mostly
fail, and only occasionally pass!

I think the easiest solution here is just to have the
gdb_test_multiple contain two patterns, each pattern consists of the
two parts, but in the alternative orders, thus, for a particular
output configuration, only one regexp will match.  With this change in
place, I no longer see the intermittent failure.

Approved-By: Tom Tromey <tom@tromey.com>
8 months agoLoongArch: Add call36 and tail36 pseudo instructions for medium code model
mengqinggang [Thu, 23 Nov 2023 07:42:49 +0000 (15:42 +0800)]
LoongArch: Add call36 and tail36 pseudo instructions for medium code model

  For tail36, it is necessary to explicitly indicate the temporary register.
  Therefore, the compiler and users will know that the tail will use a register.

  call36 func
    pcalau18i $ra, %call36(func)
    jirl      $ra, $ra, 0;

  tail36 $t0, func
    pcalau18i $t0, %call36(func)
    jirl      $zero, $t0, 0;

8 months agoLoongArch: Add new relocation R_LARCH_CALL36
mengqinggang [Thu, 28 Sep 2023 08:41:15 +0000 (16:41 +0800)]
LoongArch: Add new relocation R_LARCH_CALL36

R_LARCH_CALL36 is used for medium code model function call pcaddu18i+jirl, and
these two instructions must adjacent.

The LoongArch ABI v2.20 at here: https://github.com/loongson/la-abi-specs.

8 months agoPR31177: Let region text start at __TEXT_REGION_ORIGIN___
Georg-Johann Lay [Sun, 17 Dec 2023 18:20:54 +0000 (19:20 +0100)]
PR31177: Let region text start at __TEXT_REGION_ORIGIN___

The start of MEMORY region text currently starts hard-coded at 0.

The linker can produce more exact diagnostics when it knows the exact placements of the memory regions.

For some old devices, program memory starts at 0x8000, so allow to specify program memory start at __TEXT_REGION_ORIGIN__ similar to how the data region is described.

If ok, please apply to master.
This one is also fine to back-port.

Johann

--

AVR: Use __TEXT_REGION_ORIGIN__ as start for MEMORY region text.

ld/
PR 31177
* scripttempl/avr.sc (__TEXT_REGION_ORIGIN__): New symbol.
(MEMORY): Use as start address for the text region.

8 months agoAutomatic date update in version.in
GDB Administrator [Mon, 18 Dec 2023 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

8 months agosim: warnings: add more flags
Mike Frysinger [Sun, 17 Dec 2023 05:14:48 +0000 (00:14 -0500)]
sim: warnings: add more flags

We already build cleanly with these.

8 months agoAutomatic date update in version.in
GDB Administrator [Sun, 17 Dec 2023 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

8 months agoUse function entry point record only for entry values
Hannes Domani [Sat, 16 Dec 2023 10:24:16 +0000 (11:24 +0100)]
Use function entry point record only for entry values

PR28987 notes that optimized code sometimes shows the wrong
value of variables at the entry point of a function, if some
code was optimized away and the variable has multiple values
stored in the debug info for this location.

In this example:
```
void foo()
{
   int l_3 = 5, i = 0;
   for (; i < 8; i++)
       ;
   test(l_3, i);
}
```
When compiled with optimization, the entry point of foo is at
the test() function call, since everything else is optimized
away.
The debug info of i looks like this:
```
(gdb) info address i
Symbol "i" is multi-location:
  Base address 0x140001600  Range 0x13fd41600-0x13fd41600: the constant 0
  Range 0x13fd41600-0x13fd41600: the constant 1
  Range 0x13fd41600-0x13fd41600: the constant 2
  Range 0x13fd41600-0x13fd41600: the constant 3
  Range 0x13fd41600-0x13fd41600: the constant 4
  Range 0x13fd41600-0x13fd41600: the constant 5
  Range 0x13fd41600-0x13fd41600: the constant 6
  Range 0x13fd41600-0x13fd41600: the constant 7
  Range 0x13fd41600-0x13fd4160f: the constant 8
(gdb) p i
$1 = 0
```

Currently, when at the entry point of a function, it will
always show the initial value (here 0), while the user would
expect the last value (here 8).
This logic was introduced for showing the entry-values of
function arguments if they are available, but for some
reason this was added for non-entry-values as well.

One of the tests of amd64-entry-value.exp shows the same
problem for function arguments, if you "break stacktest"
in the following example, you stop at this line:
```
124     static void __attribute__((noinline, noclone))
125     stacktest (int r1, int r2, int r3, int r4, int r5, int r6, int s1, int s2,
126                double d1, double d2, double d3, double d4, double d5, double d6,
127                double d7, double d8, double d9, double da)
128     {
129       s1 = 3;
130       s2 = 4;
131       d9 = 3.5;
132       da = 4.5;
133 ->    e (v, v);
134     asm ("breakhere_stacktest:");
135       e (v, v);
136     }
```
But `bt` still shows the entry values:
```
s1=s1@entry=11, s2=s2@entry=12, ..., d9=d9@entry=11.5, da=da@entry=12.5
```

I've fixed this by only using the initial values when
explicitely looking for entry values.

Now the local variable of the first example is as expected:
```
(gdb) p i
$1 = 8
```

And the test of amd64-entry-value.exp shows the expected
current and entry values of the function arguments:
```
s1=3, s1@entry=11, s2=4, s2@entry=12, ..., d9=3.5, d9@entry=11.5, da=4.5, da@entry=12.5
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28987
Tested-By: Guinevere Larsen <blarsen@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
8 months ago[gdb/build] Remove dependency on _rl_term_autowrap
Tom de Vries [Sat, 16 Dec 2023 09:39:17 +0000 (10:39 +0100)]
[gdb/build] Remove dependency on _rl_term_autowrap

Commit deb1ba4e38b ("[gdb/tui] Fix TUI resizing for TERM=ansi") introduced a
dependency on readline private variable _rl_term_autowrap.

There is precedent for this, but it's something we want to get rid of
(PR build/10723).

Remove the dependency on _rl_term_autowrap, and instead calculate
readline_hidden_cols by comparing the environment variable COLS with cols as
returned by rl_get_screen_size.

Tested on x86_64-linux.

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

8 months ago[gdb/tui] Show regs when switching to regs layout
Tom de Vries [Sat, 16 Dec 2023 08:31:29 +0000 (09:31 +0100)]
[gdb/tui] Show regs when switching to regs layout

When starting gdb in CLI mode, running to main and switching into the TUI regs
layout:
...
$ gdb -q a.out -ex start -ex "layout regs"
...
we get:
...
+---------------------------------+
|                                 |
| [ Register Values Unavailable ] |
|                                 |
+---------------------------------+
...

Fix this by handling this case in tui_data_window::rerender.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR tui/28600
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28600

8 months ago[gdb/tui] Use more box_width in tui-regs.c
Tom de Vries [Sat, 16 Dec 2023 08:23:38 +0000 (09:23 +0100)]
[gdb/tui] Use more box_width in tui-regs.c

While experimenting with can_box () == false by default, I noticed two places
in tui-regs.c where we can replace a hardcoded 1 with box_width ().

It also turned out to be necessary to set scrollok to false, otherwise writing
the last char of the last line with register info will cause a scroll.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
8 months agosim: cr16: clean up unused insn operands
Mike Frysinger [Sat, 16 Dec 2023 05:29:36 +0000 (00:29 -0500)]
sim: cr16: clean up unused insn operands

The push/pop insns only have 2 operands, so delete unused "c".

The pushret/popret insns use 2 operands, but they don't implement the
logic directly, they call the push/pop implementations.  So delete the
unused "a" & "b".

8 months agosim: sh: adjust some dsp insn masks
Mike Frysinger [Sat, 16 Dec 2023 04:54:40 +0000 (23:54 -0500)]
sim: sh: adjust some dsp insn masks

The pmuls encoding is incorrect -- it looks like a copy & paste error
from the padd pmuls variant.  The SuperH software manual covers this.

On the flip side, the manual lists pwsb & pwad as insns that exist,
but no description of what they do, what the insn name means, or the
actual encoding.  Our sim implementation stubs them both out as nops.
Let's mark the fields to avoid unused variable warnings.

8 months agosim: sh: tidy up gencode slightly
Mike Frysinger [Sat, 16 Dec 2023 04:15:24 +0000 (23:15 -0500)]
sim: sh: tidy up gencode slightly

Mark a few things static/const, and clean up trailing whitespace.

8 months agosim: bfin: fix typo in bf52x ports
Mike Frysinger [Sat, 16 Dec 2023 02:40:42 +0000 (21:40 -0500)]
sim: bfin: fix typo in bf52x ports

These should be using the BF52x set of ports, not BF51x.

8 months agosim: warnings: enable -Wunused-but-set-variable
Mike Frysinger [Wed, 6 Dec 2023 13:34:29 +0000 (06:34 -0700)]
sim: warnings: enable -Wunused-but-set-variable

8 months agosim: mn10300: fix incorrect implementation of a few insns
Mike Frysinger [Thu, 7 Dec 2023 03:08:01 +0000 (20:08 -0700)]
sim: mn10300: fix incorrect implementation of a few insns

Fix a few problems caught by compiler warnings:
* Some of the asr & lsr insns were setting up the c state flag,
  but then forgetting to set it in the PSW.  Add it like the other
  asr & lsr variants.
* Some of the dmulh insns were multiplying one of the source regs
  against itself instead of against the other source reg.
* The sat16_cmp parallel insn was using the wrong register in the
  compare -- the reg1 src/dst pair are used in the sat16 op, and
  the reg2 src/dst pair are used in the add op.

8 months agoAutomatic date update in version.in
GDB Administrator [Sat, 16 Dec 2023 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

8 months agoRefine Ada overload matching
Tom Tromey [Tue, 28 Nov 2023 21:26:56 +0000 (14:26 -0700)]
Refine Ada overload matching

Currently, the overload handling in Ada assumes that any two array
types are compatible.  However, this is obviously untrue, and a user
reported an oddity where comparing two Ada strings resulted in a call
to the "=" function for packed boolean arrays.

This patch improves the situation somewhat, by requiring that the two
arrays have the same arity and compatible base element types.  This is
still over-broad, but it seems safe and is better than the status quo.

8 months agoBoolify ada_type_match
Tom Tromey [Thu, 30 Nov 2023 17:31:12 +0000 (10:31 -0700)]
Boolify ada_type_match

This changes ada_type_match to return bool.

8 months agoFix segmentation fault in bfd/elf32-hppa.c
John David Anglin [Fri, 15 Dec 2023 21:02:32 +0000 (21:02 +0000)]
Fix segmentation fault in bfd/elf32-hppa.c

2023-12-15  John David Anglin  <danglin@gcc.gnu.org>

PR ld/31148

bfd/ChangeLog:

* elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Output
relative reloc only when eh->root.type is bfd_link_hash_defined
or bfd_link_hash_defweak.

8 months agoarm: reformat -march option section in gas documentation
Matthieu Longo [Fri, 15 Dec 2023 15:08:28 +0000 (15:08 +0000)]
arm: reformat -march option section in gas documentation

Hi,

This patch contains a reformatting of -march option section in gas documentation.

For instance (see https://sourceware.org/binutils/docs-2.41/as.html#ARM-Options),
before all the options were on one line:
   For armv8-a:
   +crc: Enables CRC32 Extension. +simd: Enables VFP and NEON for Armv8-A. +crypto: Enables
   Cryptography Extensions for Armv8-A, implies +simd. +sb: Enables Speculation Barrier
   Instruction for Armv8-A. +predres: Enables Execution and Data Prediction Restriction
   Instruction for Armv8-A. +nofp: Disables all FPU, NEON and Cryptography Extensions.
   +nocrypto: Disables Cryptography Extensions.

Now, the readability is improved thanks to the itemization of the options:
   For armv8-a:
    +crc: Enables CRC32 Extension.
    +simd: Enables VFP and NEON for Armv8-A.
    +crypto: Enables Cryptography Extensions for Armv8-A, implies +simd.
    +sb: Enables Speculation Barrier Instruction for Armv8-A.
    +predres: Enables Execution and Data Prediction Restriction Instruction for Armv8-A.
    +nofp: Disables all FPU, NEON and Cryptography Extensions.
    +nocrypto: Disables Cryptography Extensions.

Ok for binutils-master? I don't have commit access so I need someone to commit on my behalf.

Regards,
Matthieu.

8 months agoaarch64: Enable Cortex-X3 CPU
Matthieu Longo [Wed, 13 Dec 2023 15:41:43 +0000 (15:41 +0000)]
aarch64: Enable Cortex-X3 CPU

Hi,

This patch adds support for the Cortex-X3 CPU to binutils.

Gas regression testing for aarch64-none-linux-gnu target and found no regressions.

Ok for binutils-master? I don't have commit access so I need someone to commit on my behalf.

Regards,

Matthieu.

8 months agoarm: document -march=armv9.[123]-a binutils options
Matthieu Longo [Fri, 15 Dec 2023 13:44:40 +0000 (13:44 +0000)]
arm: document -march=armv9.[123]-a binutils options

8 months agox86: last-insn recording should be per-subsection
Jan Beulich [Fri, 15 Dec 2023 11:42:43 +0000 (12:42 +0100)]
x86: last-insn recording should be per-subsection

Otherwise intermediate subsection switches result in inconsistent
behavior. Leverage ELF's section change hook to switch state as
necessary, limiting overhead to the bare minimum when subsections aren't
used.

8 months agoELF: reliably invoke md_elf_section_change_hook()
Jan Beulich [Fri, 15 Dec 2023 11:41:49 +0000 (12:41 +0100)]
ELF: reliably invoke md_elf_section_change_hook()

... after any (sub)section change. While certain existing target hooks
only look at now_seg, for a few others it looks as if failing to do so
could have caused anomalies if sub-sections were used. In any event a
subsequent x86 change is going to require the sub-section to be properly
in place at the time the hook is invoked.

This primarily means for obj_elf_section() to pass the new subsection
into change_section(), for it to be set right away (ahead of invoking
the hook).

Also adjust obj_elf_ident() to invoke the hook after all section
changes. (Note that obj_elf_version(), which also changes sections and
then changes them back, has no hook invocation at all so far, so none
are added. Presumably there is a reason for this difference in
behavior.)

8 months agoELF: drop "push" parameter from obj_elf_change_section()
Jan Beulich [Fri, 15 Dec 2023 11:41:21 +0000 (12:41 +0100)]
ELF: drop "push" parameter from obj_elf_change_section()

No caller outside of obj-elf.c cares about the parameter - drop it by
introducing an obj-elf.c-internal wrapper.

While adding the new function parameter, take the opportunity and change
the adjacent boolean one to "bool".

8 months agox86: don't needlessly override .bss
Jan Beulich [Fri, 15 Dec 2023 11:40:52 +0000 (12:40 +0100)]
x86: don't needlessly override .bss

ELF, COFF, and Mach-O all have custom handlers for .bss. Don't override
those; install a handler only for a.out.

8 months agorevert "x86: allow 32-bit reg to be used with U{RD,WR}MSR"
Jan Beulich [Fri, 15 Dec 2023 11:40:00 +0000 (12:40 +0100)]
revert "x86: allow 32-bit reg to be used with U{RD,WR}MSR"

This reverts commit 1f865bae65db9588f6994c02a92355bfb4e3d955. The
specification is going to by updated in a way rendering this change
wrong.

8 months agox86: fold assembly dialect attributes
Jan Beulich [Fri, 15 Dec 2023 11:05:11 +0000 (12:05 +0100)]
x86: fold assembly dialect attributes

Now that ATTSyntax and ATTMnemonic aren't use in combination anymore,
fold them and IntelSyntax into a single, enum-like attribute. Note that
this shrinks i386_opcode_modifier back to 2 32-bit words (albeit that's
not for long, seeing in-flight additions for APX).

8 months agox86: Intel syntax implies Intel mnemonics
Jan Beulich [Fri, 15 Dec 2023 11:04:39 +0000 (12:04 +0100)]
x86: Intel syntax implies Intel mnemonics

As noted in the context of d53e6b98a259 ("x86/Intel: correct disassembly
of fsub*/fdiv*") there's no such thing as Intel syntax without Intel
mnemonics. Enforce this on the assembler side, and disentangle command
line option handling on the disassembler side accordingly.

As a result in the opcode table specifying ATTMnemonic|ATTSyntax becomes
redundant with just ATTMnemonic. Drop the now meaningless ATTSyntax and
remove the then no longer accessible templates.

8 months agoArm64: fix build for certain gcc versions
Jan Beulich [Fri, 15 Dec 2023 11:04:08 +0000 (12:04 +0100)]
Arm64: fix build for certain gcc versions

Some complain (by default) about isalpha shadowing ctype.h's isalpha().
Some also complain about signed/unsigned comparison a few lines later.

8 months agoAddendum to PR31124
Georg-Johann Lay [Fri, 15 Dec 2023 08:19:08 +0000 (09:19 +0100)]
Addendum to PR31124

This is a small addendum to PR31124 "rodata in flash for
more AVR devices".

It adds some symbols so the startup code can set a lock
on the FLMAP bit field as specified by the user.

New symbols are introduced because otherwise, all the
computations / decisions would have to be performed at
run-time.

It approved, please apply to master.

Johann

--

ld/
PR 31124
* scripttempl/avr.sc: Adjust comments.
[MAYBE_FLMAP]: Add symbols __flmap_value and __flmap_value_with_lock.
Remove __flmap_lsl4.

8 months agosim: m32r: fix mloop.in variant stamp deps
Mike Frysinger [Fri, 15 Dec 2023 03:45:22 +0000 (22:45 -0500)]
sim: m32r: fix mloop.in variant stamp deps

The migration to local.mk in commit 0a129eb19a773d930d60b084209570f663db2053
accidentally listed the deps for all mloop steps as mloop.in instead of the
various variants that m32r uses.

Reported-by: Simon Marchi <simon.marchi@polymtl.ca>
8 months agosim: m32r: use @cpu@_fill_argbuf_tp to set trace & profile state
Mike Frysinger [Fri, 15 Dec 2023 03:34:28 +0000 (22:34 -0500)]
sim: m32r: use @cpu@_fill_argbuf_tp to set trace & profile state

The mloop.in code does this, but these variants do not.  Use it to
avoid unused function warnings.  The fast_p logic in these files
also looks off, but that'll require a bit more work to fixup.

  CC       m32r/mloopx.o
m32r/mloopx.c:37:1: error: ‘m32rxf_fill_argbuf_tp’ defined but not used [-Werror=unused-function]
   37 | m32rxf_fill_argbuf_tp (const SIM_CPU *cpu, ARGBUF *abuf,
      | ^~~~~~~~~~~~~~~~~~~~~

  CC       m32r/mloop2.o
m32r/mloop2.c:37:1: error: ‘m32r2f_fill_argbuf_tp’ defined but not used [-Werror=unused-function]
   37 | m32r2f_fill_argbuf_tp (const SIM_CPU *cpu, ARGBUF *abuf,
      | ^~~~~~~~~~~~~~~~~~~~~

Reported-by: Simon Marchi <simon.marchi@polymtl.ca>
Tested-By: Simon Marchi <simon.marchi@polymtl.ca>
8 months agosim: igen: do not reindent literal semantics output
Mike Frysinger [Fri, 15 Dec 2023 03:29:56 +0000 (22:29 -0500)]
sim: igen: do not reindent literal semantics output

When generating semantics.c from .igen source files, indenting the code
makes it more readable, but confuses compiler diagnostics.  The latter
is a bit more important than the former, so bias towards that.

For example, with an introduced error, we can see w/gcc-13:

(before this change)
  CC       mn10300/semantics.o
../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’:
../../../sim/mn10300/am33-2.igen:11:5: error: ‘srcreg’ undeclared (first use in this function)
   11 |   srcreg = translate_rreg (SD_, RN2);
      |     ^~~~~~

(with this change)
  CC       mn10300/semantics.o
../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’:
../../../sim/mn10300/am33-2.igen:11:3: error: ‘srcreg’ undeclared (first use in this function)
   11 |   srcreg = translate_rreg (SD_, RN2);
      |   ^~~~~~

8 months agoregen ld POTFILES
Alan Modra [Fri, 15 Dec 2023 03:12:24 +0000 (13:42 +1030)]
regen ld POTFILES