diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-08-07 10:59:33 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2020-08-07 10:59:35 -0400 |
commit | b161a60d1fe2a7383c7940815687c6100b97204e (patch) | |
tree | f12e3423a7fe7902cd700b3594e3de8ebe09bf15 /gdb/observable.h | |
parent | d2854d8d5a82946ace7f5b626f19c2b73f86d1f6 (diff) | |
download | gdb-b161a60d1fe2a7383c7940815687c6100b97204e.zip gdb-b161a60d1fe2a7383c7940815687c6100b97204e.tar.gz gdb-b161a60d1fe2a7383c7940815687c6100b97204e.tar.bz2 |
gdb: pass target to thread_ptid_changed observable
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
Diffstat (limited to 'gdb/observable.h')
-rw-r--r-- | gdb/observable.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/observable.h b/gdb/observable.h index 070cf0f..da0a9b1 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -27,6 +27,7 @@ struct so_list; struct objfile; struct thread_info; struct inferior; +struct process_stratum_target; struct trace_state_variable; namespace gdb @@ -165,8 +166,9 @@ extern observable<struct gdbarch */* newarch */> architecture_changed; /* The thread's ptid has changed. The OLD_PTID parameter specifies the old value, and NEW_PTID specifies the new value. */ -extern observable<ptid_t /* old_ptid */, ptid_t /* new_ptid */> - thread_ptid_changed; +extern observable<process_stratum_target * /* target */, + ptid_t /* old_ptid */, ptid_t /* new_ptid */> + thread_ptid_changed; /* The inferior INF has been added to the list of inferiors. At this point, it might not be associated with any process. */ |