]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
4 years agoDocument pseudo-terminal and interrupting changes users/palves/ctrl-c
Pedro Alves [Thu, 3 Jun 2021 18:39:19 +0000 (19:39 +0100)] 
Document pseudo-terminal and interrupting changes

This documents changes done in previous patches:

 - the fact that on GNU/Linux, GDB creates a pseudo-terminal for the
   inferior instead of juggling terminal settings.

 - That when the inferior and GDB share the terminal, you can't
   interrupt some programs with Ctrl-C.

 - That on GNU/Linux, you may get "Program stopped." instead of
   "Program received SIGINT" in response to Ctrl-C.

 - That run+detach may result in the program dying with SIGHUP.

I was surprised that we do not currently have a node/section
specifically to talk about interrupting programs.  Thus I've added a
new "Interrupting" section under the "Stopping and Continuing"
chapter, with some xrefs to other sections.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* NEWS: Document pseudo-terminal, "tty /dev/tty" and Ctrl-C/SIGINT
changes.  Document "set/show debug managed-tty".

gdb/doc/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.texinfo (Input/Output): Document that GDB may start a
program associated with a pseudo-terminal.  Document "tty
/dev/tty".  Document "set/show debug managed-tty".
(Attach): Document what happens on run+detach on systems where GDB
creates a pseudo-terminal for the inferior.
(Stopping and Continuing): Add new Interrupting node.
(Background Execution): Add anchor.
(Features for Debugging MS Windows PE Executables): Add anchor.

Change-Id: I267a0f9300c7ac4d2e7f14a9ba8eabc1eafcc5a7

4 years agoGNU/Linux: Interrupt/Ctrl-C with SIGSTOP instead of SIGINT [PR gdb/9425, PR gdb/14559]
Pedro Alves [Thu, 3 Jun 2021 18:39:19 +0000 (19:39 +0100)] 
GNU/Linux: Interrupt/Ctrl-C with SIGSTOP instead of SIGINT [PR gdb/9425, PR gdb/14559]

After the "Always put inferiors in their own terminal/session
[gdb/9425, gdb/14559]" change, when a user types "Ctrl-C" while the
inferior is running, GDB is the one who gets the SIGINT, not the
inferior process.  GDB then forwards the SIGINT to the inferior with
target_pass_ctrlc.

That was necessary but not not sufficient to fix PRs gdb/9425,
gdb/14559, because if a program blocks SIGINT with e.g. sigprocmask,
then if GDB sends it a SIGINT, the signal isn't ever delivered to the
process, so ptrace does not intercept it.  You type Ctrl-C, but
nothing happens.  Similarly, if a program uses sigwait to wait for
SIGINT, and the program receives a SIGINT, the SIGINT is _not_
intercepted by ptrace, it goes straight to the inferior.

Now that the Ctrl-C results in a SIGINT sent to GDB instead of the
inferior, we can make GDB interrupt the program any other way we like.
This patch makes non-stop-capable ports interrupt the program with
stop_all_threads / target_stop (i.e., SIGSTOP) instead of
target_pass_ctrlc (i.e., SIGINT), which always works -- SIGSTOP can't
be blocked/ignored.  (In the future GDB may even switch to
PTRACE_INTERRUPT on Linux, though that's a project of its own.)

Another advantage here is with multi-target -- currently, because GDB
relies on Ctrl-C stopping one thread, and then stopping all other
threads in reaction to that stop, target_pass_ctrlc tries to find one
inferior with a thread that is running, in any target.  If the
selected target for some reason fails to process the Ctrl-C request,
then the Ctrl-C ends up lost.  The mechanism implemented in this patch
is different -- we never have to pick a thread, inferior or target --
we're going to stop everything, so we end up in stop_all_threads.

For non-stop, the patch preserves the current behavior of only
stopping one thread in reaction to Ctrl-C, so it can still happen that
the thread that GDB selects to stop disappears and the Ctrl-C ends up
being lost.  However, because now GDB always sees the SIGINT first, we
can change how Ctrl-C behaves there too.  We could even make it
configurable -- for example, it could be reasonable that Ctrl-C simply
drops the CLI back to the prompt, without stopping anything at all.
That might be interesting for "set observer-mode on", at least.

This commit has a user-visible behavior change in all-stop mode --
when you interrupt the program with Ctrl-C, instead of:

  Thread 1 "threads" received signal SIGINT, Interrupt.

You'll get:

  Thread 1 "threads" stopped.

Which is what you already got with the "interrupt" command in non-stop
mode.

If you really want to pass a SIGINT to the program, you can then issue:

  (gdb) signal SIGINT

This commit also adjusts the testsuite to cope with that output
alternative.

With this change, the gdb.base/sigint-sigwait.exp and
gdb.base/sigint-masked-out.exp testcases now pass cleanly on
GNU/Linux, on both native debugging and gdbserver + "maint set
target-non-stop on", so the kfails are adjusted accordingly.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

PR gdb/9425
PR gdb/14559
* event-top.c (default_quit_handler): Mark infrun event-loop
handler with mark_infrun_async_event_handler_ctrl_c instead of
passing the Ctrl-C to the target directly with target_pass_ctrlc.
* infcmd.c (interrupt_target_1): On non-stop targets, Mark infrun
event-loop handler with
mark_infrun_async_event_handler_interrupt_all instead of using
target_interrupt.
* infrun.c (interrupt_all_requested, switch_to_stop_thread)
(sync_interrupt_all)
(mark_infrun_async_event_handler_interrupt_all)
(mark_infrun_async_event_handler_ctrl_c): New.
(infrun_async_inferior_event_handler): Handle Ctrl-C/interrupt
requests.
* infrun.h (mark_infrun_async_event_handler_interrupt_all)
(mark_infrun_async_event_handler_ctrl_c): Declare.
* linux-nat.c (wait_for_signal): Don't handle Ctrl-C here.
(linux_nat_wait_1): Handle it here, by marking the infrun event
handler, and returning TARGET_WAITKIND_IGNORE with the quit flag
still set.
* target.c (maybe_pass_ctrlc): New.
(target_terminal::inferior, target_terminal::restore_inferior):
Use it.
(target_pass_ctrlc): Ass there's no non-stop target pushed.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

PR gdb/9425
PR gdb/14559
* gdb.base/bp-cmds-continue-ctrl-c.exp: Expect "stopped" in
alternative to "signal SIGINT".
* gdb.base/interrupt-daemon-attach.exp: Likewise.
* gdb.base/interrupt-daemon.exp: Likewise.
* gdb.base/interrupt-noterm.exp: Likewise.
* gdb.base/interrupt.exp: Likewise.
* gdb.base/random-signal.exp: Likewise.
* gdb.base/range-stepping.exp: Likewise.
* gdb.gdb/selftest.exp: Likewise.
* gdb.mi/new-ui-mi-sync.exp: Likewise.
* gdb.multi/multi-target-interrupt.exp: Likewise.
* gdb.multi/multi-target-no-resumed.exp: Likewise.
* gdb.multi/multi-term-settings.exp: Likewise.
* gdb.server/reconnect-ctrl-c.exp: Likewise.
* gdb.threads/async.exp: Likewise.
* gdb.threads/continue-pending-status.exp: Likewise.
* gdb.threads/leader-exit.exp: Likewise.
* gdb.threads/manythreads.exp: Likewise.
* gdb.threads/pthreads.exp: Likewise.
* gdb.threads/schedlock.exp: Likewise.
* gdb.threads/sigthread.exp: Likewise.

* lib/gdb.exp (can_interrupt_blocked_sigint): New.
* gdb.base/sigint-masked-out.exp (test_ctrl_c)
(test_interrupt_cmd): Use can_interrupt_blocked_sigint, and don't
kfail if true.
* gdb.base/sigint-sigwait.exp (test_ctrl_c, test_interrupt_cmd):
Likewise.

Change-Id: I83c1b6a20deea1f1909156adde1d60b8f6f2629b

4 years agoconvert previous_inferior_ptid to strong reference to thread_info
Pedro Alves [Thu, 3 Jun 2021 18:39:19 +0000 (19:39 +0100)] 
convert previous_inferior_ptid to strong reference to thread_info

While working on a patch, I spotted a regression in the
gdb.multi/multi-target-no-resumed.exp.exp testcase.  Debugging the
issue, I realized that the problem was related to how I was using
previous_inferior_ptid to look up the thread the user had last
selected.  The problem is that previous_inferior_ptid alone doesn't
tell you which target that ptid is from, and I was just always using
the current target, which was incorrect.  Two different targets may
have threads with the same ptid.

I decided to fix this by replacing previous_inferior_ptid with a
strong reference to the thread, called previous_thread.

A new update_previous_thread function is added can be used to updated
previous_thread from inferior_ptid.

This must be called in several places that really want to get rid of
previous_thread thread, and reset the thread id counter, otherwise we
get regressions like these:

  (gdb) info threads -gid
    Id   GId  Target Id                               Frame
 - * 1    1    Thread 2974541.2974541 "tids-gid-reset" main () at src/gdb/testsuite/gdb.multi/tids-gid-reset.c:21
 - (gdb) PASS: gdb.multi/tids-gid-reset.exp: single-inferior: after restart: info threads -gid
 + * 1    2    Thread 2958361.2958361 "tids-gid-reset" main () at src/gdb/testsuite/gdb.multi/tids-gid-reset.c:21
 + (gdb) FAIL: gdb.multi/tids-gid-reset.exp: single-inferior: after restart: info threads -gid

and:

  Core was generated by `build/gdb/testsuite/outputs/gdb.reverse/sigall-precsave/si'.
  Program terminated with signal SIGTRAP, Trace/breakpoint trap.
  #0  gen_ABRT () at src/gdb/testsuite/gdb.reverse/sigall-reverse.c:398
  398      kill (getpid (), SIGABRT);
 +[Current thread is 1 (LWP 2662066)]
  Restored records from core file build/gdb/testsuite/outputs/gdb.reverse/sigall-precsave/sigall.precsave.
  #0  gen_ABRT () at src/gdb/testsuite/gdb.reverse/sigall-reverse.c:398
  398      kill (getpid (), SIGABRT);

  continue
  Continuing.

 -Program received signal SIGABRT, Aborted.
 +Thread 1 received signal SIGABRT, Aborted.
  0x00007ffff7dfd55b in kill () at ../sysdeps/unix/syscall-template.S:78
  78     ../sysdeps/unix/syscall-template.S: No such file or directory.
 -(gdb) PASS: gdb.reverse/sigall-precsave.exp: sig-test-1: get signal ABRT
 +(gdb) FAIL: gdb.reverse/sigall-precsave.exp: sig-test-1: get signal ABRT

I.e., GDB was failing to restart the thread counter back to 1, because
the previous_thread thread was being help due to the strong reference.

Tested on GNU/Linux native, gdbserver and gdbserver + "maint set
target-non-stop on".

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* infcmd.c (kill_command, detach_command, disconnect_command):
Call update_previous_thread.
* infrun.c (previous_inferior_ptid): Delete.
(previous_thread): New.
(update_previous_thread): New.
(proceed, init_wait_for_inferior): Call update_previous_thread.
(normal_stop): Adjust to compare previous_thread and
inferior_thread.  Call update_previous_thread.
* infrun.h (update_previous_thread): Declare.
* target.c (target_pre_inferior, target_preopen): Call
update_previous_thread.

Change-Id: I4f06dd81f00848bb7d6d26a94ff091e2a4e646d9

4 years agoexists_non_stop_target: Avoid flushing frames
Pedro Alves [Thu, 3 Jun 2021 18:39:19 +0000 (19:39 +0100)] 
exists_non_stop_target: Avoid flushing frames

A following patch adds an exists_non_stop_target call in the
target_terminal routines, and that surprisingly caused a weird
regression / GDB crash:

 $ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver" TESTS="gdb.base/signest.exp"
 ...
 configuring for gdbserver local testing (extended-remote)
 Using src/gdb/testsuite/config/extended-gdbserver.exp as tool-and-target-specific interface file.
 Running src/gdb/testsuite/gdb.base/signest.exp ...
 ERROR: GDB process no longer exists

Debugging the core, we see infinite recursion:

 (top-gdb) bt 20
 #0  0x0000561d6a1bfeff in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #1  0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 #2  0x0000561d6a1b989f in frame_unwind_find_by_frame (this_frame=0x561d6b19f9c0, this_cache=0x561d6b19f9d8) at src/gdb/frame-unwind.c:174
 #3  0x0000561d6a1bff04 in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #4  0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 #5  0x0000561d6a1b989f in frame_unwind_find_by_frame (this_frame=0x561d6b19f9c0, this_cache=0x561d6b19f9d8) at src/gdb/frame-unwind.c:174
 #6  0x0000561d6a1bff04 in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #7  0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 #8  0x0000561d6a1b989f in frame_unwind_find_by_frame (this_frame=0x561d6b19f9c0, this_cache=0x561d6b19f9d8) at src/gdb/frame-unwind.c:174
 #9  0x0000561d6a1bff04 in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #10 0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 #11 0x0000561d6a1b989f in frame_unwind_find_by_frame (this_frame=0x561d6b19f9c0, this_cache=0x561d6b19f9d8) at src/gdb/frame-unwind.c:174
 #12 0x0000561d6a1bff04 in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #13 0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 #14 0x0000561d6a1b989f in frame_unwind_find_by_frame (this_frame=0x561d6b19f9c0, this_cache=0x561d6b19f9d8) at src/gdb/frame-unwind.c:174
 #15 0x0000561d6a1bff04 in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #16 0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 #17 0x0000561d6a1b989f in frame_unwind_find_by_frame (this_frame=0x561d6b19f9c0, this_cache=0x561d6b19f9d8) at src/gdb/frame-unwind.c:174
 #18 0x0000561d6a1bff04 in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #19 0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 (More stack frames follow...)

 (top-gdb) bt -30
 #157054 0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 #157055 0x0000561d6a1b989f in frame_unwind_find_by_frame (this_frame=0x561d6b19f9c0, this_cache=0x561d6b19f9d8) at src/gdb/frame-unwind.c:174
 #157056 0x0000561d6a1bff04 in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #157057 0x0000561d6a1bfeb8 in get_frame_arch (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:2939
 #157058 0x0000561d6a1b989f in frame_unwind_find_by_frame (this_frame=0x561d6b19f9c0, this_cache=0x561d6b19f9d8) at src/gdb/frame-unwind.c:174
 #157059 0x0000561d6a1bff04 in frame_unwind_arch (next_frame=0x561d6b19f9c0) at src/gdb/frame.c:2950
 #157060 0x0000561d6a1bbc65 in frame_unwind_pc (this_frame=0x561d6b19f9c0) at src/gdb/frame.c:970
 #157061 0x0000561d6a1bf54c in get_frame_pc (frame=0x561d6b19fa90) at src/gdb/frame.c:2625
 #157062 0x0000561d6a1bf63e in get_frame_address_in_block (this_frame=0x561d6b19fa90) at src/gdb/frame.c:2655
 #157063 0x0000561d6a0cae7f in dwarf2_frame_cache (this_frame=0x561d6b19fa90, this_cache=0x561d6b19faa8) at src/gdb/dwarf2/frame.c:1010
 #157064 0x0000561d6a0cb928 in dwarf2_frame_this_id (this_frame=0x561d6b19fa90, this_cache=0x561d6b19faa8, this_id=0x561d6b19faf0) at src/gdb/dwarf2/frame.c:1227
 #157065 0x0000561d6a1baf72 in compute_frame_id (fi=0x561d6b19fa90) at src/gdb/frame.c:588
 #157066 0x0000561d6a1bb16e in get_frame_id (fi=0x561d6b19fa90) at src/gdb/frame.c:636
 #157067 0x0000561d6a1bb224 in get_stack_frame_id (next_frame=0x561d6b19fa90) at src/gdb/frame.c:650
 #157068 0x0000561d6a26ecd0 in insert_hp_step_resume_breakpoint_at_frame (return_frame=0x561d6b19fa90) at src/gdb/infrun.c:7809
 #157069 0x0000561d6a26b88a in handle_signal_stop (ecs=0x7ffc67022830) at src/gdb/infrun.c:6428
 #157070 0x0000561d6a269d81 in handle_inferior_event (ecs=0x7ffc67022830) at src/gdb/infrun.c:5741
 #157071 0x0000561d6a265bd0 in fetch_inferior_event () at src/gdb/infrun.c:4120
 #157072 0x0000561d6a244c24 in inferior_event_handler (event_type=INF_REG_EVENT) at src/gdb/inf-loop.c:41
 #157073 0x0000561d6a435cc4 in remote_async_serial_handler (scb=0x561d6b4a8990, context=0x561d6b4a4c48) at src/gdb/remote.c:14403
 #157074 0x0000561d6a460bc5 in run_async_handler_and_reschedule (scb=0x561d6b4a8990) at src/gdb/ser-base.c:138
 #157075 0x0000561d6a460cae in fd_event (error=0, context=0x561d6b4a8990) at src/gdb/ser-base.c:189
 #157076 0x0000561d6a76a191 in handle_file_event (file_ptr=0x561d6b233ae0, ready_mask=1) at src/gdbsupport/event-loop.cc:575
 #157077 0x0000561d6a76a743 in gdb_wait_for_event (block=1) at src/gdbsupport/event-loop.cc:701
 #157078 0x0000561d6a7694ee in gdb_do_one_event () at src/gdbsupport/event-loop.cc:237
 #157079 0x0000561d6a2df16b in start_event_loop () at src/gdb/main.c:421
 #157080 0x0000561d6a2df2b6 in captured_command_loop () at src/gdb/main.c:481
 #157081 0x0000561d6a2e0d16 in captured_main (data=0x7ffc67022bd0) at src/gdb/main.c:1353
 #157082 0x0000561d6a2e0da8 in gdb_main (args=0x7ffc67022bd0) at src/gdb/main.c:1370
 #157083 0x0000561d69eb3d82 in main (argc=13, argv=0x7ffc67022cf8, envp=0x7ffc67022d68) at src/gdb/gdb.c:33

This was caused by exists_non_stop_target flushing the frame cache via
scoped_restore_current_thread/switch_to_thread, while we're in the
middle of unwinding.

Fix this by making exists_non_stop_target only switch the inferior,
like done in target_pass_ctrlc.

The annota1.exp change is necessary because we'd get a regression
otherwise:

  @@ -238,8 +238,6 @@ Continuing.

   \032\032breakpoints-invalid

  -\032\032frames-invalid
  -
   \032\032breakpoint 3

   Breakpoint 3,
  @@ -276,7 +274,7 @@ printf.c
   \032\032pre-prompt
   (gdb)
   \032\032prompt
  -PASS: gdb.base/annota1.exp: continue to printf
  +FAIL: gdb.base/annota1.exp: continue to printf

... because this patch avoids flushing the frame cache that lead to
that missing frames-invalid.  We still need to match frames-invalid
because against gdbserver + "maint set target non-stop on", some other
code path flushes the frame cache resulting in the annotation being
emitted anyway.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* target.c (exists_non_stop_target): Use
scoped_restore_current_inferior and set_current_inferior instead
of scoped_restore_current_thread / switch_to_inferior_no_thread.

Change-Id: I8402483ee755e64e54d8b7c4a67c177557f569bd

4 years agoAlways put inferiors in their own terminal/session [gdb/9425, gdb/14559]
Pedro Alves [Thu, 3 Jun 2021 18:39:19 +0000 (19:39 +0100)] 
Always put inferiors in their own terminal/session [gdb/9425, gdb/14559]

Currently, on GNU/Linux, it is not possible to interrupt with Ctrl-C
programs that block or ignore SIGINT, with e.g., sigprocmask or
signal(SIGINT, SIG_IGN).  You type Ctrl-C, but nothing happens.
Similarly, if a program uses sigwait to wait for SIGINT, and the
program receives a SIGINT, the SIGINT is _not_ intercepted by ptrace,
it goes straight to the inferior.  These problems have been known for
years, and recorded in gdb/9425, gdb/14559.

This is a consequence of how GDB implements interrupting programs with
Ctrl-C -- when GDB spawns a new process, it makes the process use the
same terminal as GDB, and then makes the process's process group be
the foreground process group in GDB's terminal.  This means that when
the process is running in the foreground, after e.g. "continue", when
the user types Ctrl-C, the kernel sends a SIGINT to the foreground
process group, which is the inferior.  GDB then intercepts the SIGINT
via ptrace, the same way it intercepts any other signal, stops all the
other threads of the inferior if in all-stop, and presents the
"Program received SIGINT" stop to the user.

This patch paves the way to address gdb/9425, gdb/14559, by turning
Ctrl-C handling around such that the SIGINT always reaches GDB first,
not the inferior.  That is done by making GDB put inferiors in their
own terminal/session created by GDB.  I.e., GDB creates a
pseudo-terminal master/slave pair, makes the inferior run with the
slave as its terminal, and pumps output/input on the master end.
Because the inferior is run with its own session/terminal, GDB is free
to remain as the foreground process in its own terminal, which means
that the Ctrl-C SIGINT always reaches GDB first, instead of reaching
the inferior first, and then GDB reacting to the ptrace-intercepted
SIGINT.  Because GDB gets the SIGINT first, GDB is then free to
handle it by interrupting the program any way it sees fit.  A
following patch will then make GDB interrupt the program with SIGSTOP
instead of SIGINT, which always works even if the inferior
blocks/ignores SIGINT -- SIGSTOP can't be ignored.  (In the future GDB
may even switch to PTRACE_INTERRUPT, though that's a project of its
own.)

Having the inferior in its own terminal also means that GDB is in
control of when inferior output is flushed to the screen.  When
debugging with the CLI, this means that inferior output is now never
interpersed with GDB's output in an unreadable fashion.  This will
also allow fixing the problem of inferior output really messing up the
screen in the TUI, forcing users to Ctrl-L to refresh the screen.
This patch does not address the TUI part, but it shouldn't be too hard
-- I wrote a quick&dirty prototype patch doing that a few years back,
so I know it works.

Implementation wise, here's what is happening:

 - when GDB spawns an inferior, unless the user asked otherwise with
   "tty /dev/tty", GDB creates a pty pair, and makes the slave end the
   inferior's terminal.  Note that starting an inferior on a given
   terminal already exists, given the "tty" command.  GDB records the
   master and slave ends of the pty.

 - GDB registers that new terminal's master end on the event loop.
   When the master is written to, it means the inferior has written
   some output on its terminal.  The event loop wakes up and GDB
   flushes the inferior output to its own terminal / to the screen.

 - When target_terminal state is switched to "inferior", with
   target_tarminal::inferiors(), GDB registers the stdin file
   descriptor on the event loop with a callback that forwards input
   typed on GDB's terminal to the inferior's tty.

 - Similarly, when GDB receives a SIGWINCH signal, meaning GDB's
   terminal was resized, GDB resizes the inferior's terminal too.

 - GDB puts the inferior in its own session, and there's a "session
   leader" process between GDB and the inferior.  The latter is
   because session leaders have special properties, one of which is,
   if they exit, all progresses in the foreground process group in the
   session get a SIGHUP.  If the spawned inferior was the session
   leader itself, if you were debugging an inferior that forks and
   follow to the child, if the parent (the session leader) exits, then
   the child would get a SIGHUP.  Forking twice when launching an
   inferior, and making the first child be the session leader, and the
   second child the inferior avoids that problem.

 - When the inferior exits or is killed, GDB sends a SIGHUP to the
   session leader, waits for the leader to exit and then destroys the
   terminal.  The session leader's SIGHUP handler makes the session
   leader pgrp be the foreground process group and then exits.  This
   sequence is important comparing to just closing the terminal and
   letting the session leader terminate due to the SIGHUP the kernel
   sends, because when the session leader exits, all processes in the
   foreground process group get a SIGHUP, meaning that if the detached
   process was still in the foreground, it would get a SIGHUP, and
   likely die.

 - The gdb.multi/multi-term-settings.exp was adjusted to test for
   shared and not-shared terminal/session.  Without the change, we get
   failures:

    FAIL: gdb.multi/multi-term-settings.exp: inf1_how=run: inf2_how=run: continue (expected SIGTTOU)
    FAIL: gdb.multi/multi-term-settings.exp: inf1_how=run: inf2_how=run: stop with control-c (Quit)

Tested on GNU/Linux native, gdbserver and gdbserver + "maint target
set-non-stop on".  Also build-tested tested on mingw32-w64, Solaris
11, and OpenBSD.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

PR gdb/9425
PR gdb/14559
* fork-child.c (child_has_managed_tty_hook): New.
* inf-ptrace.c (inf_ptrace_me): If we created a managed tty, raise
SIGSTOP.
(inf_ptrace_handle_session_leader_fork): New.
(inf_ptrace_target::create_inferior): Pass it down as
handle_session_leader_fork callback.
* inf-ptrace.h (inf_ptrace_target) <handle_session_leader_fork>:
New virtual method.
* inferior.h (child_terminal_on_sigwinch): Declare.
* inflow.c: Include "gdbsupport/event-loop.h",
"gdbsupport/refcounted-object.h", "gdbsupport/gdb_wait.h",
"gdbsupport/managed-tty.h".
(USES_FORK_CHILD): Define, and wrap fork-child.c-related code with
it.
(struct run_terminal_info): New.
(struct terminal_info) <run_terminal>: Now a run_terminal_info.
<process_group>: Default to -1.
<save_from_tty>: New method.
(sigint_ours): Update comments.
(inferior_thisrun_terminal_pty_fd): New.
(input_fd_redirected): New.
(sharing_input_terminal): Adjust.
(gdb_tcgetattr, gdb_tcsetattr, make_raw, class scoped_raw_termios)
(child_terminal_flush_from_to, child_terminal_flush_stdout)
(inferior_stdout_event_handler, inferior_stdin_event_handler): New.
(child_terminal_inferior): Handle inferiors with gdb-managed ttys.
(child_terminal_save_inferior): Handle inferiors with gdb-managed
ttys.  Use save_from_tty.
(child_terminal_ours_1): Handle inferiors with gdb-managed ttys.
(terminal_info::~terminal_info): Use delete instead of xfree.
(child_terminal_on_sigwinc): New.
(inflow_inferior_exit): Release terminal created by GDB.
(copy_terminal_info): Assert there's no run_terminal yet in TO
yet.  Incref run_terminal after copying.
(child_terminal_info): Handle inferiors with gdb-managed ttys.
(new_tty_prefork): Allocate pseudo-terminal.
(created_managed_tty): New.
(new_tty): Remove __GO32__ and _WIN32 #ifdefs, not needed given
USES_FORK_CHILD.
(new_tty_postfork): Handle inferiors with gdb-managed ttys.
(show_debug_managed_tty): New.
(_initialize_inflow): Register "set/show debug managed-tty".
* linux-nat.c (waitpid_sigstop, waitpid_fork)
(linux_nat_target::handle_session_leader_fork): New.
* linux-nat.h (linux_nat_target) <handle_session_leader_fork>:
Declare override.
* nat/fork-inferior.c: Include
"gdbsupport/scoped_ignore_sigttou.h", "gdbsupport/managed-tty.h",
<sys/types.h> and <sys/wait.h>.
(session_leader_hup): New.
(fork_inferior): Add handle_session_leader_fork parameter.  If the
inferior has a gdb-managed tty, don't use vfork, and fork twice,
with the first fork becoming the session leader.  Call
handle_session_leader_fork.
* nat/fork-inferior.h (fork_inferior): Add
handle_session_leader_fork parameter and update comment.
(child_has_managed_tty_hook): Declare.
* terminal.h (created_managed_tty, child_gdb_owns_session):
Declare.
* tui/tui-win.c: Include "inferior.h".
(tui_async_resize_screen): Call child_terminal_on_sigwinch.

gdbsupport/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

PR gdb/9425
PR gdb/14559
* Makefile.am (libgdbsupport_a_SOURCES): Add managed-tty.cc.
* Makefile.in: Regenerate.
* managed-tty.cc: New.
* managed-tty.h: New.

gdbserver/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

PR gdb/9425
PR gdb/14559
* fork-child.cc (child_has_managed_tty_hook): New.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

PR gdb/9425
PR gdb/14559
* gdb.multi/multi-term-settings.exp (create_inferior): Document
"run-session", "run-share" and "run-tty" instead of "run" and
"tty".  Adjust to handle "run-session" vs "run-share".
(coretest): Adjust to handle "run-session" vs "run-share".
(how_modes): Use "run-session", "run-share" and "run-tty" instead
of "run" and "tty".

Change-Id: I2569e189294044891e68a66401b381e4b999b19c

4 years agoMove scoped_ignore_sigttou to gdbsupport/
Pedro Alves [Thu, 3 Jun 2021 18:39:19 +0000 (19:39 +0100)] 
Move scoped_ignore_sigttou to gdbsupport/

A following patch will want to use scoped_ignore_sigttou in code
shared between GDB and GDBserver.  Move it under gdbsupport/.

Note that despite what inflow.h/inflow.c's first line says, inflow.c
is no longer about ptrace, it is about terminal management.  Some
other files were unnecessarily including inflow.h, I guess a leftover
from the days when inflow.c really was about ptrace.  Those inclusions
are simply dropped.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* Makefile.in (HFILES_NO_SRCDIR): Remove inflow.h.
* inf-ptrace.c, inflow.c, procfs.c: Don't include "inflow.h".
* inflow.h: Delete, moved to gdbsupport/ under a different name.
* ser-unix.c: Don't include "inflow.h".  Include
"gdbsupport/scoped_ignore_sigttou.h".

gdbsupport/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* scoped_ignore_sigttou.h: New file, moved from gdb/ and renamed.

Change-Id: Ie390abf42c3a78bec6d282ad2a63edd3e623559a

4 years agotarget_terminal::ours_for_output before printing signal received
Pedro Alves [Thu, 3 Jun 2021 18:39:19 +0000 (19:39 +0100)] 
target_terminal::ours_for_output before printing signal received

A following patch will make GDB put spawned inferiors in their own
terminal/session (on GNU/Linux).  In that case, GDB is in control of
when is the inferior's output flushed to the screen.  A sync point is
when target_terminal state goes from inferior -> ours/ours_for_output.

The gdb.multi/multi-term-settings.exp testcase exposed a bug where an
inferior output flush is missing, resulting in this regression:

Good:

 (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: info inferiors
 continue
 Continuing.
 pid=1275538, count=0
 pid=1276069, count=0

 Thread 1.1 "multi-term-sett" received signal SIGTTOU, Stopped (tty output).
 [Switching to process 1275538]
 0x00007ffff7ecda14 in __tcsetattr (fd=0, optional_actions=0, termios_p=0x7fffffffd450) at ../sysdeps/unix/sysv/linux/tcsetattr.c:83
 83 ../sysdeps/unix/sysv/linux/tcsetattr.c: No such file or directory.
 (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: continue (expected SIGTTOU)
 Quit
 (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: stop with control-c (Quit)

Bad:

 (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: info inferiors
 continue
 Continuing.
 pid=1287638, count=0

 Thread 1.1 "multi-term-sett" received signal SIGTTOU, Stopped (tty output).
 pid=1287663, count=0                      <<<<<< HERE
 [Switching to process 1287638]
 0x00007ffff7ecda14 in __tcsetattr (fd=0, optional_actions=0, termios_p=0x7fffffffd450) at ../sysdeps/unix/sysv/linux/tcsetattr.c:83
 83 ../sysdeps/unix/sysv/linux/tcsetattr.c: No such file or directory.
 (gdb) FAIL: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: continue
 Quit
 (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: stop with control-c (Quit)

Notice the "<<<<<< HERE" line in the "Bad" output above -- that is
inferior output being printed on the screen _after_ GDB says the
thread stopped...  That's obviously bogus, the output was printed by
the inferior before it was stopped.

The fix is to claim back the terminal for output before printing the
"signal received SIGTTOU" message.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* infrun.c (normal_stop): Call target_terminal::ours_for_output
before calling signal_received observers.

Change-Id: Iea106c33b4c585562fc3579ca85d43481fa214f0

4 years agogdb.mi/mi-logging.exp, don't send input to GDB while the inferior is running
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
gdb.mi/mi-logging.exp, don't send input to GDB while the inferior is running

The gdb.mi/mi-logging.exp testcase sends a sequence of execution
commands to the GDB terminal while the inferior is running, like this:

 send_gdb "1002-exec-step\n"
 send_gdb "1003-exec-next\n"

expecting that GDB will consume the "1003-exec-next" intput after the
inferior stops for the 1002-exec-step.

That's a flawed assumption in general, because the inferior itself
could consume the "1003-exec-next" input while it is stepping.

When GDB puts the inferior in its own terminal, while the inferior is
running, GDB marshals input from its terminal to the inferior's
terminal.  The result is that input typed while the inferior is
running never goes to GDB, and so the test fails.

The previous patch addressed issues like this by making the inferior
and GDB share the same terminal for tests that really wanted to test
some aspect of a shared terminal.  For gdb.mi/mi-logging.exp though,
there's really no reason to send input while the program is running,
so the fix here is to stop it from doing so.

While debugging the testcase, I ran into the fact that it reuses the
same log file for more than one [open] sequence, overwriting previous
runs.  The testcase also deletes the log files at the very end, which
makes it impossible to inspect the logs after a failure run.  The
patch addresses those issues as well.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.mi/mi-logging.exp: Do not reuse log files for different
runs.  Delete logs at the start of the testcase, not at the
end.
(wait_open, gdb_test_file): New procedures.  Use them.

Change-Id: Ife215a82391a020041fd05478bd8dbee6e04d607

4 years agoMake inferior/GDB share terminal in tests that exercise GDB/inferior reading same...
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
Make inferior/GDB share terminal in tests that exercise GDB/inferior reading same input

Some testcases exercise some aspect that only makes sense when GDB and
the inferior are sharing the same terminal, meaning GDB and the
inferior are reading from the same input file.

This commit makes sure that continues to be tested even after GDB
changed to put inferiors in their own session/terminal by default, by
issuing "tty /dev/tty".  The tests would fail otherwise.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.base/annota-input-while-running.exp: Issue "tty /dev/tty"
before starting program.
* gdb.base/continue-all-already-running.exp: Likewise.
* gdb.base/infcall-input.exp: Likewise.

Change-Id: Ia5f9061bf28a5e780194aa75b37b6058de0614ee

4 years agoMake inferior/GDB share terminal in tests expecting output after detach
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
Make inferior/GDB share terminal in tests expecting output after detach

A following patch will make GDB put spawned inferiors in their own
terminal/session.  A consequence of that is that if you do "run", and
then "detach", GDB closes the terminal, so expecting inferior output
after detach no longer works, the inferior is alive, but its output
goes nowhere.

There's only one testcase that expects output out of an inferior after
detach.  Tweak it to output to GDB's terminal instead.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.threads/process-dies-while-detaching.exp: Issue "tty
/dev/tty" before starting program.

Change-Id: Ic62bca178295763fb9c47657ee459fe715f7865e

4 years agoSpecial-case "set inferior-tty /dev/tty"
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
Special-case "set inferior-tty /dev/tty"

The following patches will make GDB spawn inferiors in their own
session and tty by default.  Meaning, GDB will create and manage a pty
for the inferior instead of the inferior and GDB sharing the same
terminal and GDB having to juggle terminal settings depending on
whether the inferior running or gdb showing the prompt.

For some use cases however, it will still be useful to be able to tell
GDB to spawn the inferior in the same terminal & session as GDB, like
today.

Setting the inferior tty to "/dev/tty" seems like an obvious way to
get that, as /dev/tty is a special file that represents the terminal
for the current process.  This leaves "tty" with no arguments free for
a different behavior.

This patch hardcodes "/dev/tty" in is_gdb_terminal for that reason.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* inflow.c (is_gdb_terminal): Hardcode "/dev/tty".
(new_tty): Don't create a tty if is_gdb_terminal is true.
(new_tty_postfork): Always allocate a run_terminal.
(create_tty_session): Don't create a session if sharing the
terminal with GDB.

Change-Id: I4dc7958f823fa4e30c21a2c3fe4d8434a5d5ed40

4 years agoDon't check parent pid in gdb.threads/{ia64-sigill,siginfo-threads,watchthreads-reord...
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
Don't check parent pid in gdb.threads/{ia64-sigill,siginfo-threads,watchthreads-reorder}.c

A following patch will make GDB always put spawned inferiors in their
own terminal session.  To do that, GDB forks twice, creating an extra
"session leader" process between gdb and the inferior process.

gdb.threads/{ia64-sigill,siginfo-threads,watchthreads-reorder}.c all
check whether the parent process is GDB.  If it isn't, they just bail,
and the testcase fails.  After the changes mentioned above, this
parent check will fail if GDB is putting inferiors in their own
terminal session, because in that case, the test's parent is the extra
"session leader" process between gdb and the test process.  The tracer
will be the test process's grandparent, not the direct parent.

Since the test programs already check whether there's a ptracer
attached, there's no real need for this parent pid check.  Just remove
it.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.threads/ia64-sigill.c (main): Don't check whether the parent
pid is the tracer.
* gdb.threads/siginfo-threads.c (main): Don't check whether the
parent pid is the tracer.
* gdb.threads/watchthreads-reorder.c (main): Don't check whether
the parent pid is the tracer.

Change-Id: Iea0b06fb93c31bde1a0993c52b3fe8a5f408aec7

4 years agoFix gdb.multi/multi-term-settings.exp race
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
Fix gdb.multi/multi-term-settings.exp race

The gdb.multi/multi-term-settings.exp testcase sometimes fails like so:

 Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.multi/multi-term-settings.exp ...
 FAIL: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: stop with control-c (SIGINT)

It's easier to reproduce if you stress the machine at the same time, like e.g.:

  $ stress -c 24

Looking at gdb.log, we see:

 (gdb) attach 60422
 Attaching to program: build/gdb/testsuite/outputs/gdb.multi/multi-term-settings/multi-term-settings, process 60422
 [New Thread 60422.60422]
 Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...
 Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.31.so...
 Reading symbols from /lib64/ld-linux-x86-64.so.2...
 (No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
 0x00007f2fc2485334 in __GI___clock_nanosleep (clock_id=<optimized out>, clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7ffe23126940, rem=rem@entry=0x0) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
 78 ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory.
 (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: inf2: attach
 set schedule-multiple on
 (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: set schedule-multiple on
 info inferiors
   Num  Description       Connection                         Executable
   1    process 60404     1 (extended-remote localhost:2349) build/gdb/testsuite/outputs/gdb.multi/multi-term-settings/multi-term-settings
 * 2    process 60422     1 (extended-remote localhost:2349) build/gdb/testsuite/outputs/gdb.multi/multi-term-settings/multi-term-settings
 (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: info inferiors
 pid=60422, count=46
 pid=60422, count=47
 pid=60422, count=48
 pid=60422, count=49
 pid=60422, count=50
 pid=60422, count=51
 pid=60422, count=52
 pid=60422, count=53
 pid=60422, count=54
 pid=60422, count=55
 pid=60422, count=56
 pid=60422, count=57
 pid=60422, count=58
 pid=60422, count=59
 pid=60422, count=60
 pid=60422, count=61
 pid=60422, count=62
 pid=60422, count=63
 pid=60422, count=64
 pid=60422, count=65
 pid=60422, count=66
 pid=60422, count=67
 pid=60422, count=68
 pid=60422, count=69
 pid=60404, count=54
 pid=60404, count=55
 pid=60404, count=56
 pid=60404, count=57
 pid=60404, count=58
 PASS: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: continue
 Quit
 (gdb) FAIL: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: stop with control-c (SIGINT)

If you look at the testcase's sources, you'll see that the intention
is to resumes the program with "continue", wait to see a few of those
"pid=..., count=..." lines, and then interrupt the program with
Ctrl-C.  But somehow, that resulted in GDB printing "Quit", instead of
the Ctrl-C stopping the program with SIGINT.

Here's what is happening:

 #1 - those "pid=..., count=..." lines we see above weren't actually
      output by the inferior after it has been continued (see #1).
      Note that "inf1_how" and "inf2_how" are "attach".  What happened
      is that those "pid=..., count=..." lines were output by the
      inferiors _before_ they were attached to.  We see them at that
      point instead of earlier, because that's where the testcase
      reads from the inferiors' spawn_ids.

 #2 - The testcase mistakenly thinks those "pid=..., count=..." lines
      happened after the continue was processed by GDB, meaning it has
      waited enough, and so sends the Ctrl-C.  GDB hasn't yet passed
      the terminal to the inferior, so the Ctrl-C results in that
      Quit.

The fix here is twofold:

 #1 - flush inferior output right after attaching

 #2 - consume the "Continuing" printed by "continue", indicating the
      inferior has the terminal.  This is the same as done throughout
      the testsuite to handle this exact problem of sending Ctrl-C too
      soon.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.multi/multi-term-settings.exp (create_inferior): Flush
inferior output.
(coretest): Use $gdb_test_name.  After issuing "continue", wait
for "Continuing".

Change-Id: Iba7671dfe1eee6b98d29cfdb05a1b9aa2f9defb9

4 years agoMake gdb.base/long-inferior-output.exp fail fast
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
Make gdb.base/long-inferior-output.exp fail fast

A local change I was working on had a bug that made GDB lose inferior
output, which was caught by the gdb.base/long-inferior-output.exp
testcase.  While debugging the problem, I found it useful to have the
testcase fail quickly when it noticed output was missing.

Also, tighten the regexes to make sure that we don't get
spurious/repeated/bogus output between each "this is line number ..."
line.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.base/long-inferior-output.exp: Don't set "more" when we see
an unexpected "this is line number" number.

Change-Id: I53e8499bd8fdbf961431a7f2a94d263da6a9f573

4 years agoprefork_hook: Remove 'args' parameter
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
prefork_hook: Remove 'args' parameter

prefork_hook's 'args' parameter is only used in debug output in
gdbserver.  Remove it.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* fork-child.c (prefork_hook): Remove 'args' parameter.  All
callers adjusted.
* nat/fork-inferior.h (prefork_hook): Remove 'args' parameter.
All callers adjusted.
* nat/fork-inferior.c (fork_inferior): Adjust.

gdbserver/fork-child.cc
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* fork-child.cc (prefork_hook): Remove 'args' parameter, and
references.

Change-Id: Iaf8977af7dd6915c123b0d50ded93395bdafd920

4 years agoTest interrupting programs that block SIGINT [gdb/9425, gdb/14559]
Pedro Alves [Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)] 
Test interrupting programs that block SIGINT [gdb/9425, gdb/14559]

This adds a couple testcases that exercise interrupting programs that
block SIGINT.  One tests a program that uses sigprocmask to mask out
SIGINT, and the other tests a program that waits for SIGINT with
sigwait.  On GNU/Linux, it is currently impossible to interrupt such a
program with Ctrl-C, and you can't interrupt it with the "interrupt"
command in all-stop mode either.

These currently fail, and are suitably kfailed.  The rest of the
series will fix the fails.

Tested on GNU/Linux native, gdbserver, and gdbserver + "maint set
target-non-stop on".

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

PR gdb/9425
PR gdb/14559
* gdb.base/sigint-masked-out.c: New file.
* gdb.base/sigint-masked-out.exp: New file.
* gdb.base/sigint-sigwait.c: New file.
* gdb.base/sigint-sigwait.exp: New file.

Change-Id: Iddb70c0a2c92550027fccb6f51ecba1292d233c8

4 years agoFix silent gdb.base/annota1.exp test coverage regression
Pedro Alves [Mon, 14 Jun 2021 20:29:32 +0000 (21:29 +0100)] 
Fix silent gdb.base/annota1.exp test coverage regression

This commit fixes a test coverage regression caused by:

 commit b001de2320446ec803b4ee5e0b9710b025b84469
 Author:     Andrew Burgess <andrew.burgess@embecosm.com>
 AuthorDate: Mon Nov 26 17:56:39 2018 +0000
 Commit:     Andrew Burgess <andrew.burgess@embecosm.com>
 CommitDate: Wed Dec 12 17:33:52 2018 +0000

     gdb: Update test pattern to deal with native-extended-gdbserver

While looking at a regression caused by a local patch I was working
on, I noticed this:

 \1a\1apre-prompt
 (gdb)
 \1a\1aprompt
 PASS: gdb.base/annota1.exp: breakpoint info
 PASS: gdb.base/annota1.exp: run until main breakpoint
 run

 \1a\1apost-prompt
 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/outputs/gdb.base/annota1/annota1
 next

Note how above, we get the "run until main breakpoint" pass even
before "run" shows up in the log!  The issue is that the test isn't
really testing anything, it always passes regardless of the gdb
output.

There are a few problems here, fixed by this commit:

 - using {} to build the list for [join], when the strings we're
   joining include variable names that must be expanded.  Such list
   need to be built with [list] instead.

 - [join] joins strings with a space character by default.  We need to
   pass the empty string as second parameter so that it just concats
   the strings.

 - doing too much in a "-re" (calling procedures), which doesn't work
   correctly.  I've seen this before and never digged deeper into why.
   Probably something to do with how gdb_test_multiple is implemented.
   Regardless, easy and clear enough to build the pattern first into a
   variable.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.base/annota1.exp: Build list using [list] instead of {}.
Tell [join] to join with no character.  Build expected pattern in
separate variable instead of in the -re expression directly.

Change-Id: Ib3c89290f0e9ae4a0a43422853fcd4a7a7e12b18

4 years agoInclude missing header signal.h
Bernd Edlinger [Mon, 14 Jun 2021 12:49:21 +0000 (14:49 +0200)] 
Include missing header signal.h

2021-06-14  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* compile/compile.c: Include missing header signal.h.

4 years agoUse consistent type in binutils/dwarf.c
Eric Botcazou [Mon, 14 Jun 2021 13:43:19 +0000 (15:43 +0200)] 
Use consistent type in binutils/dwarf.c

If you look at the type used for implicit_const objects in binutils/dwarf.c,
you'll get sometimes bfd_signed_vma and sometimes dwarf_signed_vma.

They are the same on 64-bit hosts, but not on 32-bit hosts, and the latter
discrepancy, in particular in process_abbrev_set, is responsible for the
following error issued by objdump on some object files containing DWARF 5:

binutils/dwarf.c:1108: read LEB value is too large to store in destination
variable

binutis/
* dwarf.c (struct abbrev_attr): Change type of implicit_const.
(add_abbrev_attr): Likewise.
(process_abbrev_set): Likewise.
(display_debug_abbrev): Adjust to above change.

4 years agoGNU gettext introduced this change[0] in version 0.19.8 to fix gettext detection...
Michael Forney [Mon, 14 Jun 2021 13:05:39 +0000 (14:05 +0100)] 
GNU gettext introduced this change[0] in version 0.19.8 to fix gettext detection with musl libc, since it does not define these internal symbols.

This allows binutils to build with musl gettext rather than falling
back to the bundled version.

[0] https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commit;h=b67399b4

2021-06-13  Michael Forney  <mforney@mforney.org>

config/ChangeLog:

        * gettext.m4 (AM_GNU_GETTEXT): Skip checks for the internal
        symbols _nl_msg_cat_cntr, _nl_domain_bindings, and
        _nl_expand_alias, if __GNU_GETTEXT_SUPPORTED_REVISION is defined.
Backport of gettext serial 68 patch.

intl/ChangeLog:

* configure: Regenerate.
---
Thi

4 years agogas: fold three as_warn() in emit_expr_with_reloc()
Jan Beulich [Mon, 14 Jun 2021 06:18:58 +0000 (08:18 +0200)] 
gas: fold three as_warn() in emit_expr_with_reloc()

Simply use the available abstraction instead of, effectively, trying to
open-code it.

4 years agogas: drop TC_ADDRESS_BYTES conditionals
Jan Beulich [Mon, 14 Jun 2021 06:18:07 +0000 (08:18 +0200)] 
gas: drop TC_ADDRESS_BYTES conditionals

I've been repeatedly confused by, in particular, the .dc.a potable[]
entry being conditional. Grepping in gas/config/ reveals only very few
targets actually #define-ing it. But as of 7be1c4891a20 the symbol is
always defined, so #ifdef-s are pointless (and, as said, potentially
confusing).

Also adjust documentation to reflect this.

4 years agosim: ppc: use common version.o too
Mike Frysinger [Mon, 14 Jun 2021 01:35:05 +0000 (21:35 -0400)] 
sim: ppc: use common version.o too

The common version.o we're building can be used for the ppc subdir,
so switch it over too.

4 years agosim: rx: move cycle-accurate settings to CPPFLAGS
Mike Frysinger [Sun, 13 Jun 2021 05:32:33 +0000 (01:32 -0400)] 
sim: rx: move cycle-accurate settings to CPPFLAGS

This is the last unique setting that rx has in its config.h, so by
moving this to CPPFLAGS, we can drop its config.h entirely.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 14 Jun 2021 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agosim: start unifying portability shims
Mike Frysinger [Sat, 29 May 2021 20:07:43 +0000 (16:07 -0400)] 
sim: start unifying portability shims

There are some functions that gnulib does not yet provide fallbacks
for, so start a common file of our own for holding existing stubs.

4 years agosim: unify sim-load.o building
Mike Frysinger [Mon, 7 Jun 2021 05:48:06 +0000 (01:48 -0400)] 
sim: unify sim-load.o building

Since this file does not rely on any port-specific settings, move it
up to building as part of the common step so we only do it once in a
multibuild.

4 years agosim: rx: replace cycle-stats with common profile settings
Mike Frysinger [Sat, 12 Jun 2021 16:01:27 +0000 (12:01 -0400)] 
sim: rx: replace cycle-stats with common profile settings

The common sim-profile option controls whether to keep track of
runtime execution (like cycle count), so switch the rx-specific
cycle-stats option over to that.

4 years agosim: assume sys/select.h always exists
Mike Frysinger [Sat, 29 May 2021 19:20:28 +0000 (15:20 -0400)] 
sim: assume sys/select.h always exists

Now that gnulib provides this, assume it exists.

4 years agosim: erc32: replace caddr_t with void*
Mike Frysinger [Wed, 9 Jun 2021 22:05:25 +0000 (18:05 -0400)] 
sim: erc32: replace caddr_t with void*

This BSDism was never accepted into standards, so replace it with the
portable void* type instead.

4 years agosim: erc32/ppc: fix handling of $EXEEXT
Mike Frysinger [Wed, 9 Jun 2021 22:04:57 +0000 (18:04 -0400)] 
sim: erc32/ppc: fix handling of $EXEEXT

4 years agosim: overhaul alignment settings management
Mike Frysinger [Mon, 7 Jun 2021 04:54:20 +0000 (00:54 -0400)] 
sim: overhaul alignment settings management

Currently, the sim-config module will abort if alignment settings
haven't been specified by the port's configure.ac.  This is a bit
weird when we've allowed SIM_AC_OPTION_ALIGNMENT to seem like it's
optional to use.  Thus everyone invokes it.

There are 4 alignment settings, but really only 2 matters: strict
and nonstrict.  The "mixed" setting is just the default ("unset"),
and "forced" isn't used directly by anyone (it's available as a
runtime option for some ports).

The m4 macro has 2 args: the "wire" settings (which represents the
hardwired port behavior), and the default settings (which are used
if nothing else is specified).  If none are specified, then the
build won't work (see above as if SIM_AC_OPTION_ALIGNMENT wasn't
called).  If default settings are provided, then that is used, but
we allow the user to override at runtime.  Otherwise, the "wire"
settings are used and user runtime options to change are ignored.

Most ports specify a default, or set the "wire" to nonstrict.  A
few set "wire" to strict, but it's not clear that's necessary as
it doesn't make the code behavior, by default, any different.  It
might make things a little faster, but we should provide the user
the choice of the compromises to make: force a specific mode at
compile time for faster runtime, or allow the choice at runtime.
More likely it seems like an oversight when these ports were
initially created, and/or copied & pasted from existing ports.

With all that backstory, let's get to what this commit does.

First kill off the idea of a compile-time default alignment and
set it to nonstrict in the common code.  For any ports that want
strict alignment by default, that code is moved to sim_open while
initializing the sim.  That means WITH_DEFAULT_ALIGNMENT can be
completely removed.

Moving the default alignment to the runtime also allows removal
of setting the "wire" settings at configure time.  Which allows
removing of all arguments to SIM_AC_OPTION_ALIGNMENT and moving
that call to common code.

The macro logic can be reworked to not pass WITH_ALIGNMENT as -D
CPPFLAG and instead move it to config.h.

All of these taken together mean we can hoist the macro up to the
top level and share it among all sims so behavior is consistent
among all the ports.

4 years agosim: unify bug & package settings
Mike Frysinger [Mon, 7 Jun 2021 00:48:46 +0000 (20:48 -0400)] 
sim: unify bug & package settings

Move these options up to the common dir so we only test & export
them once across all ports.  The AC_INIT macro does a lot of the
heavy lifting already which allows further simplification.

4 years agosim: unify debug/stdio/trace/profile build settings
Mike Frysinger [Mon, 7 Jun 2021 00:35:02 +0000 (20:35 -0400)] 
sim: unify debug/stdio/trace/profile build settings

Move these options up to the common dir so we only test & export
them once across all ports.

The ppc code needs a little extra care with its trace settings as
it's not exactly the same API as the common code.  The other knobs
are the same though.

4 years agosim: split debug/stdio/trace/profile options into dedicated m4 files
Mike Frysinger [Mon, 7 Jun 2021 00:16:48 +0000 (20:16 -0400)] 
sim: split debug/stdio/trace/profile options into dedicated m4 files

This follows existing organizational structure with one configure option
per m4 file, and will make it easier to move to the common configure dir.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 13 Jun 2021 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agosim: ppc: unify header & function & type tests too
Mike Frysinger [Sat, 12 Jun 2021 17:18:29 +0000 (13:18 -0400)] 
sim: ppc: unify header & function & type tests too

Since ppc now shares a config.h with the top-level, move all of its
relevant settings up a level.  The ppc port tests a lot more funcs,
but that's because its syscall emulation is a lot more complete.
We'll probably utilize some of these in the common code too.

4 years agoremote: Fix indentation in remote_new_objfile.
John Baldwin [Sat, 12 Jun 2021 17:43:29 +0000 (10:43 -0700)] 
remote: Fix indentation in remote_new_objfile.

gdb/remote.c:14541:5: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
    if (current_inferior ()->in_initial_library_scan)
    ^
gdb/remote.c:14527:3: note: previous statement is here
  if (remote == nullptr)
  ^

gdb/ChangeLog:

* remote.c (remote_new_objfile): Fix indentation.

4 years agosim: ppc: unify env settings too
Mike Frysinger [Sat, 12 Jun 2021 16:57:02 +0000 (12:57 -0400)] 
sim: ppc: unify env settings too

The ppc port doesn't share a lot of the common logic, but there are
a few bits that bleed across.  Have it use the common configure for
environment settings too to avoid duplicate define errors after the
recent unification with the other ports.

4 years agosim: unify environment build settings
Mike Frysinger [Mon, 7 Jun 2021 00:11:02 +0000 (20:11 -0400)] 
sim: unify environment build settings

Move the --sim-enable-environment option up to the common dir so we
only test & export it once across all ports.

4 years agosim: unify assert build settings
Mike Frysinger [Sun, 6 Jun 2021 22:45:05 +0000 (18:45 -0400)] 
sim: unify assert build settings

Move the --sim-enable-assert option up to the common dir so we only
test & export it once across all ports.

4 years agosim: unify platform function & header tests
Mike Frysinger [Tue, 18 May 2021 00:34:52 +0000 (20:34 -0400)] 
sim: unify platform function & header tests

Move the various platform tests up a level to avoid duplication
across the ports.  When building multiple versions, this speeds
things up a bit.

For now we move the obvious stuff up a level, but we don't turn
own the config.h entirely just yet -- we still have some tests
related to libraries that need consideration.

4 years agoreadelf: don't clear section_headers in process_file_header
Alan Modra [Sat, 12 Jun 2021 02:29:22 +0000 (11:59 +0930)] 
readelf: don't clear section_headers in process_file_header

* readelf.c (process_file_header): Don't clear section_headers.

4 years agoRe: readelf section reading
Alan Modra [Sat, 12 Jun 2021 01:24:21 +0000 (10:54 +0930)] 
Re: readelf section reading

Fix commit 4de91c10cdd9, which cached the single section header read
to pick up file header extension fields.  Also, testing e_shoff in
get_section_headers opened a hole for fuzzers where we'd end up with
segfaults due to non-zero e_shnum but NULL section_headers.

* readelf.c (get_section_headers): Don't test e_shoff here, leave
that to get_32bit_section_headers or get_64bit_section_headers.
(process_object): Throw away section header read to print file
header extension.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 12 Jun 2021 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoFix ChangeLog entry location
Simon Marchi [Fri, 11 Jun 2021 22:09:57 +0000 (18:09 -0400)] 
Fix ChangeLog entry location

This ChangeLog entry is in the wrong file, fix that.

Change-Id: I43464e1bdb94d2f40d4c7dfaf425fc498851964c

4 years agomi-sym-info.exp: Increase timeout for 114-symbol-info-functions
Kevin Buettner [Thu, 10 Jun 2021 02:52:08 +0000 (19:52 -0700)] 
mi-sym-info.exp: Increase timeout for 114-symbol-info-functions

Loading libc.so's symbols increased the amount of time needed for
114-symbol-info-function to fetch symbols, causing a timeout during my
testing.  I enclosed the entire block with a "with_timeout_factor 4",
which fixes the problem for me.  (Using 2 also fixed it for me, but it
might not be enough when running this test on slower machines.)

gdb/testsuite/ChangeLog:

* gdb.mi/mi-sym-info.exp (114-symbol-info-function test): Increase
timeout.

4 years agoprint-symbol-loading.exp: Allow libc symbols to be already loaded
Kevin Buettner [Thu, 10 Jun 2021 02:31:18 +0000 (19:31 -0700)] 
print-symbol-loading.exp: Allow libc symbols to be already loaded

One consequence of changing libpthread_name_p() in solib.c to (also)
match libc is that the symbols for libc will now be loaded by
solib_add() in solib.c.  I think this is mostly harmless because
we'll likely want these symbols to be loaded anyway, but it did cause
two failures in gdb.base/print-symbol-loading.exp.

Specifically...

1)

sharedlibrary .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib

now looks like this:

sharedlibrary .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib

2)

sharedlibrary .*
Loading symbols for shared libraries: .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib

now looks like this:

sharedlibrary .*
Loading symbols for shared libraries: .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib

Fixing case #2 ended up being easier than #1.  #1 had been using
gdb_test_no_output to correctly match this no-output case.  I
ended up replacing it with gdb_test_multiple, matching the exact
expected output for each of the two now acceptable cases.

For case #2, I simply added an optional non-capturing group
for the potential new output.

gdb/testsuite/ChangeLog:

* gdb.base/print-symbol-loading.exp (proc test_load_shlib):
Allow "Symbols already loaded for..." messages.

4 years agotestsuite/glib-2.34: Match/consume optional libthread_db related output
Kevin Buettner [Thu, 10 Jun 2021 01:56:23 +0000 (18:56 -0700)] 
testsuite/glib-2.34: Match/consume optional libthread_db related output

When using glibc-2.34, we now see messages related to the loading of
the thread library for non-thread programs.  E.g.  for the test case,
gdb.base/execl-update-breakpoints.exp, we will see the following when
starting the program:

(gdb) break -qualified main
Breakpoint 1 at 0x100118c: file /ironwood1/sourceware-git/f34-2-glibc244_fix/bld/../../worktree-glibc244_fix/gdb/testsuite/gdb.base/execl-update-breakpoints.c, line 34.
(gdb) run
Starting program: [...]/execl-update-breakpoints1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

The two lines of output related to libthread_db are new; we didn't see
these in the past.  This is a side effect of libc now containing the
pthread API - we can no longer tell whether the program is
multi-threaded by simply looking for libpthread.so.  That said, I
think that we now want to load libthread_db anyway since it's used to
resolve TLS variables; i.e. we need it for correctly determining the
value of errno.

This commit adds the necessary regular expressions to match this
(optional) additional output in the two tests which were failing
without it.

gdb/testsuite/ChangeLog:

* gdb.base/execl-update-breakpoints.exp: Add regular
expression for optionally matching output related to
libthread_db.
* gdb.base/fork-print-inferior-events.exp: Likewise.

4 years agolibthread_db initialization changes related to upcoming glibc-2.34
Kevin Buettner [Thu, 10 Jun 2021 01:07:45 +0000 (18:07 -0700)] 
libthread_db initialization changes related to upcoming glibc-2.34

This commit makes some adjustments to accomodate the upcoming
glibc-2.34 release.  Beginning with glibc-2.34, functionality formerly
contained in libpthread has been moved to libc.  For the time being,
libpthread.so still exists in the file system, but it won't show up in
ldd output and therefore won't be able to trigger initialization of
libthread_db related code.  E.g...

Fedora 34 / glibc-2.33.9000:

[kev@f34-2 gdb]$ ldd testsuite/outputs/gdb.threads/tls/tls
linux-vdso.so.1 (0x00007ffcf94fa000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007ff0ba9af000)
libm.so.6 => /lib64/libm.so.6 (0x00007ff0ba8d4000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff0ba8b9000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff0ba6c6000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff0babf0000)

Fedora 34 / glibc-2.33:

[kev@f34-1 gdb]$ ldd testsuite/outputs/gdb.threads/tls/tls
linux-vdso.so.1 (0x00007fff32dc0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f815f6de000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f815f4bf000)
libm.so.6 => /lib64/libm.so.6 (0x00007f815f37b000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f815f360000)
libc.so.6 => /lib64/libc.so.6 (0x00007f815f191000)
/lib64/ld-linux-x86-64.so.2 (0x00007f815f721000)

Note that libpthread is missing from the ldd output for the
glibc-2.33.9000 machine.

This means that (unless we happen to think of some entirely different
mechanism), we'll now need to potentially match "libc" in addition to
"libpthread" as libraries which might be thread libraries.  This
accounts for the change made in solib.c.  Note that the new code
attempts to match "/libc." via strstr().  That trailing dot (".")
avoids inadvertently matching libraries such as libcrypt (and
all the other many libraries which begin with "libc").

To avoid attempts to load libthread_db when encountering older
versions of libc, we now attempt to find "pthread_create" (which is a
symbol that we'd expect to be in any pthread library) in the
associated objfile.  This accounts for the changes in
linux-thread-db.c.

I think that other small adjustments will need to be made elsewhere
too.  I've been working through regressions on my glibc-2.33.9000
machine; I've fixed some fairly "obvious" changes in the testsuite
(which are in other commits).  For the rest, it's not yet clear to me
whether the handful of remaining failures represent a problem in glibc
or gdb.  I'm still investigating, however, I'll note that these are
problems that I only see on my glibc-2.33.9000 machine.

gdb/ChangeLog:

* solib.c (libpthread_name_p): Match "libc" in addition
to "libpthread".
* linux-thread-db.c (libpthread_objfile_p): New function.
(libpthread_name_p): Adjust preexisting callers to use
libpthread_objfile_p().

4 years agogdb: remove unused struct call_site_stuff forward declaration
Simon Marchi [Fri, 11 Jun 2021 15:36:48 +0000 (11:36 -0400)] 
gdb: remove unused struct call_site_stuff forward declaration

This is unused (and was event when it was introduced).  Remove it.

gdb/ChangeLog:

* dwarf2/loc.h (struct call_site_stuff): Remove.

Change-Id: Iaa82cb7cfd9768998553b4c9211aca7529eb402f

4 years agogdb, testsuite: Fix mi-var-child-f.exp for Intel compilers.
Felix Willgerodt [Thu, 6 May 2021 12:14:07 +0000 (14:14 +0200)] 
gdb, testsuite: Fix mi-var-child-f.exp for Intel compilers.

mi-var-child-f.exp uses array.f as the inferior, which uses an unnamed
main function.  This causes false positive fails for Intel compilers, as
they emit the following DWARF:

~~~
0x0000002a:   DW_TAG_subprogram
                DW_AT_low_pc    (0x0000000000404800)
                DW_AT_high_pc   (0x000000000040484c)
                DW_AT_frame_base        (DW_OP_reg6 RBP)
                DW_AT_linkage_name      ("MAIN__")
                DW_AT_name      ("_unnamed_main$$")
                DW_AT_decl_file ("array.f")
                DW_AT_decl_line (16)
                DW_AT_external  (true)
                DW_AT_main_subprogram   (true)
~~~

The testsuite for fortran uses test_compiler_info to determine a hardcoded
string which is used to run to main and as a testing regex:

~~~
proc fortran_main {} {
    if {[test_compiler_info {gcc-4-[012]-*}]
         || [test_compiler_info {gcc-*}]
         || [test_compiler_info {icc-*}] {
return "MAIN__"
    } elseif {[test_compiler_info {clang-*}]} {
return "MAIN_"
    } else {
return "unknown"
    }
}
~~~

GDB however uses DW_AT_name mostly in its output, which fails the regex.
To fix this testcase immediately, I modernized array.f and gave it a named
main.  There was no specific reason it was unnamed anyway.  Fixing
the testsuite properly is not straightforward.  fortran_main and
test_compiler_info would need some changes, which has broader influences.
I might look at this later down the road.

gdb/testsuite/ChangeLog:
2021-06-11  Felix Willgerodt  <felix.willgerodt@intel.com>

* gdb.mi/array.f: Convert into...
* gdb.mi/array.f90: ...this.
* gdb.mi/mi-var-child-f.exp: Use array.f90.

4 years agoImplement Rust raw identifiers
Tom Tromey [Fri, 11 Jun 2021 14:14:09 +0000 (08:14 -0600)] 
Implement Rust raw identifiers

This patch implements Rust raw identifiers in the lexer in gdb.  There
was an earlier patch to do this, but the contributor didn't reply to
my email asking whether he had sorted out his copyright assignment.

This is relatively straightforward, but a small test suite addition
was needd to ensure that the new test is skipped on older versions of
rustc -- ones that predate the introduction of raw identifiers.

gdb/ChangeLog
2021-06-11  Tom Tromey  <tom@tromey.com>

PR rust/23427
* rust-parse.c (rust_parser::lex_identifier): Handle raw
identifiers.
(rust_lex_tests): Add raw identifier tests.

gdb/testsuite/ChangeLog
2021-06-11  Tom Tromey  <tom@tromey.com>

PR rust/23427
* lib/rust-support.exp (rust_compiler_version): New caching proc.
* gdb.rust/rawids.exp: New file.
* gdb.rust/rawids.rs: New file.

4 years agox86: Always define TC_PARSE_CONS_EXPRESSION
H.J. Lu [Fri, 11 Jun 2021 13:19:16 +0000 (06:19 -0700)] 
x86: Always define TC_PARSE_CONS_EXPRESSION

Always define TC_PARSE_CONS_EXPRESSION to properly wrap constants for
all x86 targets.

* config/tc-i386.c (x86_cons): Handle GOT/PLT relocations only
if needed.
* config/tc-i386.h (TC_PARSE_CONS_EXPRESSION): Always define.

4 years agoRISC-V: Update the riscv_opts.[rvc|rve] in the riscv_set_arch.
Nelson Chu [Fri, 11 Jun 2021 09:23:43 +0000 (17:23 +0800)] 
RISC-V: Update the riscv_opts.[rvc|rve] in the riscv_set_arch.

We also need to update the riscv_opts.[rvc|rve] for elf attributes.
Otherwise, the following case will fail,

$ cat cadd.s
.attribute arch, "rv64gc"
c.add   a0, a1
$ riscv64-unknown-elf-as cadd.s -o cadd.o
cadd.s: Assembler messages:
cadd.s:2: Error: illegal operands `c.add a0,a1

After applying this patch,

$ riscv64-unknown-elf-as cadd.s -o cadd.o
$ riscv64-unknown-elf-objdump -d cadd.o

cadd.o:     file format elf64-littleriscv

Disassembly of section .text:

0000000000000000 <.text>:
   0:   952e                    add     a0,a0,a1
        ...

gas/
    * config/tc-riscv.c (riscv_set_arch): Call riscv_set_rvc
    and riscv_set_rve both for -march and elf attributes.
    (riscv_after_parse_args): Likewise.

4 years agoreadelf info leaks from one object to the next
Alan Modra [Fri, 11 Jun 2021 03:19:02 +0000 (12:49 +0930)] 
readelf info leaks from one object to the next

A number of filedata entries were not cleared.  Make sure they are
all cleared out, except the ones needed for archive handling.

* readelf.c (struct filedata): Move archive_file_offset and
archive_file_size earlier.
(free_filedata): Clear using memset.

4 years agoreadelf section reading
Alan Modra [Fri, 11 Jun 2021 04:42:07 +0000 (14:12 +0930)] 
readelf section reading

This is a followup to git commit 8ff66993e0b5, a patch aimed at
segfaults found invoking readelf multiple times with fuzzed objects.
In that patch I added code to clear more stashed data early in
process_section_headers, along with any stashed section headers.  This
patch instead relies on clearing out the stash at the end of
process_object, making sure that process_object doesn't exit early.

The patch also introduces some new wrapper functions.

* readelf.c (GET_ELF_SYMBOLS): Delete.  Replace with..
(get_elf_symbols): ..this new function throughout.
(get_32bit_section_headers): Don't free section_headers.
(get_64bit_section_headers): Likewise.
(get_section_headers): New function, use throughout in place of
32bit and 64bit variants.
(get_dynamic_section): Similarly.
(process_section_headers): Don't free filedata memory here.
(get_file_header): Don't get section headers here..
(process_object): ..Read them here instead.  Don't exit without
freeing filedata memory.

4 years agoPR27952, Disallow ET_DYN DF_1_PIE linker input
Alan Modra [Fri, 11 Jun 2021 04:36:47 +0000 (14:06 +0930)] 
PR27952, Disallow ET_DYN DF_1_PIE linker input

This patch adds a new elf_tdata flag, is_pie, set during the linker's
open_input_bfds processing.  The flag is then used to reject attempts
to link a PIE as if it were a shared library.

bfd/
PR 27952
* elf-bfd.h (struct elf_obj_tdata): Add is_pie.
* elflink.c (elf_link_add_object_symbols): Set is_pie.
ld/
PR 27952
* ldelf.c (ldelf_after_open): Error on input PIEs too.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 11 Jun 2021 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agogdb/testsuite: capture GDB tty name in default_gdb_spawn
Simon Marchi [Thu, 10 Jun 2021 18:30:33 +0000 (14:30 -0400)] 
gdb/testsuite: capture GDB tty name in default_gdb_spawn

The TUI test gdb.tui/empty.exp fails with the native-extended-gdbserver
board, and takes a very long time to run due to numerous timeouts.  The
symptom, when looking at the logs, is that the TUI windows that we
expect to be resized are not resized.  Digging down, I found that GDB
didn't receive any SIGWINCH that should have resulted from
Term::resize's stty calls.

The reason for this is:

- The native-extended-gdbserver overrides gdb_start to first start GDB,
  then start GDBserver with --multi, then connect GDB to GDBserver.
  This means that two TCL "spawn"s are done, one for GDB and one for
  GDBserver.

- The TUI test framework  wants to know GDB's TTY name, so it can pass
  it to stty, to fake terminal resizes.  To do so, it overrides the
  spawn built-in proc to capture the tty name from the internals of the
  built-in proc.  It saves the TTY name to the gdb_spawn_name global
  variable.

- Because the native-extended-gdbserver boards starts both GDB and
  GDBserver, the final value of gdb_spawn_name is the name of
  GDBserver's TTY.

- When the TUI test framework attempts to resize GDB's terminal, it in
  fact resizes GDBserver's terminal.  So obviously, GDB doesn't get the
  SIGWINCH, and we don't get the expected TUI redraw.

Fix that by moving the hack to lib/gdb.exp, overriding the builtin spawn
all the time.  The override saves the TTY name in the
last_spawn_tty_name global.  The default_gdb_spawn proc then saves it in
the gdb_tty_name global.  This way, we specifically capture GDB's TTY
name in gdb_tty_name, not the TTY name of other spawned processes.

Remove tuiterm_env_init and tuiterm_env_finish, since they are now
empty.  In turn, the gdb_finish_hooks mechanism is now unused, remove it
as well.  It would be easy to add them back if needed.

gdb/ChangeLog:

* lib/gdb.exp (default_gdb_exit): Unset gdb_tty_name.
(spawn_capture_tty_name): New, override builtin spawn.
(default_gdb_spawn): Capture GDB's TTY name.
* lib/tuiterm.exp (tuiterm_spawn): Remove.
(tuiterm_env_init, tuiterm_env_finish): Remove spawn override.
(Term) <resize>: Use new variable name.
(tuiterm_env_init, tuiterm_env_finish): Remove.
(tuiterm_env): Don't call tuiterm_env_init and register
tuiterm_env_finish in gdb_finish_hooks.
(gdb_finish_hooks): Remove.
(gdb_finish): Don't call finish hooks.

Change-Id: Ia5ab74184a52a996416022308f8d0cc523355a78

4 years ago[gdb/testsuite] Fix timeout in gdb.mi/user-selected-context-sync.exp with gcc-11
Tom de Vries [Thu, 10 Jun 2021 11:38:03 +0000 (13:38 +0200)] 
[gdb/testsuite] Fix timeout in gdb.mi/user-selected-context-sync.exp with gcc-11

When running test-case gdb.mi/user-selected-context-sync.exp with gcc-11, we
get:
...
continue^M
Continuing.^M
FAIL: gdb.mi/user-selected-context-sync.exp: mode=all-stop: test_setup: \
  inferior 1: continue to breakpoint: continue thread 1.2 to infinite \
  loop breakpoint (timeout)
...

This is a regression since commit aa33ea68330 "testsuite, mi: avoid a clang
bug in 'user-selected-context-sync.exp'", which fixes a similar hang when
using clang.

The source before the commit contains:
...
  while (1);
...
and after the commit:
...
  int spin = 1;
  while (spin);
...

[ FWIW, I've filed a PR gcc/101011 - Inconsistent debug info for "while (1);"
to mention that gcc-11 has different behaviour for these two loops. ]

The problem is that:
- the test-case expects the behaviour that a breakpoint set
  on the while line will trigger on every iteration, and
- that is not guaranteed by either version of the loop.

Fix this by using a while loop with a dummy body:
...
  volatile int dummy = 0;
  while (1)
    dummy = !dummy;
...
and setting the breakpoint in the body.

Tested on x86_64-linux with clang 10.0.1, gcc-4.8, gcc 7.5.0 and gcc 11.1.1.

gdb/testsuite/ChangeLog:

2021-06-10  Tom de Vries  <tdevries@suse.de>

* gdb.mi/user-selected-context-sync.c (child_sub_function, main):
Rewrite while (1) using dummy loop body.

4 years agoarm: avoid "shadowing" of glibc function name
Jan Beulich [Thu, 10 Jun 2021 10:40:11 +0000 (12:40 +0200)] 
arm: avoid "shadowing" of glibc function name

Old enough glibc has an (unguarded) declaration of index() in string.h,
which triggers a "shadows a global declaration" warning.

4 years agoarm: fix array-out-of-bounds upon register parsing error
Jan Beulich [Thu, 10 Jun 2021 10:39:40 +0000 (12:39 +0200)] 
arm: fix array-out-of-bounds upon register parsing error

Despite the comment ahead of the enum explicitly pointing out the need
to also update the corresponding array, 1b8833198c0 ("Add support for
MVE instructions: vcmp and vpt") failed to do so. Oddly enough the issue
appears to be spotted only by rather old gcc (4.3-ish in my case).

4 years agox86: suppress LEA optimization in a specific 16-bit case
Jan Beulich [Thu, 10 Jun 2021 10:39:08 +0000 (12:39 +0200)] 
x86: suppress LEA optimization in a specific 16-bit case

In 16-bit mode a 16-bit address size LEA with a 16-bit displacement and
a 32-bit destination is shorter to encode than the corresponding MOV.
Commit fe134c656991 ("x86: optimize LEA")'s promise was to only do the
transformation when the encoding size wouldn't grow, i.e. it did go a
little too far. Restrict this specific case of the transformation to
-O2.

4 years ago [gdb/testsuite] Convert multi-line function call into single line.
Bhuvanendra Kumar N [Thu, 10 Jun 2021 07:15:27 +0000 (12:45 +0530)] 
[gdb/testsuite] Convert multi-line function call into single line.

    After this clang backend patch(https://reviews.llvm.org/D91734), 8 test points
    started to FAIL in this test case. As mentioned in this PR, "...this test is
    trying to next over a function call; gcc attributes all parameter evaluation
    to the function name, while clang will attribute each parameter to its own
    location. And when the parameters span across multiple source lines, the
    is_stmt heuristic kicks in, so we stop on each line with actual parameters...".

    gdb.base/foll-exec.c test file snippet :
    . . .
     42   execlp (prog, /* tbreak-execlp */
     43           prog,
     44           "execlp arg1 from foll-exec",
     45           (char *) 0);
     46
     47   printf ("foll-exec is about to execl(execd-prog)...\n");
    . . .

    Line table: (before clang backend patch for the above code snippet) :
    0x000000b0: 84 address += 8,  line += 2
                0x000000000020196a     42      3      1   0             0
    0x000000b1: 08 DW_LNS_const_add_pc (0x0000000000000011)
    0x000000b2: 41 address += 3,  line += 5
                0x000000000020197e     47      3      1   0             0

    Line table: (after clang backend patch for the above code snippet) :
    0x000000b5: 84 address += 8,  line += 2
                0x0000000000201958     42     11      1   0             0
    0x000000b6: 05 DW_LNS_set_column (4)
    0x000000b8: 75 address += 7,  line += 1
                0x000000000020195f     43      4      1   0             0
    0x000000b9: 05 DW_LNS_set_column (3)
    0x000000bb: 73 address += 7,  line += -1
                0x0000000000201966     42      3      1   0             0
    0x000000bc: 08 DW_LNS_const_add_pc (0x0000000000000011)
    0x000000bd: 4f address += 4,  line += 5
                0x000000000020197b     47      3      1   0             0

    Following 8 test points started to fail after the above clang backend patch.

    FAIL: gdb.base/foll-exec.exp: step through execlp call
    FAIL: gdb.base/foll-exec.exp: step after execlp call
    FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp)
    FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp)
    FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp)
    FAIL: gdb.base/foll-exec.exp: step through execl call
    FAIL: gdb.base/foll-exec.exp: step after execl call
    FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl)

    As we can note, reason for these new test failures is due to additional
    .debug_line entries getting created in case of clang compiler, hence to fix
    this issue, test case required either additional next command during
    these multi-line function call or combine these multi-line function call into
    single line. This PR has taken the latter approach and converted the multi-line
    function call into single line in foll-exec.c, thereby there is no change in
    .debug_line entries now and test case works as expected.

4 years ago[gdb/testsuite] Fix gdb.cp/nested-types.exp with check-read1
Tom de Vries [Thu, 10 Jun 2021 05:36:19 +0000 (07:36 +0200)] 
[gdb/testsuite] Fix gdb.cp/nested-types.exp with check-read1

With check-read1 I occasionally run into:
...
FAIL: gdb.cp/nested-types.exp: ptype S10 (limit = 7) \
  // parse failed (timeout)
...
I can trigger this reliably by running check-read1 in conjunction with
stress -c 5.

Fix this by breaking up the regexp in cp_test_ptype_class.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-10  Tom de Vries  <tdevries@suse.de>

* lib/cp-support.exp (cp_test_ptype_class): Break up regexp.
* gdb.cp/nested-types.exp: Remove usage of read1 timeout factor.

4 years ago[gdb/testsuite] Fix gdb.cp/cplusfuncs.exp with check-read1
Tom de Vries [Thu, 10 Jun 2021 05:36:19 +0000 (07:36 +0200)] 
[gdb/testsuite] Fix gdb.cp/cplusfuncs.exp with check-read1

When running check-read1, we run into:
...
FAIL: gdb.cp/cplusfuncs.exp: info function for "operator=(" (timeout)
...

Fix this by using using gdb_test_lines in info_func_regexp.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-10  Tom de Vries  <tdevries@suse.de>

* gdb.cp/cplusfuncs.exp (info_func_regexp): Use gdb_test_lines.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 10 Jun 2021 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agosim: cleanup obsolete NULL fallback
Mike Frysinger [Sun, 6 Jun 2021 22:13:41 +0000 (18:13 -0400)] 
sim: cleanup obsolete NULL fallback

We require C11 which defines NULL, so drop the inconsistent set of
fallback defines in the codebase.

4 years agosim: mn10300: tweak engine halt hook
Mike Frysinger [Sun, 6 Jun 2021 03:10:14 +0000 (23:10 -0400)] 
sim: mn10300: tweak engine halt hook

The hook is a void func, so defining it to 0 triggers warnings,
and isn't really needed.

4 years agosim: nrun: tweak init of callback endian
Mike Frysinger [Sun, 6 Jun 2021 02:50:57 +0000 (22:50 -0400)] 
sim: nrun: tweak init of callback endian

Allow ports to initialize the callback endian if they want.  This will
allow delegation of the logic out of common code in the future.

Also switch from the CURRENT_TARGET_BYTE_ORDER macro to the underlying
current_target_byte_order storage since the latter has been setup by
the sim-config module based on the same macros.  This will allow the
nrun module to be moved to common building for sharing.

4 years agosim: bpf: use CURRENT_TARGET_BYTE_ORDER
Mike Frysinger [Sun, 6 Jun 2021 02:48:23 +0000 (22:48 -0400)] 
sim: bpf: use CURRENT_TARGET_BYTE_ORDER

Code should be going through this macro rather than accessing the
underlying value directly.

4 years agosim: cgen: inline cgen_init logic
Mike Frysinger [Sat, 5 Jun 2021 14:21:46 +0000 (10:21 -0400)] 
sim: cgen: inline cgen_init logic

This function has done only one thing: post-process command line
settings to see if profiling or tracing has been enabled, and if
so, set the run_fast_p flag in the simulator state.  That flag is
only used in one place: to select the fast or slow cgen engine.
By inlining the run_fast_p logic to the one place it's used, we
can delete a good amount of logic specific to cgen ports: both
the call to cgen_init and the conditional simulator state.  This
in turn allows us to have a single simulator state struct across
all ports so we can share objects more between them, and makes
the sim_open calls look more consistent.

4 years agoUpdate read1 example in gdb/testsuite/README
Tom Tromey [Wed, 9 Jun 2021 14:34:47 +0000 (08:34 -0600)] 
Update read1 example in gdb/testsuite/README

Tom de Vries noticed that the recent changes to the testsuite's
configury required an update to the README.  This patch changes the
text to document the new reality.

2021-06-09  Tom Tromey  <tromey@adacore.com>

* README (Example): Update read1 example.

4 years agoRemove Daniel Jacobwitz from the maintainers list
Nick Clifton [Wed, 9 Jun 2021 16:02:54 +0000 (17:02 +0100)] 
Remove Daniel Jacobwitz from the maintainers list

4 years agogdb/testsuite: add some logging in Term::_check_box
Simon Marchi [Wed, 9 Jun 2021 14:47:54 +0000 (10:47 -0400)] 
gdb/testsuite: add some logging in Term::_check_box

I was diagnosing some problem with a TUI test case, which lead me to
improve the logging of _check_box a bit.  It did help me, so I think it
would be nice to have it upstream.

gdb/testsuite/ChangeLog:

* lib/tuiterm.exp (Term) <_check_box>: Improve logging.

Change-Id: I887e83c02507d6c59c991e17f795c844ed63bacf

4 years agoFix the creation of archives for Sparc Solaris2 targets by eliminating the support...
Nick Clifton [Wed, 9 Jun 2021 10:10:16 +0000 (11:10 +0100)] 
Fix the creation of archives for Sparc Solaris2 targets by eliminating the support for generic SPARC ELF files.

PR 27666
bfd * config.bfd: Do not add the sparc_elf32_vec or sparc_elf64_vec
vectors to Sparc Solaris2 targets.

ld * testsuite/ld-sparc/sparc.exp: Do not run the sparctests or
sparc64tests for Solaris2 targets.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 9 Jun 2021 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoUse is/is not to check for None in python code.
Lancelot SIX [Mon, 7 Jun 2021 22:14:55 +0000 (23:14 +0100)] 
Use is/is not to check for None in python code.

While reviewing a patch sent to the mailing list, I noticed there are few
places where python code checks if a variable is 'None' or not by using the
comparison operators '==' and '!='.  PEP8[1], which is used as coding standard
in GDB coding standards, recommends using 'is' / 'is not' when comparing to a
singleton such as 'None'.

This patch proposes to change the instances of '== None' by 'is None' and
'!= None' by 'is not None'.

[1] https://www.python.org/dev/peps/pep-0008/

gdb/doc/ChangeLog:

* python.texi (Writing a Pretty-Printer): Use 'is None' instead of
'== None'.

gdb/ChangeLog:

* python/lib/gdb/FrameDecorator.py (FrameDecorator): Use 'is None' instead of
'== None'.
(FrameVars): Use 'is not None' instead of '!= None'.
* python/lib/gdb/command/frame_filters.py (SetFrameFilterPriority): Use 'is None'
instead of '== None' and 'is not None' instead of '!= None'.

gdb/testsuite/ChangeLog:

* gdb.base/premature-dummy-frame-removal.py (TestUnwinder): Use
'is None' instead of '== None' and 'is not None' instead of
'!= None'.
* gdb.python/py-frame-args.py (lookup_function): Same.
* gdb.python/py-framefilter-invalidarg.py (Reverse_Function): Same.
* gdb.python/py-framefilter.py (Reverse_Function): Same.
* gdb.python/py-nested-maps.py (lookup_function): Same.
* gdb.python/py-objfile-script-gdb.py (lookup_function): Same.
* gdb.python/py-prettyprint.py (lookup_function): Same.
* gdb.python/py-section-script.py (lookup_function): Same.
* gdb.python/py-unwind-inline.py (dummy_unwinder): Same.
* gdb.python/python.exp: Same.
* gdb.rust/pp.py (lookup_function): Same.

4 years agogdb: try to load libthread_db only after reading all shared libraries when attaching...
Simon Marchi [Tue, 8 Jun 2021 20:50:53 +0000 (16:50 -0400)] 
gdb: try to load libthread_db only after reading all shared libraries when attaching / handling a fork child

When trying to attach to a pthread process on a Linux system with glibc 2.33,
we get:

    $ ./gdb -q -nx --data-directory=data-directory -p 1472010
    Attaching to process 1472010
    [New LWP 1472013]
    [New LWP 1472014]
    [New LWP 1472015]
    Error while reading shared library symbols for /usr/lib/libpthread.so.0:
    Cannot find user-level thread for LWP 1472015: generic error
    0x00007ffff6d3637f in poll () from /usr/lib/libc.so.6
    (gdb)

When attaching to a process (or handling a fork child, an operation very
similar to attaching), GDB reads the shared library list from the
process.  For each shared library (if "set auto-solib-add" is on), it
reads its symbols and calls the "new_objfile" observable.

The libthread-db code monitors this observable, and if it sees an
objfile named somewhat like "libpthread.so" go by, it tries to load
libthread_db.so in the GDB process itself.  libthread_db knows how to
navigate libpthread's data structures to get information about the
existing threads.

To locate these data structures, libthread_db calls ps_pglobal_lookup
(implemented in proc-service.c), passing in a symbol name and expecting
an address in return.

Before glibc 2.33, libthread_db always asked for symbols found in
libpthread.  There was no ordering problem: since we were always trying
to load libthread_db in reaction to processing libpthread (and reading
in its symbols) and libthread_db only asked symbols from libpthread, the
requested symbols could always be found.  Starting with glibc 2.33,
libthread_db now asks for a symbol name that can be found in
/lib/ld-linux-x86-64.so.2 (_rtld_global).  And the ordering in which GDB
reads the shared libraries from the inferior when attaching is
unfortunate, in that libpthread is processed before ld-linux.  So when
loading libthread_db in reaction to processing libpthread, and
libthread_db requests the symbol that is from ld-linux, GDB is not yet
able to supply it.

That problematic symbol lookup happens in the thread_from_lwp function,
when we call td_ta_map_lwp2thr_p, and an exception is thrown at this
point:

    #0  0x00007ffff6681012 in __cxxabiv1::__cxa_throw (obj=0x60e000006100, tinfo=0x555560033b50 <typeinfo for gdb_exception_error>, dest=0x55555d9404bc <gdb_exception_error::~gdb_exception_error()>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:78
    #1  0x000055555e5d3734 in throw_it(return_reason, errors, const char *, typedef __va_list_tag __va_list_tag *) (reason=RETURN_ERROR, error=GENERIC_ERROR, fmt=0x55555f0c5360 "Cannot find user-level thread for LWP %ld: %s", ap=0x7fffffffaae0) at /home/simark/src/binutils-gdb/gdbsupport/common-exceptions.cc:200
    #2  0x000055555e5d37d4 in throw_verror (error=GENERIC_ERROR, fmt=0x55555f0c5360 "Cannot find user-level thread for LWP %ld: %s", ap=0x7fffffffaae0) at /home/simark/src/binutils-gdb/gdbsupport/common-exceptions.cc:208
    #3  0x000055555e0b0ed2 in verror (string=0x55555f0c5360 "Cannot find user-level thread for LWP %ld: %s", args=0x7fffffffaae0) at /home/simark/src/binutils-gdb/gdb/utils.c:171
    #4  0x000055555e5e898a in error (fmt=0x55555f0c5360 "Cannot find user-level thread for LWP %ld: %s") at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:43
    #5  0x000055555d06b4bc in thread_from_lwp (stopped=0x617000035d80, ptid=...) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:418
    #6  0x000055555d07040d in try_thread_db_load_1 (info=0x60c000011140) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:912
    #7  0x000055555d071103 in try_thread_db_load (library=0x55555f0c62a0 "libthread_db.so.1", check_auto_load_safe=false) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1014
    #8  0x000055555d072168 in try_thread_db_load_from_sdir () at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1091
    #9  0x000055555d072d1c in thread_db_load_search () at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1146
    #10 0x000055555d07365c in thread_db_load () at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1203
    #11 0x000055555d07373e in check_for_thread_db () at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1246
    #12 0x000055555d0738ab in thread_db_new_objfile (objfile=0x61300000c0c0) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1275
    #13 0x000055555bd10740 in std::__invoke_impl<void, void (*&)(objfile*), objfile*> (__f=@0x616000068d88: 0x55555d073745 <thread_db_new_objfile(objfile*)>) at /usr/include/c++/10.2.0/bits/invoke.h:60
    #14 0x000055555bd02096 in std::__invoke_r<void, void (*&)(objfile*), objfile*> (__fn=@0x616000068d88: 0x55555d073745 <thread_db_new_objfile(objfile*)>) at /usr/include/c++/10.2.0/bits/invoke.h:153
    #15 0x000055555bce0392 in std::_Function_handler<void (objfile*), void (*)(objfile*)>::_M_invoke(std::_Any_data const&, objfile*&&) (__functor=..., __args#0=@0x7fffffffb4a0: 0x61300000c0c0) at /usr/include/c++/10.2.0/bits/std_function.h:291
    #16 0x000055555d3595c0 in std::function<void (objfile*)>::operator()(objfile*) const (this=0x616000068d88, __args#0=0x61300000c0c0) at /usr/include/c++/10.2.0/bits/std_function.h:622
    #17 0x000055555d356b7f in gdb::observers::observable<objfile*>::notify (this=0x555566727020 <gdb::observers::new_objfile>, args#0=0x61300000c0c0) at /home/simark/src/binutils-gdb/gdb/../gdbsupport/observable.h:106
    #18 0x000055555da3f228 in symbol_file_add_with_addrs (abfd=0x61200001ccc0, name=0x6190000d9090 "/usr/lib/libpthread.so.0", add_flags=..., addrs=0x7fffffffbc10, flags=..., parent=0x0) at /home/simark/src/binutils-gdb/gdb/symfile.c:1131
    #19 0x000055555da3f763 in symbol_file_add_from_bfd (abfd=0x61200001ccc0, name=0x6190000d9090 "/usr/lib/libpthread.so.0", add_flags=<error reading variable: Cannot access memory at address 0xffffffffffffffb0>, addrs=0x7fffffffbc10, flags=<error reading variable: Cannot access memory at address 0xffffffffffffffc0>, parent=0x0) at /home/simark/src/binutils-gdb/gdb/symfile.c:1167
    #20 0x000055555d95f9fa in solib_read_symbols (so=0x6190000d8e80, flags=...) at /home/simark/src/binutils-gdb/gdb/solib.c:681
    #21 0x000055555d96233d in solib_add (pattern=0x0, from_tty=0, readsyms=1) at /home/simark/src/binutils-gdb/gdb/solib.c:987
    #22 0x000055555d93646e in enable_break (info=0x608000008f20, from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib-svr4.c:2238
    #23 0x000055555d93cfc0 in svr4_solib_create_inferior_hook (from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib-svr4.c:3049
    #24 0x000055555d96610d in solib_create_inferior_hook (from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib.c:1195
    #25 0x000055555cdee318 in post_create_inferior (from_tty=0) at /home/simark/src/binutils-gdb/gdb/infcmd.c:318
    #26 0x000055555ce00e6e in setup_inferior (from_tty=0) at /home/simark/src/binutils-gdb/gdb/infcmd.c:2439
    #27 0x000055555ce59c34 in handle_one (event=...) at /home/simark/src/binutils-gdb/gdb/infrun.c:4887
    #28 0x000055555ce5cd00 in stop_all_threads () at /home/simark/src/binutils-gdb/gdb/infrun.c:5064
    #29 0x000055555ce7f0da in stop_waiting (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:8006
    #30 0x000055555ce67f5c in handle_signal_stop (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:6062
    #31 0x000055555ce63653 in handle_inferior_event (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:5727
    #32 0x000055555ce4f297 in fetch_inferior_event () at /home/simark/src/binutils-gdb/gdb/infrun.c:4105
    #33 0x000055555cdbe3bf in inferior_event_handler (event_type=INF_REG_EVENT) at /home/simark/src/binutils-gdb/gdb/inf-loop.c:42
    #34 0x000055555d018047 in handle_target_event (error=0, client_data=0x0) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:4060
    #35 0x000055555e5ea77e in handle_file_event (file_ptr=0x60600008b1c0, ready_mask=1) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:575
    #36 0x000055555e5eb09c in gdb_wait_for_event (block=0) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:701
    #37 0x000055555e5e8d19 in gdb_do_one_event () at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:212
    #38 0x000055555dd6e0d4 in wait_sync_command_done () at /home/simark/src/binutils-gdb/gdb/top.c:528
    #39 0x000055555dd6e372 in maybe_wait_sync_command_done (was_sync=0) at /home/simark/src/binutils-gdb/gdb/top.c:545
    #40 0x000055555d0ec7c8 in catch_command_errors (command=0x55555ce01bb8 <attach_command(char const*, int)>, arg=0x7fffffffe28d "1472010", from_tty=1, do_bp_actions=false) at /home/simark/src/binutils-gdb/gdb/main.c:452
    #41 0x000055555d0f03ad in captured_main_1 (context=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1149
    #42 0x000055555d0f1239 in captured_main (data=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1232
    #43 0x000055555d0f1315 in gdb_main (args=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1257
    #44 0x000055555bb70cf9 in main (argc=7, argv=0x7fffffffde88) at /home/simark/src/binutils-gdb/gdb/gdb.c:32

The exception is caught here:

    #0  __cxxabiv1::__cxa_begin_catch (exc_obj_in=0x60e0000060e0) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_catch.cc:84
    #1  0x000055555d95fded in solib_read_symbols (so=0x6190000d8e80, flags=...) at /home/simark/src/binutils-gdb/gdb/solib.c:689
    #2  0x000055555d96233d in solib_add (pattern=0x0, from_tty=0, readsyms=1) at /home/simark/src/binutils-gdb/gdb/solib.c:987
    #3  0x000055555d93646e in enable_break (info=0x608000008f20, from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib-svr4.c:2238
    #4  0x000055555d93cfc0 in svr4_solib_create_inferior_hook (from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib-svr4.c:3049
    #5  0x000055555d96610d in solib_create_inferior_hook (from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib.c:1195
    #6  0x000055555cdee318 in post_create_inferior (from_tty=0) at /home/simark/src/binutils-gdb/gdb/infcmd.c:318
    #7  0x000055555ce00e6e in setup_inferior (from_tty=0) at /home/simark/src/binutils-gdb/gdb/infcmd.c:2439
    #8  0x000055555ce59c34 in handle_one (event=...) at /home/simark/src/binutils-gdb/gdb/infrun.c:4887
    #9  0x000055555ce5cd00 in stop_all_threads () at /home/simark/src/binutils-gdb/gdb/infrun.c:5064
    #10 0x000055555ce7f0da in stop_waiting (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:8006
    #11 0x000055555ce67f5c in handle_signal_stop (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:6062
    #12 0x000055555ce63653 in handle_inferior_event (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:5727
    #13 0x000055555ce4f297 in fetch_inferior_event () at /home/simark/src/binutils-gdb/gdb/infrun.c:4105
    #14 0x000055555cdbe3bf in inferior_event_handler (event_type=INF_REG_EVENT) at /home/simark/src/binutils-gdb/gdb/inf-loop.c:42
    #15 0x000055555d018047 in handle_target_event (error=0, client_data=0x0) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:4060
    #16 0x000055555e5ea77e in handle_file_event (file_ptr=0x60600008b1c0, ready_mask=1) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:575
    #17 0x000055555e5eb09c in gdb_wait_for_event (block=0) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:701
    #18 0x000055555e5e8d19 in gdb_do_one_event () at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:212
    #19 0x000055555dd6e0d4 in wait_sync_command_done () at /home/simark/src/binutils-gdb/gdb/top.c:528
    #20 0x000055555dd6e372 in maybe_wait_sync_command_done (was_sync=0) at /home/simark/src/binutils-gdb/gdb/top.c:545
    #21 0x000055555d0ec7c8 in catch_command_errors (command=0x55555ce01bb8 <attach_command(char const*, int)>, arg=0x7fffffffe28d "1472010", from_tty=1, do_bp_actions=false) at /home/simark/src/binutils-gdb/gdb/main.c:452
    #22 0x000055555d0f03ad in captured_main_1 (context=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1149
    #23 0x000055555d0f1239 in captured_main (data=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1232
    #24 0x000055555d0f1315 in gdb_main (args=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1257
    #25 0x000055555bb70cf9 in main (argc=7, argv=0x7fffffffde88) at /home/simark/src/binutils-gdb/gdb/gdb.c:32

Catching the exception at this point means that the thread_db_info
object for this inferior will be left in place, despite the failure to
load libthread_db.  This means that there won't be further attempts at
loading libthread_db, because thread_db_load will think that
libthread_db is already loaded for this inferior and will always exit
early.  To fix this, add a try/catch around calling try_thread_db_load_1
in try_thread_db_load, such that if some exception is thrown while
trying to load libthread_db, we reset / delete the thread_db_info for
that inferior.  That alone makes attach work fine again, because
check_for_thread_db is called again in the thread_db_inferior_created
observer (that happens after we learned about all shared libraries and
their symbols), and libthread_db is successfully loaded then.

When attaching, I think that the inferior_created observer is a good
place to try to load libthread_db: it is called once everything has
stabilized, when we learned about all shared libraries.

The only problem then is that when we first try (and fail) to load
libthread_db, in reaction to learning about libpthread, we show this
warning:

    warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.

This is misleading, because we do succeed in loading it later.  So when
attaching, I think we shouldn't try to load libthread_db in reaction to
the new_objfile events, we should wait until we have learned about all
shared libraries (using the inferior_created observable).  To do so, add
an `in_initial_library_scan` flag to struct inferior.  This flag is used
to postpone loading libthread_db if we are attaching or handling a fork
child.

When debugging remotely with GDBserver, the same problem happens, except
that the qSymbol mechanism (allowing the remote side to ask GDB for
symbols values) is involved.  The fix there is the same idea, we make
GDB wait until all shared libraries and their symbols are known before
sending out a qSymbol packet.  This way, we never present the remote
side a state where libpthread.so's symbols are known but ld-linux's
symbols aren't.

gdb/ChangeLog:

* inferior.h (class inferior) <in_initial_library_scan>: New.
* infcmd.c (post_create_inferior): Set in_initial_library_scan.
* infrun.c (follow_fork_inferior): Likewise.
* linux-thread-db.c (try_thread_db_load): Catch exception thrown
by try_thread_db_load_1
(thread_db_load): Return early if in_initial_library_scan is
set.
* remote.c (remote_new_objfile): Return early if
in_initial_library_scan is set.

Change-Id: I7a279836cfbb2b362b4fde11b196b4aab82f5efb

4 years agobfd/elf: Don't read non-existing secondary relocs
Michael Matz [Tue, 8 Jun 2021 15:39:02 +0000 (17:39 +0200)] 
bfd/elf: Don't read non-existing secondary relocs

I forgot the ChangeLog commit :-/

4 years ago[gdb/testsuite] Disallow single argument in multi_line
Tom de Vries [Tue, 8 Jun 2021 15:39:05 +0000 (17:39 +0200)] 
[gdb/testsuite] Disallow single argument in multi_line

It's a common mistake of mine to do:
...
set l [list "foo" "bar"]
set re [multi_line $l]
...
and to get "foo bar" while I was expecting "foo\r\nbar", which I get after
doing instead:
...
set re [multi_line {*}$l]
...

Detect this type of mistake by erroring out in multi_line when only one
argument is passed.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-08  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (multi_line): Require more than one argument.
* gdb.base/gdbinit-history.exp: Update multi_line call.
* gdb.base/jit-reader.exp: Remove multi_line call.
* gdb.fortran/dynamic-ptype-whatis.exp: Same.

4 years agobfd/elf: Don't read non-existing secondary relocs
Michael Matz [Mon, 7 Jun 2021 13:52:31 +0000 (15:52 +0200)] 
bfd/elf: Don't read non-existing secondary relocs

Without this we unconditionally try to slurp in secondary
relocs for each input section, leading to quadratic behaviour
even for strip(1).  On write-out we already used a flag to avoid
this.

So track existence of secondary relocs on read-in as well and
only slurp in when needed.  This still doesn't implement a proper
list of secondary reloc sections, and still would exhibit quadratic
behaviour if most input sections have a secondary reloc section.
But at least on normal input this avoids any slowdown from trying
to handle secondary relocation sections.

bfd/
* elf.c (bfd_section_from_shdr): Set has_secondary_relocs flag.
(_bfd_elf_slurp_secondary_reloc_section): Use it for early-out.

4 years ago[gdb/testsuite] Fix gdb.base/info-macros.exp with check-read1
Tom de Vries [Tue, 8 Jun 2021 13:36:46 +0000 (15:36 +0200)] 
[gdb/testsuite] Fix gdb.base/info-macros.exp with check-read1

With check-read1 we run into:
...
FAIL: gdb.base/info-macros.exp: info macros info-macros.c:42 (timeout)
...

Fix this by using gdb_test_lines from gdb.base/info-types.exp.tcl.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-08  Tom de Vries  <tdevries@suse.de>

* gdb.base/info-types.exp.tcl (match_line, gdb_test_lines): Move ...
* lib/gdb.exp: ... here.
* gdb.base/info-macros.exp: Use gdb_test_lines.

4 years ago[gdb/testsuite] Simplify gdb.base/info-types.exp.tcl further
Tom de Vries [Tue, 8 Jun 2021 13:36:46 +0000 (15:36 +0200)] 
[gdb/testsuite] Simplify gdb.base/info-types.exp.tcl further

After adding support for --any in match_line, we can simplify
gdb.base/info-types.exp.tcl further: we can add the "All defined types:"
regexp in the output_lines list:
...
        set output_lines \
            [list \
+                "All defined types:" \
+                "--any" \
                 $file_re \
...

Consequently, we can simplify the state machine to track a variable "found"
with values:
-  0 (unmatched)
-  1 (matched)
- -1 (mismatch).

This makes the code generic enough to factor out into a new proc
gdb_test_lines.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-08  Tom de Vries  <tdevries@suse.de>

* gdb.base/info-types.exp.tcl (match_line): Handle --any.
(gdb_test_lines): Factor out of ...
(run_test): ... here.

4 years agox86: cover a.out in recently added tests
Jan Beulich [Tue, 8 Jun 2021 12:57:50 +0000 (14:57 +0200)] 
x86: cover a.out in recently added tests

Follow the pattern found elsewhere when relocations are involved. For
wrap32-data also drop a mistakenly left "ELF" from the test name. (Note
that Darwin, for which the wrap32 tests are also failing, is left as-is,
for there being numerous other failures already anyway, and it hence
being questionable whether that target is actually properly maintained.)

4 years agox86: minor improvements to optimize_imm() (part II)
Jan Beulich [Tue, 8 Jun 2021 12:57:18 +0000 (14:57 +0200)] 
x86: minor improvements to optimize_imm() (part II)

Don't kind-of-open-code fits_in_unsigned_{word,long}().

4 years agox86: minor improvements to optimize_disp() (part II)
Jan Beulich [Tue, 8 Jun 2021 12:56:39 +0000 (14:56 +0200)] 
x86: minor improvements to optimize_disp() (part II)

- Don't kind-of-open-code fits_in_unsigned_{word,long}().
- Fold two if()s both using fits_in_unsigned_long().

4 years agox86-64: avoid bogus warnings with 32-bit addressing
Jan Beulich [Tue, 8 Jun 2021 12:55:56 +0000 (14:55 +0200)] 
x86-64: avoid bogus warnings with 32-bit addressing

With optimize_disp() adjusting i.types[].bitfield.disp after adjusting
the value to be used as displacement, it better also stores the updated
value, to avoid subsequent "... shortened to ..." warnings. Note how
optimize_imm() already does so.

The -0xffffffff tests being added expose a separate issue: The encoding
chosen should be 1 for ModR/M.mod, not 2. This will want to be taken
care of, but not right here.

This at the same time addresses a similar warning and demonstrates a
similar encoding issue with 16-bit addressing. Since it was omitted
when introducing the lea16-optimize test, add a plain lea16 one to also
cover this.

4 years agox86: minor improvements to optimize_disp() (part I)
Jan Beulich [Tue, 8 Jun 2021 12:54:48 +0000 (14:54 +0200)] 
x86: minor improvements to optimize_disp() (part I)

- Do the zero checking first - there's no point in doing anything else
  in this case.
- Drop two pointless & where just before it was checked that the
  respective bits are clear already anyway.

4 years ago[gdb/testsuite] Fix gdb.base/batch-preserve-term-settings.exp with check-read1
Tom de Vries [Tue, 8 Jun 2021 12:50:45 +0000 (14:50 +0200)] 
[gdb/testsuite] Fix gdb.base/batch-preserve-term-settings.exp with check-read1

With check-read1, I run into:
...
FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: \
  terminal settings preserved
...

This is caused by spawn_shell matching too little output, after which
things start to go out of sync.

More specifically, the regexp:
...
       -re "PS1=\[^\r\n\]*\r\n.*$shell_prompt_re$" {
...
matches the first and part of the second line of this output:
...
PS1="gdb-subshell$ "^M
sh-4.4$ PS1="gdb-subshell$ "^M
gdb-subshell$
...
while it's supposed to match the entire output.

Fix this by splitting up the regexp into a part that skips the lines with PS1,
and one that reads the shell prompt.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-08  Tom de Vries  <tdevries@suse.de>

* gdb.base/batch-preserve-term-settings.exp (spawn_shell): Fix
matching of initial prompt.

4 years ago[gdb/testsuite] Fix gdb.threads/multi-create-ns-info-thr.exp
Tom de Vries [Tue, 8 Jun 2021 08:04:44 +0000 (10:04 +0200)] 
[gdb/testsuite] Fix gdb.threads/multi-create-ns-info-thr.exp

With a testsuite setup modified to make expect wait a little bit longer for
gdb output (see PR27957), I reliably run into:
...
PASS: gdb.threads/multi-create-ns-info-thr.exp: continue to breakpoint 1
FAIL: gdb.threads/multi-create-ns-info-thr.exp: continue to breakpoint 2 \
  (timeout)
...

This is due to this regexp:
...
       -re "Breakpoint $decimal,.*$srcfile:$bp_location1" {
...
consuming several lines using the ".*" part, while it's intended to match one
line looking like this:
...
Thread 1 "multi-create-ns" hit Breakpoint 2, create_function () \
  at multi-create.c:45^M
...

Fix this by limiting the regexp to one line.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-08  Tom de Vries  <tdevries@suse.de>

* gdb.threads/multi-create-ns-info-thr.exp: Limit breakpoint regexp to
one line.

4 years ago[gdb/testsuite] Simplify gdb.base/sect-cmd.exp
Tom de Vries [Tue, 8 Jun 2021 08:04:44 +0000 (10:04 +0200)] 
[gdb/testsuite] Simplify gdb.base/sect-cmd.exp

While looking at gdb.base/sect-cmd.exp, I noticed a few things that can be
simplified:
- use gdb_test instead of gdb_test_multiple
- use -wrap "" as regexp

Also, I noticed this:
...
           fail "$gdb_test_name, saw not found marker"
...
while our usual test naming scheme uses parentheses, like so:
...
           fail "$gdb_test_name (saw not found marker)"
...

Fix the test-name and do the simplifications.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-08  Tom de Vries  <tdevries@suse.de>

* gdb.base/sect-cmd.exp: Use gdb_test.  Use -wrap "".  Fix
test name.

4 years ago[gdb/testsuite] Fix gdb.base/sect-cmd.exp
Tom de Vries [Tue, 8 Jun 2021 08:04:44 +0000 (10:04 +0200)] 
[gdb/testsuite] Fix gdb.base/sect-cmd.exp

With a testsuite setup modified to make expect wait a little bit longer for
gdb output (see PR27957), I reliably run into:
...
(gdb) FAIL: gdb.base/sect-cmd.exp: set section .text to original \
  address (timeout)
...

The problem is a too greedy regexp:
...
       -re ".*$address1 \- $address2 is $section_name.*" {
...
which ends up consuming the gdb prompt with the terminating ".*".

Fix this by limiting the regexp to a single line.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-08  Tom de Vries  <tdevries@suse.de>

* gdb.base/sect-cmd.exp: Fix saw_section_address_line regexp.

4 years agosim: igen: harmonize tool variables
Mike Frysinger [Sat, 29 May 2021 17:34:38 +0000 (13:34 -0400)] 
sim: igen: harmonize tool variables

Separate the name of the igen program from the options used to run it.
This allows us to avoid duplicating ../igen/igen in Makefiles and reuse
the existing setting in the common Makefile.  This also allows us to
easily harmonize the use of EXEEXT between igen/local.mk and the common
makefiles when cross-compiling for e.g. Windows.

4 years agognulib: import select
Mike Frysinger [Sat, 29 May 2021 16:55:39 +0000 (12:55 -0400)] 
gnulib: import select

A few sims use this to emulate the syscall & provide network
functionality.

4 years agognulib: import netdb
Mike Frysinger [Sat, 29 May 2021 16:48:49 +0000 (12:48 -0400)] 
gnulib: import netdb

A few sims use this to provide network functionality.

4 years agosim: v850: assume chown is available
Mike Frysinger [Sat, 29 May 2021 16:47:59 +0000 (12:47 -0400)] 
sim: v850: assume chown is available

Now that gnulib provides a wrapper, assume it always exists.

4 years agognulib: import chown
Mike Frysinger [Sat, 29 May 2021 16:10:38 +0000 (12:10 -0400)] 
gnulib: import chown

A few sims use this to emulate chown syscalls.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 8 Jun 2021 00:00:41 +0000 (00:00 +0000)] 
Automatic date update in version.in