Compare commits

...

249 Commits

Author SHA1 Message Date
GDB Administrator
a4418a9c6f Automatic date update in version.in 2022-12-18 00:02:02 +00:00
GDB Administrator
bd499e7e64 Automatic date update in version.in 2022-12-17 00:01:34 +00:00
GDB Administrator
060ea40670 Automatic date update in version.in 2022-12-16 00:01:30 +00:00
GDB Administrator
827a303bfd Automatic date update in version.in 2022-12-15 00:01:59 +00:00
GDB Administrator
d14c822f09 Automatic date update in version.in 2022-12-14 00:08:31 +00:00
GDB Administrator
63ba84b864 Automatic date update in version.in 2022-12-13 00:01:17 +00:00
GDB Administrator
e4594519f2 Automatic date update in version.in 2022-12-12 00:01:08 +00:00
GDB Administrator
0ac0e85243 Automatic date update in version.in 2022-12-11 00:00:52 +00:00
GDB Administrator
ed9b90db51 Automatic date update in version.in 2022-12-10 00:01:26 +00:00
GDB Administrator
3f7f5a866f Automatic date update in version.in 2022-12-09 00:02:27 +00:00
GDB Administrator
5af1bbb8c0 Automatic date update in version.in 2022-12-08 00:00:59 +00:00
GDB Administrator
3bbf1d7c22 Automatic date update in version.in 2022-12-07 00:01:24 +00:00
GDB Administrator
4369e04787 Automatic date update in version.in 2022-12-06 00:01:01 +00:00
GDB Administrator
b7bbae0ac3 Automatic date update in version.in 2022-12-05 00:00:47 +00:00
GDB Administrator
287094e02d Automatic date update in version.in 2022-12-04 00:01:15 +00:00
GDB Administrator
2269e714cc Automatic date update in version.in 2022-12-03 00:01:09 +00:00
GDB Administrator
017aa4a1e9 Automatic date update in version.in 2022-12-02 00:01:18 +00:00
Simon Marchi
1aefce82fd gdb: disable commit resumed in target_kill
New in this version:

 - Better comment in target_kill
 - Uncomment line in test to avoid hanging when exiting, when testing on
   native-extended-gdbserver

PR 28275 shows that doing a sequence of:

 - Run inferior in background (run &)
 - kill that inferior
 - Run again

We get into this assertion:

    /home/smarchi/src/binutils-gdb/gdb/target.c:2590: internal-error: target_wait: Assertion `!proc_target->commit_resumed_state' failed.

    #0  internal_error_loc (file=0x5606b344e740 "/home/smarchi/src/binutils-gdb/gdb/target.c", line=2590, fmt=0x5606b344d6a0 "%s: Assertion `%s' failed.") at /home/smarchi/src/binutils-gdb/gdbsupport/errors.cc:54
    #1  0x00005606b6296475 in target_wait (ptid=..., status=0x7fffb9390630, options=...) at /home/smarchi/src/binutils-gdb/gdb/target.c:2590
    #2  0x00005606b5767a98 in startup_inferior (proc_target=0x5606bfccb2a0 <the_amd64_linux_nat_target>, pid=3884857, ntraps=1, last_waitstatus=0x0, last_ptid=0x0) at /home/smarchi/src/binutils-gdb/gdb/nat/fork-inferior.c:482
    #3  0x00005606b4e6c9c5 in gdb_startup_inferior (pid=3884857, num_traps=1) at /home/smarchi/src/binutils-gdb/gdb/fork-child.c:132
    #4  0x00005606b50f14a5 in inf_ptrace_target::create_inferior (this=0x5606bfccb2a0 <the_amd64_linux_nat_target>, exec_file=0x604000039f50 "/home/smarchi/build/binutils-gdb/gdb/test", allargs="", env=0x61500000a580, from_tty=1)
        at /home/smarchi/src/binutils-gdb/gdb/inf-ptrace.c:105
    #5  0x00005606b53b6d23 in linux_nat_target::create_inferior (this=0x5606bfccb2a0 <the_amd64_linux_nat_target>, exec_file=0x604000039f50 "/home/smarchi/build/binutils-gdb/gdb/test", allargs="", env=0x61500000a580, from_tty=1)
        at /home/smarchi/src/binutils-gdb/gdb/linux-nat.c:978
    #6  0x00005606b512b79b in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at /home/smarchi/src/binutils-gdb/gdb/infcmd.c:468
    #7  0x00005606b512c236 in run_command (args=0x0, from_tty=1) at /home/smarchi/src/binutils-gdb/gdb/infcmd.c:526

When running the kill command, commit_resumed_state for the
process_stratum_target (linux-nat, here) is true.  After the kill, when
there are no more threads, commit_resumed_state is still true, as
nothing touches this flag during the kill operation.  During the
subsequent run command, run_command_1 does:

    scoped_disable_commit_resumed disable_commit_resumed ("running");

We would think that this would clear the commit_resumed_state flag of
our native target, but that's not the case, because
scoped_disable_commit_resumed iterates on non-exited inferiors in order
to find active process targets.  And after the kill, the inferior is
exited, and the native target was unpushed from it anyway.  So
scoped_disable_commit_resumed doesn't touch the commit_resumed_state
flag of the native target, it stays true.  When reaching target_wait, in
startup_inferior (to consume the initial expect stop events while the
inferior is starting up and working its way through the shell),
commit_resumed_state is true, breaking the contract saying that
commit_resumed_state is always false when calling the targets' wait
method.

(note: to be correct, I think that startup_inferior should toggle
commit_resumed between the target_wait and target_resume calls, but I'll
ignore that for now)

I can see multiple ways to fix this.  In the end, we need
commit_resumed_state to be cleared by the time we get to that
target_wait.  It could be done at the end of the kill command, or at the
beginning of the run command.

To keep things in a coherent state, I'd like to make it so that after
the kill command, when the target is left with no threads, its
commit_resumed_state flag is left to false.  This way, we can keep
working with the assumption that a target with no threads (and therefore
no running threads) has commit_resumed_state == false.

Do this by adding a scoped_disable_commit_resumed in target_kill.  It
clears the target's commit_resumed_state on entry, and leaves it false
if the target does not have any resumed thread on exit.  That means,
even if the target has another inferior with stopped threads,
commit_resumed_state will be left to false, which makes sense.

Add a test that tries to cover various combinations of actions done
while an inferior is running (and therefore while commit_resumed_state
is true on the process target).

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28275
Change-Id: I8e6fe6dc1f475055921520e58cab68024039a1e9
Approved-By: Andrew Burgess <aburgess@redhat.com>
2022-12-01 10:01:43 -05:00
Simon Marchi
8c28fd36e9 gdbserver: switch to right process in find_one_thread
New in this version: add a dedicated test.

When I do this:

    $ ./gdb -nx --data-directory=data-directory -q \
        /bin/sleep \
	-ex "maint set target-non-stop on" \
	-ex "tar ext :1234" \
	-ex "set remote exec-file /bin/sleep" \
	-ex "run 1231 &" \
	-ex add-inferior \
	-ex "inferior 2"
    Reading symbols from /bin/sleep...
    (No debugging symbols found in /bin/sleep)
    Remote debugging using :1234
    Starting program: /bin/sleep 1231
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    Reading /usr/lib/debug/.build-id/a6/7a1408f18db3576757eea210d07ba3fc560dff.debug from remote target...
    [New inferior 2]
    Added inferior 2 on connection 1 (extended-remote :1234)
    [Switching to inferior 2 [<null>] (<noexec>)]
    (gdb) Reading /lib/x86_64-linux-gnu/libc.so.6 from remote target...
    attach 3659848
    Attaching to process 3659848
    /home/smarchi/src/binutils-gdb/gdb/thread.c:85: internal-error: inferior_thread: Assertion `current_thread_ != nullptr' failed.

Note the "attach" command just above.  When doing it on the command-line
with a -ex switch, the bug doesn't trigger.

The internal error of GDB is actually caused by GDBserver crashing, and
the error recovery of GDB is not on point.  This patch aims to fix just
the GDBserver crash, not the GDB problem.

GDBserver crashes with a segfault here:

    (gdb) bt
    #0  0x00005555557fb3f4 in find_one_thread (ptid=...) at /home/smarchi/src/binutils-gdb/gdbserver/thread-db.cc:177
    #1  0x00005555557fd5cf in thread_db_thread_handle (ptid=<error reading variable: Cannot access memory at address 0xffffffffffffffa0>, handle=0x7fffffffc400, handle_len=0x7fffffffc3f0)
        at /home/smarchi/src/binutils-gdb/gdbserver/thread-db.cc:461
    #2  0x000055555578a0b6 in linux_process_target::thread_handle (this=0x5555558a64c0 <the_x86_target>, ptid=<error reading variable: Cannot access memory at address 0xffffffffffffffa0>, handle=0x7fffffffc400,
        handle_len=0x7fffffffc3f0) at /home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:6905
    #3  0x00005555556dfcc6 in handle_qxfer_threads_worker (thread=0x60b000000510, buffer=0x7fffffffc8a0) at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:1645
    #4  0x00005555556e00e6 in operator() (__closure=0x7fffffffc5e0, thread=0x60b000000510) at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:1696
    #5  0x00005555556f54be in for_each_thread<handle_qxfer_threads_proper(buffer*)::<lambda(thread_info*)> >(struct {...}) (func=...) at /home/smarchi/src/binutils-gdb/gdbserver/gdbthread.h:159
    #6  0x00005555556e0242 in handle_qxfer_threads_proper (buffer=0x7fffffffc8a0) at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:1694
    #7  0x00005555556e04ba in handle_qxfer_threads (annex=0x629000000213 "", readbuf=0x621000019100 '\276' <repeats 200 times>..., writebuf=0x0, offset=0, len=4097)
        at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:1732
    #8  0x00005555556e1989 in handle_qxfer (own_buf=0x629000000200 "qXfer:threads", packet_len=26, new_packet_len_p=0x7fffffffd630) at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:2045
    #9  0x00005555556e720a in handle_query (own_buf=0x629000000200 "qXfer:threads", packet_len=26, new_packet_len_p=0x7fffffffd630) at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:2685
    #10 0x00005555556f1a01 in process_serial_event () at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:4176
    #11 0x00005555556f4457 in handle_serial_event (err=0, client_data=0x0) at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:4514
    #12 0x0000555555820f56 in handle_file_event (file_ptr=0x607000000250, ready_mask=1) at /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:573
    #13 0x0000555555821895 in gdb_wait_for_event (block=1) at /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:694
    #14 0x000055555581f533 in gdb_do_one_event (mstimeout=-1) at /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:264
    #15 0x00005555556ec9fb in start_event_loop () at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:3512
    #16 0x00005555556f0769 in captured_main (argc=4, argv=0x7fffffffe0d8) at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:3992
    #17 0x00005555556f0e3f in main (argc=4, argv=0x7fffffffe0d8) at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:4078

The reason is a wrong current process when find_one_thread is called.
The current process is the 2nd one, which was just attached.  It does
not yet have thread_db data (proc->priv->thread_db is nullptr).  As we
iterate on all threads of all process to fulfull the qxfer:threads:read
request, we get to a thread of process 1 for which we haven't read
thread_db information yet (lwp_info::thread_known is false), so we get
into find_one_thread.  find_one_thread uses
`current_process ()->priv->thread_db`, assuming the current process
matches the ptid passed as a parameter, which is wrong.  A segfault
happens when trying to dereference that thread_db pointer.

Fix this by making find_one_thread not assume what the current process /
current thread is.  If it needs to call into libthread_db, which we know
will try to read memory from the current process, then temporarily set
the current process.

In the case where the thread is already know and we return early, we
don't need to switch process.

Add a test to reproduce this specific situation.

Change-Id: I09b00883e8b73b7e5f89d0f47cb4e9c0f3d6caaa
Approved-By: Andrew Burgess <aburgess@redhat.com>
2022-12-01 10:01:43 -05:00
Andrew Burgess
0fd7bbc901 gdb: fix assert when quitting GDB while a thread is stepping
This commit addresses one of the issues identified in PR gdb/28275.

Bug gdb/28275 identifies a number of situations in which this assert:

  Assertion `!proc_target->commit_resumed_state' failed.

could be triggered.  There's actually a number of similar places where
this assert is found in GDB, the two of interest in gdb/28275 are in
target_wait and target_stop.

In one of the comments:

  https://sourceware.org/bugzilla/show_bug.cgi?id=28275#c1

steps to trigger the assertion within target_stop were identified when
using a modified version of the gdb.threads/detach-step-over.exp test
script.

In the gdb.threads/detach-step-over.exp test, we attach to a
multi-threaded inferior, and continue the inferior in asynchronous
(background) mode.  Each thread is continuously hitting a conditional
breakpoint where the condition is always false.  While the inferior is
running we detach.  The goal is that we detach while GDB is performing a
step-over for the conditional breakpoint in at least one thread.

While detaching, if a step-over is in progress, then GDB has to
complete the step over before we can detach.  This involves calling
target_stop and target_wait (see prepare_for_detach).

As far as gdb/28275 is concerned, the interesting part here, is the
the process_stratum_target::commit_resumed_state variable must be
false when target_stop and target_wait are called.

This is currently ensured because, in detach_command (infrun.c), we
create an instance of scoped_disable_commit_resumed, this ensures that
when target_detach is called, ::commit_resumed_state will be false.

The modification to the test that I propose here, and which exposed
the bug, is that, instead of using "detach" to detach from the
inferior, we instead use "quit".  Quitting GDB after attaching to an
inferior will cause GDB to first detach, and then exit.

When we quit GDB we end up calling target_detach via a different code
path, the stack looks like:

  #0 target_detach
  #1 kill_or_detach
  #2 quit_force
  #3 quit_command

Along this path there is no scoped_disable_commit_resumed created.
::commit_resumed_state can be true when we reach prepare_for_detach,
which calls target_wait and target_stop, so the assertion will trigger.

In this commit, I propose fixing this by adding the creation of a
scoped_disable_commit_resumed into target_detach.  This will ensure
that ::commit_resumed_state is false when calling prepare_for_detach
from within target_detach.

I did consider placing the scoped_disable_commit_resumed in
prepare_for_detach, however, placing it in target_detach ensures that
the target's commit_resumed_state flag is left to false if the detached
inferior was the last one for that target.  It's the same rationale as
for patch "gdb: disable commit resumed in target_kill" that comes later
in this series, but for detach instead of kill.

detach_command still includes a scoped_disable_commit_resumed too, but I
think it is still relevant to cover the resumption at the end of the
function.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28275
Change-Id: Ie128f7aba6ef0e018859275eca372e6ea738e96f
2022-12-01 10:01:43 -05:00
Andrew Burgess
d35062e449 gdb/testsuite: refactor gdb.threads/detach-step-over.exp
Factor out some bits of gdb.threads/detach-step-over.exp to procs in
preparation to adding some new variations of the test.  Rename the
existing "test" proc and make it use proc_with_prefix.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ib4412545c81c8556029e0f7bfa9dd48d7a9f3189
2022-12-01 10:01:43 -05:00
Simon Marchi
af9f3d376e gdb/testsuite: remove global declarations in gdb.threads/detach-step-over.exp
Before doing further changes to this file, change to use the :: notation
instead of declaring global variables with the `global` keyword.

Change-Id: I72301fd8f4693fea61aac054ba17245a1f4442fb
Approved-By: Andrew Burgess <aburgess@redhat.com>
2022-12-01 10:01:43 -05:00
Tiezhu Yang
5091924da9 gdb: testsuite: add new gdb_attach to check "attach" command
This commit adds new gdb_attach to centralize the failure checking of
"attach" command. Return 0 if attach failed, otherwise return 1.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Change-Id: I553cf386cef60c67d38e331904b4aa01e132104a
2022-12-01 10:01:43 -05:00
GDB Administrator
e15378735d Automatic date update in version.in 2022-12-01 00:01:17 +00:00
GDB Administrator
1160e4820e Automatic date update in version.in 2022-11-30 00:01:24 +00:00
GDB Administrator
ab415edbe5 Automatic date update in version.in 2022-11-29 00:01:01 +00:00
GDB Administrator
64849597cd Automatic date update in version.in 2022-11-28 00:00:51 +00:00
GDB Administrator
b72f03e8d1 Automatic date update in version.in 2022-11-27 00:00:50 +00:00
GDB Administrator
b285c25a4c Automatic date update in version.in 2022-11-26 00:01:07 +00:00
GDB Administrator
948a94b341 Automatic date update in version.in 2022-11-25 00:01:12 +00:00
GDB Administrator
7c3c18ec17 Automatic date update in version.in 2022-11-24 00:01:46 +00:00
GDB Administrator
07008ecd59 Automatic date update in version.in 2022-11-23 00:01:23 +00:00
GDB Administrator
a406981ad4 Automatic date update in version.in 2022-11-22 00:00:57 +00:00
GDB Administrator
2e43daba15 Automatic date update in version.in 2022-11-21 00:01:15 +00:00
GDB Administrator
6aa09dec40 Automatic date update in version.in 2022-11-20 00:02:40 +00:00
GDB Administrator
bfd95a985f Automatic date update in version.in 2022-11-19 00:00:56 +00:00
GDB Administrator
f227993960 Automatic date update in version.in 2022-11-18 00:01:09 +00:00
GDB Administrator
7ba6dca126 Automatic date update in version.in 2022-11-17 00:01:15 +00:00
GDB Administrator
103403b7a6 Automatic date update in version.in 2022-11-16 00:00:46 +00:00
GDB Administrator
cfac150a9f Automatic date update in version.in 2022-11-15 00:01:05 +00:00
GDB Administrator
c9f1c82c99 Automatic date update in version.in 2022-11-14 00:01:07 +00:00
GDB Administrator
fba2722740 Automatic date update in version.in 2022-11-13 00:00:59 +00:00
GDB Administrator
e6fc732433 Automatic date update in version.in 2022-11-12 00:01:01 +00:00
GDB Administrator
d6e758a5f6 Automatic date update in version.in 2022-11-11 00:01:25 +00:00
GDB Administrator
7c9a9652ad Automatic date update in version.in 2022-11-10 00:00:52 +00:00
GDB Administrator
7d5f6667be Automatic date update in version.in 2022-11-09 00:00:58 +00:00
GDB Administrator
7785134302 Automatic date update in version.in 2022-11-08 00:01:28 +00:00
GDB Administrator
e2a06f322d Automatic date update in version.in 2022-11-07 00:01:04 +00:00
GDB Administrator
04e493a8f0 Automatic date update in version.in 2022-11-06 00:01:00 +00:00
GDB Administrator
01b6e375c8 Automatic date update in version.in 2022-11-05 00:01:02 +00:00
GDB Administrator
d980b7acc8 Automatic date update in version.in 2022-11-04 00:00:47 +00:00
GDB Administrator
bd23a7e40e Automatic date update in version.in 2022-11-03 00:00:30 +00:00
GDB Administrator
f04f3368ac Automatic date update in version.in 2022-11-02 00:00:36 +00:00
GDB Administrator
0895f52b6d Automatic date update in version.in 2022-11-01 00:00:41 +00:00
GDB Administrator
d95e9bbbc8 Automatic date update in version.in 2022-10-31 00:00:37 +00:00
GDB Administrator
632bc25920 Automatic date update in version.in 2022-10-30 00:00:38 +00:00
GDB Administrator
23293598d0 Automatic date update in version.in 2022-10-29 00:00:50 +00:00
GDB Administrator
4d8d9f983d Automatic date update in version.in 2022-10-28 00:00:30 +00:00
GDB Administrator
396b80c6f1 Automatic date update in version.in 2022-10-27 00:00:41 +00:00
GDB Administrator
b69d4c94ae Automatic date update in version.in 2022-10-26 00:00:45 +00:00
GDB Administrator
3b6cdc18fc Automatic date update in version.in 2022-10-25 00:00:36 +00:00
GDB Administrator
341f73897e Automatic date update in version.in 2022-10-24 00:00:38 +00:00
GDB Administrator
f023b86fc5 Automatic date update in version.in 2022-10-23 00:00:26 +00:00
GDB Administrator
9c437ad2a9 Automatic date update in version.in 2022-10-22 00:00:47 +00:00
GDB Administrator
9920e89237 Automatic date update in version.in 2022-10-21 00:00:21 +00:00
GDB Administrator
eab53d6ab8 Automatic date update in version.in 2022-10-20 00:00:41 +00:00
GDB Administrator
f6b4043b4e Automatic date update in version.in 2022-10-19 00:00:37 +00:00
GDB Administrator
ae72bcc22b Automatic date update in version.in 2022-10-18 00:00:24 +00:00
GDB Administrator
4ef1fd2346 Automatic date update in version.in 2022-10-17 00:00:40 +00:00
GDB Administrator
6dd3c48731 Automatic date update in version.in 2022-10-16 00:01:05 +00:00
GDB Administrator
2218307e9b Automatic date update in version.in 2022-10-15 00:01:01 +00:00
GDB Administrator
09f01041b9 Automatic date update in version.in 2022-10-14 00:01:22 +00:00
GDB Administrator
17112c08b7 Automatic date update in version.in 2022-10-13 00:01:11 +00:00
GDB Administrator
7bba87613e Automatic date update in version.in 2022-10-12 00:00:58 +00:00
GDB Administrator
b0ad857775 Automatic date update in version.in 2022-10-11 00:01:33 +00:00
GDB Administrator
81e1d654fe Automatic date update in version.in 2022-10-10 00:00:32 +00:00
GDB Administrator
ebbafc41ad Automatic date update in version.in 2022-10-09 00:00:37 +00:00
GDB Administrator
dbac5b57d8 Automatic date update in version.in 2022-10-08 00:00:30 +00:00
GDB Administrator
01c9cd44d7 Automatic date update in version.in 2022-10-07 00:00:39 +00:00
GDB Administrator
ce2cb0f4db Automatic date update in version.in 2022-10-06 00:01:04 +00:00
GDB Administrator
b61628002a Automatic date update in version.in 2022-10-05 00:01:05 +00:00
GDB Administrator
f3d9d5f097 Automatic date update in version.in 2022-10-04 00:00:38 +00:00
GDB Administrator
7b33812e1d Automatic date update in version.in 2022-10-03 00:00:31 +00:00
GDB Administrator
421440cf34 Automatic date update in version.in 2022-10-02 00:00:36 +00:00
GDB Administrator
1d83251910 Automatic date update in version.in 2022-10-01 00:00:37 +00:00
GDB Administrator
8a8906debf Automatic date update in version.in 2022-09-30 00:00:54 +00:00
GDB Administrator
cb6780e38d Automatic date update in version.in 2022-09-29 00:00:38 +00:00
GDB Administrator
a2add1757e Automatic date update in version.in 2022-09-28 00:00:51 +00:00
GDB Administrator
a26cd6a7d4 Automatic date update in version.in 2022-09-27 00:01:06 +00:00
GDB Administrator
5af45adfd2 Automatic date update in version.in 2022-09-26 00:00:30 +00:00
GDB Administrator
940941aa4c Automatic date update in version.in 2022-09-25 00:00:33 +00:00
GDB Administrator
91ce1797ed Automatic date update in version.in 2022-09-24 00:00:31 +00:00
GDB Administrator
a7662984b1 Automatic date update in version.in 2022-09-23 00:00:56 +00:00
GDB Administrator
eb5082d26e Automatic date update in version.in 2022-09-22 00:02:08 +00:00
GDB Administrator
eb9c4ec9ac Automatic date update in version.in 2022-09-21 00:00:35 +00:00
GDB Administrator
5807a31f6c Automatic date update in version.in 2022-09-20 00:00:33 +00:00
GDB Administrator
d2c5346b58 Automatic date update in version.in 2022-09-19 00:01:02 +00:00
GDB Administrator
623d7912d4 Automatic date update in version.in 2022-09-18 00:00:32 +00:00
GDB Administrator
ab8119af6f Automatic date update in version.in 2022-09-17 00:00:26 +00:00
GDB Administrator
2732a26ff7 Automatic date update in version.in 2022-09-16 00:00:27 +00:00
GDB Administrator
eb4889aa8f Automatic date update in version.in 2022-09-15 00:00:50 +00:00
GDB Administrator
7538cdd2bb Automatic date update in version.in 2022-09-14 00:00:37 +00:00
GDB Administrator
a1bb0c2286 Automatic date update in version.in 2022-09-13 00:00:39 +00:00
GDB Administrator
a433c55d7c Automatic date update in version.in 2022-09-12 00:00:26 +00:00
GDB Administrator
6f504ec469 Automatic date update in version.in 2022-09-11 00:00:25 +00:00
GDB Administrator
6a56aeaa62 Automatic date update in version.in 2022-09-10 00:00:35 +00:00
GDB Administrator
4622ac7547 Automatic date update in version.in 2022-09-09 00:00:40 +00:00
GDB Administrator
c7362d7e28 Automatic date update in version.in 2022-09-08 00:00:26 +00:00
GDB Administrator
053e1e630f Automatic date update in version.in 2022-09-07 00:00:24 +00:00
GDB Administrator
9d8655dd9e Automatic date update in version.in 2022-09-06 00:00:25 +00:00
GDB Administrator
3de16c3fef Automatic date update in version.in 2022-09-05 00:00:40 +00:00
GDB Administrator
5fc023ad2f Automatic date update in version.in 2022-09-04 00:00:20 +00:00
GDB Administrator
1cd80001f2 Automatic date update in version.in 2022-09-03 00:00:20 +00:00
GDB Administrator
093172f8cc Automatic date update in version.in 2022-09-02 00:00:35 +00:00
GDB Administrator
605cfdff4d Automatic date update in version.in 2022-09-01 00:00:26 +00:00
GDB Administrator
f343506ba0 Automatic date update in version.in 2022-08-31 00:00:21 +00:00
GDB Administrator
940ddfe84b Automatic date update in version.in 2022-08-30 00:00:43 +00:00
GDB Administrator
d2bf65bc01 Automatic date update in version.in 2022-08-29 00:00:38 +00:00
GDB Administrator
1e032d8e37 Automatic date update in version.in 2022-08-28 00:00:32 +00:00
GDB Administrator
66b16256c6 Automatic date update in version.in 2022-08-27 00:00:20 +00:00
GDB Administrator
be809566a4 Automatic date update in version.in 2022-08-26 00:00:26 +00:00
GDB Administrator
8386c80666 Automatic date update in version.in 2022-08-25 00:00:27 +00:00
GDB Administrator
c2ac354248 Automatic date update in version.in 2022-08-24 00:00:32 +00:00
GDB Administrator
18999431bd Automatic date update in version.in 2022-08-23 00:00:24 +00:00
GDB Administrator
2f7a8c5713 Automatic date update in version.in 2022-08-22 00:00:21 +00:00
GDB Administrator
593e6dbfa5 Automatic date update in version.in 2022-08-21 00:01:41 +00:00
GDB Administrator
475b809dc3 Automatic date update in version.in 2022-08-20 00:00:30 +00:00
GDB Administrator
bba7ae6c87 Automatic date update in version.in 2022-08-19 00:00:29 +00:00
GDB Administrator
8d64760955 Automatic date update in version.in 2022-08-18 00:00:29 +00:00
GDB Administrator
b381a5f0a0 Automatic date update in version.in 2022-08-17 00:00:43 +00:00
GDB Administrator
3bad6c0231 Automatic date update in version.in 2022-08-16 00:00:55 +00:00
GDB Administrator
60f562d852 Automatic date update in version.in 2022-08-15 00:00:36 +00:00
GDB Administrator
3db7a38804 Automatic date update in version.in 2022-08-14 00:00:34 +00:00
GDB Administrator
a9d4faaab1 Automatic date update in version.in 2022-08-13 00:00:19 +00:00
GDB Administrator
331fb99750 Automatic date update in version.in 2022-08-12 00:00:29 +00:00
GDB Administrator
31abca2bb0 Automatic date update in version.in 2022-08-11 00:00:43 +00:00
GDB Administrator
855ae71fe2 Automatic date update in version.in 2022-08-10 00:00:35 +00:00
GDB Administrator
c12d23e5f4 Automatic date update in version.in 2022-08-09 00:00:37 +00:00
GDB Administrator
5dae8d106f Automatic date update in version.in 2022-08-08 00:00:23 +00:00
GDB Administrator
655b22a054 Automatic date update in version.in 2022-08-07 00:00:36 +00:00
GDB Administrator
58fbf063b2 Automatic date update in version.in 2022-08-06 00:00:24 +00:00
GDB Administrator
8f4ecf37e0 Automatic date update in version.in 2022-08-05 00:00:29 +00:00
GDB Administrator
95b8a31afc Automatic date update in version.in 2022-08-04 00:00:32 +00:00
GDB Administrator
643f73257f Automatic date update in version.in 2022-08-03 00:00:29 +00:00
GDB Administrator
7f70cce769 Automatic date update in version.in 2022-08-02 00:00:31 +00:00
GDB Administrator
2c2a9c098c Automatic date update in version.in 2022-08-01 00:00:36 +00:00
GDB Administrator
4887c2b748 Automatic date update in version.in 2022-07-31 00:00:24 +00:00
GDB Administrator
aebe1b66b7 Automatic date update in version.in 2022-07-30 00:00:27 +00:00
GDB Administrator
eac484d883 Automatic date update in version.in 2022-07-29 00:00:32 +00:00
GDB Administrator
b8032fc585 Automatic date update in version.in 2022-07-28 00:00:37 +00:00
GDB Administrator
163a4d7cc7 Automatic date update in version.in 2022-07-27 00:00:46 +00:00
GDB Administrator
c3a9f79c8e Automatic date update in version.in 2022-07-26 00:00:21 +00:00
GDB Administrator
a47c713db8 Automatic date update in version.in 2022-07-25 00:00:32 +00:00
GDB Administrator
f0641f4e27 Automatic date update in version.in 2022-07-24 00:00:38 +00:00
GDB Administrator
56958fe98b Automatic date update in version.in 2022-07-23 00:00:41 +00:00
GDB Administrator
7491e9665e Automatic date update in version.in 2022-07-22 00:00:35 +00:00
GDB Administrator
f9b0582219 Automatic date update in version.in 2022-07-21 00:00:48 +00:00
GDB Administrator
28b7a50c23 Automatic date update in version.in 2022-07-20 00:00:36 +00:00
GDB Administrator
8fae712426 Automatic date update in version.in 2022-07-19 00:00:44 +00:00
GDB Administrator
d8edb0dee8 Automatic date update in version.in 2022-07-18 00:00:49 +00:00
GDB Administrator
e705ad3b71 Automatic date update in version.in 2022-07-17 00:00:31 +00:00
GDB Administrator
15696e4045 Automatic date update in version.in 2022-07-16 00:00:30 +00:00
GDB Administrator
d9bc750c92 Automatic date update in version.in 2022-07-15 00:00:50 +00:00
GDB Administrator
d528966466 Automatic date update in version.in 2022-07-14 00:00:33 +00:00
GDB Administrator
36b7043630 Automatic date update in version.in 2022-07-13 00:00:47 +00:00
GDB Administrator
54e3ab40ae Automatic date update in version.in 2022-07-12 00:00:45 +00:00
Pedro Alves
0fe74cb9ad Fix core-file -> detach -> crash (corefiles/29275)
After loading a core file, you're supposed to be able to use "detach"
to unload the core file.  That unfortunately regressed starting with
GDB 11, with these commits:

 1192f124a3 - gdb: generalize commit_resume, avoid commit-resuming when threads have pending statuses
 408f66864a - detach in all-stop with threads running

resulting in a GDB crash:

 ...
 Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
 0x0000555555e842bf in maybe_set_commit_resumed_all_targets () at ../../src/gdb/infrun.c:2899
 2899          if (proc_target->commit_resumed_state)
 (top-gdb) bt
 #0  0x0000555555e842bf in maybe_set_commit_resumed_all_targets () at ../../src/gdb/infrun.c:2899
 #1  0x0000555555e848bf in scoped_disable_commit_resumed::reset (this=0x7fffffffd440) at ../../src/gdb/infrun.c:3023
 #2  0x0000555555e84a0c in scoped_disable_commit_resumed::reset_and_commit (this=0x7fffffffd440) at ../../src/gdb/infrun.c:3049
 #3  0x0000555555e739cd in detach_command (args=0x0, from_tty=1) at ../../src/gdb/infcmd.c:2791
 #4  0x0000555555c0ba46 in do_simple_func (args=0x0, from_tty=1, c=0x55555662a600) at ../../src/gdb/cli/cli-decode.c:95
 #5  0x0000555555c112b0 in cmd_func (cmd=0x55555662a600, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:2514
 #6  0x0000555556173b1f in execute_command (p=0x5555565c5916 "", from_tty=1) at ../../src/gdb/top.c:699

The code that crashes looks like:

 static void
 maybe_set_commit_resumed_all_targets ()
 {
   scoped_restore_current_thread restore_thread;

   for (inferior *inf : all_non_exited_inferiors ())
     {
       process_stratum_target *proc_target = inf->process_target ();

       if (proc_target->commit_resumed_state)
           ^^^^^^^^^^^

With 'proc_target' above being null.  all_non_exited_inferiors filters
out inferiors that have pid==0.  We get here at the end of
detach_command, after core_target::detach has already run, at which
point the inferior _should_ have pid==0 and no process target.  It is
clear it no longer has a process target, but, it still has a pid!=0
somehow.

The reason the inferior still has pid!=0, is that core_target::detach
just unpushes, and relies on core_target::close to actually do the
getting rid of the core and exiting the inferior.  The problem with
that is that detach_command grabs an extra strong reference to the
process stratum target, so the unpush_target inside
core_target::detach doesn't actually result in a call to
core_target::close.

Fix this my moving the cleaning up the core inferior to a shared
routine called by both core_target::close and core_target::detach.  We
still need to cleanup the inferior from within core_file::close
because there are paths to it that want to get rid of the core without
going through detach.  E.g., "core-file" -> "run".

This commit includes a new test added to gdb.base/corefile.exp to
cover the "core-file core" -> "detach" scenario.

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

Change-Id: Ic42bdd03182166b19f598428b0dbc2ce6f67c893
2022-07-11 19:24:10 +01:00
GDB Administrator
5adafe7d8a Automatic date update in version.in 2022-07-11 00:00:39 +00:00
GDB Administrator
55357c09ee Automatic date update in version.in 2022-07-10 00:00:21 +00:00
GDB Administrator
89705e474d Automatic date update in version.in 2022-07-09 00:00:32 +00:00
GDB Administrator
69a63eee25 Automatic date update in version.in 2022-07-08 00:00:33 +00:00
GDB Administrator
14d8b4fb8d Automatic date update in version.in 2022-07-07 00:00:55 +00:00
GDB Administrator
46b5376f27 Automatic date update in version.in 2022-07-06 00:00:41 +00:00
GDB Administrator
176b5961ce Automatic date update in version.in 2022-07-05 00:00:57 +00:00
GDB Administrator
9c9114ea34 Automatic date update in version.in 2022-07-04 00:00:31 +00:00
GDB Administrator
741d8b0429 Automatic date update in version.in 2022-07-03 00:00:31 +00:00
GDB Administrator
4d905b269f Automatic date update in version.in 2022-07-02 00:00:38 +00:00
GDB Administrator
d7e8e50d42 Automatic date update in version.in 2022-07-01 00:01:16 +00:00
GDB Administrator
bb517c99b9 Automatic date update in version.in 2022-06-30 00:00:35 +00:00
GDB Administrator
f916230ad2 Automatic date update in version.in 2022-06-29 00:00:54 +00:00
GDB Administrator
723f6eafe4 Automatic date update in version.in 2022-06-28 00:00:40 +00:00
GDB Administrator
4f0027f03c Automatic date update in version.in 2022-06-27 00:00:36 +00:00
GDB Administrator
c47836066d Automatic date update in version.in 2022-06-26 00:00:23 +00:00
GDB Administrator
25622428e9 Automatic date update in version.in 2022-06-25 00:00:25 +00:00
GDB Administrator
4a0f8275ab Automatic date update in version.in 2022-06-24 00:00:43 +00:00
GDB Administrator
16cd607461 Automatic date update in version.in 2022-06-23 00:00:38 +00:00
GDB Administrator
70158ce8e0 Automatic date update in version.in 2022-06-22 00:00:33 +00:00
GDB Administrator
6388cd0ce2 Automatic date update in version.in 2022-06-21 00:00:34 +00:00
GDB Administrator
3efdda735c Automatic date update in version.in 2022-06-20 00:00:29 +00:00
GDB Administrator
8ebd11a342 Automatic date update in version.in 2022-06-19 00:00:39 +00:00
GDB Administrator
4e89bb12c2 Automatic date update in version.in 2022-06-18 00:00:35 +00:00
GDB Administrator
e692cf2dc4 Automatic date update in version.in 2022-06-17 00:00:35 +00:00
GDB Administrator
f7aaf3c25f Automatic date update in version.in 2022-06-16 00:00:42 +00:00
GDB Administrator
6edaa538a3 Automatic date update in version.in 2022-06-15 00:00:29 +00:00
GDB Administrator
03b9347271 Automatic date update in version.in 2022-06-14 00:00:30 +00:00
GDB Administrator
78f29594ad Automatic date update in version.in 2022-06-13 00:00:27 +00:00
GDB Administrator
594883b3b7 Automatic date update in version.in 2022-06-12 00:00:28 +00:00
GDB Administrator
fb68c8adc4 Automatic date update in version.in 2022-06-11 00:00:39 +00:00
GDB Administrator
795e17aa6a Automatic date update in version.in 2022-06-10 00:00:36 +00:00
GDB Administrator
0096540077 Automatic date update in version.in 2022-06-09 00:00:44 +00:00
GDB Administrator
364d1397ec Automatic date update in version.in 2022-06-08 00:00:28 +00:00
GDB Administrator
f485331189 Automatic date update in version.in 2022-06-07 00:00:42 +00:00
GDB Administrator
7858d22eb9 Automatic date update in version.in 2022-06-06 00:00:40 +00:00
GDB Administrator
6f4449e6fc Automatic date update in version.in 2022-06-05 00:00:41 +00:00
GDB Administrator
0e24a7ce39 Automatic date update in version.in 2022-06-04 00:00:47 +00:00
GDB Administrator
ff62190fb0 Automatic date update in version.in 2022-06-03 00:00:30 +00:00
GDB Administrator
a71bd1ba0d Automatic date update in version.in 2022-06-02 00:00:36 +00:00
GDB Administrator
27ae093049 Automatic date update in version.in 2022-06-01 00:00:28 +00:00
GDB Administrator
0f99116612 Automatic date update in version.in 2022-05-31 00:00:24 +00:00
GDB Administrator
c639949eb1 Automatic date update in version.in 2022-05-30 00:00:19 +00:00
GDB Administrator
1f0c30994a Automatic date update in version.in 2022-05-29 00:00:20 +00:00
GDB Administrator
b2d1d9af50 Automatic date update in version.in 2022-05-28 00:00:40 +00:00
GDB Administrator
135cfbc082 Automatic date update in version.in 2022-05-27 00:00:36 +00:00
GDB Administrator
5790e687e5 Automatic date update in version.in 2022-05-26 00:00:28 +00:00
GDB Administrator
b2ac3d7001 Automatic date update in version.in 2022-05-25 00:00:25 +00:00
GDB Administrator
10e4383acb Automatic date update in version.in 2022-05-24 00:00:36 +00:00
GDB Administrator
785a855000 Automatic date update in version.in 2022-05-23 00:00:22 +00:00
GDB Administrator
7620f5f0f3 Automatic date update in version.in 2022-05-22 00:00:25 +00:00
GDB Administrator
072f31aed6 Automatic date update in version.in 2022-05-21 00:00:54 +00:00
Joel Brobecker
6d279a2c3d Bump GDB's version number to 12.1.90.DATE-git.
This commit changes gdb/version.in to 12.1.90.DATE-git.

This commit also makes the following changes in gdb/testsuite:

	* gdb.base/default.exp: Change $_gdb_minor to 2.
2022-05-01 12:00:22 -07:00
Joel Brobecker
e53a8e8685 Set GDB version number to 12.1.
This commit changes gdb/version.in to 12.1.
2022-05-01 11:46:32 -07:00
Tom Tromey
4324e94471 Import gnulib changes
This imports the gnulib patches that were mentioned by Eli.  I created
the patches from gnulib git, ran them through filterdiff, and then
applied them using update-gnulib.sh's patch-applying facility.

I think the patches are either obviously Windows-specific or harmless,
but I encourage you to look for yourself.

I tested by rebuilding on x86-64 Fedora 34, and also using the Fedora
mingw cross toolchain.
2022-04-25 07:29:02 -06:00
Andrew Burgess
e312dfbe95 gdb: move setbuf calls out of gdb_readline_no_editing_callback
After this commit:

  commit d08cbc5d32
  Date:   Wed Dec 22 12:57:44 2021 +0000

      gdb: unbuffer all input streams when not using readline

Issues were reported with some MS-Windows hosts, see the thread
starting here:

  https://sourceware.org/pipermail/gdb-patches/2022-March/187004.html

Filed in bugzilla as: PR mi/29002

The problem seems to be that calling setbuf on terminal file handles
is not always acceptable, see this mail for more details:

  https://sourceware.org/pipermail/gdb-patches/2022-April/187310.html

This commit does two things, first moving the setbuf calls out of
gdb_readline_no_editing_callback so that we don't end up calling
setbuf so often.

Then, for MS-Windows hosts, we don't call setbuf for terminals, this
appears to resolve the issues that have been reported.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29002
2022-04-24 08:44:02 -07:00
Andrew Burgess
3ab22dba1b gdb: fix 'remote show FOO-packet' aliases
The following behaviour was observed in GDB:

  (gdb) show remote X-packet
  Support for the `p' packet is auto-detected, currently unknown.

Note the message mentions the 'p' packet.  This is a regression since
this commit:

  commit 8579fd136a
  Date:   Mon Nov 8 14:58:46 2021 +0000

      gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptr

Before this commit the behaviour was:

  (gdb) show remote X-packet
  Support for the `X' packet is auto-detected, currently unknown.

The problem was caused by a failed attempt to ensure that some
allocated strings were deleted when GDB exits.  The code in the above
commit attempted to make use of 'static' to solve this problem,
however, the solution was just wrong.

In this new commit I instead allocate a static vector into which all
the allocated strings are stored, this ensures the strings are
released when GDB exits (which makes output from tools like valgrind
cleaner), but each string within the vector can be unique, which fixes
the regression.
2022-04-21 11:49:30 +01:00
Tom de Vries
f0072f79e1 [gdb/testsuite] Fix gdb.ada/float-bits.exp with -m32
With test-case gdb.ada/float-bits.exp and native we get:
...
(gdb) print 16llf#7FFFF7FF4054A56FA5B99019A5C8#^M
$9 = 5.0e+25^M
(gdb) PASS: gdb.ada/float-bits.exp: print 16llf#7FFFF7FF4054A56FA5B99019A5C8#
...
but with target board unix/-m32 we have instead:
...
(gdb) print 16llf#7FFFF7FF4054A56FA5B99019A5C8#^M
Cannot export value 2596145952482202326224873165792712 as 96-bits \
  unsigned integer (must be between 0 and 79228162514264337593543950335)^M
(gdb) FAIL: gdb.ada/float-bits.exp: print 16llf#7FFFF7FF4054A56FA5B99019A5C8#
...

Fix this by testing whether 16llf is supported by doing ptype long_long_float
which gets us either:
...
type = <16-byte float>^M
...
or:
...
type = <12-byte float>^M
...

Tested on x86_64-linux with native and unix/-m32.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29041
2022-04-15 18:01:07 +02:00
Tom de Vries
04f521a6ef [gdb/testsuite] Fix gdb.go/methods.exp with check-readmore
When running test-case gdb.go/methods.exp with make check we have:
...
(gdb) break main.T.Foo^M
Function "main.T.Foo" not defined.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) XFAIL: gdb.go/methods.exp: gdb_breakpoint: set breakpoint at main.T.Foo
...
but with make check-readmore the XFAIL fails to trigger:
...
(gdb) break main.T.Foo^M
Function "main.T.Foo" not defined.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.go/methods.exp: gdb_breakpoint: set breakpoint at main.T.Foo
...

This happens because this gdb_test_multiple "maintenance print symbols"
regexp:
...
    -re "\r\n$gdb_prompt $" {
...
matches the entire command output.

Fix this by adding the missing ^ at the regexp start.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29064
2022-04-15 16:54:21 +02:00
Lancelot SIX
d063203192 gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
Pedro Alves warned me that there is a race in
gdb.dwarf2/calling-convention.exp making the test sometimes fail on his
setup.  This can be reliably reproduced using :

    make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"

The relevant part of the gdb.log file is:

    return 35
    Function 'foo' does not follow the target calling convention.
    If you continue, setting the return value will probably lead to unpredictable behaviors.
    Make foo return now? (y or n) PASS: gdb.dwarf2/calling-convention.exp: return 35
    n
    Not confirmed
    (gdb) FAIL: gdb.dwarf2/calling-convention.exp: finish

The issue is that when doing the test for "return 35", the DejaGnu test
sends "n" (to tell GDB not to perform the return action) but never
consumes the "Not confirmed" acknowledgment sent by GDB.  Later, when
trying to do the next test, DejaGnu tries to match the leftover output
from the "return" test. As this output is not expected, the test fails.

Fix by using gdb_test to send the "n" answer and match the confirmation
and consume all output to the prompt.

Also do minor adjustments to the main regex:
  - Remove the leading ".*" which is not required.
  - Ensure that the "?" from the question is properly escaped.

Tested on x86_64-gnu-linux, using

- make check TESTS="gdb.dwarf2/calling-convention.exp"
- make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"
- make check-readmore TESTS="gdb.dwarf2/calling-convention.exp"

Co-authored-by: Pedro Alves <pedro@palves.net>
Change-Id: I42858b13db2cbd623c5c1739de65ad423e0c0938
2022-04-14 18:27:51 +01:00
Tom Tromey
db7127461e Silence -Wmaybe-uninitialized warning from target_waitstatus
Currently, one use of target_waitstatus yields a warning:

     target/waitstatus.h: In function 'void stop_all_threads()':
     target/waitstatus.h:175:13: warning: 'ws.target_waitstatus::m_value' may be used uninitialized in this function [-Wmaybe-uninitialized]
       175 |     m_value = other.m_value;
	   |     ~~~~~~~~^~~~~~~~~~~~~~~

This patch silences the warning.  I tried the "volatile member"
approach that was used for gdb::optional, but that didn't work, so
this patch simply initializes the member.
2022-04-14 10:19:16 -06:00
Tom Tromey
7b5e70a921 Fix regression on Windows with WOW64
Internally at AdaCore, we recently started testing a 64-bit gdb
debugging 32-bit processes.  This failed with gdb head, but not with
gdb 11.

The tests fail like this:

     Starting program: [...].exe
     warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for NOT_AN_IMAGE.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for NOT_AN_IMAGE.
     Do you need "set solib-search-path" or "set sysroot"?

After some debugging and bisecting, to my surprise the bug was
introduced by commit 183be222 ("gdb, gdbserver: make target_waitstatus
safe").

The problem occurs in handle_exception.  Previously the code did:

    -  ourstatus->kind = TARGET_WAITKIND_STOPPED;
    [...]
	 case EXCEPTION_BREAKPOINT:
    [...]
    -	  ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
    [...]
	   /* FALLTHROUGH */
	 case STATUS_WX86_BREAKPOINT:
	   DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT");
    -      ourstatus->value.sig = GDB_SIGNAL_TRAP;
    [...]
    -  last_sig = ourstatus->value.sig;

However, in the new code, the fallthrough case does:

    +      ourstatus->set_stopped (GDB_SIGNAL_TRAP);

... which changes the 'kind' in 'ourstatus' after falling through.

This patch rearranges the 'last_sig' setting to more closely match
what was done before (this is probably not strictly needed but also
seemed harmless), and removes the fall-through in the
'ignore_first_breakpoint' case when __x86_64__ is defined.
2022-04-14 10:02:56 -06:00
Tom de Vries
74f8cb8887 [gdb/testsuite] Fix gdb.base/annota1.exp with pie
Since commit 359efc2d89 ("[gdb/testsuite] Make gdb.base/annota1.exp more
robust") we see this fail with target board unix/-fPIE/-pie:
...
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
...

The problem is that the commit makes the number and order of matched
annotations fixed, while between target boards unix and unix/-fPIE/-pie there
is a difference:
...
 \032\032post-prompt
 Starting program: outputs/gdb.base/annota1/annota1

+\032\032breakpoints-invalid
+
 \032\032starting

 \032\032frames-invalid
...

Fix this by optionally matching the additional annotation.

Tested on x86_64-linux.
2022-04-14 14:56:21 +02:00
Tom de Vries
013dbf15db [gdb/testsuite] Make gdb.base/annota1.exp more robust
On openSUSE Tumbleweed I run into:
...
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
...

The problem is that the libthread_db message occurs at a location where it's
not expected:
...
Starting program: outputs/gdb.base/annota1/annota1 ^M
^M
^Z^Zstarting^M
^M
^Z^Zframes-invalid^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
^M
^Z^Zbreakpoints-invalid^M
^M
...

Fix this by making the matching more robust:
- rewrite the regexp such that each annotation is on a single line,
  starting with \r\n\032\032 and ending with \r\n
- add a regexp variable optional_re, that matches all possible optional
  output, and use it as a separator in the first part of the regexp

Tested on x86_64-linux.
2022-04-14 14:56:21 +02:00
Tom de Vries
f48fc32448 [gdb/testsuite] Fix gdb.base/stap-probe.exp with read1
When running test-case gdb.base/stap-probe.exp with make target check-read1, I
run into this and similar:
...
FAIL: gdb.base/stap-probe.exp: without semaphore, not optimized: \
  info probes stap (timeout)
...

Fix this by using gdb_test_lines instead of gdb_test.

Tested on x86_64-linux.
2022-04-14 13:52:19 +02:00
Tom de Vries
d4c9e8f583 [gdb/testsuite] Detect 'No MPX support'
On openSUSE Leap 15.3, mpx support has been disabled for m32, so I run into:
...
(gdb) run ^M
Starting program: outputs/gdb.arch/i386-mpx/i386-mpx ^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
No MPX support^M
...
and eventually into all sort of fails in this and other mpx test-cases.

Fix this by detecting the "No MPX support" message in have_mpx.

Tested on x86_64-linux with target boards unix and unix/-m32.
2022-04-14 13:17:24 +02:00
Tom de Vries
4f538bcbb7 [gdb/testsuite] Fix gdb.dwarf2/dw2-lines.exp for m32 pie
As reported in PR29043, when running test-case gdb.dwarf2/dw2-lines.exp with
target board unix/-m32/-fPIE/-pie, we run into:
...
Breakpoint 2, 0x56555540 in bar ()^M
(gdb) PASS: gdb.dwarf2/dw2-lines.exp: cv=2: cdw=32: lv=2: ldw=32: \
  continue to breakpoint: foo \(1\)
next^M
Single stepping until exit from function bar,^M
which has no line number information.^M
0x56555587 in main ()^M
(gdb) FAIL: gdb.dwarf2/dw2-lines.exp: cv=2: cdw=32: lv=2: ldw=32: \
  next to foo (2)
...

The problem is that the bar breakpoint ends up at an unexpected location
because:
- the synthetic debug info is incomplete and doesn't provide line info
  for the prologue part of the function, so consequently gdb uses the i386
  port prologue skipper to get past the prologue
- the i386 port prologue skipper doesn't get past a get_pc_thunk call.

Work around this in the test-case by breaking on bar_label instead.

Tested on x86_64-linux with target boards unix, unix/-m32, unix/-fPIE/-pie and
unix/-m32/-fPIE/-pie.
2022-04-13 14:29:00 +02:00
Simon Marchi
1ab8f3967d gdb/testsuite: use nopie in gdb.dwarf2/dw2-inline-param.exp
I see this failure:

    (gdb) run ^M
    Starting program: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/dw2-inline-param/dw2-inline-param ^M
    Warning:^M
    Cannot insert breakpoint 1.^M
    Cannot access memory at address 0x113b^M
    ^M
    (gdb) FAIL: gdb.dwarf2/dw2-inline-param.exp: runto: run to *0x113b

The test loads the binary in GDB, grabs the address of a symbol, strips
the binary, reloads it in GDB, runs the program, and then tries to place
a breakpoint at that address.  The problem is that the binary is built
as position independent, so the address GDB grabs in the first place
isn't where the code ends up after running.

Fix this by linking the binary as non-position-independent.  The
alternative would be to compute the relocated address where to place the
breakpoint, but that's not very straightforward, unfortunately.

I was confused for a while, I was trying to load the binary in GDB
manually to get the symbol address, but GDB was telling me the symbol
could not be found.  Meanwhile, it clearly worked in gdb.log.  The thing
is that GDB strips the binary in-place, so we don't have access to the
intermediary binary with symbols.  Change the test to output the
stripped binary to a separate file instead.

Change-Id: I66c56293df71b1ff49cf748d6784bd0e935211ba
2022-04-13 14:29:00 +02:00
Tom Tromey
0349d33f1d Fix bug in Ada number lexing
On irc, Pedro pointed out that Ada couldn't properly handle
0xffffffffffffffff.  This used to work, but is a regression due to
some patches I wrote in the Ada lexer.  This patch fixes the bug.
2022-04-12 13:02:00 -06:00
Tom Tromey
81f81faa8f Remove "Ada Settings" node from the manual
A while back, I sent a patch to unify the Ada varsize-limit setting
with the more generic max-value-size:

https://sourceware.org/pipermail/gdb-patches/2021-September/182004.html

However, it turns out I somehow neglected to send part of the patch.
Internally, I also removed the "Ada Settings" node from the manual, as
it only documents the obsolete setting.

This patch removes this text.
2022-04-12 07:01:06 -06:00
John Baldwin
aba6eff2e0 Handle TLS variable lookups when using separate debug files.
Commit df22c1e5d5 handled the case that
a separate debug file was passed as the objfile for a shared library
to svr4_fetch_objfile_link_map.  However, a separate debug file can
also be passed for TLS variables in the main executable.  In addition,
frv_fetch_objfile_link_map also expects to be passed the original
objfile rather than a separate debug file, so pull the code to resolve
a separate debug file to the main objfile up into
target_translate_tls_address.
2022-04-11 08:50:52 -07:00
Simon Marchi
4393855615 gdb: don't copy entirely optimized out values in value_copy
Bug 28980 shows that trying to value_copy an entirely optimized out
value causes an internal error.  The original bug report involves MI and
some Python pretty printer, and is quite difficult to reproduce, but
another easy way to reproduce (that is believed to be equivalent) was
proposed:

    $ ./gdb -q -nx --data-directory=data-directory -ex "py print(gdb.Value(gdb.Value(5).type.optimized_out()))"
    /home/smarchi/src/binutils-gdb/gdb/value.c:1731: internal-error: value_copy: Assertion `arg->contents != nullptr' failed.

This is caused by 5f8ab46bc6 ("gdb: constify parameter of
value_copy").  It added an assertion that the contents buffer is
allocated if the value is not lazy:

  if (!value_lazy (val))
    {
      gdb_assert (arg->contents != nullptr);

This was based on the comment on value::contents, which suggest that
this is the case:

  /* Actual contents of the value.  Target byte-order.  NULL or not
     valid if lazy is nonzero.  */
  gdb::unique_xmalloc_ptr<gdb_byte> contents;

However, it turns out that it can also be nullptr also if the value is
entirely optimized out, for example on exit of
allocate_optimized_out_value.  That function creates a lazy value, marks
the entire value as optimized out, and then clears the lazy flag.  But
contents remains nullptr.

This wasn't a problem for value_copy before, because it was calling
value_contents_all_raw on the input value, which caused contents to be
allocated before doing the copy.  This means that the input value to
value_copy did not have its contents allocated on entry, but had it
allocated on exit.  The result value had it allocated on exit.  And that
we copied bytes for an entirely optimized out value (i.e. meaningless
bytes).

From here I see two choices:

 1. respect the documented invariant that contents is nullptr only and
    only if the value is lazy, which means making
    allocate_optimized_out_value allocate contents
 2. extend the cases where contents can be nullptr to also include
    values that are entirely optimized out (note that you could still
    have some entirely optimized out values that do have contents
    allocated, it depends on how they were created) and adjust
    value_copy accordingly

Choice #1 is safe, but less efficient: it's not very useful to allocate
a buffer for an entirely optimized out value.  It's even a bit less
efficient than what we had initially, because values coming out of
allocate_optimized_out_value would now always get their contents
allocated.

Choice #2 would be more efficient than what we had before: giving an
optimized out value without allocated contents to value_copy would
result in an optimized out value without allocated contents (and the
input value would still be without allocated contents on exit).  But
it's more risky, since it's difficult to ensure that all users of the
contents (through the various_contents* accessors) are all fine with
that new invariant.

In this patch, I opt for choice #2, since I think it is a better
direction than choice #1.  #1 would be a pessimization, and if we go
this way, I doubt that it will ever be revisited, it will just stay that
way forever.

Add a selftest to test this.  I initially started to write it as a
Python test (since the reproducer is in Python), but a selftest is more
straightforward.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28980
Change-Id: I6e2f5c0ea804fafa041fcc4345d47064b5900ed7
2022-04-06 16:12:00 -04:00
Simon Marchi
810db22c7f gdb/testsuite: fix intermittent failures in gdb.mi/mi-cmd-user-context.exp
I got failures like this once on a CI:

    frame^M
    &"frame\n"^M
    ~"#0  child_sub_function () at /home/jenkins/workspace/binutils-gdb_master_build/arch/amd64/target_board/unix/src/binutils-gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:33\n"^M
    ~"33\t    dummy = !dummy; /* thread loop line */\n"^M
    ^done^M
    (gdb) ^M
    FAIL: gdb.mi/mi-cmd-user-context.exp: frame 1 (unexpected output)

The problem is that the test expects the following regexp:

  ".*#0  0x.*"

And that typically works, when the output of the frame command looks
like:

  #0  0x00005555555551bb in child_sub_function () at ...

Note the lack of hexadecimal address in the failing case.  Whether or
not the hexadecimal address is printed (roughly) depends on whether the
current PC is at the beginning of a line.  So depending on where thread
2 was when GDB stopped it (after thread 1 hit its breakpoint), we can
get either output.  Adjust the regexps to not expect an hexadecimal
prefix (0x) but a function name instead (either child_sub_function or
child_function).  That one is always printed, and is also a good check
that we are in the frame we expect.

Note that for test "frame 5", we are showing a pthread frame (on my
system), so the function name is internal to pthread, not something we
can rely on.  In that case, it's almost certain that we are not at the
beginning of a line, or that we don't have debug info, so I think it's
fine to expect the hex prefix.

And for test "frame 6", it's ok to _not_ expect a hex prefix (what the
test currently does), since we are showing thread 1, which has hit a
breakpoint placed at the beginning of a line.

When testing this, Tom de Vries pointed out that the current test code
doesn't ensure that the child threads are in child_sub_function when
they are stopped.  If the scheduler chooses so, it is possible for the
child threads to be still in the pthread_barrier_wait or child_function
functions when they get stopped.  So that would be another racy failure
waiting to happen.

The only way I can think of to ensure the child threads are in the
child_sub_function function when they get stopped is to synchronize the
threads using some variables instead of pthread_barrier_wait.  So,
replace the barrier with an array of flags (one per child thread).  Each
child thread flips its flag in child_sub_function to allow the main
thread to make progress and eventually hit the breakpoint.

I copied user-selected-context-sync.c to a new mi-cmd-user-context.c and
made modifications to that, to avoid interfering with
user-selected-context-sync.exp.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29025
Change-Id: I919673bbf9927158beb0e8b7e9e980b8d65eca90
2022-04-05 08:02:15 -04:00
Tom de Vries
b86dbc4c45 [gdb/testsuite] Fix KPASS in gdb.ada/arrayptr.exp
On openSUSE Leap 15.3 I run into:
...
KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all \
  (PRMS minimal encodings)
KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr(3) \
  (PRMS minimal encodings)
KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all(3) \
  (PRMS minimal encodings)
...

The test-case KFAILs some tests.  However, the analysis in the corresponding
PR talks of a compiler problem, so it should use XFAILs instead.

The KFAILs are setup for pre-gcc-12, but apparantly the fix has been
backported to system compiler 7.5.0, hence the KPASS.

Fix this by:
- using an XFAIL instead of a KFAIL
- matching the specific gdb output that corresponds to the XFAILs
  (reproduced on Fedora 34).

Tested on x86_64-linux, specifically openSUSE Leap 15.3 and Fedora 34.
2022-04-04 12:25:55 +02:00
Rainer Orth
09ab0d2eec Fix procfs.c compilation
procfs.c doesn't compile on Solaris:

/vol/src/gnu/gdb/hg/master/local/gdb/procfs.c: In member function ‘virtual bool procfs_target::info_proc(const char*, info_proc_what)’:
/vol/src/gnu/gdb/hg/master/local/gdb/procfs.c:3302:3: error: ‘gdb_argv’ was not declared in this scope
 3302 |   gdb_argv built_argv (args);
      |   ^~~~~~~~
/vol/src/gnu/gdb/hg/master/local/gdb/procfs.c:3303:20: error: ‘built_argv’ was not declared in this scope; did you mean ‘buildargv’?
 3303 |   for (char *arg : built_argv)
      |                    ^~~~~~~~~~
      |                    buildargv

Fixed by including  "gdbsupport/buildargv.h".

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11.
2022-03-31 10:38:01 +02:00
Andrew Burgess
95c82cbf7e gdb/mi: fix use after free of frame_info causing spurious notifications
In commit:

  commit a2757c4ed6
  Date:   Wed Mar 16 15:08:22 2022 +0000

      gdb/mi: consistently notify user when GDB/MI client uses -thread-select

Changes were made to GDB to address some inconsistencies in when
notifications are sent from a MI terminal to a CLI terminal (when
multiple terminals are in use, see new-ui command).

Unfortunately, in order to track when the currently selected frame has
changed, that commit grabs a frame_info pointer before and after an MI
command has executed, and compares the pointers to see if the frame
has changed.

This is not safe.

If the frame cache is deleted for any reason then the frame_info
pointer captured before the command started, is no longer valid, and
any comparisons based on that pointer are undefined.

This was leading to random test failures for some folk, see:

  https://sourceware.org/pipermail/gdb-patches/2022-March/186867.html

This commit changes GDB so we no longer hold frame_info pointers, but
instead store the frame_id and frame_level, this is safe even when the
frame cache is flushed.
2022-03-29 10:55:11 +01:00
Tom Tromey
7685884a38 Add Rust parser check for end of expression
I noticed that "print 5," passed in Rust -- the parser wasn't checking
that the entire input was used.  This patch fixes the problem.  This
in turn pointed out another bug in the parser, namely that it didn't
lex the next token after handling a string token.  This is also fixed
here.
2022-03-28 15:19:47 -06:00
Joel Brobecker
eb3ec1b698 Bump GDB's version number to 12.0.90.DATE-git.
This commit changes gdb/version.in to 12.0.90.DATE-git.
2022-03-20 09:55:10 +04:00
Joel Brobecker
9d7105d14c Set GDB version number to 12.0.90.
This commit changes gdb/version.in to 12.0.90.
2022-03-20 09:30:32 +04:00
Joel Brobecker
fc8b2d4b5d Update gdb/NEWS to say "in GDB 12" instead of "since GDB 11" 2022-03-20 09:25:52 +04:00
Joel Brobecker
5dd959bace Set development mode to "off" by default.
This is done by setting the "development" variable to "false"
in bfd/development.sh.
2022-03-20 09:07:50 +04:00
Joel Brobecker
5e8b7e78b6 Bump version to 12.0.90.DATE-git.
Now that the GDB 12 branch has been created,
this commit bumps the version number in gdb/version.in to
12.0.90.DATE-git

For the record, the GDB 12 branch was created
from commit 2be64de603.
2022-03-20 09:07:19 +04:00
51 changed files with 1070 additions and 284 deletions

View File

@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Controls whether to enable development-mode features by default.
development=true
development=false
# Indicate whether this is a release branch.
experimental=true

View File

@@ -16,7 +16,7 @@
In releases, the date is not included in either version strings or
sonames. */
#define BFD_VERSION_DATE 20220320
#define BFD_VERSION_DATE 20221218
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
#define REPORT_BUGS_TO @report_bugs_to@

View File

@@ -1,7 +1,7 @@
What has changed in GDB?
(Organized release by release)
*** Changes since GDB 11
*** Changes in GDB 12
* DBX mode is deprecated, and will be removed in GDB 13

View File

@@ -434,11 +434,11 @@ processInt (struct parser_state *par_state, const char *base0,
return FLOAT;
}
gdb_mpz maxval (ULONGEST_MAX / base);
gdb_mpz maxval (ULONGEST_MAX);
if (mpz_cmp (result.val, maxval.val) > 0)
error (_("Integer literal out of range"));
LONGEST value = result.as_integer<LONGEST> ();
ULONGEST value = result.as_integer<ULONGEST> ();
if ((value >> (gdbarch_int_bit (par_state->gdbarch ())-1)) == 0)
yylval.typed_val.type = type_int (par_state);
else if ((value >> (gdbarch_long_bit (par_state->gdbarch ())-1)) == 0)

View File

@@ -120,6 +120,9 @@ public:
private: /* per-core data */
/* Get rid of the core inferior. */
void clear_core ();
/* The core's section table. Note that these target sections are
*not* mapped in the current address spaces' set of target
sections --- those should come only from pure executable or
@@ -290,10 +293,8 @@ core_target::build_file_mappings ()
/* An arbitrary identifier for the core inferior. */
#define CORELOW_PID 1
/* Close the core target. */
void
core_target::close ()
core_target::clear_core ()
{
if (core_bfd)
{
@@ -307,6 +308,14 @@ core_target::close ()
current_program_space->cbfd.reset (nullptr);
}
}
/* Close the core target. */
void
core_target::close ()
{
clear_core ();
/* Core targets are heap-allocated (see core_target_open), so here
we delete ourselves. */
@@ -592,9 +601,15 @@ core_target_open (const char *arg, int from_tty)
void
core_target::detach (inferior *inf, int from_tty)
{
/* Note that 'this' is dangling after this call. unpush_target
closes the target, and our close implementation deletes
'this'. */
/* Get rid of the core. Don't rely on core_target::close doing it,
because target_detach may be called with core_target's refcount > 1,
meaning core_target::close may not be called yet by the
unpush_target call below. */
clear_core ();
/* Note that 'this' may be dangling after this call. unpush_target
closes the target if the refcount reaches 0, and our close
implementation deletes 'this'. */
inf->unpush_target (this);
/* Clear the register cache and the frame cache. */

View File

@@ -18014,7 +18014,6 @@ to be difficult.
* Ada Tasks and Core Files:: Tasking Support when Debugging Core Files
* Ravenscar Profile:: Tasking Support when using the Ravenscar
Profile
* Ada Settings:: New settable GDB parameters for Ada.
* Ada Source Character Set:: Character set of Ada source files.
* Ada Glitches:: Known peculiarities of Ada mode.
@end menu
@@ -18748,37 +18747,6 @@ it isn't currently possible to single-step through the runtime
initialization sequence. If you need to debug this code, you should
use @code{set ravenscar task-switching off}.
@node Ada Settings
@subsubsection Ada Settings
@cindex Ada settings
@table @code
@kindex set varsize-limit
@item set varsize-limit @var{size}
Prevent @value{GDBN} from attempting to evaluate objects whose size
is above the given limit (@var{size}) when those sizes are computed
from run-time quantities. This is typically the case when the object
has a variable size, such as an array whose bounds are not known at
compile time for example. Setting @var{size} to @code{unlimited}
removes the size limitation. By default, the limit is about 65KB.
The purpose of having such a limit is to prevent @value{GDBN} from
trying to grab enormous chunks of virtual memory when asked to evaluate
a quantity whose bounds have been corrupted or have not yet been fully
initialized. The limit applies to the results of some subexpressions
as well as to complete expressions. For example, an expression denoting
a simple integer component, such as @code{x.y.z}, may fail if the size of
@code{x.y} is variable and exceeds @code{size}. On the other hand,
@value{GDBN} is sometimes clever; the expression @code{A(i)}, where
@code{A} is an array variable with non-constant size, will generally
succeed regardless of the bounds on @code{A}, as long as the component
size is less than @var{size}.
@kindex show varsize-limit
@item show varsize-limit
Show the limit on types whose size is determined by run-time quantities.
@end table
@node Ada Source Character Set
@subsubsection Ada Source Character Set
@cindex Ada, source character set

View File

@@ -821,19 +821,6 @@ gdb_readline_no_editing_callback (gdb_client_data client_data)
FILE *stream = ui->instream != nullptr ? ui->instream : ui->stdin_stream;
gdb_assert (stream != nullptr);
/* Unbuffer the input stream, so that, later on, the calls to fgetc
fetch only one char at the time from the stream. The fgetc's will
get up to the first newline, but there may be more chars in the
stream after '\n'. If we buffer the input and fgetc drains the
stream, getting stuff beyond the newline as well, a select, done
afterwards will not trigger.
This unbuffering was, at one point, not applied if the input stream
was a tty, however, the buffering can cause problems, even for a tty,
in some cases. Please ensure that any changes in this area run the MI
tests with the FORCE_SEPARATE_MI_TTY=1 flag being passed. */
setbuf (stream, NULL);
/* We still need the while loop here, even though it would seem
obvious to invoke gdb_readline_no_editing_callback at every
character entered. If not using the readline library, the

View File

@@ -1974,27 +1974,51 @@ struct user_selected_context
{
/* Constructor. */
user_selected_context ()
: m_previous_ptid (inferior_ptid),
m_previous_frame (deprecated_safe_get_selected_frame ())
{ /* Nothing. */ }
: m_previous_ptid (inferior_ptid)
{
save_selected_frame (&m_previous_frame_id, &m_previous_frame_level);
}
/* Return true if the user selected context has changed since this object
was created. */
bool has_changed () const
{
return ((m_previous_ptid != null_ptid
&& inferior_ptid != null_ptid
&& m_previous_ptid != inferior_ptid)
|| m_previous_frame != deprecated_safe_get_selected_frame ());
/* Did the selected thread change? */
if (m_previous_ptid != null_ptid && inferior_ptid != null_ptid
&& m_previous_ptid != inferior_ptid)
return true;
/* Grab details of the currently selected frame, for comparison. */
frame_id current_frame_id;
int current_frame_level;
save_selected_frame (&current_frame_id, &current_frame_level);
/* Did the selected frame level change? */
if (current_frame_level != m_previous_frame_level)
return true;
/* Did the selected frame id change? If the innermost frame is
selected then the level will be -1, and the frame-id will be
null_frame_id. As comparing null_frame_id with itself always
reports not-equal, we only do the equality test if we have something
other than the innermost frame selected. */
if (current_frame_level != -1
&& !frame_id_eq (current_frame_id, m_previous_frame_id))
return true;
/* Nothing changed! */
return false;
}
private:
/* The previously selected thread. This might be null_ptid if there was
no previously selected thread. */
ptid_t m_previous_ptid;
/* The previously selected frame. This might be nullptr if there was no
previously selected frame. */
frame_info *m_previous_frame;
/* The previously selected frame. If the innermost frame is selected, or
no frame is selected, then the frame_id will be null_frame_id, and the
level will be -1. */
frame_id m_previous_frame_id;
int m_previous_frame_level;
};
static void

View File

@@ -201,6 +201,8 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
thread_rec (ptid_t (current_event.dwProcessId, current_event.dwThreadId, 0),
DONT_SUSPEND);
last_sig = GDB_SIGNAL_0;
switch (code)
{
case EXCEPTION_ACCESS_VIOLATION:
@@ -261,8 +263,10 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
on startup, first a BREAKPOINT for the 64bit ntdll.dll,
then a WX86_BREAKPOINT for the 32bit ntdll.dll.
Here we only care about the WX86_BREAKPOINT's. */
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT - ignore_first_breakpoint");
ourstatus->set_spurious ();
ignore_first_breakpoint = false;
break;
}
else if (wow64_process)
{
@@ -273,7 +277,7 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
gdb lets the target process continue.
So handle it as SIGINT instead, then the target is stopped
unconditionally. */
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT");
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT - wow64_process");
rec->ExceptionCode = DBG_CONTROL_C;
ourstatus->set_stopped (GDB_SIGNAL_INT);
break;

View File

@@ -45,6 +45,7 @@
#include "observable.h"
#include "gdbsupport/scoped_fd.h"
#include "gdbsupport/pathstuff.h"
#include "gdbsupport/buildargv.h"
/* This module provides the interface between GDB and the
/proc file system, which is used on many versions of Unix

View File

@@ -1968,15 +1968,17 @@ add_packet_config_cmd (struct packet_config *config, const char *name,
/* set/show remote NAME-packet {auto,on,off} -- legacy. */
if (legacy)
{
/* It's not clear who should take ownership of this string, so, for
now, make it static, and give copies to each of the add_alias_cmd
calls below. */
static gdb::unique_xmalloc_ptr<char> legacy_name
/* It's not clear who should take ownership of the LEGACY_NAME string
created below, so, for now, place the string into a static vector
which ensures the strings is released when GDB exits. */
static std::vector<gdb::unique_xmalloc_ptr<char>> legacy_names;
gdb::unique_xmalloc_ptr<char> legacy_name
= xstrprintf ("%s-packet", name);
add_alias_cmd (legacy_name.get (), cmds.set, class_obscure, 0,
&remote_set_cmdlist);
add_alias_cmd (legacy_name.get (), cmds.show, class_obscure, 0,
&remote_show_cmdlist);
legacy_names.emplace_back (std::move (legacy_name));
}
}

View File

@@ -271,7 +271,10 @@ struct rust_parser
operation_up parse_entry_point ()
{
lex ();
return parse_expr ();
operation_up result = parse_expr ();
if (current_token != 0)
error (_("Syntax error near '%s'"), pstate->prev_lexptr);
return result;
}
operation_up parse_tuple ();
@@ -2020,6 +2023,7 @@ rust_parser::parse_atom (bool required)
case STRING:
result = parse_string ();
lex ();
break;
case BYTESTRING:

View File

@@ -1453,11 +1453,6 @@ svr4_fetch_objfile_link_map (struct objfile *objfile)
if (objfile == current_program_space->symfile_object_file)
return info->main_lm_addr;
/* If OBJFILE is a separate debug object file, look for the
original object file. */
if (objfile->separate_debug_objfile_backlink != NULL)
objfile = objfile->separate_debug_objfile_backlink;
/* The other link map addresses may be found by examining the list
of shared libraries. */
for (struct so_list *so : current_program_space->solibs ())

View File

@@ -908,6 +908,15 @@ add_deprecated_target_alias (const target_info &tinfo, const char *alias)
void
target_kill (void)
{
/* If the commit_resume_state of the to-be-killed-inferior's process stratum
is true, and this inferior is the last live inferior with resumed threads
of that target, then we want to leave commit_resume_state to false, as the
target won't have any resumed threads anymore. We achieve this with
this scoped_disable_commit_resumed. On construction, it will set the flag
to false. On destruction, it will only set it to true if there are resumed
threads left. */
scoped_disable_commit_resumed disable ("killing");
current_inferior ()->top_target ()->kill ();
}
@@ -1296,6 +1305,11 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
struct target_ops *target = current_inferior ()->top_target ();
struct gdbarch *gdbarch = target_gdbarch ();
/* If OBJFILE is a separate debug object file, look for the
original object file. */
if (objfile->separate_debug_objfile_backlink != NULL)
objfile = objfile->separate_debug_objfile_backlink;
if (gdbarch_fetch_tls_load_module_address_p (gdbarch))
{
ptid_t ptid = inferior_ptid;
@@ -2553,6 +2567,9 @@ target_preopen (int from_tty)
void
target_detach (inferior *inf, int from_tty)
{
/* Thread's don't need to be resumed until the end of this function. */
scoped_disable_commit_resumed disable_commit_resumed ("detaching");
/* After we have detached, we will clear the register cache for this inferior
by calling registers_changed_ptid. We must save the pid_ptid before
detaching, as the target detach method will clear inf->pid. */
@@ -2583,6 +2600,8 @@ target_detach (inferior *inf, int from_tty)
inferior_ptid matches save_pid_ptid, but in our case, it does not
call it, as inferior_ptid has been reset. */
reinit_frame_cache ();
disable_commit_resumed.reset_and_commit ();
}
void

View File

@@ -418,7 +418,7 @@ private:
char *execd_pathname;
/* Syscall number */
int syscall_number;
} m_value;
} m_value {};
};
/* Extended reasons that can explain why a target/thread stopped for a

View File

@@ -49,27 +49,56 @@ foreach_with_prefix scenario {all minimal} {
gdb_test "ptype string_access" "= access array \\(<>\\) of character"
set kfail_int128support_re \
"That operation is not available on integers of more than 8 bytes\\."
set kfail_packed_array_range_re \
# GNAT >= 12.0 has the needed fix here.
set xfail_expected 0
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
set xfail_expected 1
}
gdb_test_multiple "print pa_ptr.all" "" {
-re -wrap " = \\(10, 20, 30, 40, 50, 60, 62, 63, -23, 42\\)" {
pass $gdb_test_name
}
-re -wrap " = \[0-9\]+" {
if { $xfail_expected } {
xfail $gdb_test_name
} else {
fail $gdb_test_name
}
}
}
set xfail_cannot_subscript_re \
"cannot subscript or call something of type `foo__packed_array_ptr'"
# GNAT >= 12.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
setup_kfail "minimal encodings" *-*-*
}
gdb_test "print pa_ptr.all" \
" = \\(10, 20, 30, 40, 50, 60, 62, 63, -23, 42\\)"
gdb_test_multiple "print pa_ptr(3)" "" {
-re -wrap " = 30" {
pass $gdb_test_name
# GNAT >= 12.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
setup_kfail "minimal encodings" *-*-*
}
-re -wrap $xfail_cannot_subscript_re {
if { $xfail_expected } {
xfail $gdb_test_name
} else {
fail $gdb_test_name
}
}
}
gdb_test "print pa_ptr(3)" " = 30"
# GNAT >= 12.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
setup_kfail "minimal encodings" *-*-*
set xfail_attempt_to_index_re \
"Attempt to index or call something other than an array or function"
gdb_test_multiple "print pa_ptr.all(3)" "" {
-re -wrap " = 30" {
pass $gdb_test_name
}
-re -wrap $xfail_attempt_to_index_re {
if { $xfail_expected } {
xfail $gdb_test_name
} else {
fail $gdb_test_name
}
}
}
gdb_test "print pa_ptr.all(3)" " = 30"
}

View File

@@ -42,12 +42,29 @@ gdb_test "print val_double := 16lf#bc0d83c94fb6d2ac#" " = -2.0e-19"
gdb_test "print val_double" " = -2.0e-19" \
"print val_double after assignment"
gdb_test "print 16llf#7FFFF7FF4054A56FA5B99019A5C8#" " = 5.0e\\+25"
set 16llf_supported 0
gdb_test_multiple "ptype long_long_float" "" {
-re -wrap "<16-byte float>" {
set 16llf_supported 1
pass $gdb_test_name
}
-re -wrap "<\\d+-byte float>" {
pass $gdb_test_name
}
}
if { $16llf_supported } {
gdb_test "print 16llf#7FFFF7FF4054A56FA5B99019A5C8#" " = 5.0e\\+25"
}
gdb_test "print val_long_double" " = 5.0e\\+25"
gdb_test "print val_long_double := 16llf#7FFFF7FF4054A56FA5B99019A5C8#" \
" = 5.0e\\+25"
if { $16llf_supported } {
gdb_test "print val_long_double := 16llf#7FFFF7FF4054A56FA5B99019A5C8#" \
" = 5.0e\\+25"
}
gdb_test "print val_long_double" " = 5.0e\\+25" \
"print val_long_double after assignment"
gdb_test "print 16llf#a56fa5b99019a5c800007ffff7ff4054#" \
" = <invalid float value>"
if { $16llf_supported } {
gdb_test "print 16llf#a56fa5b99019a5c800007ffff7ff4054#" \
" = <invalid float value>"
}

View File

@@ -34,3 +34,6 @@ gdb_test "print 2e1000" "Integer literal out of range"
gdb_test "print 16#ffff#" " = 65535"
gdb_test "print 16#f#e1" " = 240"
gdb_test "print 16#1#e10" " = 1099511627776"
gdb_test "print/x 16#7fffffffffffffff#" " = 0x7fffffffffffffff"
gdb_test "print 16#ffffffffffffffff#" " = -1"

View File

@@ -128,41 +128,66 @@ gdb_test_multiple "info break" "breakpoint info" {
set binexp [string_to_regexp $binfile]
set warning_slow_re \
"warning: File transfers from remote targets can be slow\[^\r\n\]+"
"warning: File transfers from remote targets can be slow\[^\r\n\]+\r\n"
set warning_gdb_index_re \
[multi_line \
"warning: Skipping \[^\r\n\]+ .gdb_index section in \[^\r\n\]+" \
"Do \"set use-deprecated-index-sections on\" before the file is read" \
"to use the section anyway\\."]
"to use the section anyway\\.\r\n"]
set reading_re \
"Reading \[^\r\n\]+"
"Reading \[^\r\n\]+\r\n"
set libthread_db_re \
[multi_line \
"\\\[Thread debugging using libthread_db enabled\\\]" \
"Using host libthread_db library \[^\r\n\]+"]
"Using host libthread_db library \[^\r\n\]+\r\n"]
set optional_re \
[list \
"\(" \
"\($reading_re)" \
"|" \
"\($warning_slow_re\)" \
"|" \
"\($libthread_db_re\)" \
"|" \
"\(\r\n$warning_gdb_index_re\)?" \
"\)*"]
set optional_re [join $optional_re ""]
set run_re \
[list \
"\r\n\032\032post-prompt\r\nStarting program: $binexp " \
"\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)\)*" \
"\(\r\n$warning_gdb_index_re\)?" \
"\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \
"\032\032starting\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)|\r\n$libthread_db_re\)*" \
"\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \
"\032\032breakpoint 1\r\n\r\n" \
"Breakpoint 1, \r\n" \
"\032\032frame-begin 0 $hex\r\n\r\n" \
"\032\032frame-function-name\r\n" \
"main\r\n" \
"\032\032frame-args\r\n \\(\\)\r\n" \
"\032\032frame-source-begin\r\n at \r\n" \
"\032\032frame-source-file\r\n.*annota1.c\r\n" \
"\032\032frame-source-file-end\r\n:\r\n" \
"\032\032frame-source-line\r\n$main_line\r\n" \
"\032\032frame-source-end\r\n\r\n\r\n" \
"\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n" \
"\032\032frame-end\r\n\r\n" \
"\032\032stopped"]
"\r\n\032\032post-prompt\r\n" \
"Starting program: $binexp \r\n" \
$optional_re \
"\(\r\n\032\032breakpoints-invalid\r\n\)?" \
$optional_re \
"\r\n\032\032starting\r\n" \
$optional_re \
"\r\n\032\032frames-invalid\r\n" \
$optional_re \
"\r\n\032\032breakpoints-invalid\r\n" \
$optional_re \
"\r\n\032\032breakpoint 1\r\n" \
"\r\n" \
"Breakpoint 1, " \
"\r\n\032\032frame-begin 0 $hex\r\n" \
"\r\n\032\032frame-function-name\r\n" \
"main" \
"\r\n\032\032frame-args\r\n" \
" \\(\\)" \
"\r\n\032\032frame-source-begin\r\n" \
" at " \
"\r\n\032\032frame-source-file\r\n" \
".*annota1.c" \
"\r\n\032\032frame-source-file-end\r\n" \
":" \
"\r\n\032\032frame-source-line\r\n" \
"$main_line" \
"\r\n\032\032frame-source-end\r\n" \
"\r\n" \
"\r\n\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n" \
"\r\n\032\032frame-end\r\n" \
"\r\n\032\032stopped\r\n"]
set run_re [join $run_re ""]

View File

@@ -207,6 +207,16 @@ gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (
gdb_test "core" "No core file now."
# Test that we can unload the core with the "detach" command.
proc_with_prefix corefile_detach {} {
clean_restart $::binfile
gdb_test "core-file $::corefile" "Core was generated by .*" "load core"
gdb_test "detach" "No core file now\\." "detach core"
}
corefile_detach
# Test a run (start) command will clear any loaded core file.
@@ -222,6 +232,8 @@ proc corefile_test_run {} {
return
}
clean_restart $::binfile
gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file"

View File

@@ -607,7 +607,7 @@ set show_conv_list \
{$_gdb_setting_str = <internal function _gdb_setting_str>} \
{$_gdb_setting = <internal function _gdb_setting>} \
{$_gdb_major = 12} \
{$_gdb_minor = 1} \
{$_gdb_minor = 2} \
{$_shell_exitsignal = void} \
{$_shell_exitcode = 0} \
}

View File

@@ -195,4 +195,9 @@ gdb_test_no_output "set remote hardware-breakpoint-limit -1"
gdb_test_no_output "set remote hardware-watchpoint-limit 2147483647"
gdb_test_no_output "set remote hardware-breakpoint-limit 2147483647"
# Check the X/P/p alias commands display the correct packet names.
foreach pkt {X P p} {
gdb_test "show remote ${pkt}-packet" "Support for the `${pkt}' packet is.*"
}
gdb_exit

View File

@@ -0,0 +1,33 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2020-2022 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
//
#include <unistd.h>
static pid_t mypid = -1;
static void
after_getpid (void)
{
}
int
main (void)
{
mypid = getpid ();
after_getpid ();
sleep (30);
}

View File

@@ -0,0 +1,122 @@
# Copyright 2022 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This test aims at testing various operations after getting rid of an inferior
# that was running in background, or while we have an inferior running in
# background. The original intent was to expose cases where the commit-resumed
# state of the process stratum target was not reset properly after killing an
# inferior running in background, which would be a problem when trying to run
# again. The test was expanded to test various combinations of
# run-control-related actions done with an inferior running in background.
if {[use_gdb_stub]} {
unsupported "test requires running"
return
}
standard_testfile
if {[build_executable "failed to prepare" $testfile $srcfile]} {
return
}
# Run one variation of the test:
#
# 1. Start an inferior in the background with "run &"
# 2. Do action 1
# 3. Do action 2
#
# Action 1 indicates what to do with the inferior running in background:
#
# - kill: kill it
# - detach: detach it
# - add: add a new inferior and switch to it, leave the inferior running in
# background alone
# - none: do nothing, leave the inferior running in background alone
#
# Action 2 indicates what to do after that:
#
# - start: use the start command
# - run: use the run command
# - attach: start a process outside of GDB and attach it
proc do_test { action1 action2 } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop on\""
clean_restart $::binfile
}
# Ensure we are at least after the getpid call, should we need it.
if { ![runto "after_getpid"] } {
return
}
# Some commands below ask for confirmation. Turn that off for simplicity.
gdb_test "set confirm off"
gdb_test_multiple "continue &" "" {
-re ".*\r\n$::gdb_prompt " {
pass $gdb_test_name
}
}
if { $action1 == "kill" } {
gdb_test "kill" "Inferior 1 .* killed.*"
} elseif { $action1 == "detach" } {
set child_pid [get_integer_valueof "mypid" -1]
if { $child_pid == -1 } {
fail "failed to extract child pid"
return
}
gdb_test "detach" "Inferior 1 .* detached.*" "detach from first instance"
# Kill the detached process, to avoid hanging when exiting GDBserver,
# when testing with the native-extended-gdbserver board.
remote_exec target "kill $child_pid"
} elseif { $action1 == "add" } {
gdb_test "add-inferior -exec $::binfile" \
"Added inferior 2 on connection 1.*" "add-inferior"
gdb_test "inferior 2" "Switching to inferior 2 .*"
} elseif { $action1 == "none" } {
} else {
error "invalid action 1"
}
if { $action2 == "start" } {
gdb_test "start" "Temporary breakpoint $::decimal\(?:\.$::decimal\)?, main .*"
} elseif { $action2 == "run" } {
gdb_test "break main" "Breakpoint $::decimal at $::hex.*"
gdb_test "run" "Breakpoint $::decimal\(?:\.$::decimal\)?, main .*"
} elseif { $action2 == "attach" } {
set test_spawn_id [spawn_wait_for_attach $::binfile]
set test_pid [spawn_id_get_pid $test_spawn_id]
if { [gdb_attach $test_pid] } {
gdb_test "detach" "Inferior $::decimal .* detached.*" \
"detach from second instance"
}
# Detach and kill this inferior so we don't leave it around.
kill_wait_spawned_process $test_spawn_id
} else {
error "invalid action 2"
}
}
foreach_with_prefix action1 { kill detach add none } {
foreach_with_prefix action2 { start run attach } {
do_test $action1 $action2
}
}

View File

@@ -42,10 +42,10 @@ proc stap_test {exec_name {args ""}} {
"check argument not at probe point"
if {[string first "-DUSE_SEMAPHORES" $args] != -1} {
gdb_test "info probes stap" \
gdb_test_lines "info probes stap" "" \
"test *user *$hex *$hex .*"
} else {
gdb_test "info probes stap" \
gdb_test_lines "info probes stap" "" \
"test *user *$hex .*"
}

View File

@@ -84,9 +84,9 @@ gdb_breakpoint "foo"
gdb_continue_to_breakpoint "foo"
gdb_test_multiple "return 35" "" {
-re ".*Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now?.*\\(y or n\\) $" {
send_gdb "n\n"
-re "Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now\\? \\(y or n\\) $" {
pass $gdb_test_name
gdb_test "n" "Not confirmed" "cancel return"
}
}

View File

@@ -21,8 +21,10 @@ if {![dwarf2_support]} {
standard_testfile .S -main.c
set binfile_stripped ${binfile}-stripped
if { [prepare_for_testing "failed to prepare" "${testfile}" \
[list $srcfile2 $srcfile] {nodebug}] } {
[list $srcfile2 $srcfile] {nodebug nopie}] } {
return -1
}
@@ -40,7 +42,7 @@ gdb_unload
# Strip out any labels there as they could corrupt the `main' name.
set objcopy_program [gdb_find_objcopy]
set command "$objcopy_program -N block_start -N block_end -N break_at ${binfile}"
set command "$objcopy_program -N block_start -N block_end -N break_at ${binfile} ${binfile_stripped}"
verbose -log "Executing: $command"
set result [catch "exec $command" output]
verbose "result is $result"
@@ -49,7 +51,7 @@ if {$result != 0} {
return -1
}
gdb_load ${binfile}
gdb_load ${binfile_stripped}
if ![runto "*${break_at}"] {
return -1

View File

@@ -114,7 +114,7 @@ proc test_1 { _cv _cdw64 _lv _ldw64 {_string_form ""}} {
return -1
}
gdb_breakpoint "bar"
gdb_breakpoint "bar_label"
gdb_continue_to_breakpoint "foo \\(1\\)"
gdb_test "next" "foo \\(2\\).*" "next to foo (2)"

View File

@@ -49,7 +49,7 @@ gdb_test_multiple "maintenance print symbols" "" {
-re "^\r\n void main.T.Bar\[^\r\n\]*(?=\r\n)" {
exp_continue
}
-re "\r\n$gdb_prompt $" {
-re "^\r\n$gdb_prompt $" {
pass $gdb_test_name
}
-re "\r\n\[^\r\n\]*(?=\r\n)" {

View File

@@ -0,0 +1,73 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2016-2022 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <pthread.h>
#include <unistd.h>
#include <stdint.h>
#define NUM_THREADS 2
static volatile int unblock_main[NUM_THREADS];
static void
child_sub_function (int child_idx)
{
volatile int dummy = 0;
unblock_main[child_idx] = 1;
while (1)
/* Dummy loop body to allow setting breakpoint. */
dummy = !dummy; /* thread loop line */
}
static void *
child_function (void *args)
{
int child_idx = (int) (uintptr_t) args;
child_sub_function (child_idx); /* thread caller line */
return NULL;
}
int
main (void)
{
int i = 0;
pthread_t threads[NUM_THREADS];
/* Make the test exit eventually. */
alarm (20);
for (i = 0; i < NUM_THREADS; i++)
pthread_create (&threads[i], NULL, child_function, (void *) (uintptr_t) i);
/* Wait for child threads to reach child_sub_function. */
for (i = 0; i < NUM_THREADS; i++)
while (!unblock_main[i])
;
volatile int dummy = 0;
while (1)
/* Dummy loop body to allow setting breakpoint. */
dummy = !dummy; /* main break line */
return 0;
}

View File

@@ -18,7 +18,7 @@
load_lib mi-support.exp
standard_testfile user-selected-context-sync.c
standard_testfile
if {[build_executable $testfile.exp $testfile ${srcfile} "debug pthreads"] == -1} {
untested "failed to compile"
@@ -79,7 +79,7 @@ mi_gdb_test "thread" \
# Check we're in frame 0.
mi_gdb_test "frame" \
".*#0 0x.*" \
".*#0 .*child_sub_function .*" \
"frame 1"
# Ask about a different frame in the current thread, the current frame
@@ -93,7 +93,7 @@ mi_gdb_test "thread" \
"info thread 6"
mi_gdb_test "frame" \
".*#0 0x.*" \
".*#0 .*child_sub_function.*" \
"frame 2"
@@ -108,7 +108,7 @@ mi_gdb_test "thread" \
"info thread 7"
mi_gdb_test "frame" \
".*#0 0x.*" \
".*#0 .*child_sub_function.*" \
"frame 3"
# Select a different frame in the current thread. Despite the use of
@@ -123,7 +123,7 @@ mi_gdb_test "thread" \
"info thread 8"
mi_gdb_test "frame" \
".*#1 0x.*" \
".*#1 .*child_function.*" \
"frame 4"
# Similar to the previous test, but this time the --frame option is

View File

@@ -0,0 +1,26 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2022 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h>
int global_var = 123;
int
main (void)
{
sleep (30);
}

View File

@@ -0,0 +1,73 @@
# Copyright 2022 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This test was introduced to reproduce a specific bug in GDBserver, where
# attaching an inferior while another one was running would trigger a segfault
# in GDBserver. Reproducing the bug required specific circumstances:
#
# - The first process must be far enough to have loaded its libc or
# libpthread (whatever triggers the loading of libthread_db), such that
# its proc->priv->thread_db is not nullptr
#
# - However, its lwp must still be in the `!lwp->thread_known` state,
# meaning GDBserver hasn't asked libthread_db to compute the thread
# handle yet. That means, GDB must not have refreshed the thread list
# yet, since that would cause the thread handles to be computed. That
# means, no stopping on a breakpoint, since that causes a thread list
# update. That's why the first inferior needs to be started with "run
# &".
#
# - Attaching the second process would segfault GDBserver.
#
# All of this to say, if modifying this test, please keep in mind the original
# intent.
standard_testfile
if [use_gdb_stub] {
unsupported "test requires running"
return
}
if { [build_executable "failed to prepare" ${testfile} ${srcfile}] } {
return
}
proc do_test {} {
save_vars { $::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maint set target-non-stop on\""
clean_restart $::binfile
}
gdb_test_multiple "run &" "" {
-re ".*$::gdb_prompt " {
pass $gdb_test_name
}
}
gdb_test "add-inferior" "Added inferior 2 on connection 1 .*"
gdb_test "inferior 2" "Switching to inferior 2 .*"
set spawn_id [spawn_wait_for_attach $::binfile]
set pid [spawn_id_get_pid $spawn_id]
# This call would crash GDBserver.
gdb_attach $pid
# Read a variable from the inferior, just to make sure the attach worked
# fine.
gdb_test "print global_var" " = 123"
}
do_test

View File

@@ -76,6 +76,9 @@ proc test_value_creation {} {
# Test address attribute is None in a non-addressable value
gdb_test "python print ('result = %s' % i.address)" "= None" "test address attribute in non-addressable value"
# Test creating / printing an optimized out value
gdb_test "python print(gdb.Value(gdb.Value(5).type.optimized_out()))"
}
# Check that we can call gdb.Value.__init__ to change a value.

View File

@@ -145,3 +145,5 @@ gdb_test "print 0x0 as fn(i64) -> ()" " = \\\(\\*mut fn \\\(i64\\\) -> \\\(\\\)\
gdb_test "print r#" "No symbol 'r' in current context"
gdb_test "printf \"%d %d\\n\", 23+1, 23-1" "24 22"
gdb_test "print 5," "Syntax error near ','"

View File

@@ -56,46 +56,165 @@ standard_testfile
set bp_lineno [gdb_get_line_number "Set breakpoint here"]
# The test proper. See description above.
proc test {condition_eval target_non_stop non_stop displaced} {
global binfile srcfile
global gdb_prompt
global decimal
global bp_lineno
global GDBFLAGS
# Number of threads started by the program.
set n_threads 10
# Number of threads started by the program.
set n_threads 10
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\""
append GDBFLAGS " -ex \"set non-stop $non_stop\""
append GDBFLAGS " -ex \"set displaced $displaced\""
append GDBFLAGS " -ex \"set schedule-multiple on\""
clean_restart $binfile
# Start GDB, configuring various settings according to the arguments.
proc start_gdb_for_test {condition_eval target_non_stop non_stop displaced} {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\""
append ::GDBFLAGS " -ex \"set non-stop $non_stop\""
append ::GDBFLAGS " -ex \"set displaced $displaced\""
append ::GDBFLAGS " -ex \"set schedule-multiple on\""
clean_restart $::binfile
}
set test_spawn_id [spawn_wait_for_attach $binfile]
gdb_test_no_output "set breakpoint condition-evaluation $condition_eval"
}
# Use the 'attach' command to attach to process with pid TESTPID. Return true
# if we believe GDB has attached and we are back at the GDB prompt, otherwise,
# return false.
proc attach_to {testpid} {
with_timeout_factor 2 {
set attached 0
set saw_attaching 0
gdb_test_multiple "attach $testpid" "attach" {
-re "Attaching to program.*process $testpid\r\n" {
set saw_attaching 1
exp_continue
}
-re "new threads in iteration" {
# Seen when "set debug libthread_db" is on.
exp_continue
}
-re "Reading symbols from|Expanding full symbols from" {
# Prevent -readnow timeout.
exp_continue
}
-re "is a zombie - the process has already terminated.*$::gdb_prompt " {
fail $gdb_test_name
}
-re "Unable to attach: .*$::gdb_prompt " {
fail $gdb_test_name
}
-re "\r\n$::gdb_prompt " {
if { $saw_attaching } {
set attached 1
pass $gdb_test_name
} else {
fail $gdb_test_name
}
}
}
}
return $attached
}
# After attaching to a multi-threaded inferior in non-stop mode, we expect to
# see a stop message from each thread. This proc waits for all of these stop
# messages. TID_RE is a regexp used to match the thread-id of the stopped
# thread.
#
# Return true if we saw a stop from each of the expected threads (based on the
# global N_THREADS value), otherwise, return false.
proc check_stops_after_non_stop_attach {tid_re} {
set any "\[^\r\n\]*"
# In non-stop, we will see one stop per thread after the prompt.
set stops 0
set test "seen all stops"
for {set thread 1} { $thread <= $::n_threads } { incr thread } {
if {[gdb_test_multiple "" $test {
-re "Thread ${tid_re} ${any} stopped" {
incr stops
}
}] != 0} {
break
}
}
# If we haven't seen all stops, then the
# gdb_test_multiple in the loop above will have
# already issued a FAIL.
if {$stops != $::n_threads} {
return false
}
pass $test
return true
}
# Prepare for a single test iteration. TESTPID is the pid of the process GDB
# will be attached too. NON_STOP indicates if GDB is configured in non-stop
# mode or not. ATTEMPT is the current attempt number, and ATTEMPTS is the
# maximum number of attempts we plan to run. TID_RE is a string used to match
# against a thread-id in GDB's stop messages.
#
# Return true if everything is prepared correctly, otherwise return false.
proc prepare_test_iter {testpid non_stop attempt attempts tid_re} {
if {![attach_to $testpid]} {
return false
}
if {$non_stop} {
if {![check_stops_after_non_stop_attach $tid_re]} {
return false
}
}
gdb_test "break ${::srcfile}:${::bp_lineno} if 0" "Breakpoint.*" \
"break LOC if 0"
if {$attempt < $attempts} {
# Kick the time out timer for another round.
gdb_test "print again = 1" " = 1" "reset timer in the inferior"
# Show the time we had left in the logs, in case
# something goes wrong.
gdb_test "print seconds_left" " = .*"
}
if {$non_stop} {
set cont_cmd "continue -a &"
} else {
set cont_cmd "continue &"
}
set cont_cmd_re [string_to_regexp $cont_cmd]
gdb_test_multiple $cont_cmd "" {
-re "^$cont_cmd_re\r\nContinuing\.\r\n$::gdb_prompt " {
pass $gdb_test_name
}
}
# Wait a bit, to give time for the threads to hit the
# breakpoint.
sleep 1
return true
}
# The test proper. See the description at the top of the file.
proc_with_prefix test_detach_command {condition_eval target_non_stop non_stop displaced} {
set test_spawn_id [spawn_wait_for_attach $::binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
set any "\[^\r\n\]*"
start_gdb_for_test $condition_eval $target_non_stop $non_stop $displaced
gdb_test "add-inferior" "Added inferior 2.*"
gdb_test "inferior 2" "Switching to .*"
gdb_load $binfile
gdb_load $::binfile
if ![runto setup_done] then {
fail "can't run to setup_done"
kill_wait_spawned_process $test_spawn_id
return
}
gdb_test_no_output "set breakpoint condition-evaluation $condition_eval"
# Get the PID of the test process.
set pid_inf2 ""
gdb_test_multiple "p mypid" "get pid of inferior 2" {
-re " = ($decimal)\r\n$gdb_prompt $" {
-re " = ($::decimal)\r\n$::gdb_prompt $" {
set pid_inf2 $expect_out(1,string)
pass $gdb_test_name
}
@@ -106,101 +225,12 @@ proc test {condition_eval target_non_stop non_stop displaced} {
with_test_prefix "iter $attempt" {
gdb_test "inferior 1" "Switching to .*"
with_timeout_factor 2 {
set attached 0
set saw_attaching 0
set eperm 0
set test "attach"
gdb_test_multiple "attach $testpid" $test {
-re "Attaching to program.*process $testpid\r\n" {
set saw_attaching 1
exp_continue
}
-re "new threads in iteration" {
# Seen when "set debug libthread_db" is on.
exp_continue
}
-re "Reading symbols from|Expanding full symbols from" {
# Prevent -readnow timeout.
exp_continue
}
-re "is a zombie - the process has already terminated.*$gdb_prompt " {
fail $gdb_test_name
}
-re "Unable to attach: .*$gdb_prompt " {
fail $gdb_test_name
}
-re "\r\n$gdb_prompt " {
if { $saw_attaching } {
set attached 1
pass $test
} else {
fail $test
}
}
}
}
if {!$attached} {
if {![prepare_test_iter $testpid $non_stop \
$attempt $attempts "$::decimal\.$::decimal"]} {
kill_wait_spawned_process $test_spawn_id
return
}
if {$non_stop} {
# In non-stop, we will see one stop per thread after
# the prompt.
set stops 0
set tid_re "$::decimal\.$::decimal"
set test "seen all stops"
for {set thread 1} { $thread <= $n_threads } { incr thread } {
if {[gdb_test_multiple "" $test {
-re "Thread ${tid_re} ${any} stopped" {
incr stops
}
}] != 0} {
break
}
}
# If we haven't seen all stops, then the
# gdb_test_multiple in the loop above will have
# already issued a FAIL.
if {$stops != $n_threads} {
kill_wait_spawned_process $test_spawn_id
return
}
pass $test
}
# Set threads stepping over a breakpoint continuously.
gdb_test "break $srcfile:$bp_lineno if 0" "Breakpoint.*" \
"break LOC if 0"
if {$attempt < $attempts} {
# Kick the time out timer for another round.
gdb_test "print again = 1" " = 1" "reset timer in the inferior"
# Show the time we had left in the logs, in case
# something goes wrong.
gdb_test "print seconds_left" " = .*"
}
if {$non_stop} {
set cont_cmd "continue -a &"
} else {
set cont_cmd "continue &"
}
set cont_cmd_re [string_to_regexp $cont_cmd]
gdb_test_multiple $cont_cmd "" {
-re "^$cont_cmd_re\r\nContinuing\.\r\n$gdb_prompt " {
pass $gdb_test_name
}
}
# Wait a bit, to give time for the threads to hit the
# breakpoint.
sleep 1
set running_count 0
set interrupted 0
gdb_test_multiple "info threads" "all threads running" {
@@ -208,14 +238,14 @@ proc test {condition_eval target_non_stop non_stop displaced} {
incr running_count
exp_continue
}
-re "Cannot execute this command while the target is running.*$gdb_prompt $" {
-re "Cannot execute this command while the target is running.*$::gdb_prompt $" {
# Testing against a remote server that doesn't do
# non-stop mode. Explicitly interrupt. This
# doesn't test the same code paths in GDB, but
# it's still something.
set interrupted 1
gdb_test_multiple "interrupt" "" {
-re "$gdb_prompt " {
-re "$::gdb_prompt " {
gdb_test_multiple "" $gdb_test_name {
-re "received signal SIGINT, Interrupt" {
pass $gdb_test_name
@@ -224,8 +254,9 @@ proc test {condition_eval target_non_stop non_stop displaced} {
}
}
}
-re "$gdb_prompt $" {
gdb_assert {$running_count == ($n_threads + 1) * 2} $gdb_test_name
-re "$::gdb_prompt $" {
gdb_assert {$running_count == ($::n_threads + 1) * 2} \
$gdb_test_name
}
}
@@ -253,6 +284,56 @@ proc test {condition_eval target_non_stop non_stop displaced} {
kill_wait_spawned_process $test_spawn_id
}
# Similar to the proc above, but this time, instead of detaching using
# the 'detach' command, we quit GDB, this will also trigger a detach, but
# through a slightly different path, which can expose different bugs.
proc_with_prefix test_detach_quit {condition_eval target_non_stop \
non_stop displaced} {
# If debugging with target remote, check whether the all-stop variant
# of the RSP is being used. If so, we can't run the background tests.
if {!$non_stop
&& [target_info exists gdb_protocol]
&& ([target_info gdb_protocol] == "remote"
|| [target_info gdb_protocol] == "extended-remote")} {
start_gdb_for_test $condition_eval $target_non_stop \
$non_stop $displaced
gdb_test_multiple "maint show target-non-stop" "" {
-wrap -re "(is|currently) on.*" {
}
-wrap -re "(is|currently) off.*" {
return
}
}
}
set test_spawn_id [spawn_wait_for_attach $::binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
set attempts 3
for {set attempt 1} { $attempt <= $attempts } { incr attempt } {
with_test_prefix "iter $attempt" {
start_gdb_for_test $condition_eval $target_non_stop \
$non_stop $displaced
if {![prepare_test_iter $testpid $non_stop \
$attempt $attempts "$::decimal"]} {
kill_wait_spawned_process $test_spawn_id
return
}
gdb_test_multiple "with confirm off -- quit" "" {
eof {
pass $gdb_test_name
}
}
}
}
kill_wait_spawned_process $test_spawn_id
}
# The test program exits after a while, in case GDB crashes. Make it
# wait at least as long as we may wait before declaring a time out
# failure.
@@ -298,7 +379,10 @@ foreach_with_prefix breakpoint-condition-evaluation {"host" "target"} {
}
foreach_with_prefix displaced {"off" "auto"} {
test ${breakpoint-condition-evaluation} ${target-non-stop} ${non-stop} ${displaced}
test_detach_command ${breakpoint-condition-evaluation} \
${target-non-stop} ${non-stop} ${displaced}
test_detach_quit ${breakpoint-condition-evaluation} \
${target-non-stop} ${non-stop} ${displaced}
}
}
}

View File

@@ -5151,6 +5151,32 @@ gdb_caching_proc can_spawn_for_attach {
return 1
}
# Centralize the failure checking of "attach" command.
# Return 0 if attach failed, otherwise return 1.
proc gdb_attach { testpid args } {
parse_args {
{pattern ""}
}
if { [llength $args] != 0 } {
error "Unexpected arguments: $args"
}
gdb_test_multiple "attach $testpid" "attach" {
-re -wrap "Attaching to.*ptrace: Operation not permitted\\." {
unsupported "$gdb_test_name (Operation not permitted)"
return 0
}
-re -wrap "$pattern" {
pass $gdb_test_name
return 1
}
}
return 0
}
# Kill a progress previously started with spawn_wait_for_attach, and
# reap its wait status. PROC_SPAWN_ID is the spawn id associated with
# the process.
@@ -8302,6 +8328,29 @@ gdb_caching_proc have_mpx {
remote_file build delete $obj
if { $status == 0 } {
verbose "$me: returning $status" 2
return $status
}
# Compile program with -mmpx -fcheck-pointer-bounds, try to trigger
# 'No MPX support', in other words, see if kernel supports mpx.
set src { int main (void) { return 0; } }
set comp_flags {}
append comp_flags " additional_flags=-mmpx"
append comp_flags " additional_flags=-fcheck-pointer-bounds"
if {![gdb_simple_compile $me-2 $src executable $comp_flags]} {
return 0
}
set result [remote_exec target $obj]
set status [lindex $result 0]
set output [lindex $result 1]
set status [expr ($status == 0) \
&& ![string equal $output "No MPX support\r\n"]]
remote_file build delete $obj
verbose "$me: returning $status" 2
return $status
}

View File

@@ -260,6 +260,41 @@ void (*deprecated_context_hook) (int id);
/* The highest UI number ever assigned. */
static int highest_ui_num;
/* Unbuffer STREAM. This is a wrapper around setbuf(STREAM, nullptr)
which applies some special rules for MS-Windows hosts. */
static void
unbuffer_stream (FILE *stream)
{
/* Unbuffer the input stream so that in gdb_readline_no_editing_callback,
the calls to fgetc fetch only one char at the time from STREAM.
This is important because gdb_readline_no_editing_callback will read
from STREAM up to the first '\n' character, after this GDB returns to
the event loop and relies on a select on STREAM indicating that more
input is pending.
If STREAM is buffered then the fgetc calls may have moved all the
pending input from the kernel into a local buffer, after which the
select will not indicate that more input is pending, and input after
the first '\n' will not be processed immediately.
Please ensure that any changes in this area run the MI tests with the
FORCE_SEPARATE_MI_TTY=1 flag being passed. */
#ifdef __MINGW32__
/* With MS-Windows runtime, making stdin unbuffered when it's
connected to the terminal causes it to misbehave. */
if (!ISATTY (stream))
setbuf (stream, nullptr);
#else
/* On GNU/Linux the issues described above can impact GDB even when
dealing with input from a terminal. For now we unbuffer the input
stream for everyone except MS-Windows. */
setbuf (stream, nullptr);
#endif
}
/* See top.h. */
ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
@@ -286,6 +321,8 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
{
buffer_init (&line_buffer);
unbuffer_stream (instream_);
if (ui_list == NULL)
ui_list = this;
else
@@ -415,6 +452,8 @@ read_command_file (FILE *stream)
{
struct ui *ui = current_ui;
unbuffer_stream (stream);
scoped_restore save_instream
= make_scoped_restore (&ui->instream, stream);

View File

@@ -343,8 +343,10 @@ struct value
LONGEST embedded_offset = 0;
LONGEST pointed_to_offset = 0;
/* Actual contents of the value. Target byte-order. NULL or not
valid if lazy is nonzero. */
/* Actual contents of the value. Target byte-order.
May be nullptr if the value is lazy or is entirely optimized out.
Guaranteed to be non-nullptr otherwise. */
gdb::unique_xmalloc_ptr<gdb_byte> contents;
/* Unavailable ranges in CONTENTS. We mark unavailable ranges,
@@ -1725,8 +1727,10 @@ value_copy (const value *arg)
val->stack = arg->stack;
val->is_zero = arg->is_zero;
val->initialized = arg->initialized;
val->unavailable = arg->unavailable;
val->optimized_out = arg->optimized_out;
if (!value_lazy (val))
if (!value_lazy (val) && !value_entirely_optimized_out (val))
{
gdb_assert (arg->contents != nullptr);
ULONGEST length = TYPE_LENGTH (value_enclosing_type (arg));
@@ -1735,8 +1739,6 @@ value_copy (const value *arg)
copy (arg_view, value_contents_all_raw (val));
}
val->unavailable = arg->unavailable;
val->optimized_out = arg->optimized_out;
val->parent = arg->parent;
if (VALUE_LVAL (val) == lval_computed)
{
@@ -4271,6 +4273,20 @@ test_insert_into_bit_range_vector ()
}
}
static void
test_value_copy ()
{
type *type = builtin_type (current_inferior ()->gdbarch)->builtin_int;
/* Verify that we can copy an entirely optimized out value, that may not have
its contents allocated. */
value_ref_ptr val = release_value (allocate_optimized_out_value (type));
value_ref_ptr copy = release_value (value_copy (val.get ()));
SELF_CHECK (value_entirely_optimized_out (val.get ()));
SELF_CHECK (value_entirely_optimized_out (copy.get ()));
}
} /* namespace selftests */
#endif /* GDB_SELF_TEST */
@@ -4355,6 +4371,7 @@ and exceeds this limit will cause an error."),
selftests::register_test ("ranges_contain", selftests::test_ranges_contain);
selftests::register_test ("insert_into_bit_range_vector",
selftests::test_insert_into_bit_range_vector);
selftests::register_test ("value_copy", selftests::test_value_copy);
#endif
}

View File

@@ -1 +1 @@
12.0.50.DATE-git
12.1.90.DATE-git

View File

@@ -155,30 +155,35 @@ thread_db_state_str (td_thr_state_e state)
}
#endif
/* Get thread info about PTID, accessing memory via the current
thread. */
/* Get thread info about PTID. */
static int
find_one_thread (ptid_t ptid)
{
td_thrhandle_t th;
td_thrinfo_t ti;
td_err_e err;
struct lwp_info *lwp;
struct thread_db *thread_db = current_process ()->priv->thread_db;
int lwpid = ptid.lwp ();
thread_info *thread = find_thread_ptid (ptid);
lwp = get_thread_lwp (thread);
lwp_info *lwp = get_thread_lwp (thread);
if (lwp->thread_known)
return 1;
/* Get information about this thread. */
err = thread_db->td_ta_map_lwp2thr_p (thread_db->thread_agent, lwpid, &th);
/* Get information about this thread. libthread_db will need to read some
memory, which will be done on the current process, so make PTID's process
the current one. */
process_info *proc = find_process_pid (ptid.pid ());
gdb_assert (proc != nullptr);
scoped_restore_current_thread restore_thread;
switch_to_process (proc);
thread_db *thread_db = proc->priv->thread_db;
td_thrhandle_t th;
int lwpid = ptid.lwp ();
td_err_e err = thread_db->td_ta_map_lwp2thr_p (thread_db->thread_agent, lwpid,
&th);
if (err != TD_OK)
error ("Cannot get thread handle for LWP %d: %s",
lwpid, thread_db_err_str (err));
td_thrinfo_t ti;
err = thread_db->td_thr_get_info_p (&th, &ti);
if (err != TD_OK)
error ("Cannot get thread info for LWP %d: %s",

View File

@@ -14,7 +14,7 @@
@SET_MAKE@
# Copyright (C) 2019-2021 Free Software Foundation, Inc.
# Copyright (C) 2019-2022 Free Software Foundation, Inc.
# This file is part of GDB.

View File

@@ -2,7 +2,7 @@
<!-- Parent-Version: 1.78 -->
<!--
Copyright (C) 2006-2022 Free Software Foundation, Inc.
Copyright (C) 2006-2021 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<!--
Copyright (C) 2007-2022 Free Software Foundation, Inc.
Copyright (C) 2007-2021 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@@ -743,6 +743,8 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
else
{
#ifndef WINDOWS32
/* Recognize ~user as a shorthand for the specified user's home
directory. */
char *end_name = strchr (dirname, '/');
char *user_name;
int malloc_user_name = 0;
@@ -881,7 +883,22 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
}
scratch_buffer_free (&pwtmpbuf);
}
#endif /* !WINDOWS32 */
#else /* WINDOWS32 */
/* On native Windows, access to a user's home directory
(via GetUserProfileDirectory) or to a user's environment
variables (via ExpandEnvironmentStringsForUser) requires
the credentials of the user. Therefore we cannot support
the ~user syntax on this platform.
Handling ~user specially (and treat it like plain ~) if
user is getenv ("USERNAME") would not be a good idea,
since it would make people think that ~user is supported
in general. */
if (flags & GLOB_TILDE_CHECK)
{
retval = GLOB_NOMATCH;
goto out;
}
#endif /* WINDOWS32 */
}
}

View File

@@ -530,12 +530,13 @@ restart:
if (h != handle_array[nhandles])
{
/* Perform handle->descriptor mapping. */
WSAEventSelect ((SOCKET) h, NULL, 0);
if (FD_ISSET (h, &handle_rfds))
SOCKET s = (SOCKET) h;
WSAEventSelect (s, NULL, 0);
if (FD_ISSET (s, &handle_rfds))
FD_SET (i, rfds);
if (FD_ISSET (h, &handle_wfds))
if (FD_ISSET (s, &handle_wfds))
FD_SET (i, wfds);
if (FD_ISSET (h, &handle_xfds))
if (FD_ISSET (s, &handle_xfds))
FD_SET (i, xfds);
}
else

View File

@@ -2033,9 +2033,17 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
# undef swab
# define swab _swab
# endif
_GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n));
/* Need to cast, because in old mingw the arguments are
(const char *from, char *to, size_t n). */
_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
# else
# if defined __hpux /* HP-UX */
_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
# elif defined __sun && !defined _XPG4 /* Solaris */
_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
# else
_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
# endif
# endif
_GL_CXXALIASWARN (swab);
#endif

View File

@@ -0,0 +1,49 @@
commit 38d0749a3077b03fda46567510b1217fb5e4e170
Author: Bruno Haible <bruno@clisp.org>
Date: Fri Apr 2 17:34:46 2021 +0200
glob: Reject ~user syntax, when flag GLOB_TILDE_CHECK is given.
Reported and patch suggested by Eli Zaretskii <eliz@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00136.html>.
* lib/glob.c (__glob) [WINDOWS32]: If flag GLOB_TILDE_CHECK is given, do
error handling like when ~user is allowed by the user is unknown.
diff --git a/gnulib/import/glob.c b/gnulib/import/glob.c
index 775911ef5b..e148f8d761 100644
--- a/gnulib/import/glob.c
+++ b/gnulib/import/glob.c
@@ -743,6 +743,8 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
else
{
#ifndef WINDOWS32
+ /* Recognize ~user as a shorthand for the specified user's home
+ directory. */
char *end_name = strchr (dirname, '/');
char *user_name;
int malloc_user_name = 0;
@@ -881,7 +883,22 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
}
scratch_buffer_free (&pwtmpbuf);
}
-#endif /* !WINDOWS32 */
+#else /* WINDOWS32 */
+ /* On native Windows, access to a user's home directory
+ (via GetUserProfileDirectory) or to a user's environment
+ variables (via ExpandEnvironmentStringsForUser) requires
+ the credentials of the user. Therefore we cannot support
+ the ~user syntax on this platform.
+ Handling ~user specially (and treat it like plain ~) if
+ user is getenv ("USERNAME") would not be a good idea,
+ since it would make people think that ~user is supported
+ in general. */
+ if (flags & GLOB_TILDE_CHECK)
+ {
+ retval = GLOB_NOMATCH;
+ goto out;
+ }
+#endif /* WINDOWS32 */
}
}

View File

@@ -0,0 +1,36 @@
commit c7b1e060d17023065c776757da406d728310cc38
Author: Bruno Haible <bruno@clisp.org>
Date: Sun Jun 20 17:18:26 2021 +0200
unistd: Avoid compilation error in C++ mode on Solaris, HP-UX, mingw.
Reported by Eli Zaretskii <eliz@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00135.html>.
* lib/unistd.in.h (swab): Consider different declarations on Solaris,
HP-UX, and old mingw.
diff --git a/gnulib/import/unistd.in.h b/gnulib/import/unistd.in.h
index d4d4ba7743..73c882f97b 100644
--- a/gnulib/import/unistd.in.h
+++ b/gnulib/import/unistd.in.h
@@ -2034,9 +2034,17 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
# undef swab
# define swab _swab
# endif
-_GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n));
-# else
+/* Need to cast, because in old mingw the arguments are
+ (const char *from, char *to, size_t n). */
+_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
+# else
+# if defined __hpux /* HP-UX */
+_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
+# elif defined __sun && !defined _XPG4 /* Solaris */
+_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
+# else
_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
+# endif
# endif
_GL_CXXALIASWARN (swab);
#endif

View File

@@ -0,0 +1,33 @@
commit 21fccfa0451ba59fba479e439465da9c360353d3
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Jul 8 10:00:30 2021 -0700
select: port better to MinGW
Problem reported by Eli Zaretskii in:
https://lists.gnu.org/r/bug-gnulib/2021-07/msg00017.html
* lib/select.c (rpl_select) [_WIN32 && !__CYGWIN__]:
Pass a SOCKET, not a HANDLE, to FD_ISSET.
diff --git a/gnulib/import/select.c b/gnulib/import/select.c
index 2fe6a18064..eddac4b61f 100644
--- a/gnulib/import/select.c
+++ b/gnulib/import/select.c
@@ -530,12 +530,13 @@ restart:
if (h != handle_array[nhandles])
{
/* Perform handle->descriptor mapping. */
- WSAEventSelect ((SOCKET) h, NULL, 0);
- if (FD_ISSET (h, &handle_rfds))
+ SOCKET s = (SOCKET) h;
+ WSAEventSelect (s, NULL, 0);
+ if (FD_ISSET (s, &handle_rfds))
FD_SET (i, rfds);
- if (FD_ISSET (h, &handle_wfds))
+ if (FD_ISSET (s, &handle_wfds))
FD_SET (i, wfds);
- if (FD_ISSET (h, &handle_xfds))
+ if (FD_ISSET (s, &handle_xfds))
FD_SET (i, xfds);
}
else

View File

@@ -180,6 +180,7 @@ fi
# Apply our local patches.
apply_patches ()
{
echo "Applying $1..."
patch -p2 -f -i "$1"
if [ $? -ne 0 ]; then
echo "Failed to apply some patches. Aborting."
@@ -188,6 +189,9 @@ apply_patches ()
}
apply_patches "patches/0001-use-windows-stat"
apply_patches "patches/0002-glob-tilde-check"
apply_patches "patches/0003-unistd-h-fix"
apply_patches "patches/0004-select-mingw"
# Regenerate all necessary files...
aclocal &&