[v2,02/12] Avoid crash in ravenscar_thread_target::wait

Message ID 20200805190841.2506771-3-tromey@adacore.com
State New
Headers show
Series
  • Fix Ravenscar regressions
Related show

Commit Message

Tom Tromey Aug. 5, 2020, 7:08 p.m.
An earlier patch caused a Ravenscar regression in
ravenscar_thread_target::wait.  In particular, add_active_thread can
return NULL when the runtime is not initialized.

gdb/ChangeLog
2020-08-05  Tom Tromey  <tromey@adacore.com>

	* ravenscar-thread.c (ravenscar_thread_target::wait): Check
	runtime_initialized.
---
 gdb/ChangeLog          | 5 +++++
 gdb/ravenscar-thread.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.26.2

Patch

diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 7fca51da2a7..47001de42d3 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -354,7 +354,8 @@  ravenscar_thread_target::wait (ptid_t ptid,
      because we might try switching threads (and thus sending packets)
      after the remote has disconnected.  */
   if (status->kind != TARGET_WAITKIND_EXITED
-      && status->kind != TARGET_WAITKIND_SIGNALLED)
+      && status->kind != TARGET_WAITKIND_SIGNALLED
+      && runtime_initialized ())
     {
       m_base_ptid = event_ptid;
       this->update_thread_list ();