From 3f66685e9e92717af0cafa20480de5548aea7298 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 24 Oct 2020 22:59:29 -0400 Subject: [PATCH] gdb: pass inferior to check_pid_namespace_match Pass the inferior argument available in thread_db_inferior_created, and use it to do most things requiring the inferior. check_pid_namespace_match is not completely decoupled from the current inferior yet, there are hidden references behind target_can_run, for example. But I think this is still a good step forward. gdb/ChangeLog: * linux-thread-db.c (check_pid_namespace_match): Add inferior parameter and use it. (thread_db_inferior_created): Pass inferior argument. Change-Id: Ib768b14fc61dcf115fe13f776691f2c2f36e0679 --- gdb/ChangeLog | 6 ++++++ gdb/linux-thread-db.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0f2a87bf7d7..af9d5abbe69 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-10-24 Simon Marchi + + * linux-thread-db.c (check_pid_namespace_match): Add inferior + parameter and use it. + (thread_db_inferior_created): Pass inferior argument. + 2020-10-24 Simon Marchi * aix-thread.c (aix_thread_inferior_created): Add inferior diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index e759ecc9513..7cbdfa5080d 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -1286,7 +1286,7 @@ thread_db_new_objfile (struct objfile *objfile) } static void -check_pid_namespace_match (void) +check_pid_namespace_match (inferior *inf) { /* Check is only relevant for local targets targets. */ if (target_can_run ()) @@ -1296,7 +1296,7 @@ check_pid_namespace_match (void) child's thread list, we'll mistakenly think it has no threads since the thread PID fields won't match the PID we give to libthread_db. */ - if (!linux_ns_same (inferior_ptid.pid (), LINUX_NS_PID)) + if (!linux_ns_same (inf->pid, LINUX_NS_PID)) { warning (_ ("Target and debugger are in different PID " "namespaces; thread lists and other data are " @@ -1312,7 +1312,7 @@ check_pid_namespace_match (void) static void thread_db_inferior_created (inferior *inf) { - check_pid_namespace_match (); + check_pid_namespace_match (inf); check_for_thread_db (); } -- 2.30.2