gdb: add asserts in thread code
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 22 Feb 2021 16:42:03 +0000 (11:42 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 22 Feb 2021 16:42:03 +0000 (11:42 -0500)
commitf53fc42716c042e560a824244fecab215ba036d1
tree6875fa0ee4046623dc13690a01d1a2895ce340d8
parentde146e1946ee45f2552c6b56714793a2eba9b823
gdb: add asserts in thread code

Unlike the previous patch, I don't propose that we take this patch into
gdb-10-branch.

This patch adds two asserts, prompted by investigating and fixing the
bug fixed by the previous patch.

The assert in find_thread_ptid would have caught the original issue
before the segfault (I think it's slightly more use friendly).

The assert in add_thread_silent would have made it clear that the
solution proposed in [1] isn't the right one.  The solution ended up
passing nullptr as a target to add_thread.  We don't want that, because
add_thread_silent uses it to look up the inferior to which to add the
thread.  If the target is nullptr, we could find an inferior with the
same pid, but belonging to an unrelated target.  So we always want a
non-nullptr target in add_thread_silent.

gdb/ChangeLog:

* thread.c (add_thread_silent): Add assert.
(find_thread_ptid): Add assert.

[1] https://sourceware.org/pipermail/gdb-patches/2021-February/176202.html

Change-Id: Ie593ee45c5eb02235e8e9fbcda612d48ce883852
gdb/ChangeLog
gdb/thread.c
This page took 0.024194 seconds and 4 git commands to generate.