[2/3] gdb: add some asserts to thread_db_notice_clone
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
This commit adds some asserts to thread_db_notice_clone, and reorders
some code. This is really just a refactor ahead of the next commit.
The changes made here are:
1. Add an assert that STOPPED is not NULL. We pass STOPPED as the
first argument to thread_from_lwp, which already assumes that the
pointer is not NULL. If STOPPED was ever NULL then we would have
hit a segfault in thread_from_lwp long ago.
2. Move the thread_from_lwp call relating to the PARENT thread
before the call relating to the CHILD thread, and assert that the
value we get back is STOPPED. The thread_from_lwp might also
gather thread-db related information about PARENT, so the call is
important, but even if PARENT cannot be managed via thread-db,
the result we get back should always still be STOPPED (see
record_thread for more details). Moving this call before the
call relating to the CHILD thread makes the next commit cleaner.
There should be no user visible changes after this commit as I believe
both of the things being asserted have always been true.
---
gdb/linux-thread-db.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
@@ -440,12 +440,17 @@ thread_db_notice_clone (ptid_t parent, ptid_t child)
return false;
thread_info *stopped = linux_target->find_thread (parent);
-
- thread_from_lwp (stopped, child);
+ gdb_assert (stopped != nullptr);
/* If we do not know about the main thread's pthread info yet, this
- would be a good time to find it. */
- thread_from_lwp (stopped, parent);
+ would be a good time to find it. This should return the same
+ thread_info as STOPPED, but a side effect of this call is that the
+ pthread/thread-db information might have been filled in if it was not
+ already known. */
+ thread_info *parent_info = thread_from_lwp (stopped, parent);
+ gdb_assert (parent_info == stopped);
+
+ thread_from_lwp (stopped, child);
return true;
}