Age | Commit message (Collapse) | Author | Files | Lines |
|
To help ensure that all debug statements have the same format, introduce
the debug_prefixed_vprintf helper. Implement linux_nat_debug_printf_1
and infrun_debug_printf_1 with it.
I would eventually like to style the module and function name with some
color, to help them stick out, but I don't really know how to do that
yet, it can always be done later.
gdb/ChangeLog:
* debug.h: New file.
* debug.c (debug_prefixed_vprintf): New function.
* infrun.c (infrun_debug_printf_1): Use debug_prefixed_vprintf.
* linux-nat.c (linux_nat_debug_printf_1): Likewise.
Change-Id: Iccc290a2dc6b5fffcbe1c2866ed8d804ad380764
|
|
Introduce this macro to print debug statements in the infrun.c file,
same idea as what was done in 9327494e0eeb ("gdb: add
linux_nat_debug_printf macro").
Although in this case, there are places outside infrun.c that print
debug statements if debug_infrun is set. So the macro has to be
declared in the header file, so that it can be used in these other
files.
Note one special case. In stop_all_threads, I've used an explicit
if (debug_infrun)
infrun_debug_printf_1 ("stop_all_threads", "done");
for the message in the SCOPE_EXIT. Otherwise, the message appears like
this:
[infrun] operator(): done
Until we find a better solution for extracting a meaningful function
name for lambda functions, I think it's fine to handle these special
cases manually, they are quite rare.
Some tests need to be updated, because they rely on some infrun debug
statements.
gdb/ChangeLog:
* infrun.h (infrun_debug_printf_1): New function declaration.
(infrun_debug_printf): New macro.
* infrun.c (infrun_debug_printf_1): Use infrun_debug_printf
throughout.
(infrun_debug_printf): New function.
* breakpoint.c (should_be_inserted): Use infrun_debug_printf.
(handle_jit_event): Likewise.
gdb/testsuite/ChangeLog:
* gdb.base/gdb-sigterm.exp (do_test): Update expected regexp.
* gdb.threads/signal-while-stepping-over-bp-other-thread.exp:
Likewise.
* gdb.threads/stepi-random-signal.exp: Likewise.
Change-Id: I66433c8a9caa64c8525ab57c593022b9d1956d5c
|
|
gdb/ChangeLog:
2020-08-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (process_event_stop_test): Fix typo "breapoint".
gdb/testsuite/ChangeLog:
2020-08-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/print-file-var.exp: Fix typo "breapoint".
* gdb.trace/strace.exp: Ditto.
|
|
I noticed what I think is a potential bug. I did not observe it nor was
I able to reproduce it using actual debugging. It's quite unlikely,
because it involves multi-target and ptid clashes. I added selftests
that demonstrate it though.
The thread_ptid_changed observer says that thread with OLD_PTID now has
NEW_PTID. Now, if for some reason we happen to have two targets
defining a thread with OLD_PTID, the observers don't know which thread
this is about.
regcache::regcache_thread_ptid_changed changes all regcaches with
OLD_PTID. If there is a regcache for a thread with ptid OLD_PTID, but
that belongs to a different target, this regcache will be erroneously
changed.
Similarly, infrun_thread_ptid_changed updates inferior_ptid if
inferior_ptid matches OLD_PTID. But if inferior_ptid currently refers
not to the thread is being changed, but to a thread with the same ptid
belonging to a different target, then inferior_ptid will erroneously be
changed.
This patch adds a `process_stratum_target *` parameter to the
`thread_ptid_changed` observable and makes the two observers use it.
Tests for both are added, which would fail if the corresponding fix
wasn't done.
gdb/ChangeLog:
* observable.h (thread_ptid_changed): Add parameter
`process_stratum_target *`.
* infrun.c (infrun_thread_ptid_changed): Add parameter
`process_stratum_target *` and use it.
(selftests): New namespace.
(infrun_thread_ptid_changed): New function.
(_initialize_infrun): Register selftest.
* regcache.c (regcache_thread_ptid_changed): Add parameter
`process_stratum_target *` and use it.
(regcache_thread_ptid_changed): New function.
(_initialize_regcache): Register selftest.
* thread.c (thread_change_ptid): Pass target to
thread_ptid_changed observable.
Change-Id: I0599e61224b6d154a7b55088a894cb88298c3c71
|
|
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (handle_segmentation_fault): Remove method.
* infrun.c (handle_segmentation_fault): Remove.
(print_signal_received_reason): Remove call to
handle_segmentation_fault.
|
|
This is a more general version of the existing handle_segmentation_fault
hook that is able to report information for an arbitrary signal, not
just SIGSEGV.
gdb/ChangeLog:
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (report_signal_info): New method.
* infrun.c (print_signal_received_reason): Invoke gdbarch
report_signal_info hook if present.
|
|
When interrupting a program in non-stop, the program gets interrupted
correctly, but GDB busy loops (the event loop is always woken up).
Here is how to reproduce it:
1. Start GDB: ./gdb -nx --data-directory=data-directory -ex "set non-stop 1" --args /bin/sleep 60
2. Run the program with "run"
3. Interrupt with ^C.
4. Look into htop, see GDB taking 100% CPU
Debugging `handle_file_event`, we see that the event source that wakes
up the event loop is the linux-nat one:
(top-gdb) p file_ptr.proc
$5 = (handler_func *) 0xb9cccd <handle_target_event(int, gdb_client_data)>
^^^^^^^^^^^^^^^^^^^
|
\-- the linux-nat callback
Debugging fetch_inferior_event and do_target_wait, we see that we
don't actually call `wait` on the linux-nat target, because
inferior_matches returns false:
auto inferior_matches = [&wait_ptid] (inferior *inf)
{
return (inf->process_target () != NULL
&& (threads_are_executing (inf->process_target ())
|| threads_are_resumed_pending_p (inf))
&& ptid_t (inf->pid).matches (wait_ptid));
};
because `threads_are_executing` is false.
What happens is:
1. User types ctrl-c, that writes in the linux-nat pipe, waking up
the event source.
2. linux-nat's wait gets called, the SIGINT event is returned, but
before returning, it marks the pipe again, in order for wait to
get called again:
/* If we requested any event, and something came out, assume there
may be more. If we requested a specific lwp or process, also
assume there may be more. */
if (target_is_async_p ()
&& ((ourstatus->kind != TARGET_WAITKIND_IGNORE
&& ourstatus->kind != TARGET_WAITKIND_NO_RESUMED)
|| ptid != minus_one_ptid))
async_file_mark ();
3. The SIGINT event is handled, the program is stopped, the stop
notification is printed.
4. The event loop is woken up again because of the `async_file_mark`
of step 2.
5. Because `inferior_matches` returns false, we never call
linux-nat's wait, so the pipe stays readable.
6. Goto 4.
Pedro says:
This commit fixes it by letting do_target_wait call target_wait even
if threads_are_executing is false. This will normally result in the
target returning TARGET_WAITKIND_NO_RESUMED, and _not_ marking its
event source again. This results in infrun only calling into the
target only once (i.e., breaking the busy loop).
Note that the busy loop bug didn't trigger in all-stop mode because
all-stop handles this by unregistering the target from the event loop
as soon as it was all stopped -- see
inf-loop.c:inferior_event_handler's INF_EXEC_COMPLETE handling. If we
remove that non-stop check from inferior_event_handler, and replace
the target_has_execution check for threads_are_executing instead, it
also fixes the issue for non-stop. I considered that as the final
solution, but decided that the solution proposed here instead is just
simpler and more future-proof design. With the
TARGET_WAITKIND_NO_RESUMED handling fixes done in the previous
patches, I think it should be possible to always keep the target
registered in the event loop, meaning we could eliminate the
target_async(0) call from inferior_event_handler as well as most of
the target_async(1) calls in the target backends. That would allow in
the future e.g., the remote target reporting asynchronous
notifications even if all threads are stopped. I haven't attempted
that, though.
gdb/ChangeLog:
yyyy-mm-dd Simon Marchi <simon.marchi@polymtl.ca>
Pedro Alves <pedro@palves.net>
PR gdb/26199
* infrun.c (threads_are_resumed_pending_p): Delete.
(do_target_wait): Remove threads_are_executing and
threads_are_resumed_pending_p checks from the inferior_matches
lambda. Update comments.
|
|
Let's consider the same use case as in the previous commit:
Say you have two inferiors 1 and 2, each connected to a different
target, A and B.
Now say you set inferior 2 running, with "continue &".
Now you select a thread of inferior 1, say thread 1.2, and continue in
the foreground. All other threads of inferior 1 are left stopped.
Thread 1.2 exits, and thus target A has no other resumed thread, so it
reports TARGET_WAITKIND_NO_RESUMED.
At this point, because the threads of inferior 2 are still executing
the TARGET_WAITKIND_NO_RESUMED event is ignored.
Now, the user types Ctrl-C. Because GDB had previously put inferior 1
in the foreground, the kernel sends the SIGINT to that inferior.
However, no thread in that inferior is executing right now, so ptrace
never intercepts the SIGINT -- it is never dequeued by any thread.
The result is that GDB's CLI is stuck. There's no way to get back the
prompt (unless inferior 2 happens to report some event).
The fix in this commit is to make handle_no_resumed give the terminal
to some other inferior that still has threads executing so that a
subsequent Ctrl-C reaches that target first (and then GDB intercepts
the SIGINT). This is a bit hacky, but seems like the best we can do
with the current design.
I think that putting all native inferiors in their own session would
help fixing this in a clean way, since with that a Ctrl-C on GDB's
terminal will _always_ reach GDB first, and then GDB can decide how to
pause the inferior. But that's a much larger change.
The testcase added by the following patch needs this fix.
gdb/ChangeLog:
PR gdb/26199
* infrun.c (handle_no_resumed): Transfer terminal to inferior with
executing threads.
|
|
handle_no_resumed is currently not considering multiple targets.
Say you have two inferiors 1 and 2, each connected to a different
target, A and B.
Now say you set inferior 2 running, with "continue &".
Now you select a thread of inferior 1, say thread 1.2, and continue in
the foreground. All other threads of inferior 1 are left stopped.
Thread 1.2 exits, and thus target A has no other resumed thread, so it
reports TARGET_WAITKIND_NO_RESUMED.
At this point, if both inferiors were running in the same target,
handle_no_resumed would realize that threads of inferior 2 are still
executing, so the TARGET_WAITKIND_NO_RESUMED event should be ignored.
But because handle_no_resumed only walks the threads of the current
target, it misses noticing that threads of inferior 2 are still
executing. The fix is just to walk over all threads of all targets.
A testcase covering the use case above will be added in a following
patch. It can't be added yet because it depends on yet another fix to
handle_no_resumed not included here.
gdb/ChangeLog:
PR gdb/26199
* infrun.c (handle_no_resumed): Handle multiple targets.
|
|
If we hit the synchronous execution command case described by
handle_no_resumed, and handle_no_resumed determines that the event
should be ignored, because it found a thread that is executing, we end
up in prepare_to_wait.
There, if the current target is not registered in the event loop right
now, we call mark_infrun_async_event_handler. With that event handler
marked, the event loop calls again into fetch_inferior_event, which
calls target_wait, which returns TARGET_WAITKIND_NO_RESUMED, and we
end up in handle_no_resumed, again ignoring the event and marking
infrun_async_event_handler. The result is that GDB is now always
keeping the CPU 100% busy in this loop, even though it continues to be
able to react to input and to real target events, because we still go
through the event-loop.
The problem is that marking of the infrun_async_event_handler in
prepare_to_wait. That is there to handle targets that don't support
asynchronous execution. So the correct predicate is whether async
execution is supported, not whether the target is async right now.
gdb/ChangeLog:
PR gdb/26199
* infrun.c (prepare_to_wait): Check target_can_async_p instead of
target_is_async_p.
|
|
I noticed that fetch_inferior_event receives the client_data parameter
from its caller, inferior_event_handler, but doesn't actually need it.
This patch removes it. In turn, inferior_event_handler doesn't use its
parameter, so remove it too.
The `data` argument used when registering
remote_async_inferior_event_handler is changed to NULL, to avoid
confusion. It could make people think that the value passed is used
somewhere, when in fact it's not.
gdb/ChangeLog:
* inf-loop.c (inferior_event_handler): Remove client_data param.
* inf-loop.h (inferior_event_handler): Likewise.
* infcmd.c (step_1): Adjust.
* infrun.c (proceed): Adjust.
(fetch_inferior_event): Remove client_data param.
(infrun_async_inferior_event_handler): Adjust.
* infrun.h (fetch_inferior_event): Remove `void *` param.
* linux-nat.c (handle_target_event): Adjust.
* record-btrace.c (record_btrace_handle_async_inferior_event):
Adjust.
* record-full.c (record_full_async_inferior_event_handler):
Adjust.
* remote.c (remote_async_inferior_event_handler): Adjust.
Change-Id: I3c2aa1eb0ea3e0985df096660d2dcd794674f2ea
|
|
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* infrun.c (generic_mourn_inferior): Use switch_to_thread instead
of writing to inferior_ptid.
(scoped_restore_exited_inferior): Delete.
(handle_vfork_child_exec_or_exit): Simplify using
scoped_restore_current_pspace_and_thread. Use switch_to_thread
instead of writing to inferior_ptid.
(THREAD_STOPPED_BY): Delete.
(thread_stopped_by_watchpoint, thread_stopped_by_sw_breakpoint)
(thread_stopped_by_hw_breakpoint): Delete.
(save_waitstatus): Use
scoped_restore_current_thread+switch_to_thread, and call
target_stopped_by_watchpoint instead of
thread_stopped_by_watchpoint, target_stopped_by_sw_breakpoint
instead of thread_stopped_by_sw_breakpoint, and
target_stopped_by_hw_breakpoint instead of
thread_stopped_by_hw_breakpoint.
(handle_inferior_event)
<TARGET_WAITKIND_EXITED/TARGET_WAITKIND_SIGNALLED>: Don't write to
inferior_ptid directly, nor
set_current_inferior/set_current_program_space. Use
switch_to_thread / switch_to_inferior_no_thread instead.
|
|
Continuing my goal of removing the "ALL_*" iterator macros, this
removes ALL_UIS, replacing it with an iterator adaptor.
gdb/ChangeLog
2020-05-16 Tom Tromey <tom@tromey.com>
* top.c (quit_force): Update.
* infrun.c (handle_no_resumed): Update.
* top.h (all_uis): New function.
(ALL_UIS): Remove.
|
|
[Simon: I send this patch on behalf of Laurent Morichetti, I added the
commit message and performance measurement stuff.
Also, this patch is better viewed with "git show -w".]
stop_all_threads, in infrun.c, is used to stop all running threads on
targets that are always non-stop. It's used, for example, when the
program hits a breakpoint while GDB is set to "non-stop off". It sends
a stop request for each running thread, then collects one wait event for
each.
Since new threads can spawn while we are stopping the threads, it's
written in a way where it makes multiple such "send stop requests to
running threads & collect wait events" passes. The function completes
when it has made two passes where it hasn't seen any running threads.
With the way it's written right now is, it iterates on the thread list,
sending a stop request for each running thread. It then waits for a
single event, after which it iterates through the thread list again. It
sends stop requests for any running threads that's been created since
the last iteration. It then consumes another single wait event.
This makes it so we iterate on O(n^2) threads in total, where n is the
number of threads. This patch changes the function to reduce it to
O(n). This starts to have an impact when dealing with multiple
thousands of threads (see numbers below). At each pass, we know the
number of outstanding stop requests we have sent, for which we need to
collect a stop event. We can therefore loop to collect this many stop
events before proceeding to the next pass and iterate on the thread list
again.
To check the performance improvements with this patch, I made an
x86/Linux program with a large number of idle threads (varying from 1000
to 10000). The program's main thread hits a breakpoint once all these
threads have started, which causes stop_all_threads to be called to stop
all these threads. I measured (by patching stop_all_threads):
- the execution time of stop_all_threads
- the total number of threads we iterate on during the complete
execution of the function (the total number of times we execute the
"for (thread_info *t : all_non_exited_threads ())" loop)
These are the execution times, in milliseconds:
# threads before after
1000 226 106
2000 997 919
3000 3461 2323
4000 4330 3570
5000 8642 6600
6000 9918 8039
7000 12662 10930
8000 16652 11222
9000 21561 15875
10000 26613 20019
Note that I very unscientifically executed each case only once.
These are the number of loop executions:
# threads before after
1000 1003002 3003
2000 4006002 6003
3000 9009002 9003
4000 16012002 12003
5000 25015002 15003
6000 36018002 18003
7000 49021002 21003
8000 64024002 24003
9000 81027002 27003
10000 100030002 30003
This last table shows pretty well the O(n^2) vs O(n) behaviors.
Reg-tested on x86 GNU/Linux (Ubuntu 16.04).
gdb/ChangeLog:
YYYY-MM-DD Laurent Morichetti <Laurent.Morichetti@amd.com>
YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com>
* infrun.c (stop_all_threads): Collect multiple wait events at
each pass.
|
|
In stop_all_threads, GDB sends signals to other threads in an attempt
to stop them. While in a typical scenario the expected wait status is
TARGET_WAITKIND_STOPPED, it is possible that the thread GDB attempted
to stop has already terminated. If so, a waitstatus other than
TARGET_WAITKIND_STOPPED would be received. Handle this case
appropriately.
If a wait status that denotes thread termination is ignored, GDB goes
into an infinite loop in stop_all_threads.
E.g.:
$ gdb ./a.out
(gdb) start
...
(gdb) add-inferior -exec ./a.out
...
(gdb) inferior 2
...
(gdb) start
...
(gdb) set schedule-multiple on
(gdb) set debug infrun 2
(gdb) continue
Continuing.
infrun: clear_proceed_status_thread (process 10449)
infrun: clear_proceed_status_thread (process 10453)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 10449
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 10449] at 0x55555555514e
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: proceed: resuming process 10453
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 10453] at 0x55555555514e
infrun: prepare_to_wait
infrun: Found 2 inferiors, starting at #0
infrun: target_wait (-1.0.0, status) =
infrun: 10449.10449.0 [process 10449],
infrun: status->kind = exited, status = 0
infrun: handle_inferior_event status->kind = exited, status = 0
[Inferior 1 (process 10449) exited normally]
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun: process 10453 executing, need stop
infrun: target_wait (-1.0.0, status) =
infrun: 10453.10453.0 [process 10453],
infrun: status->kind = exited, status = 0
infrun: stop_all_threads status->kind = exited, status = 0 process 10453
infrun: process 10453 executing, already stopping
infrun: target_wait (-1.0.0, status) =
infrun: -1.0.0 [process -1],
infrun: status->kind = no-resumed
infrun: infrun_async(0)
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
infrun: stop_all_threads status->kind = no-resumed process -1
infrun: process 10453 executing, already stopping
...
And this polling goes on forever. This patch prevents the infinite
looping behavior. For the same scenario above, we obtain the
following behavior:
...
(gdb) continue
Continuing.
infrun: clear_proceed_status_thread (process 31229)
infrun: clear_proceed_status_thread (process 31233)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 31229
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 31229] at 0x55555555514e
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: proceed: resuming process 31233
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 31233] at 0x55555555514e
infrun: prepare_to_wait
infrun: Found 2 inferiors, starting at #0
infrun: target_wait (-1.0.0, status) =
infrun: 31229.31229.0 [process 31229],
infrun: status->kind = exited, status = 0
infrun: handle_inferior_event status->kind = exited, status = 0
[Inferior 1 (process 31229) exited normally]
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun: process 31233 executing, need stop
infrun: target_wait (-1.0.0, status) =
infrun: 31233.31233.0 [process 31233],
infrun: status->kind = exited, status = 0
infrun: stop_all_threads status->kind = exited, status = 0 process 31233
infrun: saving status status->kind = exited, status = 0 for 31233.31233.0
infrun: process 31233 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun: process 31233 not executing
infrun: stop_all_threads done
(gdb)
The exit event from Inferior 1 is received and shown to the user.
The exit event from Inferior 2 is not displayed, but kept pending.
(gdb) info inferiors
Num Description Connection Executable
* 1 <null> a.out
2 process 31233 1 (native) a.out
(gdb) inferior 2
[Switching to inferior 2 [process 31233] (a.out)]
[Switching to thread 2.1 (process 31233)]
Couldn't get registers: No such process.
(gdb) continue
Continuing.
infrun: clear_proceed_status_thread (process 31233)
infrun: clear_proceed_status_thread: thread process 31233 has pending wait status status->kind = exited, status = 0 (currently_stepping=0).
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 31233
infrun: resume: thread process 31233 has pending wait status status->kind = exited, status = 0 (currently_stepping=0).
infrun: prepare_to_wait
infrun: Using pending wait status status->kind = exited, status = 0 for process 31233.
infrun: target_wait (-1.0.0, status) =
infrun: 31233.31233.0 [process 31233],
infrun: status->kind = exited, status = 0
infrun: handle_inferior_event status->kind = exited, status = 0
[Inferior 2 (process 31233) exited normally]
infrun: stop_waiting
(gdb) info inferiors
Num Description Connection Executable
1 <null> a.out
* 2 <null> a.out
(gdb)
When a process exits and we leave the process exit event pending, we
need to make sure that at least one thread is left listed in the
inferior's thread list. This is necessary in order to make sure we
have a thread that we can later resume, so the process exit event can
be collected/reported.
When native debugging, the GNU/Linux back end already makes sure that
the last LWP isn't deleted.
When remote debugging against GNU/Linux GDBserver, the GNU/Linux
GDBserver backend also makes sure that the last thread isn't deleted
until the process exit event is reported to GDBserver core.
However, between the backend reporting the process exit event to
GDBserver core, and GDB consuming the event, GDB may update the thread
list and find no thread left in the process. The process exit event
will be pending somewhere in GDBserver's stop reply queue, or
gdb/remote.c's queue, or whathever other event queue inbetween
GDBserver and infrun.c's handle_inferior_event.
This patch tweaks remote.c's target_update_thread_list implementation
to avoid deleting the last thread of an inferior.
In the past, this case of inferior-with-no-threads led to a special
case at the bottom of handle_no_resumed, where it reads:
/* Note however that we may find no resumed thread because the whole
process exited meanwhile (thus updating the thread list results
in an empty thread list). In this case we know we'll be getting
a process exit event shortly. */
for (inferior *inf : all_non_exited_inferiors (ecs->target))
In current master, that code path is still reachable with the
gdb.threads/continue-pending-after-query.exp testcase, when tested
against GDBserver, with "maint set target-non-stop" forced "on".
With this patch, the scenario that loop was concerned about is still
properly handled, because the loop above it finds the process's last
thread with "executing" set to true, and thus the handle_no_resumed
function still returns true.
Since GNU/Linux native and remote are the only targets that support
non-stop mode, and with this patch, we always make sure the inferior
has at least one thread, this patch also removes that "inferior with
no threads" special case handling from handle_no_resumed.
Since remote.c now has a special case where we treat a thread that has
already exited as if it was still alive, we might need to tweak
remote.c's target_thread_alive implementation to return true for that
thread without querying the remote side (which would say "no, not
alive"). After inspecting all the target_thread_alive calls in the
codebase, it seems that only the one from prune_threads could result
in that thread being accidentally deleted. There's only one call to
prune_threads in GDB's common code, so this patch handles this by
replacing the prune_threads call with a delete_exited_threads call.
This seems like an improvement anyway, because we'll still be doing
what the comment suggests we want to do, and, we avoid remote protocol
traffic.
Regression-tested on X86_64 Linux.
gdb/ChangeLog:
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Tom de Vries <tdevries@suse.de>
Pedro Alves <palves@redhat.com>
PR threads/25478
* infrun.c (stop_all_threads): Do NOT ignore
TARGET_WAITKIND_NO_RESUMED, TARGET_WAITKIND_THREAD_EXITED,
TARGET_WAITKIND_EXITED, TARGET_WAITKIND_SIGNALLED wait statuses
received.
(handle_no_resumed): Remove code handling a live inferior with no
threads.
* remote.c (has_single_non_exited_thread): New.
(remote_target::update_thread_list): Do not delete a thread if is
the last thread of the process.
* thread.c (thread_select): Call delete_exited_threads instead of
prune_threads.
gdb/testsuite/ChangeLog:
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Pedro Alves <palves@redhat.com>
* gdb.multi/multi-exit.c: New file.
* gdb.multi/multi-exit.exp: New file.
* gdb.multi/multi-kill.c: New file.
* gdb.multi/multi-kill.exp: New file.
|
|
In stop_all_threads, the thread events of the current top target are
enabled at the beginning of the function and then disabled at the end
(at scope exit time). Because there may be multiple targets whose
thread lists will be updated and whose threads are stopped,
enable/disable thread events for all targets.
This update caused a change in the annotations. In particular, a
"frames-invalid" annotation is printed one more time due to switching
the current inferior. Hence, gdb.base/annota1.exp and
gdb.cp/annota2.exp tests are also updated.
Regression-tested on X86_64 Linux using the default board file and the
native-extended-gdbserver board file.
gdb/ChangeLog:
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (stop_all_threads): Enable/disable thread events of all
targets. Move a debug message denoting the end of the function
into the SCOPED_EXIT block.
gdb/testsuite/ChangeLog:
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/annota1.exp: Update the expected output.
* gdb.cp/annota2.exp: Ditto.
|
|
This is a refactoring. The extracted function is placed deliberately
before 'stop_all_threads' because the function will be re-used there
in a subsequent patch for handling an exit status kind received from
a thread that GDB attempted to stop.
gdb/ChangeLog:
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (handle_inferior_event): Extract out a piece of code
into...
(mark_non_executing_threads): ...this new function.
Change-Id: I2b088f4a724f4260cb37068264964525cf62a118
|
|
In infrun.c's resume_1 function, move the definition of the local
variable PC down to its first use. This is useful if the thread we want
to resume is already gone with a pending exit event, because we avoid
the error we would see otherwise when trying to read the PC.
gdb/ChangeLog:
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (resume_1): Move a 'regcache_read_pc' call down to first
use.
|
|
It possible that a thread whose PC we attempt to read is already dead.
In this case, 'regcache_read_pc' errors out. This impacts the
"proceed" execution flow, where GDB quits early before having a chance
to check if there exists a pending event. To remedy, keep going with
a 0 value for the PC if 'regcache_read_pc' fails. Because the value
of PC before resuming a thread is mostly used for storing and checking
the next time the thread stops, this tolerance is expected to be
harmless for a dead thread/process.
gdb/ChangeLog:
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* regcache.c (regcache_read_pc_protected): New function
implementation that returns 0 if the PC cannot read via
'regcache_read_pc'.
* infrun.c (proceed): Call 'regcache_read_pc_protected'
instead of 'regcache_read_pc'.
(keep_going_pass_signal): Ditto.
gdbsupport/ChangeLog:
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* common-regcache.h (regcache_read_pc_protected): New function
declaration.
|
|
When running test-case gdb.threads/fork-child-threads.exp with gcc-8 instead
of gcc-7, we have:
...
(gdb) next^M
[Attaching after Thread 0x7ffff7fae740 (LWP 27574) fork to child process \
27578]^M
[New inferior 2 (process 27578)]^M
[Detaching after fork from parent process 27574]^M
[Inferior 1 (process 27574) detached]^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
[Switching to Thread 0x7ffff7fae740 (LWP 27578)]^M
-main () at src/gdb/testsuite/gdb.threads/fork-child-threads.c:41^M
+main () at src/gdb/testsuite/gdb.threads/fork-child-threads.c:34^M
-41 i = pthread_create (&thread, NULL, start, NULL);^M
+34 switch (fork ())^M
-(gdb) PASS: gdb.threads/fork-child-threads.exp: next over fork
+(gdb) FAIL: gdb.threads/fork-child-threads.exp: next over fork
...
This is due to the fact that gcc-8 generates more precise line info, making
the instruction after the call to fork a "recommended breakpoint location".
However, it is a bug because next is supposed to move to the next source
line.
The problem is that in process_event_stop_test we hit this code:
...
if ((ecs->event_thread->suspend.stop_pc == stop_pc_sal.pc)
&& (ecs->event_thread->current_line != stop_pc_sal.line
|| ecs->event_thread->current_symtab != stop_pc_sal.symtab))
{
if (stop_pc_sal.is_stmt)
{
/* We are at the start of a different line. So stop. Note that
we don't stop if we step into the middle of a different line.
That is said to make things like for (;;) statements work
better. */
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog,
"infrun: stepped to a different line\n");
end_stepping_range (ecs);
return;
}
...
because current_line and current_symtab have initial values:
...
(gdb) p ecs->event_thread->current_line
$8 = 0
(gdb) p ecs->event_thread->current_symtab
$9 = (symtab *) 0x0
...
Fix this in follow_fork by copying current_line and current_symtab from
parent thread to child thread.
Tested on x86_64-linux, with gcc 7.5.0 and gcc 10.0.1.
gdb/ChangeLog:
2020-05-08 Tom de Vries <tdevries@suse.de>
* infrun.c (follow_fork): Copy current_line and current_symtab to
child thread.
|
|
In infrun.c's 'displaced_step_fixup', as part of the 'finish_step_over'
flow, switch to the eventing thread *before* calling
'displaced_step_restore', because down in the flow ptid-dependent
memory accesses are used via current_inferior() and current_top_target().
Without this patch, the problem is exposed with the scenario below:
$ gdb -q
(gdb) maint set target-non-stop on
(gdb) file a.out
Reading symbols from a.out...
(gdb) set remote exec-file a.out
(gdb) target extended-remote | gdbserver --once --multi -
...
(gdb) add-inferior
[New inferior 2]
Added inferior 2 on connection 1 (extended-remote ...)
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) file a.out
Reading symbols from a.out...
(gdb) set remote exec-file a.out
(gdb) run
...
Cannot access memory at address 0x555555555042
(gdb)
The problem is, down inside 'displaced_step_restore', GDB wants to
access the memory for inferior 2 because of an internal breakpoint.
However, the current inferior and inferior_ptid are out of sync.
While inferior_ptid correctly points to the process of inf 2 that was
just started, current_inferior points to inf 1. Then, the attempt to
access the memory fails, because target_has_execution results in false
since inf 1 was not started. I was not able to simplify the failing
scenario, but it shows the problem.
After this patch, we get
... same steps above...
(gdb) run
...
[Inferior 2 (process 28652) exited normally]
(gdb)
Regression-tested on X86_64 Linux with `make check`s default board file
and also `--target_board=native-extended-gdbserver`. In fact, the bug
fixed by this patch was exposed when using the native-extended-gdbserver
board file.
gdb/ChangeLog:
2020-04-21 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (displaced_step_fixup): Switch to the event_thread
before calling displaced_step_restore, not after.
gdb/testsuite/ChangeLog:
2020-04-21 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.multi/run-only-second-inf.c: New file.
* gdb.multi/run-only-second-inf.exp: New file.
|
|
This changes get_objfile_arch to be a new inline method,
objfile::arch.
To my surprise, this function came up while profiling DWARF psymbol
reading. Making this change improved performance from 1.986 seconds
to 1.869 seconds. Both measurements were done by taking the mean of
10 runs on a fixed copy of the gdb executable.
gdb/ChangeLog
2020-04-18 Tom Tromey <tom@tromey.com>
* xcoffread.c (enter_line_range, scan_xcoff_symtab): Update.
* value.c (value_fn_field): Update.
* valops.c (find_function_in_inferior)
(value_allocate_space_in_inferior): Update.
* tui/tui-winsource.c (tui_update_source_windows_with_line):
Update.
* tui/tui-source.c (tui_source_window::set_contents): Update.
* symtab.c (lookup_global_or_static_symbol)
(find_function_start_sal_1, skip_prologue_sal)
(print_msymbol_info, find_gnu_ifunc, symbol_arch): Update.
* symmisc.c (dump_msymbols, dump_symtab_1)
(maintenance_print_one_line_table): Update.
* symfile.c (init_entry_point_info, section_is_mapped)
(list_overlays_command, simple_read_overlay_table)
(simple_overlay_update_1): Update.
* stap-probe.c (handle_stap_probe): Update.
* stabsread.c (dbx_init_float_type, define_symbol)
(read_one_struct_field, read_enum_type, read_range_type): Update.
* source.c (info_line_command): Update.
* python/python.c (gdbpy_source_objfile_script)
(gdbpy_execute_objfile_script): Update.
* python/py-type.c (save_objfile_types): Update.
* python/py-objfile.c (py_free_objfile): Update.
* python/py-inferior.c (python_new_objfile): Update.
* psymtab.c (psym_find_pc_sect_compunit_symtab, dump_psymtab)
(dump_psymtab_addrmap_1, maintenance_info_psymtabs)
(maintenance_check_psymtabs): Update.
* printcmd.c (info_address_command): Update.
* objfiles.h (struct objfile) <arch>: New method, from
get_objfile_arch.
(get_objfile_arch): Don't declare.
* objfiles.c (get_objfile_arch): Remove.
(filter_overlapping_sections): Update.
* minsyms.c (msymbol_is_function): Update.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines)
(output_nondebug_symbol): Update.
* mdebugread.c (parse_symbol, basic_type, parse_partial_symbols)
(mdebug_expand_psymtab): Update.
* machoread.c (macho_add_oso_symfile): Update.
* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap):
Update.
* linux-fork.c (checkpoint_command): Update.
* linespec.c (convert_linespec_to_sals): Update.
* jit.c (finalize_symtab): Update.
* infrun.c (insert_exception_resume_from_probe): Update.
* ia64-tdep.c (ia64_find_unwind_table): Update.
* hppa-tdep.c (internalize_unwinds): Update.
* gdbtypes.c (get_type_arch, init_float_type, objfile_type):
Update.
* gcore.c (call_target_sbrk): Update.
* elfread.c (record_minimal_symbol, elf_symtab_read)
(elf_rel_plt_read, elf_gnu_ifunc_record_cache)
(elf_gnu_ifunc_resolve_by_got): Update.
* dwarf2/read.c (create_addrmap_from_index)
(create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
(read_debug_names_from_section)
(process_psymtab_comp_unit_reader, add_partial_symbol)
(add_partial_subprogram, process_full_comp_unit)
(read_file_scope, read_func_scope, read_lexical_block_scope)
(read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, dwarf2_add_field)
(mark_common_block_symbol_computed, read_tag_pointer_type)
(read_tag_string_type, dwarf2_init_float_type)
(dwarf2_init_complex_target_type, read_base_type)
(partial_die_info::read, partial_die_info::read)
(read_attribute_value, dwarf_decode_lines_1, new_symbol)
(dwarf2_fetch_die_loc_sect_off): Update.
* dwarf2/loc.c (dwarf2_find_location_expression)
(class dwarf_evaluate_loc_desc, rw_pieced_value)
(dwarf2_evaluate_loc_desc_full, dwarf2_locexpr_baton_eval)
(dwarf2_loc_desc_get_symbol_read_needs)
(locexpr_describe_location_piece, locexpr_describe_location_1)
(loclist_describe_location): Update.
* dwarf2/index-write.c (write_debug_names): Update.
* dwarf2/frame.c (dwarf2_build_frame_info): Update.
* dtrace-probe.c (dtrace_process_dof): Update.
* dbxread.c (read_dbx_symtab, dbx_end_psymtab)
(process_one_symbol): Update.
* ctfread.c (ctf_init_float_type, read_base_type): Update.
* coffread.c (coff_symtab_read, enter_linenos, decode_base_type)
(coff_read_enum_type): Update.
* cli/cli-cmds.c (edit_command, list_command): Update.
* buildsym.c (buildsym_compunit::finish_block_internal): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint, get_sal_arch): Update.
* block.c (block_gdbarch): Update.
* annotate.c (annotate_source_line): Update.
|
|
This moves event-loop.[ch] to gdbsupport/ and updates the uses in gdb.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* run-on-main-thread.c: Update include.
* unittests/main-thread-selftests.c: Update include.
* tui/tui-win.c: Update include.
* tui/tui-io.c: Update include.
* tui/tui-interp.c: Update include.
* tui/tui-hooks.c: Update include.
* top.h: Update include.
* top.c: Update include.
* ser-base.c: Update include.
* remote.c: Update include.
* remote-notif.c: Update include.
* remote-fileio.c: Update include.
* record-full.c: Update include.
* record-btrace.c: Update include.
* python/python.c: Update include.
* posix-hdep.c: Update include.
* mingw-hdep.c: Update include.
* mi/mi-main.c: Update include.
* mi/mi-interp.c: Update include.
* main.c: Update include.
* linux-nat.c: Update include.
* interps.c: Update include.
* infrun.c: Update include.
* inf-loop.c: Update include.
* event-top.c: Update include.
* event-loop.c: Move to ../gdbsupport/.
* event-loop.h: Move to ../gdbsupport/.
* async-event.h: Update include.
* Makefile.in (COMMON_SFILES, HFILES_NO_SRCDIR): Update.
gdbsupport/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* event-loop.h: Move from ../gdb/.
* event-loop.cc: Move from ../gdb/.
|
|
This patch splits out some gdb-specific code from event-loop, into new
files async-event.[ch]. Strictly speaking this code could perhaps be
put into gdbsupport/, but because gdbserver does not currently use it,
it seemed better, for size reasons, to split it out.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* tui/tui-win.c: Include async-event.h.
* remote.c: Include async-event.h.
* remote-notif.c: Include async-event.h.
* record-full.c: Include async-event.h.
* record-btrace.c: Include async-event.h.
* infrun.c: Include async-event.h.
* event-top.c: Include async-event.h.
* event-loop.h: Move some declarations to async-event.h.
* event-loop.c: Don't include ser-event.h or top.h. Move some
code to async-event.c.
* async-event.h: New file.
* async-event.c: New file.
* Makefile.in (COMMON_SFILES): Add async-event.c.
(HFILES_NO_SRCDIR): Add async-event.h.
|
|
This moves gdb_select.h to gdbsupport/, so it can be used by other
code there.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* gdb_select.h: Move to ../gdbsupport/.
* event-loop.c: Update include path.
* top.c: Update include path.
* ser-base.c: Update include path.
* ui-file.c: Update include path.
* ser-tcp.c: Update include path.
* guile/scm-ports.c: Update include path.
* posix-hdep.c: Update include path.
* ser-unix.c: Update include path.
* gdb_usleep.c: Update include path.
* mingw-hdep.c: Update include path.
* inflow.c: Update include path.
* infrun.c: Update include path.
* event-top.c: Update include path.
gdbsupport/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* gdb_select.h: Move from ../gdb/.
|
|
Stop all threads not only if the current target is non-stop, but also
if there exists a non-stop target.
The multi-target patch (5b6d1e4fa4f "Multi-target support") made the
following change to gdb/inf-child.c:
void
inf_child_target::maybe_unpush_target ()
{
- if (!inf_child_explicitly_opened && !have_inferiors ())
+ if (!inf_child_explicitly_opened)
unpush_target (this);
}
If we are in all-stop mode with multiple inferiors, and an exit event
is received from an inferior, target_mourn_inferior() gets to this
point and without the have_inferiors() check, the target is unpushed.
This leads to having exec_ops as the top target.
Here is a test scenario. Two executables, ./a.out returns
immediately; ./sleepy just sleeps.
$ gdb ./sleepy
(gdb) start
...
(gdb) add-inferior -exec ./a.out
...
(gdb) inferior 2
[Switching to inferior 2..
(gdb) start
...
(gdb) set schedule-multiple on
(gdb) set debug infrun 1
(gdb) continue
At this point, the exit event is received from ./a.out. Normally,
this would lead to stop_all_threads() to also stop ./sleepy, but this
doesn't happen, because target_is_non_stop_p() returns false. And it
returns false because the top target is no longer the process target;
it is the exec_ops.
This patch modifies 'stop_waiting' to call 'stop_all_threads' if there
exists a non-stop target, not just when the current top target is
non-stop.
Tested on X86_64 Linux.
gdb/ChangeLog:
2020-04-01 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (stop_all_threads): Update assertion, plus when
stopping threads, take into account that we might be trying
to stop an all-stop target.
(stop_waiting): Call 'stop_all_threads' if there exists a
non-stop target.
gdb/testsuite/ChangeLog:
2020-04-01 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.multi/stop-all-on-exit.c: New test.
* gdb.multi/stop-all-on-exit.exp: New file.
|
|
Change parameters and return value of the various follow_fork
functions/methods from int to bool.
gdb/ChangeLog:
* fbsd-nat.c (fbsd_nat_target::follow_fork): Change bool to int.
* fbsd-nat.h (class fbsd_nat_target) <follow_fork>: Likewise.
* inf-ptrace.c (inf_ptrace_target::follow_fork): Likewise.
* inf-ptrace.h (struct inf_ptrace_target) <follow_fork>: Likewise.
* infrun.c (follow_fork): Likewise.
(follow_fork_inferior): Likewise.
* linux-nat.c (linux_nat_target::follow_fork): Likewise.
* linux-nat.h (class linux_nat_target): Likewise.
* remote.c (class remote_target) <follow_fork>: Likewise.
(remote_target::follow_fork): Likewise.
* target-delegates.c: Re-generate.
* target.c (default_follow_fork): Likewise.
(target_follow_fork): Likewise.
* target.h (struct target_ops) <follow_fork>: Likewise.
(target_follow_fork): Likewise.
|
|
This commit brings support for the DWARF line table is_stmt field to
GDB. The is_stmt field is used by the compiler when a single source
line is split into multiple assembler instructions, especially if the
assembler instructions are interleaved with instruction from other
source lines.
The compiler will set the is_stmt flag false from some instructions
from the source lines, these instructions are not a good place to
insert a breakpoint in order to stop at the source line.
Instructions which are marked with the is_stmt flag true are a good
place to insert a breakpoint for that source line.
Currently GDB ignores all instructions for which is_stmt is false.
This is fine in a lot of cases, however, there are some cases where
this means the debug experience is not as good as it could be.
Consider stopping at a random instruction, currently this instruction
will be attributed to the last line table entry before this point for
which is_stmt was true - as these are the only line table entries that
GDB tracks. This can easily be incorrect in code with even a low
level of optimisation.
With is_stmt tracking in place, when stopping at a random instruction
we now attribute the instruction back to the real source line, even
when is_stmt is false for that instruction in the line table.
When inserting breakpoints we still select line table entries for
which is_stmt is true, so the breakpoint placing behaviour should not
change.
When stepping though code (at the line level, not the instruction
level) we will still stop at instruction where is_stmt is true, I
think this is more likely to be the desired behaviour.
Instruction stepping is, of course, unchanged, stepping one
instruction at a time, but we should now report more accurate line
table information with each instruction step.
The original motivation for this work was a patch posted by Bernd
here:
https://sourceware.org/ml/gdb-patches/2019-11/msg00792.html
As part of that thread it was suggested that many issues would be
resolved if GDB supported line table views, this isn't something I've
attempted in this patch, though reading the spec, it seems like this
would be a useful feature to support in GDB in the future. The spec
is here:
http://dwarfstd.org/ShowIssue.php?issue=170427.1
And Bernd gives a brief description of the benefits here:
https://sourceware.org/ml/gdb-patches/2020-01/msg00147.html
With that all said, I think that there is benefit to having proper
is_stmt support regardless of whether we have views support, so I
think we should consider getting this in first, and then building view
support on top of this.
The gdb.cp/step-and-next-inline.exp test is based off a test proposed
by Bernd Edlinger in this message:
https://sourceware.org/ml/gdb-patches/2019-12/msg00842.html
gdb/ChangeLog:
* buildsym-legacy.c (record_line): Pass extra parameter to
record_line.
* buildsym.c (buildsym_compunit::record_line): Take an extra
parameter, reduce duplication in the line table, and record the
is_stmt flag in the line table.
* buildsym.h (buildsym_compunit::record_line): Add extra
parameter.
* disasm.c (do_mixed_source_and_assembly_deprecated): Ignore
non-statement lines.
* dwarf2/read.c (dwarf_record_line_1): Add extra parameter, pass
this to the symtab builder.
(dwarf_finish_line): Pass extra parameter to dwarf_record_line_1.
(lnp_state_machine::record_line): Pass a suitable is_stmt flag
through to dwarf_record_line_1.
* infrun.c (process_event_stop_test): When stepping, don't stop at
a non-statement instruction, and only refresh the step info when
we land in the middle of a line's range. Also add an extra
comment.
* jit.c (jit_symtab_line_mapping_add_impl): Initialise is_stmt
field.
* record-btrace.c (btrace_find_line_range): Only record lines
marked as is-statement.
* stack.c (frame_show_address): Show the frame address if we are
in a non-statement sal.
* symmisc.c (dump_symtab_1): Print the is_stmt flag.
(maintenance_print_one_line_table): Print a header for the is_stmt
column, and include is_stmt information in the output.
* symtab.c (find_pc_sect_line): Find lines marked as statements in
preference to non-statements.
(find_pcs_for_symtab_line): Prefer is-statement entries.
(find_line_common): Likewise.
* symtab.h (struct linetable_entry): Add is_stmt field.
(struct symtab_and_line): Likewise.
* xcoffread.c (arrange_linetable): Initialise is_stmt field when
arranging the line table.
gdb/testsuite/ChangeLog:
* gdb.cp/step-and-next-inline.cc: New file.
* gdb.cp/step-and-next-inline.exp: New file.
* gdb.cp/step-and-next-inline.h: New file.
* gdb.dwarf2/dw2-is-stmt.c: New file.
* gdb.dwarf2/dw2-is-stmt.exp: New file.
* gdb.dwarf2/dw2-is-stmt-2.c: New file.
* gdb.dwarf2/dw2-is-stmt-2.exp: New file.
* gdb.dwarf2/dw2-ranges-base.exp: Update line table pattern.
|
|
[ Migrating this from Gerrit: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/321 ]
I noticed that some functions in infcmd and infrun call each other and
all call inferior_thread, while they could just get the thread_info
pointer from their caller. That means less calls to inferior_thread, so
less reliance on global state, since inferior_thread reads
inferior_ptid.
The paths I am unsure about are:
- fetch_inferior_event calls...
- step_command_fsm::should_stop calls...
- prepare_one_step
and
- process_event_stop_test calls...
- set_step_info
Before this patch, prepare_one_step gets the thread pointer using
inferior_thread. After this patch, it gets it from the
execution_control_state structure in fetch_inferior_event. Are we sure
that the thread from the execution_control_state structure is the same
as the one inferior_thread would return? This code path is used when a
thread completes a step, but the user had specified a step count (e.g.
"step 5") so we decide to do one more step. It would be strange (and
even a bug I suppose) if the thread in the ecs structure in
fetch_inferior_event was not the same thread that is prepared to stepped
by prepare_one_step. So I believe passing the ecs thread is fine.
The same logic applies to process_event_stop_test calling
set_step_info.
gdb/ChangeLog:
* infrun.h: Forward-declare thread_info.
(set_step_info): Add thread_info parameter, add doc.
* infrun.c (set_step_info): Add thread_info parameter, move doc
to header.
* infrun.c (process_event_stop_test): Pass thread to
set_step_info call.
* infcmd.c (set_step_frame): Add thread_info pointer, pass it to
set_step_info.
(prepare_one_step): Add thread_info parameter, pass it to
set_step_frame and prepare_one_step (recursive) call.
(step_1): Pass thread to prepare_one_step call.
(step_command_fsm::should_stop): Pass thread to
prepare_one_step.
(until_next_fsm): Pass thread to set_step_frame call.
(finish_command): Pass thread to set_step_info call.
|
|
This function returns the result of a quite big condition. I think it
would be more readeable if it was broken up in smaller pieces and
commented. This is what this patch does.
I also introduced gdbarch_supports_displaced_stepping, since it shows
the intent better than checking for gdbarch_displaced_step_copy_insn_p.
I also used that new function in displaced_step_prepare_throw.
I also updated the comment on top of can_use_displaced_stepping, which
seemed a bit outdated with respect to non-stop. The comment likely
dates from before it was possible to have targets that always operate
non-stop under the hood, even when the user-visible mode is all-stop.
No functional changes intended.
gdb/ChangeLog:
* infrun.c (gdbarch_supports_displaced_stepping): New.
(use_displaced_stepping): Break up conditions in smaller pieces.
Use gdbarch_supports_displaced_stepping.
(displaced_step_prepare_throw): Use
gdbarch_supports_displaced_stepping.
|
|
With this commit:
commit 5b6d1e4fa4fc6827c7b3f0e99ff120dfa14d65d2
Date: Fri Jan 10 20:06:08 2020 +0000
Multi-target support
There was a regression in GDB's support for older aspects of the
remote protocol. Specifically, when a target sends the 'S' stop reply
packet (which doesn't include a thread-id) then GDB has to figure out
which thread actually stopped.
Before the above commit GDB figured this out by using inferior_ptid in
process_stop_reply, which contained the ptid of the current
process/thread. This would be fine for single threaded
targets (which is the only place using an S packet makes sense), but
in the general case, relying on inferior_ptid for processing a stop is
wrong - there's no reason to believe that what was GDB's current
thread will be the same thread that just stopped in the target.
With the above commit the inferior_ptid now has the value null_ptid
inside process_stop_reply, this can be seen in do_target_wait, where
we call switch_to_inferior_no_thread before calling do_target_wait_1.
The problem this causes can be seen in the new test that runs
gdbserver using the flag --disable-packet=T, and causes GDB to throw
this assertion:
inferior.c:279: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.
A similar problem was fixed in this commit:
commit 3cada74087687907311b52781354ff551e10a0ed
Date: Thu Jan 11 00:23:04 2018 +0000
Fix backwards compatibility with old GDBservers (PR remote/22597)
However, this commit deals with the case where the T packet doesn't
include a thread-id, not the S packet case. This commit solves the
problem providing a thread-id at the GDB side if the remote target
doesn't provide one. The thread-id provided comes from
remote_state::general_thread, however, though this does work, I don't
think it is the ideal solution.
The remote_state tracks two threads, the continue_thread and the
general_thread, these are updated when GDB asks the remote target to
switch threads. The general_thread is set before performing things
like register or memory accesses, and the continue_thread is set
before things like continue or step commands. Further, the
general_thread is updated after a target stops to reference the thread
that stopped.
The first thing to note from the above description is that we have a
cycle of dependency, when a T packet arrives without a thread-id we
fill in the thread-id from the general_thread data. The thread-id
from the stop event is then used to set the general_thread. This in
itself feels a little weird.
The second question is why use the general_thread at all? You'd think
given how they are originally set that the continue thread would be a
better choice. The problem with this is that the continue_thread, if
the user just does "continue", will be set to the minus_one_ptid, in
the remote protocol this means all threads. When the stop arrives
with no thread-id and we use continue_thread we end up with a very
similar assertion to before because we now end up trying to lookup a
thread using the minus_one_ptid. By contrast, once GDB has connected
to a remote target the general_thread will be set to a valid
thread-id, after which, if the target is single threaded, and stop
events arrive without a thread-id, everything works fine.
There is one slight weirdness with the above behaviour though. When
GDB first connects to the remote target inferior_ptid is null_ptid,
however, upon connecting we query the remote for its threads. As the
thread information arrives GDB adds the threads to its internal
database, and this process involves setting inferior_ptid to the id of
each new thread in turn. Once we know about all the threads we wait
for a stop event from the remote target to indicate that GDB is now in
control of the target.
The problem is that after adding the new threads we don't reset
inferior_ptid, and the code path we use to wait for a stop event from
the target also doesn't reset inferior_ptid, so it turns out that
during the initial connection inferior_ptid is not null_ptid. This is
lucky, because during the initial connection the general_thread
variable _is_ set to null_ptid.
So, during the initial connection, if the first stop event is missing
a thread-id then we "provide" a thead-id from general_thread. This
turns out to be null_ptid meaning no thread-id is known, and then
during process_stop_reply we fill in the missing thread-id using
inferior_ptid.
This was all discussed on the mailing list here:
https://sourceware.org/ml/gdb-patches/2020-02/msg01011.html
My proposal for a fix then is:
1. Move the call to switch_to_inferior_no_thread into
do_target_wait_1, this means that in all cases where we are waiting
for an inferior the inferior_ptid will be set to null_ptid. This is
good as no wait code should rely on inferior_ptid.
2. Remove the use of general_thread from the 'T' packet processing.
The general_thread read here was only ever correct by chance, and we
shouldn't be using it this way.
3. Remove use of inferior_ptid from process_stop_event as this is
wrong, and will always be null_ptid now anyway.
4. When a stop_event has null_ptid due to a lack of thread-id (either
from a T packet or an S packet) then pick the first non exited thread
in the target and use that. This will be fine for single threaded
targets. A multi-thread or multi-inferior aware remote target
should be using T packets with a thread-id, so we give a warning if
the target is multi-threaded, and we are still missing a thread-id.
5. Extend the existing test that covered the T packet with missing
thread-id to also cover the S packet.
gdb/ChangeLog:
* remote.c (remote_target::remote_parse_stop_reply): Don't use the
general_thread if the stop reply is missing a thread-id.
(remote_target::process_stop_reply): Use the first non-exited
thread if the target didn't pass a thread-id.
* infrun.c (do_target_wait): Move call to
switch_to_inferior_no_thread to ....
(do_target_wait_1): ... here.
gdb/testsuite/ChangeLog:
* gdb.server/stop-reply-no-thread.exp: Add test where T packet is
disabled.
|
|
This callback dynamically allocates a specialized displaced_step_closure, and
gives the ownership of the object to its caller. So I think it would make
sense for the callback to return an std::unique_ptr, this is what this patch
implements.
gdb/ChangeLog:
* gdbarch.sh (displaced_step_copy_insn): Change return type to an
std::unique_ptr.
* gdbarch.c: Re-generate.
* gdbarch.h: Re-generate.
* infrun.c (displaced_step_prepare_throw): Adjust to std::unique_ptr
change.
* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Change return
type to std::unique_ptr.
* aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise.
* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
* amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Likewise.
* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
* i386-tdep.h (i386_displaced_step_copy_insn): Likewise.
* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
|
|
displaced_step_inferior_state::reset and displaced_step_clear appear to
have the same goal, but they don't do the same thing.
displaced_step_inferior_state::reset clears more things than
displaced_step_clear, but it misses free'ing the closure, which
displaced_step_clear does.
This patch replaces displaced_step_clear's implementation with just a call to
displaced_step_inferior_state::reset. It then changes
displaced_step_inferior_state::step_closure to be a unique_ptr, to indicate the
fact that displaced_step_inferior_state owns the closure (and so that it is
automatically freed when the field is reset).
The test gdb.base/step-over-syscall.exp caught a problem when doing this, which
I consider to be a latent bug which my cleanup exposes. In
handle_inferior_event, in the TARGET_WAITKIND_FORKED case, if we displaced-step
over a fork syscall, we make sure to restore the memory that we used as a
displaced-stepping buffer in the child. We do so using the
displaced_step_inferior_state of the parent. However, we do it after calling
displaced_step_fixup for the parent, which clears the information in the
parent's displaced_step_inferior_state. It worked fine before, because
displaced_step_clear didn't completely clear the displaced_step_inferior_state
structure, so the required information (in this case the gdbarch) was
still available after clearing.
I fixed it by making GDB restore the child's memory before calling the
displaced_step_fixup on the parent. This way, the data in the
displaced_step_inferior_state structure is still valid when we use it for the
child. This is the error you would get in
gdb.base/step-over-syscall.exp without this fix:
/home/smarchi/src/binutils-gdb/gdb/gdbarch.c:3911: internal-error: ULONGEST gdbarch_max_insn_length(gdbarch*): Assertion `gdbarch != NULL' failed.
gdb/ChangeLog:
* infrun.c (get_displaced_step_closure_by_addr): Adjust to
std::unique_ptr.
(displaced_step_clear): Rename to...
(displaced_step_reset): ... this. Just call displaced->reset ().
(displaced_step_clear_cleanup): Rename to...
(displaced_step_reset_cleanup): ... this.
(displaced_step_prepare_throw): Adjust to std::unique_ptr.
(displaced_step_fixup): Likewise.
(resume_1): Likewise.
(handle_inferior_event): Restore child's memory before calling
displaced_step_fixup on the parent.
* infrun.h (displaced_step_inferior_state) <reset>: Adjust
to std::unique_ptr.
<step_closure>: Change type to std::unique_ptr.
|
|
Switch thread_info::resumed to bool (thread_info::executing already is a bool),
and try to change everything more or less related to that to consistently use
true/false instead of 1/0.
gdb/ChangeLog:
* fork-child.c (gdb_startup_inferior): Use bool instead of int.
* gdbthread.h (class thread_info) <resumed>: Likewise.
* infrun.c (resume_1): Likewise.
(proceed): Likewise.
(infrun_thread_stop_requested): Likewise.
(stop_all_threads): Likewise.
(handle_inferior_event): Likewise.
(restart_threads): Likewise.
(finish_step_over): Likewise.
(keep_going_stepped_thread): Likewise.
* linux-nat.c (attach_proc_task_lwp_callback): Likewise.
(linux_handle_extended_wait): Likewise.
* record-btrace.c (get_thread_current_frame_id): Likewise.
* record-full.c (record_full_wait_1): Likewise.
* remote.c (remote_target::process_initial_stop_replies): Likewise.
* target.c (target_resume): Likewise.
* thread.c (set_running_thread): Likewise.
|
|
New in v3:
- Code cleanups based on reviews.
New in v2:
- Fixed misc problems based on reviews.
- Switched to using gdbarch_program_breakpoint_here_p as opposed to
gdbarch_insn_is_breakpoint.
- Fixed matching of brk instructions. Previously the mask was incorrect, which
was showing up as a few failures in the testsuite. Now it is clean.
- New testcase (separate patch).
- Moved program_breakpoint_here () to arch-utils.c and made it the default
implementation of gdbarch_program_breakpoint_here_p.
--
It was reported to me that program breakpoints (permanent ones inserted into
the code itself) other than the one GDB uses for AArch64 (0xd4200000) do not
generate visible stops when continuing, and GDB will continue spinning
infinitely.
This happens because GDB, upon hitting one of those program breakpoints, thinks
the SIGTRAP came from a delayed breakpoint hit...
(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk #0x90f
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 14198)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 14198
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
...
... which is not the case.
If the program breakpoint is one GDB recognizes, then it will stop when it
hits it.
(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk #0x0
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 14193)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 14193
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14193] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14193.14193.0 [process 14193],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: random signal (GDB_SIGNAL_TRAP)
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun: process 14193 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun: process 14193 not executing
infrun: stop_all_threads done
Program received signal SIGTRAP, Trace/breakpoint trap.
problem_function () at brk_0.c:7
7 asm("brk %0\n\t" ::"n"(0x0));
infrun: infrun_async(0)
Otherwise GDB will keep trying to resume the inferior and will keep
seeing the SIGTRAP's, without stopping.
To the user it appears GDB has gone into an infinite loop, interruptible only
by Ctrl-C.
Also, windbg seems to use a different variation of AArch64 breakpoint compared
to GDB. This causes problems when debugging Windows on ARM binaries, when
program breakpoints are being used.
The proposed patch creates a new gdbarch method (gdbarch_program_breakpoint_here_p)
that tells GDB whether the underlying instruction is a breakpoint instruction
or not.
This is more general than only checking for the instruction GDB uses as
breakpoint.
The existing logic is still preserved for targets that do not implement this
new gdbarch method.
The end result is like so:
(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk #0x90f
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 16417)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 16417
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 16417] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 16417.16417.0 [process 16417],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: random signal (GDB_SIGNAL_TRAP)
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun: process 16417 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun: process 16417 not executing
infrun: stop_all_threads done
Program received signal SIGTRAP, Trace/breakpoint trap.
problem_function () at brk.c:7
7 asm("brk %0\n\t" ::"n"(0x900 + 0xf));
infrun: infrun_async(0)
gdb/ChangeLog:
2020-01-29 Luis Machado <luis.machado@linaro.org>
* aarch64-tdep.c (BRK_INSN_MASK): Define to 0xffe0001f.
(BRK_INSN_MASK): Define to 0xd4200000.
(aarch64_program_breakpoint_here_p): New function.
(aarch64_gdbarch_init): Set gdbarch_program_breakpoint_here_p hook.
* arch-utils.c (default_program_breakpoint_here_p): Moved from
breakpoint.c.
* arch-utils.h (default_program_breakpoint_here_p): Moved from
breakpoint.h
* breakpoint.c (bp_loc_is_permanent): Changed return type to bool and
call gdbarch_program_breakpoint_here_p.
(program_breakpoint_here): Moved to arch-utils.c, renamed to
default_program_breakpoint_here_p, changed return type to bool and
simplified.
* breakpoint.h (program_breakpoint_here): Moved prototype to
arch-utils.h, renamed to default_program_breakpoint_here_p and changed
return type to bool.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (program_breakpoint_here_p): New method.
* infrun.c (handle_signal_stop): Call
gdbarch_program_breakpoint_here_p.
|
|
This fixes a latent bug exposed by the multi-target patch (5b6d1e4fa
"Multi-target support), and then fixes two other latent bugs exposed
by fixing that first latent bug.
The symptom described in the bug report is that starting a first
inferior, then trying to run a second (multi-threaded) inferior twice,
causes libthread_db to fail to load, along with other erratic
behavior:
(gdb) run
Starting program: /tmp/foo
warning: td_ta_new failed: generic error
Going a bit deeply, I found that if the two inferiors have different
symbols, we can see that just after inferior 2 exits, we are left with
inferior 2 selected, which is correct, but the symbols in scope belong
to inferior 1, which is obviously incorrect...
This problem is that there's a path in
scoped_restore_current_thread::restore() that switches to no thread
selected, and switches the current inferior, but leaves the current
program space as is, resulting in leaving the program space pointing
to the wrong program space (the one of the other inferior). This was
happening after handling TARGET_WAITKIND_NO_RESUMED, which is an event
that triggers after TARGET_WAITKIND_EXITED for the previous inferior
exit. Subsequent symbol lookups find the symbols of the wrong
inferior.
The fix is to use switch_to_inferior_no_thread in that problem spot.
This function was recently added along with the multi-target work
exactly for these situations.
As for testing, this patch adds a new testcase that tests symbol
printing just after inferior exit, which exercises the root cause of
the problem more directly. And then, to cover the use case described
in the bug too, it also exercises the lithread_db.so mis-loading, by
using TLS printing as a proxy for being sure that threaded debugging
was activated sucessfully. The testcase fails without the fix like
this, for the "print symbol just after exit" bits:
...
[Inferior 1 (process 8719) exited normally]
(gdb) PASS: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=1: continue until exit
print re_run_var_1
No symbol "re_run_var_1" in current context.
(gdb) FAIL: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=1: print re_run_var_1
...
And like this for the "libthread_db.so loading" bits:
(gdb) run
Starting program: /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run
warning: td_ta_new failed: generic error
[New LWP 27001]
Thread 1.1 "multi-re-run" hit Breakpoint 3, all_started () at /home/pedro/gdb/binutils-gdb/build/../src/gdb/testsuite/gdb.multi/multi-re-run.c:44
44 }
(gdb) PASS: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=2: running to all_started in runto
print tls_var
Cannot find thread-local storage for LWP 27000, executable file /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run:
Cannot find thread-local variables on this target
(gdb) FAIL: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=2: print tls_var
As mentioned, that fix above goes on to expose a couple other latent
bugs. This commit fixes those as well.
The first latent bug exposed is in
infrun.c:handle_vfork_child_exec_or_exit. The current code is leaving
inf->pspace == NULL while calling clone_program_space. The idea was
to make it so that the breakpoints module doesn't use this inferior's
pspace to set breakpoints. With that, any
scoped_restore_current_thread use from within clone_program_space
tries to restore a NULL program space, which hits an assertion:
Attaching after Thread 0x7ffff74b8700 (LWP 27276) vfork to child process 27277]
[New inferior 2 (process 27277)]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
/home/pedro/gdb/binutils-gdb/build/../src/gdb/progspace.c:243: internal-error: void set_current_program_space(program_space*): Assertion `pspace != NULL' faile
d.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/vfork-follow-child-exit.exp: detach-on-fork=off: continue (GDB internal error)
That NULL pspace idea was legitimate, but it's no longer necessary,
since commit b2e586e850db ("Defer breakpoint reset when cloning
progspace for fork child"). So the fix is to just set the inferior's
program space earlier.
The other latent bug exposed is in exec.c. When exec_close is called
from the program_space destructor, it is purposedly called with a
current program space that is not the current inferior's program
space. The problem is that the multi-target work added some code to
remove_target_sections that loops over all inferiors, and uses
scoped_restore_current_thread to save/restore the previous
thread/inferior/frame state. This makes it so that exec_close returns
with the current program space set to the current inferior's program
space, which is exactly what we did not want. Then the program_space
destructor continues into free_all_objfiles, but it is now running
that method on the wrong program space, resulting in:
Reading symbols from /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads...
Reading symbols from /usr/lib/debug/usr/lib64/libpthread-2.26.so.debug...
Reading symbols from /usr/lib/debug/usr/lib64/libm-2.26.so.debug...
Reading symbols from /usr/lib/debug/usr/lib64/libc-2.26.so.debug...
Reading symbols from /usr/lib/debug/usr/lib64/ld-2.26.so.debug...
[Inferior 3 (process 9583) exited normally]
/home/pedro/gdb/binutils-gdb/build/../src/gdb/progspace.c:170: internal-error: void program_space::free_all_objfiles(): Assertion `so->objfile == NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited (GDB internal error)
The fix is to use scoped_restore_current_pspace_and_thread instead of
scoped_restore_current_thread.
gdb/ChangeLog:
2020-01-24 Pedro Alves <palves@redhat.com>
PR gdb/25410
* thread.c (scoped_restore_current_thread::restore): Use
switch_to_inferior_no_thread.
* exec.c: Include "progspace-and-thread.h".
(add_target_sections, remove_target_sections):
scoped_restore_current_pspace_and_thread instead of
scoped_restore_current_thread.
* infrun.c (handle_vfork_child_exec_or_exit): Assign the pspace
and aspace to the inferior before calling clone_program_space.
Remove stale comment.
gdb/testsuite/ChangeLog:
2020-01-24 Pedro Alves <palves@redhat.com>
PR gdb/25410
* gdb.multi/multi-re-run-1.c: New.
* gdb.multi/multi-re-run-2.c: New.
* gdb.multi/multi-re-run.exp: New.
|
|
I noticed the indentation there was off, this patch fixes it.
gdb/ChangeLog:
* infrun.c (proceed): Fix indentation.
|
|
While doing some investigation of mine, i noticed a few typos,
inaccuracies and missing information.
I went ahead and updated/improved those.
gdb/ChangeLog:
2020-01-14 Luis Machado <luis.machado@linaro.org>
* inf-ptrace.c (inf_ptrace_target::resume): Update comments.
* infrun.c (resume_1): Likewise.
(handle_inferior_event): Remove stale comment.
* linux-nat.c (linux_nat_target::resume): Update comments.
(save_stop_reason): Likewise.
(linux_nat_filter_event): Likewise.
* linux-nat.h (struct lwp_info) <stop_pc>, <stop_reason>: Likewise.
|
|
I'd like to enable the -Wmissing-declarations warning. However, it
warns for every _initialize function, for example:
CXX dcache.o
/home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’:
/home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations]
_initialize_dcache (void)
^~~~~~~~~~~~~~~~~~
The only practical way forward I found is to add back the declarations,
which were removed by this commit:
commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9
Author: John Baldwin <jhb@FreeBSD.org>
Date: Sat Sep 9 11:02:37 2017 -0700
Remove unnecessary function prototypes.
I don't think it's a big problem to have the declarations for these
functions, but if anybody has a better solution for this, I'll be happy
to use it.
gdb/ChangeLog:
* aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration.
* aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration.
* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration.
* aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration.
* aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration.
* aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration.
* ada-exp.y (_initialize_ada_exp): Add declaration.
* ada-lang.c (_initialize_ada_language): Add declaration.
* ada-tasks.c (_initialize_tasks): Add declaration.
* agent.c (_initialize_agent): Add declaration.
* aix-thread.c (_initialize_aix_thread): Add declaration.
* alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration.
* alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration.
* alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration.
* alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration.
* alpha-tdep.c (_initialize_alpha_tdep): Add declaration.
* amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration.
* amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration.
* amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration.
* amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration.
* amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration.
* amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration.
* amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration.
* amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration.
* amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration.
* amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration.
* amd64-tdep.c (_initialize_amd64_tdep): Add declaration.
* amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration.
* amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration.
* annotate.c (_initialize_annotate): Add declaration.
* arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration.
* arc-tdep.c (_initialize_arc_tdep): Add declaration.
* arch-utils.c (_initialize_gdbarch_utils): Add declaration.
* arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration.
* arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration.
* arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration.
* arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration.
* arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration.
* arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration.
* arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration.
* arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration.
* arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration.
* arm-tdep.c (_initialize_arm_tdep): Add declaration.
* arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration.
* auto-load.c (_initialize_auto_load): Add declaration.
* auxv.c (_initialize_auxv): Add declaration.
* avr-tdep.c (_initialize_avr_tdep): Add declaration.
* ax-gdb.c (_initialize_ax_gdb): Add declaration.
* bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration.
* bfin-tdep.c (_initialize_bfin_tdep): Add declaration.
* break-catch-sig.c (_initialize_break_catch_sig): Add declaration.
* break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration.
* break-catch-throw.c (_initialize_break_catch_throw): Add declaration.
* breakpoint.c (_initialize_breakpoint): Add declaration.
* bsd-uthread.c (_initialize_bsd_uthread): Add declaration.
* btrace.c (_initialize_btrace): Add declaration.
* charset.c (_initialize_charset): Add declaration.
* cli/cli-cmds.c (_initialize_cli_cmds): Add declaration.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-logging.c (_initialize_cli_logging): Add declaration.
* cli/cli-script.c (_initialize_cli_script): Add declaration.
* cli/cli-style.c (_initialize_cli_style): Add declaration.
* coff-pe-read.c (_initialize_coff_pe_read): Add declaration.
* coffread.c (_initialize_coffread): Add declaration.
* compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration.
* compile/compile.c (_initialize_compile): Add declaration.
* complaints.c (_initialize_complaints): Add declaration.
* completer.c (_initialize_completer): Add declaration.
* copying.c (_initialize_copying): Add declaration.
* corefile.c (_initialize_core): Add declaration.
* corelow.c (_initialize_corelow): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* cp-namespace.c (_initialize_cp_namespace): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-valprint.c (_initialize_cp_valprint): Add declaration.
* cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration.
* cris-tdep.c (_initialize_cris_tdep): Add declaration.
* csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration.
* csky-tdep.c (_initialize_csky_tdep): Add declaration.
* ctfread.c (_initialize_ctfread): Add declaration.
* d-lang.c (_initialize_d_language): Add declaration.
* darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration.
* darwin-nat.c (_initialize_darwin_nat): Add declaration.
* dbxread.c (_initialize_dbxread): Add declaration.
* dcache.c (_initialize_dcache): Add declaration.
* disasm-selftests.c (_initialize_disasm_selftests): Add declaration.
* disasm.c (_initialize_disasm): Add declaration.
* dtrace-probe.c (_initialize_dtrace_probe): Add declaration.
* dummy-frame.c (_initialize_dummy_frame): Add declaration.
* dwarf-index-cache.c (_initialize_index_cache): Add declaration.
* dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration.
* dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration.
* dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration.
* dwarf2expr.c (_initialize_dwarf2expr): Add declaration.
* dwarf2loc.c (_initialize_dwarf2loc): Add declaration.
* dwarf2read.c (_initialize_dwarf2_read): Add declaration.
* elfread.c (_initialize_elfread): Add declaration.
* exec.c (_initialize_exec): Add declaration.
* extension.c (_initialize_extension): Add declaration.
* f-lang.c (_initialize_f_language): Add declaration.
* f-valprint.c (_initialize_f_valprint): Add declaration.
* fbsd-nat.c (_initialize_fbsd_nat): Add declaration.
* fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration.
* filesystem.c (_initialize_filesystem): Add declaration.
* findcmd.c (_initialize_mem_search): Add declaration.
* findvar.c (_initialize_findvar): Add declaration.
* fork-child.c (_initialize_fork_child): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (_initialize_frame): Add declaration.
* frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration.
* frv-tdep.c (_initialize_frv_tdep): Add declaration.
* ft32-tdep.c (_initialize_ft32_tdep): Add declaration.
* gcore.c (_initialize_gcore): Add declaration.
* gdb-demangle.c (_initialize_gdb_demangle): Add declaration.
* gdb_bfd.c (_initialize_gdb_bfd): Add declaration.
* gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration.
* gdbarch.c (_initialize_gdbarch): Add declaration.
* gdbtypes.c (_initialize_gdbtypes): Add declaration.
* gnu-nat.c (_initialize_gnu_nat): Add declaration.
* gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration.
* gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration.
* go-lang.c (_initialize_go_language): Add declaration.
* go32-nat.c (_initialize_go32_nat): Add declaration.
* guile/guile.c (_initialize_guile): Add declaration.
* h8300-tdep.c (_initialize_h8300_tdep): Add declaration.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration.
* hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration.
* hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration.
* hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration.
* hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration.
* hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration.
* hppa-tdep.c (_initialize_hppa_tdep): Add declaration.
* i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration.
* i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration.
* i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration.
* i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration.
* i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration.
* i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration.
* i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration.
* i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration.
* i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration.
* i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration.
* i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration.
* i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration.
* i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration.
* i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration.
* i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration.
* i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration.
* i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration.
* i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration.
* i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration.
* i386-tdep.c (_initialize_i386_tdep): Add declaration.
* i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration.
* ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration.
* ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration.
* ia64-tdep.c (_initialize_ia64_tdep): Add declaration.
* ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration.
* infcall.c (_initialize_infcall): Add declaration.
* infcmd.c (_initialize_infcmd): Add declaration.
* inflow.c (_initialize_inflow): Add declaration.
* infrun.c (_initialize_infrun): Add declaration.
* interps.c (_initialize_interpreter): Add declaration.
* iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration.
* jit.c (_initialize_jit): Add declaration.
* language.c (_initialize_language): Add declaration.
* linux-fork.c (_initialize_linux_fork): Add declaration.
* linux-nat.c (_initialize_linux_nat): Add declaration.
* linux-tdep.c (_initialize_linux_tdep): Add declaration.
* linux-thread-db.c (_initialize_thread_db): Add declaration.
* lm32-tdep.c (_initialize_lm32_tdep): Add declaration.
* m2-lang.c (_initialize_m2_language): Add declaration.
* m32c-tdep.c (_initialize_m32c_tdep): Add declaration.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration.
* m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration.
* m32r-tdep.c (_initialize_m32r_tdep): Add declaration.
* m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration.
* m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration.
* m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration.
* m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration.
* m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration.
* m68k-tdep.c (_initialize_m68k_tdep): Add declaration.
* machoread.c (_initialize_machoread): Add declaration.
* macrocmd.c (_initialize_macrocmd): Add declaration.
* macroscope.c (_initialize_macroscope): Add declaration.
* maint-test-options.c (_initialize_maint_test_options): Add declaration.
* maint-test-settings.c (_initialize_maint_test_settings): Add declaration.
* maint.c (_initialize_maint_cmds): Add declaration.
* mdebugread.c (_initialize_mdebugread): Add declaration.
* memattr.c (_initialize_mem): Add declaration.
* mep-tdep.c (_initialize_mep_tdep): Add declaration.
* mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration.
* mi/mi-cmds.c (_initialize_mi_cmds): Add declaration.
* mi/mi-interp.c (_initialize_mi_interp): Add declaration.
* mi/mi-main.c (_initialize_mi_main): Add declaration.
* microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration.
* microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration.
* mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration.
* mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration.
* mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration.
* mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration.
* mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration.
* mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration.
* mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration.
* mips-tdep.c (_initialize_mips_tdep): Add declaration.
* mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration.
* mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration.
* mipsread.c (_initialize_mipsread): Add declaration.
* mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration.
* mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration.
* moxie-tdep.c (_initialize_moxie_tdep): Add declaration.
* msp430-tdep.c (_initialize_msp430_tdep): Add declaration.
* nds32-tdep.c (_initialize_nds32_tdep): Add declaration.
* nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration.
* nios2-tdep.c (_initialize_nios2_tdep): Add declaration.
* nto-procfs.c (_initialize_procfs): Add declaration.
* objc-lang.c (_initialize_objc_language): Add declaration.
* observable.c (_initialize_observer): Add declaration.
* opencl-lang.c (_initialize_opencl_language): Add declaration.
* or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration.
* or1k-tdep.c (_initialize_or1k_tdep): Add declaration.
* osabi.c (_initialize_gdb_osabi): Add declaration.
* osdata.c (_initialize_osdata): Add declaration.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* parse.c (_initialize_parse): Add declaration.
* ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration.
* ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration.
* ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration.
* ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration.
* ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration.
* ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration.
* ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration.
* printcmd.c (_initialize_printcmd): Add declaration.
* probe.c (_initialize_probe): Add declaration.
* proc-api.c (_initialize_proc_api): Add declaration.
* proc-events.c (_initialize_proc_events): Add declaration.
* proc-service.c (_initialize_proc_service): Add declaration.
* procfs.c (_initialize_procfs): Add declaration.
* producer.c (_initialize_producer): Add declaration.
* psymtab.c (_initialize_psymtab): Add declaration.
* python/python.c (_initialize_python): Add declaration.
* ravenscar-thread.c (_initialize_ravenscar): Add declaration.
* record-btrace.c (_initialize_record_btrace): Add declaration.
* record-full.c (_initialize_record_full): Add declaration.
* record.c (_initialize_record): Add declaration.
* regcache-dump.c (_initialize_regcache_dump): Add declaration.
* regcache.c (_initialize_regcache): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* remote-notif.c (_initialize_notif): Add declaration.
* remote-sim.c (_initialize_remote_sim): Add declaration.
* remote.c (_initialize_remote): Add declaration.
* reverse.c (_initialize_reverse): Add declaration.
* riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration.
* riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration.
* riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration.
* riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration.
* riscv-tdep.c (_initialize_riscv_tdep): Add declaration.
* rl78-tdep.c (_initialize_rl78_tdep): Add declaration.
* rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration.
* rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep):
Add declaration.
* rs6000-nat.c (_initialize_rs6000_nat): Add declaration.
* rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration.
* run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration.
* rust-exp.y (_initialize_rust_exp): Add declaration.
* rx-tdep.c (_initialize_rx_tdep): Add declaration.
* s12z-tdep.c (_initialize_s12z_tdep): Add declaration.
* s390-linux-nat.c (_initialize_s390_nat): Add declaration.
* s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration.
* s390-tdep.c (_initialize_s390_tdep): Add declaration.
* score-tdep.c (_initialize_score_tdep): Add declaration.
* ser-go32.c (_initialize_ser_dos): Add declaration.
* ser-mingw.c (_initialize_ser_windows): Add declaration.
* ser-pipe.c (_initialize_ser_pipe): Add declaration.
* ser-tcp.c (_initialize_ser_tcp): Add declaration.
* ser-uds.c (_initialize_ser_socket): Add declaration.
* ser-unix.c (_initialize_ser_hardwire): Add declaration.
* serial.c (_initialize_serial): Add declaration.
* sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration.
* sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration.
* sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration.
* sh-tdep.c (_initialize_sh_tdep): Add declaration.
* skip.c (_initialize_step_skip): Add declaration.
* sol-thread.c (_initialize_sol_thread): Add declaration.
* solib-aix.c (_initialize_solib_aix): Add declaration.
* solib-darwin.c (_initialize_darwin_solib): Add declaration.
* solib-dsbt.c (_initialize_dsbt_solib): Add declaration.
* solib-frv.c (_initialize_frv_solib): Add declaration.
* solib-svr4.c (_initialize_svr4_solib): Add declaration.
* solib-target.c (_initialize_solib_target): Add declaration.
* solib.c (_initialize_solib): Add declaration.
* source-cache.c (_initialize_source_cache): Add declaration.
* source.c (_initialize_source): Add declaration.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration.
* sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration.
* sparc-nat.c (_initialize_sparc_nat): Add declaration.
* sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration.
* sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration.
* sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration.
* sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration.
* sparc-tdep.c (_initialize_sparc_tdep): Add declaration.
* sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration.
* sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration.
* sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration.
* sparc64-nat.c (_initialize_sparc64_nat): Add declaration.
* sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration.
* sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration.
* sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration.
* sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration.
* sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration.
* sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration.
* stabsread.c (_initialize_stabsread): Add declaration.
* stack.c (_initialize_stack): Add declaration.
* stap-probe.c (_initialize_stap_probe): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* symfile-debug.c (_initialize_symfile_debug): Add declaration.
* symfile-mem.c (_initialize_symfile_mem): Add declaration.
* symfile.c (_initialize_symfile): Add declaration.
* symmisc.c (_initialize_symmisc): Add declaration.
* symtab.c (_initialize_symtab): Add declaration.
* target.c (_initialize_target): Add declaration.
* target-connection.c (_initialize_target_connection): Add
declaration.
* target-dcache.c (_initialize_target_dcache): Add declaration.
* target-descriptions.c (_initialize_target_descriptions): Add declaration.
* thread.c (_initialize_thread): Add declaration.
* tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration.
* tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration.
* tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration.
* tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration.
* tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration.
* tracectf.c (_initialize_ctf): Add declaration.
* tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration.
* tracefile.c (_initialize_tracefile): Add declaration.
* tracepoint.c (_initialize_tracepoint): Add declaration.
* tui/tui-hooks.c (_initialize_tui_hooks): Add declaration.
* tui/tui-interp.c (_initialize_tui_interp): Add declaration.
* tui/tui-layout.c (_initialize_tui_layout): Add declaration.
* tui/tui-regs.c (_initialize_tui_regs): Add declaration.
* tui/tui-stack.c (_initialize_tui_stack): Add declaration.
* tui/tui-win.c (_initialize_tui_win): Add declaration.
* tui/tui.c (_initialize_tui): Add declaration.
* typeprint.c (_initialize_typeprint): Add declaration.
* ui-style.c (_initialize_ui_style): Add declaration.
* unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration.
* unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration.
* unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration.
* unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration.
* unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration.
* unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration.
* unittests/filtered_iterator-selftests.c
(_initialize_filtered_iterator_selftests): Add declaration.
* unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration.
* unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration.
* unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration.
* unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration.
* unittests/main-thread-selftests.c
(_initialize_main_thread_selftests): Add declaration.
* unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration.
* unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration.
* unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration.
* unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration.
* unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration.
* unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration.
* unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration.
* unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration.
* unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration.
* unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration.
* unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration.
* unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration.
* unittests/style-selftests.c (_initialize_style_selftest): Add declaration.
* unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration.
* unittests/tui-selftests.c (_initialize_tui_selftest): Add
declaration.
* unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration.
* unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration.
* unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration.
* unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration.
* user-regs.c (_initialize_user_regs): Add declaration.
* utils.c (_initialize_utils): Add declaration.
* v850-tdep.c (_initialize_v850_tdep): Add declaration.
* valops.c (_initialize_valops): Add declaration.
* valprint.c (_initialize_valprint): Add declaration.
* value.c (_initialize_values): Add declaration.
* varobj.c (_initialize_varobj): Add declaration.
* vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration.
* vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration.
* vax-tdep.c (_initialize_vax_tdep): Add declaration.
* windows-nat.c (_initialize_windows_nat): Add declaration.
(_initialize_check_for_gdb_ini): Add declaration.
(_initialize_loadable): Add declaration.
* windows-tdep.c (_initialize_windows_tdep): Add declaration.
* x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration.
* x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration.
* xcoffread.c (_initialize_xcoffread): Add declaration.
* xml-support.c (_initialize_xml_support): Add declaration.
* xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration.
* xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration.
* xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration.
* xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration.
Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
|
|
Currently, we can only support resuming multiple targets at the same
time if all targets are in non-stop mode (or user-visible all-stop
mode with target backend in non-stop mode).
This patch makes GDB error out if the user tries to resume more than
one target at the same time and one of the resumed targets isn't in
non-stop mode:
(gdb) info inferiors
Num Description Connection Executable
1 process 15303 1 (native) a.out
* 2 process 15286 2 (extended-remote :9999) a.out
(gdb) set schedule-multiple on
(gdb) c
Continuing.
Connection 2 (extended-remote :9999) does not support multi-target resumption.
This is here later in the series instead of in the main multi-target
patch because it depends the previous patch, which added
process_stratum_target::connection_string().
gdb/ChangeLog:
2020-01-10 Pedro Alves <palves@redhat.com>
* infrun.c: Include "target-connection.h".
(check_multi_target_resumption): New.
(proceed): Call it.
* target-connection.c (make_target_connection_string): Make
extern.
* target-connection.h (make_target_connection_string): Declare.
|
|
This commit adds multi-target support to GDB. What this means is that
with this commit, GDB can now be connected to different targets at the
same time. E.g., you can debug a live native process and a core dump
at the same time, connect to multiple gdbservers, etc.
Actually, the word "target" is overloaded in gdb. We already have a
target stack, with pushes several target_ops instances on top of one
another. We also have "info target" already, which means something
completely different to what this patch does.
So from here on, I'll be using the "target connections" term, to mean
an open process_stratum target, pushed on a target stack. This patch
makes gdb have multiple target stacks, and multiple process_stratum
targets open simultaneously. The user-visible changes / commands will
also use this terminology, but of course it's all open to debate.
User-interface-wise, not that much changes. The main difference is
that each inferior may have its own target connection.
A target connection (e.g., a target extended-remote connection) may
support debugging multiple processes, just as before.
Say you're debugging against gdbserver in extended-remote mode, and
you do "add-inferior" to prepare to spawn a new process, like:
(gdb) target extended-remote :9999
...
(gdb) start
...
(gdb) add-inferior
Added inferior 2
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) file a.out
...
(gdb) start
...
At this point, you have two inferiors connected to the same gdbserver.
With this commit, GDB will maintain a target stack per inferior,
instead of a global target stack.
To preserve the behavior above, by default, "add-inferior" makes the
new inferior inherit a copy of the target stack of the current
inferior. Same across a fork - the child inherits a copy of the
target stack of the parent. While the target stacks are copied, the
targets themselves are not. Instead, target_ops is made a
refcounted_object, which means that target_ops instances are
refcounted, which each inferior counting for a reference.
What if you want to create an inferior and connect it to some _other_
target? For that, this commit introduces a new "add-inferior
-no-connection" option that makes the new inferior not share the
current inferior's target. So you could do:
(gdb) target extended-remote :9999
Remote debugging using :9999
...
(gdb) add-inferior -no-connection
[New inferior 2]
Added inferior 2
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) info inferiors
Num Description Executable
1 process 18401 target:/home/pedro/tmp/main
* 2 <null>
(gdb) tar extended-remote :10000
Remote debugging using :10000
...
(gdb) info inferiors
Num Description Executable
1 process 18401 target:/home/pedro/tmp/main
* 2 process 18450 target:/home/pedro/tmp/main
(gdb)
A following patch will extended "info inferiors" to include a column
indicating which connection an inferior is bound to, along with a
couple other UI tweaks.
Other than that, debugging is the same as before. Users interact with
inferiors and threads as before. The only difference is that
inferiors may be bound to processes running in different machines.
That's pretty much all there is to it in terms of noticeable UI
changes.
On to implementation.
Since we can be connected to different systems at the same time, a
ptid_t is no longer a unique identifier. Instead a thread can be
identified by a pair of ptid_t and 'process_stratum_target *', the
later being the instance of the process_stratum target that owns the
process/thread. Note that process_stratum_target inherits from
target_ops, and all process_stratum targets inherit from
process_stratum_target. In earlier patches, many places in gdb were
converted to refer to threads by thread_info pointer instead of
ptid_t, but there are still places in gdb where we start with a
pid/tid and need to find the corresponding inferior or thread_info
objects. So you'll see in the patch many places adding a
process_stratum_target parameter to functions that used to take only a
ptid_t.
Since each inferior has its own target stack now, we can always find
the process_stratum target for an inferior. That is done via a
inf->process_target() convenience method.
Since each inferior has its own target stack, we need to handle the
"beneath" calls when servicing target calls. The solution I settled
with is just to make sure to switch the current inferior to the
inferior you want before making a target call. Not relying on global
context is just not feasible in current GDB. Fortunately, there
aren't that many places that need to do that, because generally most
code that calls target methods already has the current context
pointing to the right inferior/thread. Note, to emphasize -- there's
no method to "switch to this target stack". Instead, you switch the
current inferior, and that implicitly switches the target stack.
In some spots, we need to iterate over all inferiors so that we reach
all target stacks.
Native targets are still singletons. There's always only a single
instance of such targets.
Remote targets however, we'll have one instance per remote connection.
The exec target is still a singleton. There's only one instance. I
did not see the point of instanciating more than one exec_target
object.
After vfork, we need to make sure to push the exec target on the new
inferior. See exec_on_vfork.
For type safety, functions that need a {target, ptid} pair to identify
a thread, take a process_stratum_target pointer for target parameter
instead of target_ops *. Some shared code in gdb/nat/ also need to
gain a target pointer parameter. This poses an issue, since gdbserver
doesn't have process_stratum_target, only target_ops. To fix this,
this commit renames gdbserver's target_ops to process_stratum_target.
I think this makes sense. There's no concept of target stack in
gdbserver, and gdbserver's target_ops really implements a
process_stratum-like target.
The thread and inferior iterator functions also gain
process_stratum_target parameters. These are used to be able to
iterate over threads and inferiors of a given target. Following usual
conventions, if the target pointer is null, then we iterate over
threads and inferiors of all targets.
I tried converting "add-inferior" to the gdb::option framework, as a
preparatory patch, but that stumbled on the fact that gdb::option does
not support file options yet, for "add-inferior -exec". I have a WIP
patchset that adds that, but it's not a trivial patch, mainly due to
need to integrate readline's filename completion, so I deferred that
to some other time.
In infrun.c/infcmd.c, the main change is that we need to poll events
out of all targets. See do_target_wait. Right after collecting an
event, we switch the current inferior to an inferior bound to the
target that reported the event, so that target methods can be used
while handling the event. This makes most of the code transparent to
multi-targets. See fetch_inferior_event.
infrun.c:stop_all_threads is interesting -- in this function we need
to stop all threads of all targets. What the function does is send an
asynchronous stop request to all threads, and then synchronously waits
for events, with target_wait, rinse repeat, until all it finds are
stopped threads. Now that we have multiple targets, it's not
efficient to synchronously block in target_wait waiting for events out
of one target. Instead, we implement a mini event loop, with
interruptible_select, select'ing on one file descriptor per target.
For this to work, we need to be able to ask the target for a waitable
file descriptor. Such file descriptors already exist, they are the
descriptors registered in the main event loop with add_file_handler,
inside the target_async implementations. This commit adds a new
target_async_wait_fd target method that just returns the file
descriptor in question. See wait_one / stop_all_threads in infrun.c.
The 'threads_executing' global is made a per-target variable. Since
it is only relevant to process_stratum_target targets, this is where
it is put, instead of in target_ops.
You'll notice that remote.c includes some FIXME notes. These refer to
the fact that the global arrays that hold data for the remote packets
supported are still globals. For example, if we connect to two
different servers/stubs, then each might support different remote
protocol features. They might even be different architectures, like
e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a
host/controller scenario as a single program. That isn't going to
work correctly today, because of said globals. I'm leaving fixing
that for another pass, since it does not appear to be trivial, and I'd
rather land the base work first. It's already useful to be able to
debug multiple instances of the same server (e.g., a distributed
cluster, where you have full control over the servers installed), so I
think as is it's already reasonable incremental progress.
Current limitations:
- You can only resume more that one target at the same time if all
targets support asynchronous debugging, and support non-stop mode.
It should be possible to support mixed all-stop + non-stop
backends, but that is left for another time. This means that
currently in order to do multi-target with gdbserver you need to
issue "maint set target-non-stop on". I would like to make that
mode be the default, but we're not there yet. Note that I'm
talking about how the target backend works, only. User-visible
all-stop mode works just fine.
- As explained above, connecting to different remote servers at the
same time is likely to produce bad results if they don't support the
exact set of RSP features.
FreeBSD updates courtesy of John Baldwin.
gdb/ChangeLog:
2020-01-10 Pedro Alves <palves@redhat.com>
John Baldwin <jhb@FreeBSD.org>
* aarch64-linux-nat.c
(aarch64_linux_nat_target::thread_architecture): Adjust.
* ada-tasks.c (print_ada_task_info): Adjust find_thread_ptid call.
(task_command_1): Likewise.
* aix-thread.c (sync_threadlists, aix_thread_target::resume)
(aix_thread_target::wait, aix_thread_target::fetch_registers)
(aix_thread_target::store_registers)
(aix_thread_target::thread_alive): Adjust.
* amd64-fbsd-tdep.c: Include "inferior.h".
(amd64fbsd_get_thread_local_address): Pass down target.
* amd64-linux-nat.c (ps_get_thread_area): Use ps_prochandle
thread's gdbarch instead of target_gdbarch.
* break-catch-sig.c (signal_catchpoint_print_it): Adjust call to
get_last_target_status.
* break-catch-syscall.c (print_it_catch_syscall): Likewise.
* breakpoint.c (breakpoints_should_be_inserted_now): Consider all
inferiors.
(update_inserted_breakpoint_locations): Skip if inferiors with no
execution.
(update_global_location_list): When handling moribund locations,
find representative inferior for location's pspace, and use thread
count of its process_stratum target.
* bsd-kvm.c (bsd_kvm_target_open): Pass target down.
* bsd-uthread.c (bsd_uthread_target::wait): Use
as_process_stratum_target and adjust thread_change_ptid and
add_thread calls.
(bsd_uthread_target::update_thread_list): Use
as_process_stratum_target and adjust find_thread_ptid,
thread_change_ptid and add_thread calls.
* btrace.c (maint_btrace_packet_history_cmd): Adjust
find_thread_ptid call.
* corelow.c (add_to_thread_list): Adjust add_thread call.
(core_target_open): Adjust add_thread_silent and thread_count
calls.
(core_target::pid_to_str): Adjust find_inferior_ptid call.
* ctf.c (ctf_target_open): Adjust add_thread_silent call.
* event-top.c (async_disconnect): Pop targets from all inferiors.
* exec.c (add_target_sections): Push exec target on all inferiors
sharing the program space.
(remove_target_sections): Remove the exec target from all
inferiors sharing the program space.
(exec_on_vfork): New.
* exec.h (exec_on_vfork): Declare.
* fbsd-nat.c (fbsd_add_threads): Add fbsd_nat_target parameter.
Pass it down.
(fbsd_nat_target::update_thread_list): Adjust.
(fbsd_nat_target::resume): Adjust.
(fbsd_handle_debug_trap): Add fbsd_nat_target parameter. Pass it
down.
(fbsd_nat_target::wait, fbsd_nat_target::post_attach): Adjust.
* fbsd-tdep.c (fbsd_corefile_thread): Adjust
get_thread_arch_regcache call.
* fork-child.c (gdb_startup_inferior): Pass target down to
startup_inferior and set_executing.
* gdbthread.h (struct process_stratum_target): Forward declare.
(add_thread, add_thread_silent, add_thread_with_info)
(in_thread_list): Add process_stratum_target parameter.
(find_thread_ptid(inferior*, ptid_t)): New overload.
(find_thread_ptid, thread_change_ptid): Add process_stratum_target
parameter.
(all_threads()): Delete overload.
(all_threads, all_non_exited_threads): Add process_stratum_target
parameter.
(all_threads_safe): Use brace initialization.
(thread_count): Add process_stratum_target parameter.
(set_resumed, set_running, set_stop_requested, set_executing)
(threads_are_executing, finish_thread_state): Add
process_stratum_target parameter.
(switch_to_thread): Use is_current_thread.
* i386-fbsd-tdep.c: Include "inferior.h".
(i386fbsd_get_thread_local_address): Pass down target.
* i386-linux-nat.c (i386_linux_nat_target::low_resume): Adjust.
* inf-child.c (inf_child_target::maybe_unpush_target): Remove
have_inferiors check.
* inf-ptrace.c (inf_ptrace_target::create_inferior)
(inf_ptrace_target::attach): Adjust.
* infcall.c (run_inferior_call): Adjust.
* infcmd.c (run_command_1): Pass target to
scoped_finish_thread_state.
(proceed_thread_callback): Skip inferiors with no execution.
(continue_command): Rename 'all_threads' local to avoid hiding
'all_threads' function. Adjust get_last_target_status call.
(prepare_one_step): Adjust set_running call.
(signal_command): Use user_visible_resume_target. Compare thread
pointers instead of inferior_ptid.
(info_program_command): Adjust to pass down target.
(attach_command): Mark target's 'thread_executing' flag.
(stop_current_target_threads_ns): New, factored out from ...
(interrupt_target_1): ... this. Switch inferior before making
target calls.
* inferior-iter.h
(struct all_inferiors_iterator, struct all_inferiors_range)
(struct all_inferiors_safe_range)
(struct all_non_exited_inferiors_range): Filter on
process_stratum_target too. Remove explicit.
* inferior.c (inferior::inferior): Push dummy target on target
stack.
(find_inferior_pid, find_inferior_ptid, number_of_live_inferiors):
Add process_stratum_target parameter, and pass it down.
(have_live_inferiors): Adjust.
(switch_to_inferior_and_push_target): New.
(add_inferior_command, clone_inferior_command): Handle
"-no-connection" parameter. Use
switch_to_inferior_and_push_target.
(_initialize_inferior): Mention "-no-connection" option in
the help of "add-inferior" and "clone-inferior" commands.
* inferior.h: Include "process-stratum-target.h".
(interrupt_target_1): Use bool.
(struct inferior) <push_target, unpush_target, target_is_pushed,
find_target_beneath, top_target, process_target, target_at,
m_stack>: New.
(discard_all_inferiors): Delete.
(find_inferior_pid, find_inferior_ptid, number_of_live_inferiors)
(all_inferiors, all_non_exited_inferiors): Add
process_stratum_target parameter.
* infrun.c: Include "gdb_select.h" and <unordered_map>.
(target_last_proc_target): New global.
(follow_fork_inferior): Push target on new inferior. Pass target
to add_thread_silent. Call exec_on_vfork. Handle target's
reference count.
(follow_fork): Adjust get_last_target_status call. Also consider
target.
(follow_exec): Push target on new inferior.
(struct execution_control_state) <target>: New field.
(user_visible_resume_target): New.
(do_target_resume): Call target_async.
(resume_1): Set target's threads_executing flag. Consider resume
target.
(commit_resume_all_targets): New.
(proceed): Also consider resume target. Skip threads of inferiors
with no execution. Commit resumtion in all targets.
(start_remote): Pass current inferior to wait_for_inferior.
(infrun_thread_stop_requested): Consider target as well. Pass
thread_info pointer to clear_inline_frame_state instead of ptid.
(infrun_thread_thread_exit): Consider target as well.
(random_pending_event_thread): New inferior parameter. Use it.
(do_target_wait): Rename to ...
(do_target_wait_1): ... this. Add inferior parameter, and pass it
down.
(threads_are_resumed_pending_p, do_target_wait): New.
(prepare_for_detach): Adjust calls.
(wait_for_inferior): New inferior parameter. Handle it. Use
do_target_wait_1 instead of do_target_wait.
(fetch_inferior_event): Adjust. Switch to representative
inferior. Pass target down.
(set_last_target_status): Add process_stratum_target parameter.
Save target in global.
(get_last_target_status): Add process_stratum_target parameter and
handle it.
(nullify_last_target_wait_ptid): Clear 'target_last_proc_target'.
(context_switch): Check inferior_ptid == null_ptid before calling
inferior_thread().
(get_inferior_stop_soon): Pass down target.
(wait_one): Rename to ...
(poll_one_curr_target): ... this.
(struct wait_one_event): New.
(wait_one): New.
(stop_all_threads): Adjust.
(handle_no_resumed, handle_inferior_event): Adjust to consider the
event's target.
(switch_back_to_stepped_thread): Also consider target.
(print_stop_event): Update.
(normal_stop): Update. Also consider the resume target.
* infrun.h (wait_for_inferior): Remove declaration.
(user_visible_resume_target): New declaration.
(get_last_target_status, set_last_target_status): New
process_stratum_target parameter.
* inline-frame.c (clear_inline_frame_state(ptid_t)): Add
process_stratum_target parameter, and use it.
(clear_inline_frame_state (thread_info*)): New.
* inline-frame.c (clear_inline_frame_state(ptid_t)): Add
process_stratum_target parameter.
(clear_inline_frame_state (thread_info*)): Declare.
* linux-fork.c (delete_checkpoint_command): Pass target down to
find_thread_ptid.
(checkpoint_command): Adjust.
* linux-nat.c (linux_nat_target::follow_fork): Switch to thread
instead of just tweaking inferior_ptid.
(linux_nat_switch_fork): Pass target down to thread_change_ptid.
(exit_lwp): Pass target down to find_thread_ptid.
(attach_proc_task_lwp_callback): Pass target down to
add_thread/set_running/set_executing.
(linux_nat_target::attach): Pass target down to
thread_change_ptid.
(get_detach_signal): Pass target down to find_thread_ptid.
Consider last target status's target.
(linux_resume_one_lwp_throw, resume_lwp)
(linux_handle_syscall_trap, linux_handle_extended_wait, wait_lwp)
(stop_wait_callback, save_stop_reason, linux_nat_filter_event)
(linux_nat_wait_1, resume_stopped_resumed_lwps): Pass target down.
(linux_nat_target::async_wait_fd): New.
(linux_nat_stop_lwp, linux_nat_target::thread_address_space): Pass
target down.
* linux-nat.h (linux_nat_target::async_wait_fd): Declare.
* linux-tdep.c (get_thread_arch_regcache): Pass target down.
* linux-thread-db.c (struct thread_db_info::process_target): New
field.
(add_thread_db_info): Save target.
(get_thread_db_info): New process_stratum_target parameter. Also
match target.
(delete_thread_db_info): New process_stratum_target parameter.
Also match target.
(thread_from_lwp): Adjust to pass down target.
(thread_db_notice_clone): Pass down target.
(check_thread_db_callback): Pass down target.
(try_thread_db_load_1): Always push the thread_db target.
(try_thread_db_load, record_thread): Pass target down.
(thread_db_target::detach): Pass target down. Always unpush the
thread_db target.
(thread_db_target::wait, thread_db_target::mourn_inferior): Pass
target down. Always unpush the thread_db target.
(find_new_threads_callback, thread_db_find_new_threads_2)
(thread_db_target::update_thread_list): Pass target down.
(thread_db_target::pid_to_str): Pass current inferior down.
(thread_db_target::get_thread_local_address): Pass target down.
(thread_db_target::resume, maintenance_check_libthread_db): Pass
target down.
* nto-procfs.c (nto_procfs_target::update_thread_list): Adjust.
* procfs.c (procfs_target::procfs_init_inferior): Declare.
(proc_set_current_signal, do_attach, procfs_target::wait): Adjust.
(procfs_init_inferior): Rename to ...
(procfs_target::procfs_init_inferior): ... this and adjust.
(procfs_target::create_inferior, procfs_notice_thread)
(procfs_do_thread_registers): Adjust.
* ppc-fbsd-tdep.c: Include "inferior.h".
(ppcfbsd_get_thread_local_address): Pass down target.
* proc-service.c (ps_xfer_memory): Switch current inferior and
program space as well.
(get_ps_regcache): Pass target down.
* process-stratum-target.c
(process_stratum_target::thread_address_space)
(process_stratum_target::thread_architecture): Pass target down.
* process-stratum-target.h
(process_stratum_target::threads_executing): New field.
(as_process_stratum_target): New.
* ravenscar-thread.c
(ravenscar_thread_target::update_inferior_ptid): Pass target down.
(ravenscar_thread_target::wait, ravenscar_add_thread): Pass target
down.
* record-btrace.c (record_btrace_target::info_record): Adjust.
(record_btrace_target::record_method)
(record_btrace_target::record_is_replaying)
(record_btrace_target::fetch_registers)
(get_thread_current_frame_id, record_btrace_target::resume)
(record_btrace_target::wait, record_btrace_target::stop): Pass
target down.
* record-full.c (record_full_wait_1): Switch to event thread.
Pass target down.
* regcache.c (regcache::regcache)
(get_thread_arch_aspace_regcache, get_thread_arch_regcache): Add
process_stratum_target parameter and handle it.
(current_thread_target): New global.
(get_thread_regcache): Add process_stratum_target parameter and
handle it. Switch inferior before calling target method.
(get_thread_regcache): Pass target down.
(get_thread_regcache_for_ptid): Pass target down.
(registers_changed_ptid): Add process_stratum_target parameter and
handle it.
(registers_changed_thread, registers_changed): Pass target down.
(test_get_thread_arch_aspace_regcache): New.
(current_regcache_test): Define a couple local test_target_ops
instances and use them for testing.
(readwrite_regcache): Pass process_stratum_target parameter.
(cooked_read_test, cooked_write_test): Pass mock_target down.
* regcache.h (get_thread_regcache, get_thread_arch_regcache)
(get_thread_arch_aspace_regcache): Add process_stratum_target
parameter.
(regcache::target): New method.
(regcache::regcache, regcache::get_thread_arch_aspace_regcache)
(regcache::registers_changed_ptid): Add process_stratum_target
parameter.
(regcache::m_target): New field.
(registers_changed_ptid): Add process_stratum_target parameter.
* remote.c (remote_state::supports_vCont_probed): New field.
(remote_target::async_wait_fd): New method.
(remote_unpush_and_throw): Add remote_target parameter.
(get_current_remote_target): Adjust.
(remote_target::remote_add_inferior): Push target.
(remote_target::remote_add_thread)
(remote_target::remote_notice_new_inferior)
(get_remote_thread_info): Pass target down.
(remote_target::update_thread_list): Skip threads of inferiors
bound to other targets. (remote_target::close): Don't discard
inferiors. (remote_target::add_current_inferior_and_thread)
(remote_target::process_initial_stop_replies)
(remote_target::start_remote)
(remote_target::remote_serial_quit_handler): Pass down target.
(remote_target::remote_unpush_target): New remote_target
parameter. Unpush the target from all inferiors.
(remote_target::remote_unpush_and_throw): New remote_target
parameter. Pass it down.
(remote_target::open_1): Check whether the current inferior has
execution instead of checking whether any inferior is live. Pass
target down.
(remote_target::remote_detach_1): Pass down target. Use
remote_unpush_target.
(extended_remote_target::attach): Pass down target.
(remote_target::remote_vcont_probe): Set supports_vCont_probed.
(remote_target::append_resumption): Pass down target.
(remote_target::append_pending_thread_resumptions)
(remote_target::remote_resume_with_hc, remote_target::resume)
(remote_target::commit_resume): Pass down target.
(remote_target::remote_stop_ns): Check supports_vCont_probed.
(remote_target::interrupt_query)
(remote_target::remove_new_fork_children)
(remote_target::check_pending_events_prevent_wildcard_vcont)
(remote_target::remote_parse_stop_reply)
(remote_target::process_stop_reply): Pass down target.
(first_remote_resumed_thread): New remote_target parameter. Pass
it down.
(remote_target::wait_as): Pass down target.
(unpush_and_perror): New remote_target parameter. Pass it down.
(remote_target::readchar, remote_target::remote_serial_write)
(remote_target::getpkt_or_notif_sane_1)
(remote_target::kill_new_fork_children, remote_target::kill): Pass
down target.
(remote_target::mourn_inferior): Pass down target. Use
remote_unpush_target.
(remote_target::core_of_thread)
(remote_target::remote_btrace_maybe_reopen): Pass down target.
(remote_target::pid_to_exec_file)
(remote_target::thread_handle_to_thread_info): Pass down target.
(remote_target::async_wait_fd): New.
* riscv-fbsd-tdep.c: Include "inferior.h".
(riscv_fbsd_get_thread_local_address): Pass down target.
* sol2-tdep.c (sol2_core_pid_to_str): Pass down target.
* sol-thread.c (sol_thread_target::wait, ps_lgetregs, ps_lsetregs)
(ps_lgetfpregs, ps_lsetfpregs, sol_update_thread_list_callback):
Adjust.
* solib-spu.c (spu_skip_standalone_loader): Pass down target.
* solib-svr4.c (enable_break): Pass down target.
* spu-multiarch.c (parse_spufs_run): Pass down target.
* spu-tdep.c (spu2ppu_sniffer): Pass down target.
* target-delegates.c: Regenerate.
* target.c (g_target_stack): Delete.
(current_top_target): Return the current inferior's top target.
(target_has_execution_1): Refer to the passed-in inferior's top
target.
(target_supports_terminal_ours): Check whether the initial
inferior was already created.
(decref_target): New.
(target_stack::push): Incref/decref the target.
(push_target, push_target, unpush_target): Adjust.
(target_stack::unpush): Defref target.
(target_is_pushed): Return bool. Adjust to refer to the current
inferior's target stack.
(dispose_inferior): Delete, and inline parts ...
(target_preopen): ... here. Only dispose of the current inferior.
(target_detach): Hold strong target reference while detaching.
Pass target down.
(target_thread_name): Add assertion.
(target_resume): Pass down target.
(target_ops::beneath, find_target_at): Adjust to refer to the
current inferior's target stack.
(get_dummy_target): New.
(target_pass_ctrlc): Pass the Ctrl-C to the first inferior that
has a thread running.
(initialize_targets): Rename to ...
(_initialize_target): ... this.
* target.h: Include "gdbsupport/refcounted-object.h".
(struct target_ops): Inherit refcounted_object.
(target_ops::shortname, target_ops::longname): Make const.
(target_ops::async_wait_fd): New method.
(decref_target): Declare.
(struct target_ops_ref_policy): New.
(target_ops_ref): New typedef.
(get_dummy_target): Declare function.
(target_is_pushed): Return bool.
* thread-iter.c (all_matching_threads_iterator::m_inf_matches)
(all_matching_threads_iterator::all_matching_threads_iterator):
Handle filter target.
* thread-iter.h (struct all_matching_threads_iterator, struct
all_matching_threads_range, class all_non_exited_threads_range):
Filter by target too. Remove explicit.
* thread.c (threads_executing): Delete.
(inferior_thread): Pass down current inferior.
(clear_thread_inferior_resources): Pass down thread pointer
instead of ptid_t.
(add_thread_silent, add_thread_with_info, add_thread): Add
process_stratum_target parameter. Use it for thread and inferior
searches.
(is_current_thread): New.
(thread_info::deletable): Use it.
(find_thread_ptid, thread_count, in_thread_list)
(thread_change_ptid, set_resumed, set_running): New
process_stratum_target parameter. Pass it down.
(set_executing): New process_stratum_target parameter. Pass it
down. Adjust reference to 'threads_executing'.
(threads_are_executing): New process_stratum_target parameter.
Adjust reference to 'threads_executing'.
(set_stop_requested, finish_thread_state): New
process_stratum_target parameter. Pass it down.
(switch_to_thread): Also match inferior.
(switch_to_thread): New process_stratum_target parameter. Pass it
down.
(update_threads_executing): Reimplement.
* top.c (quit_force): Pop targets from all inferior.
(gdb_init): Don't call initialize_targets.
* windows-nat.c (windows_nat_target) <get_windows_debug_event>:
Declare.
(windows_add_thread, windows_delete_thread): Adjust.
(get_windows_debug_event): Rename to ...
(windows_nat_target::get_windows_debug_event): ... this. Adjust.
* tracefile-tfile.c (tfile_target_open): Pass down target.
* gdbsupport/common-gdbthread.h (struct process_stratum_target):
Forward declare.
(switch_to_thread): Add process_stratum_target parameter.
* mi/mi-interp.c (mi_on_resume_1): Add process_stratum_target
parameter. Use it.
(mi_on_resume): Pass target down.
* nat/fork-inferior.c (startup_inferior): Add
process_stratum_target parameter. Pass it down.
* nat/fork-inferior.h (startup_inferior): Add
process_stratum_target parameter.
* python/py-threadevent.c (py_get_event_thread): Pass target down.
gdb/gdbserver/ChangeLog:
2020-01-10 Pedro Alves <palves@redhat.com>
* fork-child.c (post_fork_inferior): Pass target down to
startup_inferior.
* inferiors.c (switch_to_thread): Add process_stratum_target
parameter.
* lynx-low.c (lynx_target_ops): Now a process_stratum_target.
* nto-low.c (nto_target_ops): Now a process_stratum_target.
* linux-low.c (linux_target_ops): Now a process_stratum_target.
* remote-utils.c (prepare_resume_reply): Pass the target to
switch_to_thread.
* target.c (the_target): Now a process_stratum_target.
(done_accessing_memory): Pass the target to switch_to_thread.
(set_target_ops): Ajust to use process_stratum_target.
* target.h (struct target_ops): Rename to ...
(struct process_stratum_target): ... this.
(the_target, set_target_ops): Adjust.
(prepare_to_access_memory): Adjust comment.
* win32-low.c (child_xfer_memory): Adjust to use
process_stratum_target.
(win32_target_ops): Now a process_stratum_target.
|
|
gdb/ChangeLog:
2020-01-10 Pedro Alves <palves@redhat.com>
* infrun.c (handle_no_resumed): Use all_non_exited_inferiors.
|
|
- Make get_last_target_status arguments optional. A following patch
will add another argument to get_last_target_status (the event's
target), and passing nullptr when we don't care for some piece of
info is handier than creating dummy local variables.
- Declare nullify_last_target_wait_ptid in a header, and remove the
local extern declaration from linux-fork.c.
gdb/ChangeLog:
2020-01-10 Pedro Alves <palves@redhat.com>
* break-catch-sig.c (signal_catchpoint_print_it): Don't pass a
ptid to get_last_target_status.
* break-catch-syscall.c (print_it_catch_syscall): Don't pass a
ptid to get_last_target_status.
* infcmd.c (continue_command): Don't pass a target_waitstatus to
get_last_target_status.
(info_program_command): Don't pass a target_waitstatus to
get_last_target_status.
* infrun.c (init_wait_for_inferior): Use
nullify_last_target_wait_ptid.
(get_last_target_status): Handle nullptr arguments.
(nullify_last_target_wait_ptid): Clear target_last_waitstatus.
(print_stop_event): Don't pass a ptid to get_last_target_status.
(normal_stop): Don't pass a ptid to get_last_target_status.
* infrun.h (get_last_target_status, set_last_target_status): Move
comments here and update.
(nullify_last_target_wait_ptid): Declare.
* linux-fork.c (fork_load_infrun_state): Remove local extern
declaration of nullify_last_target_wait_ptid.
* linux-nat.c (get_detach_signal): Don't pass a target_waitstatus
to get_last_target_status.
|
|
Once each inferior has its own target stack, we'll need to make sure
that the right inferior is selected before we call into target
methods.
It kind of sounds worse than it is in practice. Not that many places
need to be concerned.
In thread.c, we add a new switch_to_thread_if_alive function that
centralizes the switching before calls to target_thread_alive. Other
cases are handled with explicit switching.
gdb/ChangeLog:
2020-01-10 Pedro Alves <palves@redhat.com>
* gdbthread.h (scoped_restore_current_thread)
<dont_restore, restore, m_dont_restore>: Declare.
* thread.c (thread_alive): Add assertion. Return bool.
(switch_to_thread_if_alive): New.
(prune_threads): Switch inferior/thread.
(print_thread_info_1): Switch thread before calling target methods.
(scoped_restore_current_thread::restore): New, factored out from
...
(scoped_restore_current_thread::~scoped_restore_current_thread):
... this.
(scoped_restore_current_thread::scoped_restore_current_thread):
Add assertion.
(thread_apply_all_command, thread_select): Use
switch_to_thread_if_alive.
* infrun.c (proceed, restart_threads, handle_signal_stop)
(switch_back_to_stepped_thread): Switch current thread before
calling target methods.
|
|
In non-stop mode, if you resume the program in the background (with
"continue&", for example), then gdb makes sure to not switch the
current thread behind your back. That means that you can be sure that
the commands you type apply to the thread you selected, even if some
other thread that was running in the background hits some event just
while you're typing.
In all-stop mode, however, if you resume the program in the
background, gdb let's the current thread switch behind your back.
This is bogus, of course. All-stop and non-stop background
resumptions should behave the same.
This patch fixes that, and adds a testcase that exposes the bad
behavior in current master.
The fork-running-state.exp changes are necessary because that
preexisting testcase was expecting the old behavior:
Before:
continue &
Continuing.
(gdb)
[Attaching after process 8199 fork to child process 8203]
[New inferior 2 (process 8203)]
info threads
Id Target Id Frame
1.1 process 8199 "fork-running-st" (running)
* 2.1 process 8203 "fork-running-st" (running)
(gdb)
After:
continue &
Continuing.
(gdb)
[Attaching after process 24660 fork to child process 24664]
[New inferior 2 (process 24664)]
info threads
Id Target Id Frame
* 1.1 process 24660 "fork-running-st" (running)
2.1 process 24664 "fork-running-st" (running)
(gdb)
Here we see that before this patch GDB switches current inferior to
the new inferior behind the user's back, as a side effect of handling
the fork.
The delete_exited_threads call in inferior_appeared is there to fix an
issue that Baris found in a previous version of this patch. The
fetch_inferior_event change increases the refcount of the current
thread, and in case the fetched inferior event denotes a thread exit,
the thread will not be deleted right away. A non-deleted but exited
thread stays in the inferior's thread list. This, in turn, causes the
"init_thread_list" call in inferior.c to be skipped. A consequence is
that the global thread ID counter is not restarted if the current
thread exits, and then the inferior is restarted:
(gdb) start
Temporary breakpoint 1 at 0x4004d6: file main.c, line 21.
Starting program: /tmp/main
Temporary breakpoint 1, main () at main.c:21
21 foo ();
(gdb) info threads -gid
Id GId Target Id Frame
* 1 1 process 16106 "main" main () at main.c:21
(gdb) c
Continuing.
[Inferior 1 (process 16106) exited normally]
(gdb) start
Temporary breakpoint 2 at 0x4004d6: file main.c, line 21.
Starting program: /tmp/main
Temporary breakpoint 2, main () at main.c:21
21 foo ();
(gdb) info threads -gid
Id GId Target Id Frame
* 1 2 process 16138 "main" main () at main.c:21
^^^
Notice that GId == 2 above. It should have been "1" instead.
The new tids-git-reset.exp testcase exercises the problem above.
gdb/ChangeLog:
2020-01-10 Pedro Alves <palves@redhat.com>
* gdbthread.h (scoped_restore_current_thread)
<dont_restore, restore, m_dont_restore>: Declare.
* thread.c (thread_alive): Add assertion. Return bool.
(switch_to_thread_if_alive): New.
(prune_threads): Switch inferior/thread.
(print_thread_info_1): Switch thread before calling target methods.
(scoped_restore_current_thread::restore): New, factored out from
...
(scoped_restore_current_thread::~scoped_restore_current_thread):
... this.
(scoped_restore_current_thread::scoped_restore_current_thread):
Add assertion.
(thread_apply_all_command, thread_select): Use
switch_to_thread_if_alive.
gdb/testsuite/ChangeLog:
2020-01-10 Pedro Alves <palves@redhat.com>
* gdb.base/fork-running-state.exp (do_test): Adjust expected
output.
* gdb.threads/async.c: New.
* gdb.threads/async.exp: New.
* gdb.multi/tids-gid-reset.c: New.
* gdb.multi/tids-gid-reset.exp: New.
|
|
gdb/ChangeLog:
Update copyright year range in all GDB files.
|
|
This makes the skip command work in optimized builds, where skipped
functions may be inlined. Previously that was only working when
stepping into a non-inlined function.
|
|
While debugging something, i noticed this odd FIXME comment. It seems stale
and therefore here's a patch removing it.
gdb/ChangeLog:
2019-12-02 Luis Machado <luis.machado@linaro.org>
* infrun.c (follow_fork_inferior): Remove outdated FIXME comment.
Change-Id: I2436ca4ae4a6741012cafe8123325f738b692c9c
|
|
Similar to the MSYMBOL version of this patch, improves readability
and will eventually allow making name private.
gdb/ChangeLog:
2019-11-22 Christian Biesinger <cbiesinger@google.com>
* ada-exp.y: Update.
* ada-lang.c (sort_choices): Update.
(ada_print_symbol_signature): Update.
(resolve_subexp): Update.
(ada_parse_renaming): Update.
(ada_read_renaming_var_value): Update.
(lesseq_defined_than): Update.
(remove_extra_symbols): Update.
(remove_irrelevant_renamings): Update.
(ada_add_block_symbols): Update.
(ada_collect_symbol_completion_matches): Update.
(ada_is_renaming_symbol): Update.
(aggregate_assign_from_choices): Update.
(ada_evaluate_subexp): Update.
(ada_has_this_exception_support): Update.
(ada_is_non_standard_exception_sym): Update.
(ada_add_exceptions_from_frame): Update.
(ada_add_global_exceptions): Update.
(ada_print_subexp): Update.
* ax-gdb.c (gen_var_ref): Update.
(gen_maybe_namespace_elt): Update.
(gen_expr_for_cast): Update.
(gen_expr): Update.
* block.h: Update.
* blockframe.c (find_pc_partial_function): Update.
* breakpoint.c (print_breakpoint_location): Update.
(update_static_tracepoint): Update.
* btrace.c (ftrace_print_function_name): Update.
(ftrace_function_switched): Update.
* buildsym.c (find_symbol_in_list): Update.
* c-exp.y: Update.
* c-typeprint.c (c_print_typedef): Update.
(c_type_print_template_args): Update.
* cli/cli-cmds.c (edit_command): Update.
(list_command): Update.
(print_sal_location): Update.
* coffread.c (patch_opaque_types): Update.
(process_coff_symbol): Update.
(coff_read_enum_type): Update.
* compile/compile-c-symbols.c (c_symbol_substitution_name): Update.
(convert_one_symbol): Update.
(hash_symname): Update.
(eq_symname): Update.
* compile/compile-cplus-symbols.c (convert_one_symbol): Update.
* compile/compile-cplus-types.c (debug_print_scope): Update.
* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update.
* compile/compile-object-load.c (get_out_value_type): Update.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
(search_symbol_list): Update.
(cp_lookup_symbol_imports_or_template): Update.
* cp-support.c (overload_list_add_symbol): Update.
* ctfread.c (psymtab_to_symtab): Update.
* dbxread.c (cp_set_block_scope): Update.
* dictionary.c (iter_match_first_hashed): Update.
(iter_match_next_hashed): Update.
(insert_symbol_hashed): Update.
(iter_match_next_linear): Update.
* dictionary.h: Update.
* dwarf2loc.c (func_get_frame_base_dwarf_block): Update.
(locexpr_describe_location_piece): Update.
(locexpr_describe_location_1): Update.
(locexpr_generate_c_location): Update.
(loclist_describe_location): Update.
(loclist_generate_c_location): Update.
* dwarf2read.c (dw2_debug_names_lookup_symbol): Update.
(read_func_scope): Update.
(process_enumeration_scope): Update.
(new_symbol): Update.
(dwarf2_const_value): Update.
(dwarf2_symbol_mark_computed): Update.
* eval.c (evaluate_funcall): Update.
(evaluate_subexp_standard): Update.
* expprint.c (print_subexp_standard): Update.
(dump_subexp_body_standard): Update.
* f-valprint.c (info_common_command_for_block): Update.
* findvar.c (get_hosting_frame): Update.
(default_read_var_value): Update.
* go-lang.c (go_symbol_package_name): Update.
* guile/scm-block.c (bkscm_print_block_smob): Update.
* guile/scm-symbol.c (syscm_print_symbol_smob): Update.
(gdbscm_symbol_name): Update.
(gdbscm_symbol_linkage_name): Update.
(gdbscm_symbol_print_name): Update.
* infcall.c (get_function_name): Update.
* infcmd.c (jump_command): Update.
(finish_command): Update.
* infrun.c (insert_exception_resume_breakpoint): Update.
* linespec.c (canonicalize_linespec): Update.
(create_sals_line_offset): Update.
(convert_linespec_to_sals): Update.
(complete_label): Update.
(find_label_symbols_in_block): Update.
* m2-typeprint.c (m2_print_typedef): Update.
* mdebugread.c (mdebug_reg_to_regnum): Update.
(parse_symbol): Update.
(mylookup_symbol): Update.
* mi/mi-cmd-stack.c (list_arg_or_local): Update.
(list_args_or_locals): Update.
* objc-lang.c (compare_selectors): Update.
(info_selectors_command): Update.
(compare_classes): Update.
(info_classes_command): Update.
(find_imps): Update.
* p-typeprint.c (pascal_print_typedef): Update.
* printcmd.c (build_address_symbolic): Update.
(info_address_command): Update.
(print_variable_and_value): Update.
* python/py-framefilter.c (extract_sym): Update.
(py_print_single_arg): Update.
* python/py-symbol.c (sympy_str): Update.
(sympy_get_name): Update.
(sympy_get_linkage_name): Update.
* python/python.c (gdbpy_rbreak): Update.
* record-btrace.c (btrace_get_bfun_name): Update.
(btrace_call_history): Update.
* rust-lang.c (rust_print_typedef): Update.
* solib-frv.c (frv_fdpic_find_canonical_descriptor): Update.
* stabsread.c (stab_reg_to_regnum): Update.
(define_symbol): Update.
(read_enum_type): Update.
(common_block_end): Update.
(cleanup_undefined_types_1): Update.
(scan_file_globals): Update.
* stack.c (print_frame_arg): Update.
(print_frame_args): Update.
(find_frame_funname): Update.
(info_frame_command_core): Update.
(iterate_over_block_locals): Update.
(print_block_frame_labels): Update.
(do_print_variable_and_value): Update.
(iterate_over_block_arg_vars): Update.
(return_command): Update.
* symmisc.c (dump_symtab_1): Update.
(print_symbol): Update.
* symtab.c (eq_symbol_entry): Update.
(symbol_cache_dump): Update.
(lookup_language_this): Update.
(find_pc_sect_line): Update.
(skip_prologue_sal): Update.
(symbol_search::compare_search_syms): Update.
(treg_matches_sym_type_name): Update.
(search_symbols): Update.
(print_symbol_info): Update.
(rbreak_command): Update.
(completion_list_add_symbol): Update.
(find_gnu_ifunc): Update.
(get_symbol_address): Update.
(search_module_symbols): Update.
(info_module_subcommand): Update.
* symtab.h (SYMBOL_NATURAL_NAME): Remove.
(SYMBOL_LINKAGE_NAME): Remove.
(SYMBOL_DEMANGLED_NAME): Remove.
(SYMBOL_PRINT_NAME): Remove.
(SYMBOL_SEARCH_NAME): Remove.
* tracepoint.c (set_traceframe_context): Update.
(validate_actionline): Update.
(collection_list::collect_symbol): Update.
(encode_actions_1): Update.
(info_scope_command): Update.
(print_one_static_tracepoint_marker): Update.
* typeprint.c (typedef_hash_table::add_template_parameters): Update.
* valops.c (address_of_variable): Update.
(find_overload_match): Update.
(find_oload_champ): Update.
Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
|
|
include-what-you-use reported this:
../../../src/binutils-gdb/gdb/infcmd.c should remove these lines:
- #include <signal.h> // lines 22-22
- #include "cli/cli-decode.h" // lines 48-48
- #include "cli/cli-utils.h" // lines 56-56
- #include "event-top.h" // lines 38-38
- #include "infcall.h" // lines 57-57
- #include "parser-defs.h" // lines 39-39
../../../src/binutils-gdb/gdb/infrun.c should remove these lines:
- #include <signal.h> // lines 37-37
- #include "cli/cli-script.h" // lines 31-31
- #include "continuations.h" // lines 54-54
- #include "dictionary.h" // lines 45-45
- #include "gdbsupport/gdb_wait.h" // lines 28-28
- #include "interps.h" // lines 55-55
Remove those includes.
Tested by rebuilding, and by quick inspection that the include fields
were indeed unnecessary.
gdb/ChangeLog:
* infcmd.c: Remove includes.
* infrun.c: Remove includes.
Change-Id: I5e25af54ecd2235960c4127add8f604ddbb19153
|