binutils-gdb.git
4 years agox86: Support GNU_PROPERTY_X86_ISA_1_BASELINE marker
H.J. Lu [Fri, 30 Oct 2020 13:49:57 +0000 (06:49 -0700)]
x86: Support GNU_PROPERTY_X86_ISA_1_BASELINE marker

GCC 11 supports -march=x86-64-v[234] to enable x86 micro-architecture ISA
levels:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97250

X86 ISA markers are updated:

https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/13

GNU_PROPERTY_X86_ISA_1_BASELINE is added and GNU_PROPERTY_X86_ISA_1_V[234]
are updated:

 #define GNU_PROPERTY_X86_ISA_1_BASELINE (1U << 0)
 #define GNU_PROPERTY_X86_ISA_1_V2       (1U << 1)
 #define GNU_PROPERTY_X86_ISA_1_V3       (1U << 2)
 #define GNU_PROPERTY_X86_ISA_1_V4       (1U << 3)

Add -z x86-64-baseline linker command line option to mark x86-64-baseline
ISA level as needed.

bfd/

PR gas/26703
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Generate
GNU_PROPERTY_X86_ISA_1_BASELINE for -z x86-64-baseline.

binutils/

PR gas/26703
* readelf.c (decode_x86_isa): Handle
* GNU_PROPERTY_X86_ISA_1_BASELINE.
* testsuite/binutils-all/i386/empty.d: Updated.
* testsuite/binutils-all/i386/ibt.d: Likewise.
* testsuite/binutils-all/i386/pr21231a.d: Likewise.
* testsuite/binutils-all/i386/pr21231b.d: Likewise.
* testsuite/binutils-all/i386/shstk.d: Likewise.
* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
* testsuite/binutils-all/x86-64/empty.d: Likewise.
* testsuite/binutils-all/x86-64/ibt-x32.d: Likewise.
* testsuite/binutils-all/x86-64/ibt.d: Likewise.
* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
* testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
* testsuite/binutils-all/x86-64/shstk.d: Likewise.

gas/

PR gas/26703
* config/tc-i386.c (output_insn): Update for
GNU_PROPERTY_X86_ISA_1_BASELINE.
* testsuite/gas/i386/property-1.d: Updated.
* testsuite/gas/i386/property-2.d: Likewise.
* testsuite/gas/i386/property-3.d: Likewise.
* testsuite/gas/i386/property-4.d: Likewise.
* testsuite/gas/i386/property-5.d: Likewise.
* testsuite/gas/i386/property-6.d: Likewise.
* testsuite/gas/i386/property-11.d: Likewise.
* testsuite/gas/i386/property-12.d: Likewise.
* testsuite/gas/i386/x86-64-property-1.d: Likewise.
* testsuite/gas/i386/x86-64-property-2.d: Likewise.
* testsuite/gas/i386/x86-64-property-3.d: Likewise.
* testsuite/gas/i386/x86-64-property-4.d: Likewise.
* testsuite/gas/i386/x86-64-property-5.d: Likewise.
* testsuite/gas/i386/x86-64-property-6.d: Likewise.
* testsuite/gas/i386/x86-64-property-11.d: Likewise.
* testsuite/gas/i386/x86-64-property-12.d: Likewise.

include/

PR gas/26703
* elf/common.h (GNU_PROPERTY_X86_ISA_1_BASELINE): New.
(GNU_PROPERTY_X86_ISA_1_V2): Uppdated.
(GNU_PROPERTY_X86_ISA_1_V3): Likewise.
(GNU_PROPERTY_X86_ISA_1_V4): Likewise.

ld/

PR gas/26703
* NEWS: Mention -z x86-64-baseline.
* ld.texi: Document -z x86-64-baseline.
* emulparams/x86-64-level.sh: Handle -z x86-64-baseline.
* testsuite/ld-elf/x86-feature-1a.rd: Update.
* testsuite/ld-elf/x86-feature-1b.rd: Likewise.
* testsuite/ld-elf/x86-feature-1c.rd: Likewise.
* testsuite/ld-elf/x86-feature-1d.rd: Likewise.
* testsuite/ld-elf/x86-feature-1e.rd: Likewise.
* testsuite/ld-i386/pr23372c.d: Likewise.
* testsuite/ld-i386/pr23486c.d: Likewise.
* testsuite/ld-i386/pr23486d.d: Likewise.
* testsuite/ld-i386/pr24322a.d: Likewise.
* testsuite/ld-i386/pr24322b.d: Likewise.
* testsuite/ld-i386/property-1a.r: Likewise.
* testsuite/ld-i386/property-2a.r: Likewise.
* testsuite/ld-i386/property-3.r: Likewise.
* testsuite/ld-i386/property-3a.r: Likewise.
* testsuite/ld-i386/property-4.r: Likewise.
* testsuite/ld-i386/property-4a.r: Likewise.
* testsuite/ld-i386/property-5.r: Likewise.
* testsuite/ld-i386/property-5a.r: Likewise.
* testsuite/ld-i386/property-7a.r: Likewise.
* testsuite/ld-i386/property-x86-3.d: Likewise.
* testsuite/ld-i386/property-x86-4a.d: Likewise.
* testsuite/ld-i386/property-x86-5.d: Likewise.
* testsuite/ld-i386/property-x86-cet1.d: Likewise.
* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
* testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
* testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
* testsuite/ld-i386/property-x86-ibt2.d: Likewise.
* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
* testsuite/ld-i386/property-x86-ibt4.d: Likewise.
* testsuite/ld-i386/property-x86-ibt5.d: Likewise.
* testsuite/ld-i386/property-x86-isa1.d: Likewise.
* testsuite/ld-i386/property-x86-isa2.d: Likewise.
* testsuite/ld-i386/property-x86-isa3.d: Likewise.
* testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
* testsuite/ld-i386/property-x86-shstk2.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
* testsuite/ld-i386/property-x86-shstk4.d: Likewise.
* testsuite/ld-i386/property-x86-shstk5.d: Likewise.
* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372c.d: Likewise.
* testsuite/ld-x86-64/pr23486c-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486c.d: Likewise.
* testsuite/ld-x86-64/pr23486d-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486d.d: Likewise.
* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
* testsuite/ld-x86-64/pr24322a.d: Likewise.
* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
* testsuite/ld-x86-64/pr24322b.d: Likewise.
* testsuite/ld-x86-64/pr24458a-x32.d: Likewise.
* testsuite/ld-x86-64/pr24458a.d: Likewise.
* testsuite/ld-x86-64/pr24458b-x32.d: Likewise.
* testsuite/ld-x86-64/pr24458b.d: Likewise.
* testsuite/ld-x86-64/pr24458c-x32.d: Likewise.
* testsuite/ld-x86-64/pr24458c.d: Likewise.
* testsuite/ld-x86-64/property-1a.r: Likewise.
* testsuite/ld-x86-64/property-2a.r: Likewise.
* testsuite/ld-x86-64/property-3.r: Likewise.
* testsuite/ld-x86-64/property-3a.r: Likewise.
* testsuite/ld-x86-64/property-4.r: Likewise.
* testsuite/ld-x86-64/property-4a.r: Likewise.
* testsuite/ld-x86-64/property-5.r: Likewise.
* testsuite/ld-x86-64/property-5a.r: Likewise.
* testsuite/ld-x86-64/property-7a.r: Likewise.
* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-3.d: Likewise.
* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-5.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt2.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa1-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa1.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa2-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa2.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa3-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa3.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk2.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.
* testsuite/ld-i386/i386.exp: Run property-x86-isa4.
* testsuite/ld-i386/property-x86-isa4.d: New file.
* testsuite/ld-x86-64/property-x86-isa4-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa4.d: Likewise.
* ld/testsuite/ld-x86-64/x86-64.exp: Run property-x86-isa4
and property-x86-isa4-x32.

4 years ago[PATCH][GAS] aarch64: Add WFIT instruction for Armv8.7-a
Przemyslaw Wirkus [Fri, 30 Oct 2020 10:27:24 +0000 (10:27 +0000)]
[PATCH][GAS] aarch64: Add WFIT instruction for Armv8.7-a

This patch adds new to Armv8.7 WFIT instruction which take one operand:

    WFIT <Xt>

Where:
    <Xt> is 64-bit name of the general-purpose source register, encoded in the
         "Rd" field.

For more details regarding WFIT (Wait For Interrupt with Timeout) instruction for
Armv8.7-a please refer to Arm A64 Instruction set documentation for Armv8-A
architecture profile, see document pages 570 of [0].

[0]: https://developer.arm.com/docs/ddi0596/i

gas/ChangeLog:

2020-10-30  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* NEWS: Update docs.
* testsuite/gas/aarch64/system-5.d: Update test with WFIT insn.
* testsuite/gas/aarch64/system-5.s: Update test with WFIT insn.

opcodes/ChangeLog:

2020-10-30  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* aarch64-tbl.h (struct aarch64_opcode): New instruction WFIT.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.

4 years agogdb/infrun: disable pagination in fetch_inferior_event
Tankut Baris Aktemur [Fri, 30 Oct 2020 07:13:57 +0000 (08:13 +0100)]
gdb/infrun: disable pagination in fetch_inferior_event

Having pagination enabled when handling an inferior event gives the
user an option to quit, which causes early exit in GDB's flow and may
lead to half-baked state.  For instance, here is a case where we quit
in the middle of handling an inferior exit:

  $ gdb ./a.out
  Reading symbols from ./a.out...
  (gdb) set height 2
  (gdb) run
  Starting program: ./a.out
  --Type <RET> for more, q to quit, c to continue without paging--q
  Quit
  Couldn't get registers: No such process.
  (gdb) set height unlimited
  Couldn't get registers: No such process.
  (gdb) info threads
    Id   Target Id         Frame
  * 1    process 27098     Couldn't get registers: No such process.
  Couldn't get registers: No such process.
  (gdb)

Or suppose having a multi-threaded program like below:

  static void *
  fun (void *dummy)
  {
    int a = 1; /* break-here */
    return NULL;
  }

  int
  main (void)
  {
    pthread_t thread;
    pthread_create (&thread, NULL, fun, NULL);
    pthread_join (thread, NULL);

    return 0;
  }

If we define a breakpoint at line "break-here", we expect only Thread
2 to hit it.

  $ gdb ./a.out
  Reading symbols from ./a.out...
  (gdb) break 7
  Breakpoint 1 at 0x1182: file mt.c, line 7.
  (gdb) set height 2
  (gdb) run
  Starting program: ./a.out
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
  [New Thread 0x7ffff77c4700 (LWP 23048)]
  --Type <RET> for more, q to quit, c to continue without paging--q
  Quit
  (gdb) set height unlimited
  (gdb) info thread
    Id   Target Id                                 Frame
  * 1    Thread 0x7ffff7fe3740 (LWP 23044) "a.out" 0x00007ffff7bbed2d in ...
    2    Thread 0x7ffff77c4700 (LWP 23048) "a.out" fun (dummy=0x0) at mt.c:7
  (gdb)

The prompt for continuation was triggered because Thread 2 hit the
breakpoint.  (If we had hit 'c', we were going to see that stop event,
but we didn't.)  The context did not switch to Thread 2.  GDB also did
not execute several other things it would normally do in
infrun.c:normal_stop after outputting "[Switching to Thread ...]" (but
it seems harmless in this case).  If we 'continue' at this state, both
threads run until termination, and we don't see the breakpoint hit
event ever.

Here is another related and more complicated scenario that leads to a
GDB crash.  Create two inferiors, one sitting on top of a native
target, and the other on a remote target, so that we have a
multi-target setting, like so:

  (gdb) i inferiors
    Num  Description       Connection     Executable
    1    process 13786     1 (native)     a.out
  * 2    process 13806     2 (remote ...) target:a.out

Next, resume both inferiors to run until termination:

  (gdb) set schedule-multiple on
  (gdb) set height 2
  (gdb) continue
  Continuing.
  --Type <RET> for more, q to quit, c to continue without paging--[Inferior 2 (process 13806) exited normally]

  terminate called after throwing an instance of 'gdb_exception_error'
  Aborted

Here, GDB first received a termination event from Inferior 1.  GDB
attempted to print this event, triggering a "prompt for continue", and
GDB started polling for events, hoping to get an input from the user.
However, the exit event from Inferior 2 was received instead.  So, GDB
started processing an exit event while being in the middle of
processing another exit event.  It was not ready for this situation
and eventually crashed.

To address these cases, temporarily disable pagination in
fetch_inferior_event.  This doesn't affect commands like 'info
threads', 'backtrace', or 'thread apply'.

Regression-tested on X86_64 Linux.

gdb/ChangeLog:
2020-10-30  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* infrun.c (fetch_inferior_event): Temporarily disable pagination.

gdb/testsuite/ChangeLog:
2020-10-30  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.base/paginate-after-ctrl-c-running.exp: Update with no pagination
behavior.
* gdb.base/paginate-bg-execution.exp: Ditto.
* gdb.base/paginate-inferior-exit.exp: Ditto.
* gdb.base/double-prompt-target-event-error.c: Remove.
* gdb.base/double-prompt-target-event-error.exp: Remove.

4 years agoMove lookup_selected_frame to frame.c
Pedro Alves [Thu, 9 Jul 2020 19:12:15 +0000 (20:12 +0100)]
Move lookup_selected_frame to frame.c

This function is now external, and isn't really threads related.  Move
it to frame.c.

gdb/ChangeLog:

* thread.c (lookup_selected_frame): Move ...
* frame.c (lookup_selected_frame): ... here.

Change-Id: Ia96b79c15767337c68efd3358bcc715ce8e26c15

4 years agoMake scoped_restore_current_thread's cdtors exception free (RFC)
Pedro Alves [Fri, 30 Oct 2020 17:26:15 +0000 (18:26 +0100)]
Make scoped_restore_current_thread's cdtors exception free (RFC)

If the remote target closes while we're reading registers/memory for
restoring the selected frame in scoped_restore_current_thread's dtor,
the corresponding TARGET_CLOSE_ERROR error is swallowed by the
scoped_restore_current_thread's dtor, because letting exceptions
escape from a dtor is bad.  It isn't great to lose that errors like
that, though.  I've been thinking about how to avoid it, and I came up
with this patch.

The idea here is to make scoped_restore_current_thread's dtor do as
little as possible, to avoid any work that might throw in the first
place.  And to do that, instead of having the dtor call
restore_selected_frame, which re-finds the previously selected frame,
just record the frame_id/level of the desired selected frame, and have
get_selected_frame find the frame the next time it is called.  In
effect, this implements most of Cagney's suggestion, here:

  /* On demand, create the selected frame and then return it.  If the
     selected frame can not be created, this function prints then throws
     an error.  When MESSAGE is non-NULL, use it for the error message,
     otherwize use a generic error message.  */
  /* FIXME: cagney/2002-11-28: At present, when there is no selected
     frame, this function always returns the current (inner most) frame.
     It should instead, when a thread has previously had its frame
     selected (but not resumed) and the frame cache invalidated, find
     and then return that thread's previously selected frame.  */
  extern struct frame_info *get_selected_frame (const char *message);

The only thing missing to fully implement that would be to make
reinit_frame_cache just clear selected_frame instead of calling
select_frame(NULL), and the call select_frame(NULL) explicitly in the
places where we really wanted reinit_frame_cache to go back to the
current frame too.  That can done separately, though, I'm not
proposing to do that in this patch.

Note that this patch renames restore_selected_frame to
lookup_selected_frame, and adds a new restore_selected_frame function
that doesn't throw, to be paired with the also-new save_selected_frame
function.

There's a restore_selected_frame function in infrun.c that I think can
be replaced by the new one in frame.c.

Also done in this patch is make the get_selected_frame's parameter be
optional, so that we don't have to pass down nullptr explicitly all
over the place.

lookup_selected_frame should really move from thread.c to frame.c, but
I didn't do that here, just to avoid churn in the patch while it
collects comments.  I did make it extern and declared it in frame.h
already, preparing for the move.  I will do the move as a follow up
patch if people agree with this approach.

Incidentally, this patch alone would fix the crashes fixed by the
previous patches in the series, because with this,
scoped_restore_current_thread's constructor doesn't throw either.

gdb/ChangeLog:

* blockframe.c (block_innermost_frame): Use get_selected_frame.
* frame.c
(scoped_restore_selected_frame::scoped_restore_selected_frame):
Use save_selected_frame.  Save language as well.
(scoped_restore_selected_frame::~scoped_restore_selected_frame):
Use restore_selected_frame, and restore language as well.
(selected_frame_id, selected_frame_level): New.
(selected_frame): Update comments.
(save_selected_frame, restore_selected_frame): New.
(get_selected_frame): Use lookup_selected_frame.
(get_selected_frame_if_set): Delete.
(select_frame): Record selected_frame_level and selected_frame_id.
* frame.h (scoped_restore_selected_frame) <m_level, m_lang>: New
fields.
(get_selected_frame): Make 'message' parameter optional.
(get_selected_frame_if_set): Delete declaration.
(select_frame): Update comments.
(save_selected_frame, restore_selected_frame)
(lookup_selected_frame): Declare.
* gdbthread.h (scoped_restore_current_thread) <m_lang>: New field.
* infrun.c (struct infcall_control_state) <selected_frame_level>:
New field.
(save_infcall_control_state): Use save_selected_frame.
(restore_selected_frame): Delete.
(restore_infcall_control_state): Use restore_selected_frame.
* stack.c (select_frame_command_core, frame_command_core): Use
get_selected_frame.
* thread.c (restore_selected_frame): Rename to ...
(lookup_selected_frame): ... this and make extern.  Select the
current frame if the frame level is -1.
(scoped_restore_current_thread::restore): Also restore the
language.
(scoped_restore_current_thread::~scoped_restore_current_thread):
Don't try/catch.
(scoped_restore_current_thread::scoped_restore_current_thread):
Save the language as well.  Use save_selected_frame.

Change-Id: I73fd1cfc40d8513c28e5596383b7ecd8bcfe700f

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 30 Oct 2020 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: fix documentation of gdbarch_displaced_step_hw_singlestep
Simon Marchi [Thu, 29 Oct 2020 22:11:14 +0000 (18:11 -0400)]
gdb: fix documentation of gdbarch_displaced_step_hw_singlestep

The last commit missed updating the doc of
gdbarch_displaced_step_hw_singlestep to avoid mentioning the removed
parameter, this one fixes it.

gdb/ChangeLog:

* gdbarch.sh (displaced_step_hw_singlestep): Adjust
documentation.
* gdbarch.h: Re-generate.

Change-Id: I33675d9a6c253443eee707e8285d16615ce20aaa

4 years agogdb: remove parameter of gdbarch_displaced_step_hw_singlestep
Simon Marchi [Thu, 29 Oct 2020 22:02:13 +0000 (18:02 -0400)]
gdb: remove parameter of gdbarch_displaced_step_hw_singlestep

I noticed that the closure parameter of
gdbarch_displaced_step_hw_singlestep is never used by any
implementation of the method, so this patch removes it.

gdb/ChangeLog:

* gdbarch.sh (displaced_step_hw_singlestep): Remove closure
parameter.
* aarch64-tdep.c (aarch64_displaced_step_hw_singlestep):
Likewise.
* aarch64-tdep.h (aarch64_displaced_step_hw_singlestep):
Likewise.
* arch-utils.c (default_displaced_step_hw_singlestep):
Likewise.
* arch-utils.h (default_displaced_step_hw_singlestep):
Likewise.
* rs6000-tdep.c (ppc_displaced_step_hw_singlestep):
Likewise.
* s390-tdep.c (s390_displaced_step_hw_singlestep):
Likewise.
* gdbarch.c: Re-generate.
* gdbarch.h: Re-generate.
* infrun.c (resume_1): Adjust.

Change-Id: I7354f0b22afc2692ebff0cd700a462db8f389fc1

4 years agoRemove call to exec_close
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Remove call to exec_close

There's no need to call exec_close from ~progspace, because that
method just does some cleanup that's already going to be done during
destruction.  This patch removes the call.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* progspace.c (program_space::~program_space): Don't call
exec_close.

4 years agoDon't change current program space in exec_target::close
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Don't change current program space in exec_target::close

Now that we've removed the macros and moved various functions to be
methods on program_space (removing uses of current_program_space),
it's clear that exec_target::close can operate on program spaces
without changing the current program space.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* exec.c (exec_target::close): Don't change current program
space.

4 years agoChange add_target_sections_of_objfile to method on program_space
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Change add_target_sections_of_objfile to method on program_space

This changes add_target_sections_of_objfile to be a method on
program_space.  It is renamed to be another overload of
add_target_sections, because they are semantically equivalent in a
sense.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* symfile.c (add_symbol_file_command): Update.
* exec.c (program_space::add_target_sections): Rename.
* symfile-mem.c (symbol_file_add_from_memory): Update.
* progspace.h (struct program_space) <add_target_sections>:
Declare new overload.
* exec.h (add_target_sections_of_objfile): Don't declare.

4 years agoChange add_target_sections to method on program_space
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Change add_target_sections to method on program_space

This changes add_target_sections to be a method on program_space.
Like the earlier change to remove_target_sections, this makes sense
because this function is manipulating data that is stored on the
program space.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* solib.c (solib_map_sections): Update.
* exec.c (program_space::add_target_sections): Now a method.
(exec_file_attach): Update.
* exec.h (add_target_sections): Don't declare.
* progspace.h (struct program_space) <add_target_sections>:
Declare.

4 years agoChange remove_target_sections to method on program_space
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Change remove_target_sections to method on program_space

This changes remove_target_sections to be a method on program_space.
This makes sense because this function manipulates data that is
attached to the program space.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* progspace.h (struct program_space) <remove_target_sections>:
Declare.
* exec.c (program_space::remove_target_sections): Now a method.
* exec.h (remove_target_sections): Don't declare.

4 years agoChange program_space_empty_p to method on program_space
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Change program_space_empty_p to method on program_space

This changes program_space_empty_p to be a method on program_space.
It also changes it to return bool.  I removed the "_p" suffix because
"empty" is a "well-known" C++ method name.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* inferior.c (delete_inferior): Update.
* progspace.c (program_space::empty): Rename from
program_space_empty_p.  Return bool.
* progspace.h (struct program_space) <empty>: New method.
(program_space_empty_p): Don't declare.

4 years agoChange clear_program_space_solib_cache to method on program_space
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Change clear_program_space_solib_cache to method on program_space

This changes clear_program_space_solib_cache to be a method on
program_space.  Also, it removes a call to this function from the
program_space destructor, as that is not necessary.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* progspace.c (program_space::~program_space): Don't call
clear_program_space_solib_cache.
(program_space::clear_solib_cache): Rename from
clear_solib_cache.
* solib.c (handle_solib_event): Update.
* progspace.h (struct program_space) <clear_solib_cache>: New
method.
(clear_program_space_solib_cache): Don't declare.

4 years agoRemove symfile_objfile macro
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Remove symfile_objfile macro

This removes the symfile_objfile macro, in favor of just spelling out
the member access.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* windows-tdep.c (windows_solib_create_inferior_hook): Update.
* target.c (info_target_command): Update.
* symfile.c (syms_from_objfile_1, finish_new_objfile)
(symbol_file_clear, reread_symbols): Update.
* symfile-mem.c (add_symbol_file_from_memory_command): Update.
* stabsread.c (scan_file_globals): Update.
* solib.c (update_solib_list): Update.
* solib-svr4.c (elf_locate_base, open_symbol_file_object)
(svr4_fetch_objfile_link_map, enable_break)
(svr4_relocate_main_executable)
(svr4_iterate_over_objfiles_in_search_order): Update.
* solib-frv.c (lm_base, enable_break)
(frv_relocate_main_executable): Update.
(main_got, frv_fdpic_find_canonical_descriptor): Update.
(frv_fetch_objfile_link_map): Update.
* solib-dsbt.c (lm_base, dsbt_relocate_main_executable): Update.
* solib-darwin.c (darwin_solib_create_inferior_hook): Update.
* solib-aix.c (solib_aix_solib_create_inferior_hook): Update.
* remote.c (remote_target::get_offsets): Update.
(remote_target::start_remote)
(extended_remote_target::post_attach): Update.
* objfiles.c (entry_point_address_query): Update.
* nto-procfs.c (nto_procfs_target::create_inferior): Update.
* minsyms.c (get_symbol_leading_char): Update.
* frame.c (inside_main_func): Update.
* progspace.h (symfile_objfile): Remove macro.

4 years agoChange program_space::ebfd to a gdb_bfd_ref_ptr
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Change program_space::ebfd to a gdb_bfd_ref_ptr

This changes program_space::ebfd to a gdb_bfd_ref_ptr, removing some
manual management.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* exec.c (exec_file_attach): Update.
* progspace.c (program_space::exec_close): Update.
* progspace.h (struct program_space) <ebfd>: Now a
gdb_bfd_ref_ptr.
<set_exec_bfd>: Change argument type.
<exec_bfd>: Update.

4 years agoRemove the exec_bfd macro
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Remove the exec_bfd macro

This removes the exec_bfd macro, in favor of new accessors on
program_space.  In one spot the accessor can't be used; but this is
still a big improvement over the macro, IMO.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* windows-tdep.c (windows_solib_create_inferior_hook): Update.
* symfile.c (reread_symbols): Update.
* symfile-mem.c (add_symbol_file_from_memory_command)
(add_vsyscall_page): Update.
* source-cache.c (source_cache::get_plain_source_lines): Update.
* solib-svr4.c (find_program_interpreter, elf_locate_base)
(svr4_current_sos_direct, svr4_exec_displacement)
(svr4_relocate_main_executable): Update.
(svr4_iterate_over_objfiles_in_search_order): Update.
* solib-frv.c (enable_break2, enable_break): Update.
* solib-dsbt.c (lm_base, enable_break): Update.
* solib-darwin.c (find_program_interpreter)
(darwin_solib_create_inferior_hook): Update.
* sol-thread.c (rw_common, ps_pdmodel): Update.
* rs6000-nat.c (rs6000_nat_target::create_inferior): Update.
* remote.c (compare_sections_command)
(remote_target::trace_set_readonly_regions): Update.
* remote-sim.c (get_sim_inferior_data)
(gdbsim_target::create_inferior, gdbsim_target::create_inferior): Update.
(gdbsim_target_open, gdbsim_target::files_info): Update.
* exec.h (exec_bfd): Remove macro.
* progspace.c (initialize_progspace): Update.
* proc-service.c (ps_addr_to_core_addr, core_addr_to_ps_addr):
Update.
* nto-procfs.c (nto_procfs_target::post_attach)
(nto_procfs_target::create_inferior): Update.
* maint.c (maintenance_info_sections): Update.
* linux-thread-db.c (thread_db_target::get_thread_local_address):
Update.
* infcmd.c (post_create_inferior): Update.
* gcore.c (default_gcore_arch, default_gcore_target): Update.
(objfile_find_memory_regions): Update.
* exec.c (validate_exec_file, exec_file_attach)
(exec_read_partial_read_only, print_section_info): Update.
* corelow.c (core_target_open): Update.
* corefile.c (reopen_exec_file, validate_files): Update.
* arm-tdep.c (gdb_print_insn_arm): Update.
* arch-utils.c (gdbarch_update_p, default_print_insn): Update.
* progspace.h (struct program_space) <exec_bfd, set_exec_bfd>: New
methods.

4 years agoRemove current_target_sections macro
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Remove current_target_sections macro

This removes the current_target_sections macro, replacing it with uses
of the appropriate member from current_program_space.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* progspace.h (current_target_sections): Remove macro.
* solib-svr4.c (scan_dyntag): Update.
* solib-dsbt.c (scan_dyntag): Update.
* exec.c (exec_target::close): Update.
(add_target_sections, add_target_sections_of_objfile)
(remove_target_sections, exec_target::get_section_table)
(exec_target::files_info, set_section_command)
(exec_set_section_address, exec_target::has_memory)
(exec_target::has_memory): Update.

4 years agoRemove exec_bfd_mtime define
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Remove exec_bfd_mtime define

This removes the exec_bfd_mtime define, in favor of directly using the
appropriate member of the current program space.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* source-cache.c (source_cache::get_plain_source_lines): Use
current_program_space.
* corefile.c (reopen_exec_file): Use current_program_space.
* exec.c (exec_file_attach): Use current_program_space.
* exec.h (exec_bfd_mtime): Remove.

4 years agoRemove commented-out code from gcore.c
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Remove commented-out code from gcore.c

I found some code in gcore.c that has been commented out since

d3420b2fce5e (Mark Kettenis     2003-09-04 166) #if 1 /* See if this even matters...  */

This patch deletes this entire function, because the body was reduced
to just "return 0".

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* gcore.c (default_gcore_mach): Remove.
(create_gcore_bfd): Update.

4 years agoChange exec_close to be a method on program_space
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Change exec_close to be a method on program_space

exec_close uses the current program space, so it seemed cleaner to
change it to be a method on program_space.  This patch makes this
change.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* progspace.c (program_space::exec_close): New method, from
exec_close in exec.c.
* exec.c (exec_close): Move to progspace.c.
(exec_target::close, exec_file_attach): Update.
* progspace.h (struct program_space) <exec_close>: Declare
method.

4 years agoRemove exec_filename macro
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Remove exec_filename macro

This removes the exec_filename macro, replacing it with uses of the
member of current_program_space.  This also renames that member, and
changes it to be a unique pointer.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* progspace.h (struct program_space) <exec_filename>: Rename from
pspace_exec_filename.  Now a unique_xmalloc_ptr.
* inferior.c (print_selected_inferior): Update.
(print_inferior): Update.
* mi/mi-main.c (print_one_inferior): Update.
* exec.h (exec_filename): Remove macro.
* corefile.c (get_exec_file): Update.
* exec.c (exec_close): Update.
(exec_file_attach): Update.
* progspace.c (clone_program_space): Update.
(print_program_space): Update.

4 years agoAdd target_section constructor
Tom Tromey [Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)]
Add target_section constructor

This adds a constructor to target_section, simplifying the code that
creates instances of this.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* target-section.h (struct target_section): Add constructor.
* exec.c (build_section_table, add_target_sections_of_objfile):
Update.
* corelow.c (core_target::build_file_mappings): Update.

4 years agoFix an illegal memory access problem when processing secondary relocs for architectur...
Nick Clifton [Thu, 29 Oct 2020 20:13:00 +0000 (20:13 +0000)]
Fix an illegal memory access problem when processing secondary relocs for architectures which support both REL and RELA relocs.

PR 26809
* elf.c (_bfd_elf_slurp_secondary_reloc_section): Use the correct
sized reloc reading function.
(_bfd_elf_write_secondary_reloc_section): Use the correct sized
reloc writing function.

4 years agoaarch64: Fix DSB instruction 'missing immediate expression' errors
Przemyslaw Wirkus [Thu, 29 Oct 2020 16:30:46 +0000 (16:30 +0000)]
aarch64: Fix DSB instruction 'missing immediate expression' errors

This patch fixes errors with DSB instruction after introduction of DSB nXS
variant. That change would cause GAS to reject valid DSB immediate string
operands.

gas/ChangeLog:

2020-10-28  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* config/tc-aarch64.c (parse_operands): Check for C0-C15 value of DSB
immediate string operand.
* testsuite/gas/aarch64/system-4.d: Update test.
* testsuite/gas/aarch64/system-4.s: Update test.

4 years agodwarf: Also match abbrev base when searching abbrev list
H.J. Lu [Thu, 29 Oct 2020 16:19:25 +0000 (09:19 -0700)]
dwarf: Also match abbrev base when searching abbrev list

A .debug_abbrev section can have multiple CUs.  When caching abbrev list,
we need to check abbrev base to support multiple CUs.

PR binutils/26808
* dwarf.c (abbrev_list): Add abbrev_base.
(new_abbrev_list): Add an abbrev_base argument and record it.
(find_abbrev_list_by_abbrev_offset): Add an abbrev_base argument
and match it.
(process_debug_info): Pass abbrev_base to new_abbrev_list and
find_abbrev_list_by_abbrev_offset.
(display_debug_abbrev): Pass 0 abbrev_base to new_abbrev_list
and find_abbrev_list_by_abbrev_offset.
* testsuite/binutils-all/x86-64/pr26808.dump: New file.
* testsuite/binutils-all/x86-64/pr26808.dwp.bz2: Likewise.
* testsuite/binutils-all/x86-64/x86-64.exp: Run PR binutils/26808
test.

4 years agogdb: restore thread after detaching or killing an inferior
Tankut Baris Aktemur [Thu, 29 Oct 2020 14:33:39 +0000 (15:33 +0100)]
gdb: restore thread after detaching or killing an inferior

The "detach inferiors N" command causes the current inferior to
switch.  E.g.:

  $ gdb a.out
  Reading symbols from a.out...
  (gdb) start
  ...
  (gdb) add-inferior
  [New inferior 2]
  Added inferior 2 on connection 1 (native)
  (gdb) inferior 2
  [Switching to inferior 2 [<null>] (<noexec>)]
  (gdb) info inferiors
    Num  Description       Connection           Executable
    1    process 18242     1 (native)           /path/to/a.out
  * 2    <null>            1 (native)
  (gdb) detach inferiors 1
  Detaching from program: /path/to/a.out, process 18242
  [Inferior 1 (process 18242) detached]
  (gdb) info inferiors
    Num  Description       Connection           Executable
  * 1    <null>                                 /path/to/a.out
    2    <null>            1 (native)
  (gdb)

The same switch happens with the "kill inferiors N" command.  Prevent
it by restoring the current thread.

gdb/ChangeLog:
2020-10-29  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

PR gdb/19318
* inferior.c (detach_inferior_command): Restore the current thread.
(kill_inferior_command): Ditto.

gdb/testsuite/ChangeLog:
2020-10-29  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.base/kill-detach-inferiors-cmd.exp: Check that 'kill
inferiors' and 'detach inferiors' do not change the current
inferior.

4 years agoFix a potential illegal memory access by objcopy when extracting dwo sections.
Nick Clifton [Thu, 29 Oct 2020 11:17:39 +0000 (11:17 +0000)]
Fix a potential illegal memory access by objcopy when extracting dwo sections.

 PR 26805
 * objcopy.c (is_dwo_section): Check for missing or short section
 names.

4 years ago[gdb/testsuite] Fix DUPLICATEs in gdb.threads/tls.exp
Tom de Vries [Thu, 29 Oct 2020 06:55:46 +0000 (07:55 +0100)]
[gdb/testsuite] Fix DUPLICATEs in gdb.threads/tls.exp

With test-case gdb.threads/tls.exp, we get these:
...
DUPLICATE: gdb.threads/tls.exp: selected thread: 4
DUPLICATE: gdb.threads/tls.exp: selected thread: 2
DUPLICATE: gdb.threads/tls.exp: selected thread: 3
...

Fix these using with_test_prefix.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-29  Tom de Vries  <tdevries@suse.de>

* gdb.threads/tls.exp: Fix DUPLICATEs.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 29 Oct 2020 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years ago[gdb/testsuite] Fix gdb.python/py-symbol.exp with -readnow
Tom de Vries [Wed, 28 Oct 2020 20:04:12 +0000 (21:04 +0100)]
[gdb/testsuite] Fix gdb.python/py-symbol.exp with -readnow

When running test-case gdb.python/py-symbol.exp with target board readnow, we
get:
...
FAIL: gdb.python/py-symbol.exp: print line number of rr
FAIL: gdb.python/py-symbol.exp: print value of rr
...

These are FAILs due to PR25857.

Mark these FAILs as KFAILs.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* gdb.python/py-symbol.exp: Add KFAILs for -readnow.

4 years ago[gdb/testsuite] Fix re-read FAILs with -readnow
Tom de Vries [Wed, 28 Oct 2020 20:04:12 +0000 (21:04 +0100)]
[gdb/testsuite] Fix re-read FAILs with -readnow

When running the testsuite with target board readnow, we run into:
...
FAIL: gdb.ada/exec_changed.exp: start second
FAIL: gdb.ada/exec_changed.exp: start just first
FAIL: gdb.base/reread.exp: opts= "" "" : run to foo() second time
FAIL: gdb.base/reread.exp: opts= "" "" : second pass: run to foo() second time
FAIL: gdb.base/reread.exp: opts= "-fPIE" "ldflags=-pie" : \
  run to foo() second time
FAIL: gdb.base/reread.exp: opts= "-fPIE" "ldflags=-pie" : second pass: \
  run to foo() second time
...

These are FAILs due to PR26800.

Mark these as KFAILs.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* gdb.ada/exec_changed.exp: Add KFAILs for -readnow.
* gdb.base/reread.exp: Same.

4 years ago[gdb/testsuite] Fix gdb.rust/traits.exp with -readnow
Tom de Vries [Wed, 28 Oct 2020 20:04:12 +0000 (21:04 +0100)]
[gdb/testsuite] Fix gdb.rust/traits.exp with -readnow

With test-case gdb.rust/traits.exp and target board readnow we get:
...
FAIL: gdb.rust/traits.exp: print *td
FAIL: gdb.rust/traits.exp: print *tu
...

Mark these FAILs as KFAILs.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (readnow): Handle arg.
* gdb.rust/traits.exp: Add KFAILs for -readnow.

4 years ago[gdb/testsuite] Fix gdb.base/relocate.exp with -readnow
Tom de Vries [Wed, 28 Oct 2020 20:04:12 +0000 (21:04 +0100)]
[gdb/testsuite] Fix gdb.base/relocate.exp with -readnow

With test-case gdb.base/relocate.exp and target board readnow, we get:
...
FAIL: gdb.base/relocate.exp: symbol-file with offset
FAIL: gdb.base/relocate.exp: add-symbol-file with offset
FAIL: gdb.base/relocate.exp: add-symbol-file with offset, text address given
FAIL: gdb.base/relocate.exp: add-symbol-file with offset, data address given
...

Fix these FAILs by updating the regexps for -readnow.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* gdb.base/relocate.exp: Update regexp for -readnow.

4 years ago[gdb/testsuite] Fix gdb.dwarf2/dw2-error.exp with -readnow
Tom de Vries [Wed, 28 Oct 2020 20:04:12 +0000 (21:04 +0100)]
[gdb/testsuite] Fix gdb.dwarf2/dw2-error.exp with -readnow

With test-case gdb.dwarf2/dw2-error.exp and target board readnow, we get:
...
FAIL: gdb.dwarf2/dw2-error.exp: break -q main
...

In the normal case, after running into the dwarf error, the minimal symbols
are still available, but with -readnow this is not the case.

Mark the FAIL as KFAIL.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/dw2-error.exp: Mark failure break in main as known with
-readnow.

4 years ago[gdb/symtab] Fix language of frame without debug info
Tom de Vries [Wed, 28 Oct 2020 20:04:12 +0000 (21:04 +0100)]
[gdb/symtab] Fix language of frame without debug info

On openSUSE Leap 15.2, I run into this FAIL with target board readnow and
test-case gdb.dwarf2/dw2-align.exp:
...
(gdb) set lang c++^M
Warning: the current language does not match this frame.^M
(gdb) FAIL: gdb.dwarf2/dw2-align.exp: set lang c++
...

Adding some extra debugging shows that the current language differs without
and with readnow:
...
 Breakpoint 1, 0x00000000004004ab in main ()^M
 (gdb) show lang^M
-The current source language is "auto; currently c".^M
+The current source language is "auto; currently asm".^M
...

This is explained by find_pc_compunit_symtab (0x4004ab) called from
select_frame, which:
- without readnow: returns NULL, and
- with readnow: returns the symtab for the CU crtn.S, wich has language
  "MIPS assembler".

In the former case, the symtab for crtn.S is not expanded, and
find_pc_compunit_symtab hits the default NULL return.  In the latter case, the
symtab for crtn.S is expanded, and the "best match" loop in
find_pc_compunit_symtab returns that symtab as its best match.

The GLOBAL_BLOCK for crtn.S has these outer limits of the address range:
...
(gdb) p /x b.startaddr
$6 = 0x4003c2
(gdb) p /x b.endaddr
$7 = 0x40053d
...
and 0x4004ab indeed fits in that range, which explains why the CU is
considered a match.

However, the actual address ranges for the CU are:
...
    00000040 ffffffffffffffff 0000000000000000 (base address)
    00000040 00000000004003c2 00000000004003c7
    00000040 0000000000400538 000000000040053d
    00000040 <End of list>
...
which confirms that the CU should not be considered a match.

The problem is that the "best match" loop is based on the assumption that a
symtab with a better match will be found, but in this case we don't find a
better match because there's no debug info describing main.

Fix this by preferring to use the addres map in the "best match" loop, which
will accurately tell us that addrmap_find (bv.map, 0x4004ab) == NULL.

Tested on x86_64-linux (that is, openSUSE Leap 15.2), with and without
readnow.  In the case of a readnow run, brings down the number of unexpected
failures from 66 to 38.

The FAIL does not reproduce on f.i. Ubuntu 18.04.5, because there the exec
does not contain debug info for crtn.S.  The dwarf assembly test-case mimics
the scenario described above, and reproduces the FAIL with and without
-readnow, for both mentioned OS configurations.

Also fixes PR25980 - "Overlapping Dwarf Compile Units with non-overlapping
subranges gives incorrect line information".

gdb/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

PR symtab/26772
* symtab.c (find_pc_sect_compunit_symtab): In case there's an address
map, check it in the "best match" loop.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

PR symtab/26772
* gdb.dwarf2/dw2-ranges-overlap.c: New test.
* gdb.dwarf2/dw2-ranges-overlap.exp: New file.

4 years agoUse sha256 for hashes in the release process
Andreas Rammhold [Mon, 26 Oct 2020 03:03:29 +0000 (04:03 +0100)]
Use sha256 for hashes in the release process

I just came across the GDB 10.1 release notes and saw that md5 is still
being used in those. I thought it would be a good idea to instead have a
more modern, secure and wildly available hash function such as SHA256 as
part of the release process.

The changes have been done rather mechnically via sed but executing the
`src-release.sh -b gdb` did work so I am confident about the result.

While this does not directly address the release mails, I was wasn't
able to find the template/script used for those, this is probably still
an improvement.

ChangeLog:
* src-release.sh: Use sha256sum instead of md5sum.

binutils/ChangeLog:
* README-how-to-make-a-release: Use sha256sum instead of md5sum.

Change-Id: I9cf19ea40699137c45463b8514f6e29271af2347

4 years agoaarch64: Add CSR PDEC instruction
Przemyslaw Wirkus [Wed, 28 Oct 2020 14:16:39 +0000 (14:16 +0000)]
aarch64: Add CSR PDEC instruction

This patch adds:
+ New feature +csre to -march command line.
+ New instruction CSR PDEC associated with CSRE feature.

Please note that CSRE system registers were already upstreamed. This patch
should finalize CSRE feature implementation.

CSRE feature adds CSR PDEC (Decrements Call stack pointer by the size of
a Call stack record) instruction. Although this instruction has operand
(PDEC) it's instruction's only operand. PDEC forces instruction field Rt
to be set to 0b1111. This results in fixed opcode of the instruction.

gas/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* NEWS: Update docs.
* config/tc-aarch64.c (parse_csr_operand): New operand parser.
(parse_operands): Call to CSR operand parser.
* testsuite/gas/aarch64/csre_csr-invalid.d: New test.
* testsuite/gas/aarch64/csre_csr-invalid.l: New test.
* testsuite/gas/aarch64/csre_csr-invalid.s: New test.
* testsuite/gas/aarch64/csre_csr.d: New test.
* testsuite/gas/aarch64/csre_csr.s: New test.

include/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* opcode/aarch64.h (AARCH64_FEATURE_CSRE): New -march feature.
(enum aarch64_opnd): New CSR instruction field AARCH64_OPND_CSRE_CSR.

opcodes/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* aarch64-opc.c (aarch64_print_operand): CSR PDEC operand print-out.
* aarch64-tbl.h (CSRE): New CSRE feature handler.
(_CSRE_INSN): New CSRE instruction type.
(struct aarch64_opcode): New 'csre' entry for a CSRE CLI feature.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.

4 years agoaarch64: Add WFET instruction for Armv8.7-a
Przemyslaw Wirkus [Wed, 28 Oct 2020 14:09:25 +0000 (14:09 +0000)]
aarch64: Add WFET instruction for Armv8.7-a

This patch adds new to Armv8.7 WFET instruction which take one operand:

    WFET <Xt>

Where:
    <Xt> is 64-bit name of the general-purpose source register, encoded in the
         "Rd" field.

For more details regarding WFET (Wait For Event with Timeout) instruction for
Armv8.7-a please refer to Arm A64 Instruction set documentation for Armv8-A
architecture profile, see document pages 565 of [0].

[0]: https://developer.arm.com/docs/ddi0596/i

gas/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* NEWS: Update docs.
* testsuite/gas/aarch64/system-5.d: New test.
* testsuite/gas/aarch64/system-5.s: New test.

opcodes/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* aarch64-tbl.h (struct aarch64_opcode): Add new WFET instruction encoding
and operand description.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.

4 years agoaarch64: Add DSB instruction Armv8.7-a variant
Przemyslaw Wirkus [Wed, 28 Oct 2020 14:01:36 +0000 (14:01 +0000)]
aarch64: Add DSB instruction Armv8.7-a variant

This patch adds new variant (nXS) of DSB memory barrier instruction
available in Armv8.7-a. New nXS variant has different encoding in
comparison with pre Armv8.7-a DSB memory barrier variant thus new
instruction and new operand was added.

DSB memory nXS barrier variant specifies the limitation on the barrier
operation. Allowed values are:

DSB SYnXS|#28
DSB ISHnXS|#24
DSB NSHnXS|#20
DSB OSHnXS|#16

Please note that till now,  for barriers, barrier operation was encoded in
4-bit unsigned immediate CRm field (in the range 0 to 15).
For DSB memory nXS barrier variant, barrier operation is a 5-bit unsigned
assembly instruction immediate, encoded in instruction in two bits CRm<3:2>:

CRm<3:2>  #imm
  00       16
  01       20
  10       24
  11       28

This patch extends current AArch64 barrier instructions with above mapping.

Notable patch changes include:
+ New DSB memory barrier variant encoding for Armv8.7-a.
+ New operand BARRIER_DSB_NXS for above instruction in order to
distinguish between existing and new DSB instruction flavour.
+ New set of DSB nXS barrier options.
+ New instruction inserter and extractor map between instruction
immediate 5-bit value and 2-bit CRm field of the instruction itself (see
FLD_CRm_dsb_nxs).
+ Regeneration of aarch64-[asm|dis|opc]-2.c files.
+ Test cases to cover new instruction assembling and disassembling.

For more details regarding DSB memory barrier instruction and its
Armv8.7-a flavour please refer to Arm A64 Instruction set documentation
for Armv8-A architecture profile, see document pages 132-133 of [0].

[0]: https://developer.arm.com/docs/ddi0596/i

gas/ChangeLog:

2020-10-23  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* NEWS: Docs update.
* config/tc-aarch64.c (parse_operands): Add
AARCH64_OPND_BARRIER_DSB_NXS handler.
(md_begin): Add content of aarch64_barrier_dsb_nxs_options to
aarch64_barrier_opt_hsh hash.
* testsuite/gas/aarch64/system-4-invalid.d: New test.
* testsuite/gas/aarch64/system-4-invalid.l: New test.
* testsuite/gas/aarch64/system-4-invalid.s: New test.
* testsuite/gas/aarch64/system-4.d: New test.
* testsuite/gas/aarch64/system-4.s: New test.

include/ChangeLog:

2020-10-23  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* opcode/aarch64.h (enum aarch64_opnd): New operand
AARCH64_OPND_BARRIER_DSB_NXS.
(aarch64_barrier_dsb_nxs_options): Declare DSB nXS options.

opcodes/ChangeLog:

2020-10-23  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* aarch64-asm.c (aarch64_ins_barrier_dsb_nxs): New inserter.
* aarch64-asm.h (AARCH64_DECL_OPD_INSERTER): New inserter
ins_barrier_dsb_nx.
* aarch64-dis.c (aarch64_ext_barrier_dsb_nxs): New extractor.
* aarch64-dis.h (AARCH64_DECL_OPD_EXTRACTOR): New extractor
ext_barrier_dsb_nx.
* aarch64-opc.c (aarch64_print_operand): New options table
aarch64_barrier_dsb_nxs_options.
* aarch64-opc.h (enum aarch64_field_kind): New field name FLD_CRm_dsb_nxs.
* aarch64-tbl.h (struct aarch64_opcode): Define DSB nXS barrier
Armv8.7-a instruction.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.

4 years agoaarch64: Add basic support for armv8.7-a architecture
Przemyslaw Wirkus [Wed, 28 Oct 2020 13:58:17 +0000 (13:58 +0000)]
aarch64: Add basic support for armv8.7-a architecture

This patch adds support for AArch64 -march=armv8.7-a command line option
in GAS.

Please note that this change ONLY extends -march= command line interface
with a new "armv8.7-a" option. Architectural changes like new instructions
will be added in following patches.

gas/ChangeLog:

2020-10-16  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* NEWS: Docs update.
* config/tc-aarch64.c (armv8.7-a): New arch.
* doc/c-aarch64.texi (-march=armv8.7-a): Update docs.

include/ChangeLog:

2020-10-16  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* opcode/aarch64.h (AARCH64_FEATURE_V8_7): New feature bitmask.
(AARCH64_ARCH_V8_7): New arch feature set.

opcodes/ChangeLog:

2020-10-16  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* aarch64-tbl.h (ARMV8_7): New macro.

4 years agoFix a potential illegal memory access when creating an srec format file.
Nick Clifton [Wed, 28 Oct 2020 11:07:02 +0000 (11:07 +0000)]
Fix a potential illegal memory access when creating an srec format file.

PR 26774
* srec.c (srec_write_symbols): Do not emit symbols in sections
that have been removed from the output.

4 years agoFix compile time warning building with gcc 11.
Nick Clifton [Wed, 28 Oct 2020 10:56:00 +0000 (10:56 +0000)]
Fix compile time warning building with gcc 11.

PR 26795
* elfedit.c (process_archive): Remove spurious call to free().

4 years ago[gdb/testsuite] Fix gdb.cp/nsalias.exp with -readnow
Tom de Vries [Wed, 28 Oct 2020 09:01:32 +0000 (10:01 +0100)]
[gdb/testsuite] Fix gdb.cp/nsalias.exp with -readnow

When running test-case gdb.cp/nsalias.exp with target board readnow, we get:
...
FAIL: gdb.cp/nsalias.exp: complaint for too many recursively imported \
  declarations
...

The complaint is not detected, because:
- the complaint is triggered during the file command instead of during
  "print N100::x"
- the "set complaints 1" is not effective because it's issued
  after the file command

Fix the FAIL by setting the complaints limit earlier, and detecting the
complaint also during the file command.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_file_cmd): Set gdb_file_cmd_msg.
* gdb.cp/nsalias.exp: Set complaints limit before file cmd.  Expect
complaint during file command for -readnow.

4 years ago[gdb/testsuite] Fix typo in gdb.cp/nsalias.exp
Tom de Vries [Wed, 28 Oct 2020 09:01:32 +0000 (10:01 +0100)]
[gdb/testsuite] Fix typo in gdb.cp/nsalias.exp

Fix typo "compaint" -> "complaint".

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* gdb.cp/nsalias.exp: Fix typo in test name.

4 years ago[gdb/testsuite] Fix gdb.dwarf2/dw2-filename.exp with -readnow
Tom de Vries [Wed, 28 Oct 2020 09:01:32 +0000 (10:01 +0100)]
[gdb/testsuite] Fix gdb.dwarf2/dw2-filename.exp with -readnow

When running test-case gdb.dwarf2/dw2-filename.exp with target board -readnow,
we run into:
...
FAIL: gdb.dwarf2/dw2-filename.exp: info sources
...

The normal output is:
...
(gdb) info sources^M
Source files for which symbols have been read in:^M
^M
Source files for which symbols will be read in on demand:^M
^M
src/gdb/testsuite/gdb.dwarf2/file1.txt^M
(gdb)
...
but with -readnow file1.txt appears in the "Source files for which symbols
have been read in" catagory instead, as expected.

Fix the FAIL by making the regexp match the -readnow output.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/dw2-filename.exp: Update regexp for -readnow.

4 years ago[gdb/testsuite] Fix gdb.dwarf2/dw2-stack-boundary.exp with -readnow
Tom de Vries [Wed, 28 Oct 2020 09:01:32 +0000 (10:01 +0100)]
[gdb/testsuite] Fix gdb.dwarf2/dw2-stack-boundary.exp with -readnow

When running test-case gdb.dwarf2/dw2-stack-boundary.exp with target board
readnow, we run into:
...
FAIL: gdb.dwarf2/dw2-stack-boundary.exp: check partial symtab errors
...

The cause for the FAIL is that these complaints are not there:
...
During symbol reading: location description stack underflow^M
During symbol reading: location description stack overflow^M
...

Fix this by KFAILing the complaints for -readnow.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/dw2-stack-boundary.exp: KFAILing the complaints for
-readnow.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 28 Oct 2020 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years ago[gdb/testsuite] Fix gdb.base/multi-forks.exp timeout with -readnow
Tom de Vries [Tue, 27 Oct 2020 22:17:09 +0000 (23:17 +0100)]
[gdb/testsuite] Fix gdb.base/multi-forks.exp timeout with -readnow

When running test-case gdb.base/multi-forks.exp with target board readnow, we
run into:
...
FAIL: gdb.base/multi-forks.exp: run to exit 1 (timeout)
...

Fix this by using exp_continue.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

* gdb.base/multi-forks.exp: Use exp_continue to fix timeout.

4 years ago[gdb/testsuite] Fix DUPLICATEs in gdb.base/multi-forks.exp
Tom de Vries [Tue, 27 Oct 2020 22:17:09 +0000 (23:17 +0100)]
[gdb/testsuite] Fix DUPLICATEs in gdb.base/multi-forks.exp

When running test-case gdb.base/multi-forks.exp I get:
...
DUPLICATE: gdb.base/multi-forks.exp: run to exit 2
DUPLICATE: gdb.base/multi-forks.exp: run to exit 2
...

Fix these by using test_with_prefix.

Tested on x86_64-linux.

4 years ago[gdb/testsuite] Fix gdb.base/maint.exp FAILs with -readnow
Tom de Vries [Tue, 27 Oct 2020 22:17:09 +0000 (23:17 +0100)]
[gdb/testsuite] Fix gdb.base/maint.exp FAILs with -readnow

When running test-case gdb.base/maint.exp with target board readnow, we run
into:
...
FAIL: gdb.base/maint.exp: mt expand-symtabs
FAIL: gdb.base/maint.exp: maint print objfiles: psymtabs
FAIL: gdb.base/maint.exp: maint print psymbols -source
FAIL: gdb.base/maint.exp: maint print psymbols -pc
FAIL: gdb.base/maint.exp: maint info line-table with filename of symtab that \
  is not currently expanded
...

When using -readnow:
- there are no partial symtabs
- all symtabs are expanded at symbol load time
and these differences from normal behaviour cause the FAILs.

Update the tests for -readnow.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

* gdb.base/maint.exp: Update for -readnow.

4 years ago[gdb/testsuite] Fix gdb.cp/psymtab-parameter.exp with -readnow
Tom de Vries [Tue, 27 Oct 2020 22:17:09 +0000 (23:17 +0100)]
[gdb/testsuite] Fix gdb.cp/psymtab-parameter.exp with -readnow

When running test-case gdb.cp/psymtab-parameter.exp with target board readnow,
we run into:
...
FAIL: gdb.cp/psymtab-parameter.exp: maintenance info symtabs
...

The FAIL is expected, as mentioned in the comment:
...
 # The goal is to keep the CU (Compilation Unit) unexpanded.  It would be
 # rather XFAIL than FAIL here.  For example -readnow breaks it.
 gdb_test_no_output "maintenance info symtabs"
...

Fix the FAIL by skipping the command for -readnow.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

* gdb.cp/psymtab-parameter.exp: Don't expect unexpanded CU for
-readnow.

4 years agoFix gdb.python/py-format-string.exp with Clang
Gary Benson [Tue, 27 Oct 2020 17:02:39 +0000 (17:02 +0000)]
Fix gdb.python/py-format-string.exp with Clang

GDB includes the virtual table pointer when formatting polymorphic
C++ objects for printing, but GCC and Clang name these differently:
GCC emits a DW_AT_name of "_vptr.Base" when describing the virtual
table pointer of a type derived from type "Base", whereas Clang
will emit "_vptr$Base" in this situation.  This commit fixes a
testcase which failed because of this.

gdb/testsuite/ChangeLog:

* gdb.python/py-format-string.exp (test_deref_refs): Treat
"_vptr$Base" as correct, in addition to "_vptr.Base".
(test_mixed): Likewise.

4 years agoAdd skip_fortran_tests to two Fortran testcases
Gary Benson [Tue, 27 Oct 2020 16:54:38 +0000 (16:54 +0000)]
Add skip_fortran_tests to two Fortran testcases

This commit adds missing skip_fortran_tests checks to two Fortran
testcases that did not have it.  It also fixes a copy-paste error
in a comment.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-fortran-modules.exp: Check skip_fortran_tests.
* gdb.mi/mi-vla-fortran.exp: Likewise.  Also fix a comment.

4 years agoFix seg-fault when running the ld testsuite for the hppa64-linux target.
Nick Clifton [Tue, 27 Oct 2020 16:23:09 +0000 (16:23 +0000)]
Fix seg-fault when running the ld testsuite for the hppa64-linux target.

* elf64-hppa.c (elf_hppa_final_link_relocate): Check that the
symbol's section is being output before adding its offset to the
addend when processing R_PARISC_SECREL32.

4 years agoFix the decoding of DW_FORM_ref_addr DWARF attribute.
Nick Clifton [Tue, 27 Oct 2020 16:17:13 +0000 (16:17 +0000)]
Fix the decoding of DW_FORM_ref_addr DWARF attribute.

* dwarf.c (struct abbrev_list): New structure.  Used to collect
lists of abbreviation sets.
(struct abbrev_map): New structure.  Used to map CU offsets to
abbreviation offsets.
(record_abbrev_list): New function.  A new entry to an
abbreviation list.
(free_all_abbrevs): Update to free abbreviation lists.
(new_abbrev_list): New function.  Start a new abbreviation
list.
(find_abbrev_list_by_abbrev_offset): New function.
(find_abbrev_map_by_offset): New function.
(add_abbrev): Add abbrev_list parameter.
(add_abbrev_attr): Likewise.
(process_abbrev_section): Rename to process_abbrev_set and add
list parameter.
(get_type_abbrev_from_form): New function.  Attempts to decode the
forms used by DW_AT_type attributes.
(get_type_signedness): Display type names if operating in wide
mode.  Use get_type_abbrev_from_form.
(read_and_display_attr_value): Use get_type_abbrev_from_form.
(process_debug_info): Pre-parse the CU headers to collate all the
abbrevs before starting the main scan.
(process_debug_abbrev): Do not free any loaded abbrevs.
(free_debug_memory): Free the abbrev maps.

4 years agogdb: remove unused includes in m32c-tdep.c
Simon Marchi [Tue, 27 Oct 2020 14:37:58 +0000 (10:37 -0400)]
gdb: remove unused includes in m32c-tdep.c

include-what-you-use says:

    ../../../src/binutils-gdb/gdb/m32c-tdep.c should remove these lines:
    - #include "dis-asm.h"  // lines 24-24
    - #include "dwarf2/expr.h"  // lines 31-31
    - #include "dwarf2/frame.h"  // lines 30-30
    - #include "elf-bfd.h"  // lines 21-21
    - #include "elf/m32c.h"  // lines 22-22
    - #include "target.h"  // lines 37-37
    - struct m32c_reg;  // lines 45-45

That looks right, remove them.  Tested by rebuilding.

gdb/ChangeLog:

* m32c-tdep.c: Remove unused includes.

Change-Id: I28b41795f3bcc5406488dbf272c9e86fd5781b6b

4 years agogdb: remove unused includes in xtensa-tdep.c
Simon Marchi [Tue, 27 Oct 2020 14:28:27 +0000 (10:28 -0400)]
gdb: remove unused includes in xtensa-tdep.c

include-what-you-use says that these includes are not necessary in
xtensa-tdep.c:

    ../../../src/binutils-gdb/gdb/xtensa-tdep.c should remove these lines:
    - #include "dis-asm.h"  // lines 29-29
    - #include "dummy-frame.h"  // lines 36-36
    - #include "dwarf2.h"  // lines 37-37
    - #include "dwarf2/loc.h"  // lines 39-39
    - #include "inferior.h"  // lines 30-30
    - #include "objfiles.h"  // lines 25-25
    - #include "remote.h"  // lines 45-45
    - #include "serial.h"  // lines 46-46
    - #include "symfile.h"  // lines 24-24

That looks about right, so remove them.  Tested by re-building.

gdb/ChangeLog:

* xtensa-tdep.c: Remove includes.

Change-Id: I9774ec59a68dd94e06967713d2f271b1760f6e6a

4 years agogdb/breakpoint: use gdb::option for the '-force' flag
Tankut Baris Aktemur [Tue, 27 Oct 2020 09:56:03 +0000 (10:56 +0100)]
gdb/breakpoint: use gdb::option for the '-force' flag

Use the gdb::option framework for the '-force' flag of the 'condition'
command.  This gives tab-completion ability for the flag.

gdb/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* breakpoint.c (struct condition_command_opts): New struct.
(condition_command_option_defs): New static global.
(make_condition_command_options_def_group): New function.
(condition_completer): Update to consider the '-force' flag.
(condition_command): Use gdb::option for the '-force' flag.

gdb/testsuite/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.base/condbreak.exp: Update the completion tests to
consider the '-force' flag.

4 years ago[gdb/testsuite] Fix section matching in find_pc_sect_compunit_symtab
Tom de Vries [Tue, 27 Oct 2020 12:28:27 +0000 (13:28 +0100)]
[gdb/testsuite] Fix section matching in find_pc_sect_compunit_symtab

When running test-case gdb.base/list-ambiguous.exp with target board readnow,
we run into:
...
FAIL: gdb.base/list-ambiguous.exp: list ambiguous_fun
...

The test-case contains two static functions ambiguous_fun, one in
list-ambiguous0.c and one in list-ambiguous1.c.

The list command is supposed to show both, but only the one from
list-ambiguous0.c is shown.

This is due to the section check in find_pc_sect_compunit_symtab.  It checks
whether the candidate compunit_symtab contains a symbol that has the required
section.  This check is only done for GLOBAL_BLOCK symbols.

The check succeeds for the compunit_symtab for list-ambiguous0.c, because it
contains main, but it fails for list-ambiguous0.c because it has no global
symbols.

Fix this by extending the section check to STATIC_BLOCK symbols.

Tested on x86_64-linux.

gdb/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

* symtab.c (find_pc_sect_compunit_symtab): Include STATIC_BLOCK
symbols in section check.

gdb/testsuite/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

* gdb.base/list-ambiguous-readnow.exp: New file.

4 years ago[gdb/symtab] Use early continue in find_pc_sect_compunit_symtab
Tom de Vries [Tue, 27 Oct 2020 12:28:27 +0000 (13:28 +0100)]
[gdb/symtab] Use early continue in find_pc_sect_compunit_symtab

Function find_pc_sect_compunit_symtab contains a loop:
...
  for (compunit_symtab *cust : obj_file->compunits ())
    {
      ...
      if (...)
        {
          /* Lots of code.  */
        }
    }
...

Reduce indentation level and improve readability by using early continue.

Tested on x86_64-linux.

gdb/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

* symtab.c (find_pc_sect_compunit_symtab): Use early continue.

4 years agogdb/breakpoint: add flags to 'condition' and 'break' commands to force condition
Tankut Baris Aktemur [Tue, 27 Oct 2020 09:56:03 +0000 (10:56 +0100)]
gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition

The previous patch made it possible to define a condition if it's
valid at some locations.  If the condition is invalid at all of the
locations, it's rejected.  However, there may be cases where the user
knows the condition *will* be valid at a location in the future,
e.g. due to a shared library load.

To make it possible that such condition can be defined, this patch
adds an optional '-force' flag to the 'condition' command, and,
respectively, a '-force-condition' flag to the 'break'command.  When
the force flag is passed, the condition is not rejected even when it
is invalid for all the current locations (note that all the locations
would be internally disabled in this case).

For instance:

  (gdb) break test.c:5
  Breakpoint 1 at 0x1155: file test.c, line 5.
  (gdb) cond 1 foo == 42
  No symbol "foo" in current context.

Defining the condition was not possible because 'foo' is not
available.  The user can override this behavior with the '-force'
flag:

  (gdb) cond -force 1 foo == 42
  warning: failed to validate condition at location 1.1, disabling:
    No symbol "foo" in current context.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if foo == 42
  1.1                         N   0x0000000000001155 in main at test.c:5

Now the condition is accepted, but the location is automatically
disabled.  If a future location has a context in which 'foo' is
available, that location would be enabled.

For the 'break' command, -force-condition has the same result:

  (gdb) break test.c:5 -force-condition if foo == 42
  warning: failed to validate condition at location 0x1169, disabling:
    No symbol "foo" in current context.
  Breakpoint 1 at 0x1169: file test.c, line 5.

gdb/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* breakpoint.h (set_breakpoint_condition): Add a new bool parameter.
* breakpoint.c: Update the help text of the 'condition' and 'break'
commands.
(set_breakpoint_condition): Take a new bool parameter
to control whether condition definition should be forced even when
the condition expression is invalid in all of the current locations.
(condition_command): Update the call to 'set_breakpoint_condition'.
(find_condition_and_thread): Take the "-force-condition" flag into
account.
        * linespec.c (linespec_keywords): Add "-force-condition" as an
element.
        (FORCE_KEYWORD_INDEX): New #define.
        (linespec_lexer_lex_keyword): Update to consider "-force-condition"
as a keyword.
* ada-lang.c (create_ada_exception_catchpoint): Ditto.
* guile/scm-breakpoint.c (gdbscm_set_breakpoint_condition_x): Ditto.
* python/py-breakpoint.c (bppy_set_condition): Ditto.
* NEWS: Mention the changes to the 'break' and 'condition' commands.

gdb/testsuite/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.base/condbreak-multi-context.exp: Expand to test forcing
the condition.
* gdb.linespec/cpcompletion.exp: Update to consider the
'-force-condition' keyword.
* gdb.linespec/explicit.exp: Ditto.
* lib/completion-support.exp: Ditto.

gdb/doc/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.texinfo (Set Breaks): Document the '-force-condition' flag
of the 'break'command.
* gdb.texinfo (Conditions): Document the '-force' flag of the
'condition' command.

4 years agogdb/breakpoint: disable a bp location if condition is invalid at that location
Tankut Baris Aktemur [Tue, 27 Oct 2020 09:56:03 +0000 (10:56 +0100)]
gdb/breakpoint: disable a bp location if condition is invalid at that location

Currently, for a conditional breakpoint, GDB checks if the condition
can be evaluated in the context of the first symtab and line (SAL).
In case of an error, defining the conditional breakpoint is aborted.
This prevents having a conditional breakpoint whose condition may
actually be meaningful for some of the location contexts.  This patch
makes it possible to define conditional BPs by checking all location
contexts.  If the condition is meaningful for even one context, the
breakpoint is defined.  The locations for which the condition gives
errors are disabled.

The bp_location struct is introduced a new field, 'disabled_by_cond'.
This field denotes whether the location is disabled automatically
because the condition was non-evaluatable.  Disabled-by-cond locations
cannot be enabled by the user.  But locations that are not
disabled-by-cond can be enabled/disabled by the user manually as
before.

For a concrete example, consider 3 contexts of a function 'func'.

  class Base
  {
  public:
    int b = 20;

    void func () {}
  };

  class A : public Base
  {
  public:
    int a = 10;

    void func () {}
  };

  class C : public Base
  {
  public:
    int c = 30;

    void func () {}
  };

Note that

* the variable 'a' is defined only in the context of A::func.
* the variable 'c' is defined only in the context of C::func.
* the variable 'b' is defined in all the three contexts.

With the existing GDB, it's not possible to define a conditional
breakpoint at 'func' if the condition refers to 'a' or 'c':

  (gdb) break func if a == 10
  No symbol "a" in current context.
  (gdb) break func if c == 30
  No symbol "c" in current context.
  (gdb) info breakpoints
  No breakpoints or watchpoints.

With this patch, it becomes possible:

  (gdb) break func if a == 10
  warning: failed to validate condition at location 1, disabling:
    No symbol "a" in current context.
  warning: failed to validate condition at location 3, disabling:
    No symbol "a" in current context.
  Breakpoint 1 at 0x11b6: func. (3 locations)
  (gdb) break func if c == 30
  Note: breakpoint 1 also set at pc 0x11ce.
  Note: breakpoint 1 also set at pc 0x11c2.
  Note: breakpoint 1 also set at pc 0x11b6.
  warning: failed to validate condition at location 1, disabling:
    No symbol "c" in current context.
  warning: failed to validate condition at location 2, disabling:
    No symbol "c" in current context.
  Breakpoint 2 at 0x11b6: func. (3 locations)
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if a == 10
  1.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         y   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         N*  0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  2       breakpoint     keep y   <MULTIPLE>
          stop only if c == 30
  2.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  2.2                         N*  0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  2.3                         y   0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  (*): Breakpoint condition is invalid at this location.

Here, uppercase 'N' denotes that the location is disabled because of
the invalid condition, as mentioned with a footnote in the legend of
the table.  Locations that are disabled by the user are still denoted
with lowercase 'n'.  Executing the code hits the breakpoints 1.2 and
2.3 as expected.

Defining a condition on an unconditional breakpoint gives the same
behavior above:

  (gdb) break func
  Breakpoint 1 at 0x11b6: func. (3 locations)
  (gdb) cond 1 a == 10
  warning: failed to validate condition at location 1.1, disabling:
    No symbol "a" in current context.
  warning: failed to validate condition at location 1.3, disabling:
    No symbol "a" in current context.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if a == 10
  1.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         y   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         N*  0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  (*): Breakpoint condition is invalid at this location.

Locations that are disabled because of a condition cannot be enabled
by the user:

  ...
  (gdb) enable 1.1
  Breakpoint 1's condition is invalid at location 1, cannot enable.

Resetting the condition enables the locations back:

  ...
  (gdb) cond 1
  Breakpoint 1's condition is now valid at location 1, enabling.
  Breakpoint 1's condition is now valid at location 3, enabling.
  Breakpoint 1 now unconditional.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
  1.1                         y   0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         y   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         y   0x00000000000011ce in C::func() at condbreak-multi-context.cc:39

If a location is disabled by the user, a condition can still be defined
but the location will remain disabled even if the condition is meaningful
for the disabled location:

  ...
  (gdb) disable 1.2
  (gdb) cond 1 a == 10
  warning: failed to validate condition at location 1.1, disabling:
    No symbol "a" in current context.
  warning: failed to validate condition at location 1.3, disabling:
    No symbol "a" in current context.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if a == 10
  1.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         n   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         N*  0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  (*): Breakpoint condition is invalid at this location.

The condition of a breakpoint can be changed.  Locations'
enable/disable states are updated accordingly.

  ...
  (gdb) cond 1 c == 30
  warning: failed to validate condition at location 1.1, disabling:
    No symbol "c" in current context.
  Breakpoint 1's condition is now valid at location 3, enabling.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if c == 30
  1.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         N*  0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         y   0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  (*): Breakpoint condition is invalid at this location.

  (gdb) cond 1 b == 20
  Breakpoint 1's condition is now valid at location 1, enabling.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if b == 20
  1.1                         y   0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         n   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         y   0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  # Note that location 1.2 was disabled by the user previously.

If the condition expression is bad for all the locations, it will be
rejected.

  (gdb) cond 1 garbage
  No symbol "garbage" in current context.

For conditions that are invalid or valid for all the locations of a
breakpoint, the existing behavior is preserved.

Regression-tested on X86_64 Linux.

gdb/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* breakpoint.h (class bp_location) <disabled_by_cond>: New field.
* breakpoint.c (set_breakpoint_location_condition): New function.
(set_breakpoint_condition): Disable a breakpoint location if parsing
the condition string gives an error.
(should_be_inserted): Update to consider the 'disabled_by_cond' field.
(build_target_condition_list): Ditto.
(build_target_command_list): Ditto.
(build_bpstat_chain): Ditto.
(print_one_breakpoint_location): Ditto.
(print_one_breakpoint): Ditto.
(breakpoint_1): Ditto.
(bp_location::bp_location): Ditto.
(locations_are_equal): Ditto.
(update_breakpoint_locations): Ditto.
(enable_disable_bp_num_loc): Ditto.
(init_breakpoint_sal): Use set_breakpoint_location_condition.
(find_condition_and_thread_for_sals): New static function.
(create_breakpoint): Call find_condition_and_thread_for_sals.
(location_to_sals): Call find_condition_and_thread_for_sals instead
of find_condition_and_thread.

gdb/testsuite/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.base/condbreak-multi-context.cc: New file.
* gdb.base/condbreak-multi-context.exp: New file.

gdb/doc/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.texinfo (Set Breaks): Document disabling of breakpoint
locations for which the breakpoint condition is invalid.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 27 Oct 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agold: Pass -fno-lto in ld-elfweak/elfweak.exp
H.J. Lu [Mon, 26 Oct 2020 23:45:25 +0000 (16:45 -0700)]
ld: Pass -fno-lto in ld-elfweak/elfweak.exp

* testsuite/ld-elfweak/elfweak.exp: Pass $NOLTO_CFLAGS to CC.

4 years agoFix some minor bugs in test suite command logging
Tom Tromey [Mon, 26 Oct 2020 23:10:25 +0000 (17:10 -0600)]
Fix some minor bugs in test suite command logging

I noticed that the test suite command logging would create a file like
"gdb.cmd.-1".  I tracked this down to a substraction in
standard_output_file_with_gdb_instance.

Then, I saw that the .in file was not created for MI.  This is fixed
by adding a call to default_mi_gdb_start.

Finally, commands might not end up in the .in file in some cases.  For
me this happened because the test took a long time, so I got impatient
and killed it.  Flushing the file after each write seemed like a good
thing to do here.

gdb/testsuite/ChangeLog
2020-10-26  Tom Tromey  <tom@tromey.com>

* lib/mi-support.exp (default_mi_gdb_start): Call
gdb_stdin_log_init.
* lib/gdb.exp (standard_output_file_with_gdb_instance): Don't
subtract one from gdb_instances.
(gdb_stdin_log_write): Flush in_file.

4 years ago[gdb/symtab] Read CU base address for enqueued CU
Tom de Vries [Mon, 26 Oct 2020 19:28:47 +0000 (20:28 +0100)]
[gdb/symtab] Read CU base address for enqueued CU

Consider the test-case contained in this patch.  It consists of
two CUs:
- cu1, containing a DW_TAG_variable DIE foo
- cu2, containing a DW_TAG_base_type DIE int
where the variable foo has type int, in other words, there's an inter-CU
reference.

When expanding the symtab for cu1, expansion of the symtab for cu2 is
enqueued, and later processed by process_full_comp_unit.  However, processing
of .debug_ranges fails because the range is specified relative to a base
address which is considered not to be present because
!cu->base_address.has_value (), and we run into this case in
dwarf2_ranges_process:
...
      if (!base.has_value ())
        {
          /* We have no valid base address for the ranges
             data.  */
          complaint (_("Invalid .debug_ranges data (no base address)"));
          return 0;
        }
...

Fix this in process_full_comp_unit by setting cu->base_address.

Tested on x86_64-linux.

gdb/ChangeLog:

2020-10-26  Tom de Vries  <tdevries@suse.de>

* dwarf2/read.c (process_full_comp_unit): Call
dwarf2_find_base_address.

gdb/testsuite/ChangeLog:

2020-10-26  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/enqueued-cu-base-addr.exp: New file.

4 years agoDon't inherit range-type signed-ness from underlying type
Tom Tromey [Mon, 26 Oct 2020 18:54:19 +0000 (12:54 -0600)]
Don't inherit range-type signed-ness from underlying type

A recent commit changed gdb to inherit the signed-ness of a range type
from its underlying type:

    commit cfabbd351a174406fd5aa063303f5c8bf9266bbc
    Author: Tom Tromey <tom@tromey.com>
    Date:   Sat Oct 17 11:41:59 2020 -0600

      Make range types inherit signed-ness from base type

This passed testing -- but unfortunately, additional testing at
AdaCore showed that this change was incorrect.  GNAT, at least, can
emit an unsigned range type whose underlying type is signed.

This patch reverts the code change from the above.  I chose not to
reintroduce the FIXME comments, because now we know that they are
incorrect.  Instead, this patch also adds a comment to
create_range_type.

A new test case is included as well.

2020-10-26  Tom Tromey  <tromey@adacore.com>

* gdbtypes.c (create_range_type): Revert previous patch.  Add
comment.

gdb/testsuite/ChangeLog
2020-10-26  Tom Tromey  <tromey@adacore.com>

* gdb.ada/unsigned_range/foo.adb: New file.
* gdb.ada/unsigned_range/pack.adb: New file.
* gdb.ada/unsigned_range/pack.ads: New file.
* gdb.ada/unsigned_range.exp: New file.

4 years agogdb::handle_eintr, remove need to specify return type
Pedro Alves [Tue, 8 Sep 2020 16:34:41 +0000 (17:34 +0100)]
gdb::handle_eintr, remove need to specify return type

This eliminates the need to specify the return type when using
handle_eintr.  We let the compiler deduce it for us.

Also, use lowercase for function parameter names.  Uppercase should
only be used on template parameters.

gdb/ChangeLog:

* nat/linux-waitpid.c: Include "gdbsupport/eintr.h".
(my_waitpid): Use gdb::handle_eintr.

gdbserver/ChangeLog:

* netbsd-low.cc (netbsd_waitpid, netbsd_process_target::kill)
(netbsd_qxfer_libraries_svr4): Use gdb::handle_eintr without
explicit type.

gdbsupport/ChangeLog:

* eintr.h (handle_eintr): Replace Ret template parameter with
ErrorValType.  Use it as type of the failure value.  Deduce the
function's return type using decltype.  Use lowercase for function
parameter names.

4 years ago[gdb/testsuite] Prevent pagination in GDB_INTERNALFLAGS
Tom de Vries [Mon, 26 Oct 2020 15:05:15 +0000 (16:05 +0100)]
[gdb/testsuite] Prevent pagination in GDB_INTERNALFLAGS

When running test-case gdb.base/corefile.exp with target board readnow, we run
into:
...
Reading symbols from outputs/gdb.base/corefile/corefile...^M
Expanding full symbols from outputs/gdb.base/corefile/corefile...^M
[New LWP 2293]^M
Core was generated by `outputs/gdb.base/corefile/co'.^M
Program terminated with signal SIGABRT, Aborted.^M
--Type <RET> for more, q to quit, c to continue without paging--\
  FAIL: gdb.base/corefile.exp: (timeout) starting with -core
...

In commit bd447abb24 "Make gdb.base/corefile.exp work on terminals with few
rows", pagination (in the same test-case) is prevented using:
...
set stty_init "rows 25 cols 80"
...
but this doesn't work in our case because using -readnow adds an extra line
"Expanding full symbols".

The test passes when increasing rows to 26.  However, increasing the rows by
some n only fixes the problem for n lines, and things will break again if
somehow we end up with n + 1 lines.

Instead, fix this by setting heigth and width in INTERNAL_GDBFLAGS.  This
solution was not chosen in commit bd447abb24 because it doesn't handle
pagination due to the introduction text.  But it does handle the pagination
due to the extra "Expanding full symbols", and any other line printed during
and after file loading.

Tested on x86_64-linux, with and without readnow.

With -readnow, fixes timeout FAILs in gdb.base/corefile.exp and
gdb.base/reread-readsym.exp.

gdb/testsuite/ChangeLog:

2020-10-26  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (INTERNAL_GDBFLAGS): Set heigth and width.

4 years agogas: Clear all auto-assigned file slots
H.J. Lu [Mon, 26 Oct 2020 13:16:08 +0000 (06:16 -0700)]
gas: Clear all auto-assigned file slots

Since a file slot is auto-assigned for the #APP marker appeared before
the first .file <NUMBER> directive has been seen, clear all auto-assigned
file slots when seeing the first .file <NUMBER> directive.

PR gas/26778
* * dwarf2dbg.c (num_of_auto_assigned): New.
(allocate_filenum): Increment num_of_auto_assigned.
(dwarf2_directive_filename): Clear the slots auto-assigned
before the first .file <NUMBER> directive was seen.
* testsuite/gas/i386/dwarf4-line-1.d: New file.
* testsuite/gas/i386/dwarf4-line-1.s: Likewise.
* testsuite/gas/i386/i386.exp: Run dwarf4-line-1.

4 years agoInvoke the linker's error handling script with the keyword "undefined-symbol" when...
Nick Clifton [Mon, 26 Oct 2020 12:39:50 +0000 (12:39 +0000)]
Invoke the linker's error handling script with the keyword "undefined-symbol" when using it to help with undefined symbol errors.

PR 26626
* ldmain.c (undefined_symbol): Use the keyword undefined-symbol
when invoking the error handling script for undefined symbols.
* ld.texi: Update documentation.

4 years ago[gdb/testsuite] Add missing ranges base in dw2-objfile-overlap-*.S
Tom de Vries [Mon, 26 Oct 2020 10:08:38 +0000 (11:08 +0100)]
[gdb/testsuite] Add missing ranges base in dw2-objfile-overlap-*.S

When doing a gdb testsuite run with this trigger patch:
...
@@ -14454,6 +14454,7 @@ dwarf2_ranges_process

       if (!base.has_value ())
        {
+         gdb_assert (false);
          /* We have no valid base address for the ranges
             data.  */
          complaint (_("Invalid .debug_ranges data (no base address)"));
...
we run into the assert with test-case gdb.dwarf2/dw2-objfile-overlap.exp.

Fix this by adding the missing .debug_ranges base in
gdb.dwarf2/dw2-objfile-overlap-*.S.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-26  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/dw2-objfile-overlap-inner.S: Specify default base address
for CU.
* gdb.dwarf2/dw2-objfile-overlap-outer.S: Same.

4 years agoUpdate gas/ChangeLog of last commit
Lifang Xia [Mon, 26 Oct 2020 10:02:33 +0000 (18:02 +0800)]
Update gas/ChangeLog of last commit

gas/
* ChangeLog: Update ChangLog of 2e58f3923ef

4 years agoC-SKY: Fix the literal dump of big vector constant.
Cooper Qu [Mon, 19 Oct 2020 07:45:36 +0000 (15:45 +0800)]
C-SKY: Fix the literal dump of big vector constant.

gas/
* config/tc-csky.c (dump_literals): Fix the literal dump of big
vector constant.

4 years agoCSKY: Change default linker script for elf toolchain.
Cooper Qu [Mon, 12 Oct 2020 14:31:29 +0000 (22:31 +0800)]
CSKY: Change default linker script for elf toolchain.

ld/
* emulparams/cskyelf.sh (TEXT_START_ADDR): Change to 0x60000000.
(DATA_ADDR) : Define.
(OTHER_SYMBOLS) : Define.
(OTHER_BSS_SYMBOLS) : Set symbol __sbss__.
(OTHER_BSS_END_SYMBOLS) : Set symbol __ebss__.
* ld/emulparams/cskyelf_linux.sh : Don't include cskyelf.sh.
* testsuite/ld-csky/data.d : Fix '/s*' to match spaces.
* testsuite/ld-csky/hilo16.d : Likewise.

Change-Id: Ia29b32eab4157ae5be0fc0b6125fb5b7d9dac939

4 years agoCSKY: Change plsl.u16 to plsl.16.
Cooper Qu [Mon, 12 Oct 2020 14:31:14 +0000 (22:31 +0800)]
CSKY: Change plsl.u16 to plsl.16.

gas/
* testsuite/gas/csky/enhance_dsp.s : Change plsl.u16 to plsl.16.
* testsuite/gas/csky/enhance_dsp.d : Change plsl.u16 to plsl.16.

opcodes/
* csky-opc.h (csky_v2_opcodes): Change plsl.u16 to plsl.16.

Change-Id: Ifb43573192e215527355f6541365b9f6a8ec80a4

4 years agoCSKY: Add version flag in eflag and fix bug in disassembling register.
Cooper Qu [Mon, 12 Oct 2020 14:30:18 +0000 (22:30 +0800)]
CSKY: Add version flag in eflag and fix bug in disassembling register.

gas/
* config/tc-csky.c (md_begin): Add version flag in eflag.

include/
* opcode/csky.h (CSKY_VERSION_V1): Define, currently used.
(CSKY_VERSION_V2): Define.
(CSKY_VERSION_V3): Define.

Change-Id: Iafe3a9ce6fe544880a225b9fae439275a828bb34

4 years agoCSKY: Fix and add some instructions for VDSPV1.
Cooper Qu [Mon, 12 Oct 2020 14:29:09 +0000 (22:29 +0800)]
CSKY: Fix and add some instructions for VDSPV1.

gas/
* config/tc-csky.c (get_operand_value): Add handler for
OPRND_TYPE_IMM5b_VSH and OPRND_TYPE_VREG_WITH_INDEX.
* testsuite/gas/csky/csky_vdsp.d : Fix the disassembling
for vector register.

opcodes/
* csky-dis.c (csky_output_operand): Add handler for
OPRND_TYPE_IMM5b_VSH and OPRND_TYPE_VREG_WITH_INDEX.
* csky-opc.h (OPRND_TYPE_VREG_WITH_INDEX): New enum.
(OPRND_TYPE_IMM5b_VSH): New enum.
(csky_v2_opcodes): Fix and add some instructions for VDSPV1.

Change-Id: Ia5675d7b716fe5c331e6121ad8f83061ef6454bb

4 years agoChange avxvnni disassembler output from {vex3} to {vex}
Cui,Lili [Mon, 26 Oct 2020 01:35:26 +0000 (09:35 +0800)]
Change avxvnni disassembler output from {vex3} to {vex}

gas/

* testsuite/gas/i386/avx-vnni.d: Change psuedo prefix from
{vex3} to {vex}
* testsuite/gas/i386/x86-64-avx-vnni.d: Likewise.

opcodes/

* i386-dis.c: Change "XV" to print "{vex}" pseudo prefix.

4 years agogdb: move ptrace.m4 to gdbsupport
Simon Marchi [Mon, 26 Oct 2020 01:08:49 +0000 (21:08 -0400)]
gdb: move ptrace.m4 to gdbsupport

ptrace.m4, providing the GDB_AC_PTRACE autoconf macro, is used by gdb,
gdbserver and gdbsupport.  I think it would make sense to move it to
gdbsupport.

gdb/ChangeLog:

* acinclude.m4: Update ptrace.m4 path.
* ptrace.m4: Moved to gdbsupport.

gdbserver/ChangeLog:

* acinclude.m4: Update ptrace.m4 path.

gdbsupport/ChangeLog:

* Makefile.in: Re-generate.
* acinclude.m4: Update ptrace.m4 path.
* ptrace.m4: Move here.

Change-Id: I849c149fd5dd8c3b2b0af38654fb353e3727871b

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 26 Oct 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: use inferior parameter in add_vsyscall_page
Simon Marchi [Sun, 25 Oct 2020 03:00:10 +0000 (23:00 -0400)]
gdb: use inferior parameter in add_vsyscall_page

Use the new inferior parameter instead of target_gdbarch.  There are
still hidden references to the current context behind core_bfd and
exec_bfd, but this seemed better than nothing.

gdb/ChangeLog:

* symfile-mem.c (add_vsyscall_page): Use inferior parameter
instead of target_gdbarch.

Change-Id: Iaf5ace555ee8e46cbef5190aca1f6fe639f06677

4 years agogdb: make jit.c use the inferior_created inferior parameter
Simon Marchi [Sun, 25 Oct 2020 02:59:51 +0000 (22:59 -0400)]
gdb: make jit.c use the inferior_created inferior parameter

Use the inferior parameter now available in jit_inferior_created_hook.
It is passed down to jit_inferior_init, which uses it as much as
possible instead of the current inferior or current program space.

gdb/ChangeLog:

* jit.c (jit_reader_load_command): Pass current inferior.
(jit_inferior_init): Change parameter type to inferior, use it.
(jit_inferior_created): Remove.
(jit_inferior_created_hook): Pass inferior parameter down.
(_initialize_jit): Use jit_inferior_created_hook instead of
jit_inferior_created.
* jit.h (jit_inferior_created_hook): Add inferior parameter.
* infrun.c (follow_exec): Pass inferior to
jit_inferior_created_hook.

Change-Id: If3a2114a933370dd313d5abd623136d273cdb8fa

4 years agogdb: pass inferior to check_pid_namespace_match
Simon Marchi [Sun, 25 Oct 2020 02:59:29 +0000 (22:59 -0400)]
gdb: pass inferior to check_pid_namespace_match

Pass the inferior argument available in thread_db_inferior_created, and
use it to do most things requiring the inferior.
check_pid_namespace_match is not completely decoupled from the current
inferior yet, there are hidden references behind target_can_run, for
example.  But I think this is still a good step forward.

gdb/ChangeLog:

* linux-thread-db.c (check_pid_namespace_match): Add inferior
parameter and use it.
(thread_db_inferior_created): Pass inferior argument.

Change-Id: Ib768b14fc61dcf115fe13f776691f2c2f36e0679

4 years agogdb: add inferior parameter to inferior_created observable
Simon Marchi [Sun, 25 Oct 2020 02:59:04 +0000 (22:59 -0400)]
gdb: add inferior parameter to inferior_created observable

I think it would make sense for the inferior_created observable to say
which inferior is being dealt with, rather than relying on it being the
current inferior.

This patch adds an inferior parameter to inferior_created, but does not
change the callbacks to use it.

gdb/ChangeLog:

* aix-thread.c (aix_thread_inferior_created): Add inferior
parameter.
* bsd-uthread.c (bsd_uthread_inferior_created): Likewise.
* dummy-frame.c (cleanup_dummy_frames): Likewise.
* jit.c (jit_inferior_created): Likewise.
* linux-thread-db.c (thread_db_inferior_created): Likewise.
* m68k-linux-tdep.c (m68k_linux_inferior_created): Likewise.
* observable.h (inferior_created): Likewise.
* ravenscar-thread.c (ravenscar_inferior_created): Likewise.
* symfile-mem.c (add_vsyscall_page): Likewise.
* infcmd.c (post_create_inferior): Pass inferior argument.

Change-Id: I2543d19ff055a9df6b269929faea10b27d2adc5e

4 years agoasan: alpha-vms: buffer overflow
Alan Modra [Sun, 25 Oct 2020 11:51:45 +0000 (22:21 +1030)]
asan: alpha-vms: buffer overflow

* vms-misc.c (_bfd_vms_save_counted_string): Count length byte
towards maxlen.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 25 Oct 2020 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdbserver: re-generate configure
Simon Marchi [Sat, 24 Oct 2020 16:44:18 +0000 (12:44 -0400)]
gdbserver: re-generate configure

I get this diff when I re-generate the configure script in gdbserver,
probably leftovers from e911c6663bb8 ("Require kinfo_get_file and
kinfo_get_vmmap for FreeBSD hosts").

gdbserver/ChangeLog:

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

Change-Id: Id19a72ea9f3e7c7b4fdb0f319c9c0bbad0e39aeb

4 years agoDocument the GDB 10.1 release in gdb/ChangeLog
Joel Brobecker [Sat, 24 Oct 2020 04:36:42 +0000 (08:36 +0400)]
Document the GDB 10.1 release in gdb/ChangeLog

gdb/ChangeLog:

GDB 10.1 released.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 24 Oct 2020 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agold: Set plug_opt only if compiler is available
H.J. Lu [Fri, 23 Oct 2020 18:24:58 +0000 (11:24 -0700)]
ld: Set plug_opt only if compiler is available

* testsuite/config/default.exp (plug_opt): Set only if compiler
is available.

4 years ago[gdb/testsuite] Don't use default form in Dwarf::_guess_form
Tom de Vries [Fri, 23 Oct 2020 16:49:48 +0000 (18:49 +0200)]
[gdb/testsuite] Don't use default form in Dwarf::_guess_form

The only possible form for a DW_AT_low_pc attribute is DW_FORM_addr.

When specifying in dwarf assembly a low_pc attribute without explicit form:
...
  {low_pc {main_label - 4}}
...
the resulting attribute uses DW_FORM_string, which is misinterpreted by gdb
when reading it as:
...
        cu->base_address = attr->as_address ();
...

Stop using DW_FORM_string as default form.  Instead, use a default form based
on the attribute name, if possible and unambiguous.  Otherwise, error out.

F.i.:
- for DW_AT_low_pc we use DW_FORM_addr.
- For DW_AT_high_pc, we don't specify a default form because it could be
  either address or constant class.
- For DW_AT_name, we use DW_FORM_string.  While we could encode with
  DW_FORM_strp instead, DW_FORM_string is always ok.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-23  Tom de Vries  <tdevries@suse.de>

* lib/dwarf.exp (Dwarf::_guess_form): Return "" by default instead of
DW_FORM_string.
(Dwarf::_default_form): New proc.
(Dwarf::_handle_DW_TAG): Use _default_form.  Error out if no form was
guessed.

4 years ago[gdb/testsuite] Use $srcfile in DW_AT_name for CU
Tom de Vries [Fri, 23 Oct 2020 12:55:04 +0000 (14:55 +0200)]
[gdb/testsuite] Use $srcfile in DW_AT_name for CU

In dwarf assembly test-case ada-linkage-name.exp, we have:
...
standard_testfile .c -debug.S
  ...
  cu {} {
    DW_TAG_compile_unit {
      {DW_AT_name     ada-linkage-name.c}
...
Use $srcfile instead of ada-linkage-name.c.

In dwarf assembly test-case atomic-type.exp, we have:
...
standard_testfile .c -dw.S
  ...
  cu {} {
    DW_TAG_compile_unit {
      {DW_AT_name     atomic-type-dw.c}
...
The dwarf generated into atomic-type-dw.S is meant to represent the code in
atomic-type.c, not atomic-type-dw.c, so use $srcfile instead of
atomic-type-dw.c.

Fix these and similar.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-23  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/ada-linkage-name.exp: Use $srcfile for DW_AT_name of CU.
* gdb.dwarf2/atomic-type.exp: Same.
* gdb.dwarf2/bad-regnum.exp: Same.
* gdb.dwarf2/cpp-linkage-name.exp: Same.
* gdb.dwarf2/dw2-align.exp: Same.
* gdb.dwarf2/dw2-bad-elf.exp: Same.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp: Same.
* gdb.dwarf2/dw2-bad-unresolved.exp: Same.
* gdb.dwarf2/dw2-namespaceless-anonymous.exp: Same.
* gdb.dwarf2/dw2-opt-structptr.exp: Same.
* gdb.dwarf2/dw2-unusual-field-names.exp: Same.
* gdb.dwarf2/enum-type.exp: Same.
* gdb.dwarf2/frame-inlined-in-outer-frame.exp: Same.
* gdb.dwarf2/info-locals-optimized-out.exp: Same.
* gdb.dwarf2/main-subprogram.exp: Same.
* gdb.dwarf2/missing-type-name.exp: Same.
* gdb.dwarf2/nonvar-access.exp: Same.
* gdb.dwarf2/typedef-void-finish.exp: Same.
* gdb.dwarf2/var-access.exp: Same.
* gdb.dwarf2/void-type.exp: Same.

4 years agoada-typeprint.c::ada_print_type: Remove redundant call to ada_check_typedef
Joel Brobecker [Fri, 23 Oct 2020 10:15:15 +0000 (14:15 +0400)]
ada-typeprint.c::ada_print_type: Remove redundant call to ada_check_typedef

This commit removes a call to ada_check_typedef which has already
been done a few lines earlier in the same function, so the second one
is superfluous.

gdb/ChangeLog:

        * ada-typeprint.c (ada_print_type): Remove superfluous second call
        to ada_check_typedef.

4 years agogdb: move f_language class into a header file
Andrew Burgess [Wed, 16 Sep 2020 15:27:30 +0000 (16:27 +0100)]
gdb: move f_language class into a header file

Moves the f_language class from f-lang.c into f-lang.h.  The benefit
of this is that functions declared in other f-*.c files can become
member functions without having to go through a level of indirection.

Some additional support functions have now become private member
functions of the f_language class, these are mostly functions that
then called some other function that was itself a member of the
language_defn class hierarchy.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* f-exp.y (f_parse): Rename to...
(f_language::parser): ...this.
* f-lang.c (f_get_encoding): Rename to...
(f_language::get_encoding): ...this.
(f_op_print_tab): Rename to...
(f_language::op_print_tab): ...this.
(exp_descriptor_f): Rename to...
(f_language::exp_descriptor_tab): ...this.
(class f_language): Moved to f-lang.h.
(f_language::language_arch_info): New function, moved out of class
declaration.
(f_language::search_name_hash): Likewise.
(f_language::lookup_symbol_nonlocal): Likewise.
(f_language::get_symbol_name_matcher_inner): Likewise.
* f-lang.h: Add 'valprint.h' include.
(class f_language): Moved here from f-lang.c.
* f-typeprint.c (f_type_print_args): Delete commented out
declaration.
(f_print_typedef): Rename to...
(f_language::print_typedef): ...this.
(f_print_type): Rename to...
(f_language::print_type): ...this.
(f_type_print_varspec_prefix): Delete declaration and rename to...
(f_language::f_type_print_varspec_prefix): ...this.
(f_type_print_varspec_suffix): Delete declaration and rename to...
(f_language::f_type_print_varspec_suffix): ...this.
(f_type_print_base): Delete declaration and rename to...
(f_language::f_type_print_base): ...this.
* f-valprint.c (f_value_print_inner): Rename to...
(f_language::value_print_inner): ...this.
* parse.c: Delete 'f-lang.h' include.

4 years agogdb: Improve documentation comment on language_defn::print_type
Andrew Burgess [Mon, 21 Sep 2020 11:10:04 +0000 (12:10 +0100)]
gdb: Improve documentation comment on language_defn::print_type

Improves the comment at the declaration of language_defn::print_type.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* language.h (language_defn::print_type): Add variable names in
declaration, and update header comment.

4 years agogdb: Rename language_defn::demangle
Andrew Burgess [Sat, 19 Sep 2020 19:38:11 +0000 (20:38 +0100)]
gdb: Rename language_defn::demangle

GDB already has a global symbol `demangle` (a boolean), having a
language method called `demangle` is not a good idea as we often want
to reference `demangle` the control variable inside `demangle` the
member function.

This commit renames `demangle` the member function to
`demangle_symbol`.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language::demangle): Rename to...
(ada_language::demangle_symbol): ...this.
* c-lang.c (cplus_language::demangle): Rename to...
(cplus_language::demangle_symbol): ...this.
* d-lang.c (d_language::demangle): Rename to...
(d_language::demangle_symbol): ...this.
* f-lang.c (f_language::demangle): Rename to...
(f_language::demangle_symbol): ...this.
* go-lang.c (go_language::demangle): Rename to...
(go_language::demangle_symbol): ...this.
* language.c (language_demangle): Update call to demangle_symbol.
(auto_or_unknown_language::demangle): Rename to...
(auto_or_unknown_language::demangle_symbol): ...this.
* language.h (language_defn::demangle): Rename to...
(language_defn::demangle_symbol): ...this.
* objc-lang.c (objc_language::demangle): Rename to...
(objc_language::demangle_symbol): ...this.
* rust-lang.c (rust_language::demangle): Rename to...
(rust_language::demangle_symbol): ...this.

4 years agogdb: remove LA_ITERATE_OVER_SYMBOLS macro
Andrew Burgess [Fri, 14 Aug 2020 14:07:52 +0000 (15:07 +0100)]
gdb: remove LA_ITERATE_OVER_SYMBOLS macro

Replace the single use of the LA_ITERATE_OVER_SYMBOLS macro with the
macro's definition, and delete the macro.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* language.h (LA_ITERATE_OVER_SYMBOLS): Delete.
(iterate_over_file_blocks): Replace use of macro with the macros
definition.