From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1158) id 492133858D1E; Tue, 2 May 2023 15:33:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 492133858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683041581; bh=bnyJ7xf6hgGOO1pjlnhpST1bM2v4qcOSJizJMdbX0+Q=; h=From:To:Subject:Date:From; b=Ok+Y1orN51Td2MqTDlAD3LPmGnRHwSlmJQapQaljdsBdmSV+i+mlRNzYLOoP2rnDe cxxXbVL+/oKEQ5+gr7aY31xSpnuUcDXBv2jVqRfCX28K7v2qPEOe8BjIKLJ285D5KU 9BDDphMP0DOZD4LDy6428rxQ+yeY8dkHZ5MQE8P0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ulrich Weigand To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix Assertion pid != 0 failure in AIX. X-Act-Checkin: binutils-gdb X-Git-Author: Aditya Kamath X-Git-Refname: refs/heads/master X-Git-Oldrev: e29e63040dd09449a21762bcacabdf31d580beee X-Git-Newrev: a047f82b3c5e34072f1ca77af486a77a744ccdd5 Message-Id: <20230502153301.492133858D1E@sourceware.org> Date: Tue, 2 May 2023 15:33:01 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Da047f82b3c5e= 34072f1ca77af486a77a744ccdd5 commit a047f82b3c5e34072f1ca77af486a77a744ccdd5 Author: Aditya Kamath Date: Tue May 2 10:08:14 2023 -0500 Fix Assertion pid !=3D 0 failure in AIX. =20 In AIX if there is a main and a thread created from it , then once the program completed execution and goes to pd_disable () inferior_ptid had pid 0 leading to an assertion failure while finding the thread's da= ta in aix-thread.c file. =20 This patch is a fix for the same. Diff: --- gdb/aix-thread.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index c587027fb6d..fbe80d656c2 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -1049,17 +1049,17 @@ pd_activate (pid_t pid) application is pthreaded, and if so, prepare for thread debugging. */ =20 static void -pd_enable (void) +pd_enable (inferior *inf) { int status; char *stub_name; struct bound_minimal_symbol ms; struct aix_thread_variables *data; =20 - if (!inferior_ptid.pid ()) + if (inf =3D=3D NULL) return; =20 - data =3D get_thread_data_helper_for_ptid (inferior_ptid); + data =3D get_aix_thread_variables_data (inf); =20 /* Don't initialize twice. */ if (data->pd_able) @@ -1070,7 +1070,7 @@ pd_enable (void) =20 /* Check whether the application is pthreaded. */ stub_name =3D NULL; - status =3D pthdb_session_pthreaded (inferior_ptid.pid (), PTHDB_FLAG_REG= S, + status =3D pthdb_session_pthreaded (inf->pid, PTHDB_FLAG_REGS, &pd_callbacks, &stub_name); if ((status !=3D PTHDB_SUCCESS && status !=3D PTHDB_NOT_PTHREADED) || !stub_name) @@ -1088,7 +1088,6 @@ pd_enable (void) current_inferior ()->push_target (&aix_thread_ops); data->pd_able =3D 1; =20 - inferior *inf =3D current_inferior (); /* When attaching / handling fork child, don't try activating thread debugging until we know about all shared libraries. */ if (inf->in_initial_library_scan) @@ -1097,16 +1096,16 @@ pd_enable (void) /* If we're debugging a core file or an attached inferior, the pthread library may already have been initialized, so try to activate thread debugging. */ - pd_activate (inferior_ptid.pid ()); + pd_activate (inf->pid); } =20 /* Undo the effects of pd_enable(). */ =20 static void -pd_disable (void) +pd_disable (inferior *inf) { struct aix_thread_variables *data; - data =3D get_thread_data_helper_for_ptid (inferior_ptid); + data =3D get_aix_thread_variables_data (inf); =20 if (!data->pd_able) return; @@ -1129,7 +1128,7 @@ static void new_objfile (struct objfile *objfile) { if (objfile) - pd_enable (); + pd_enable (current_inferior ()); } =20 /* Attach to process specified by ARGS. */ @@ -1137,7 +1136,7 @@ new_objfile (struct objfile *objfile) static void aix_thread_inferior_created (inferior *inf) { - pd_enable (); + pd_enable (inf); } =20 /* Detach from the process attached to by aix_thread_attach(). */ @@ -1147,7 +1146,7 @@ aix_thread_target::detach (inferior *inf, int from_tt= y) { target_ops *beneath =3D this->beneath (); =20 - pd_disable (); + pd_disable (inf); beneath->detach (inf, from_tty); } =20 @@ -2066,7 +2065,7 @@ aix_thread_target::mourn_inferior () { target_ops *beneath =3D this->beneath (); =20 - pd_disable (); + pd_disable (current_inferior ()); beneath->mourn_inferior (); }