<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:12.0pt;
font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#467886;
text-decoration:underline;}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-IN" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Respected Ulrich and community members,<br>
<br>
Hi,<br>
<br>
</span><span style="font-size:11.0pt;color:#212121">>+ if (get_signaled_thread (pid) == tid<br>
>+ && in_thread_list (proc_target, ptid_t (pid)))<br>
>Didn't you want to change this?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121">In enthusiasm I missed it. Sorry for the same. Please check now.
<br>
<br>
>+ auto itr = in_queue_threads.find (priv->pdtid);<br>
>+ if (itr == in_queue_threads.end ()<br>
>Why don't you use .count like elsewhere?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121">This also is done.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121">Kindly let me know if v5 is okay.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121">Pasting results of v5 patch.
</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Gdb.threads/thread_events.exp test case result after this patch<br>
<br>
=== gdb Summary ===</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> gmake check RUNTESTFLAGS='gdb.threads/thread_events.exp CC_FOR_TARGET="/opt/freeware/bin/gcc" CXX_FOR_TARGET="/opt/freeware/bin/g++" CXXFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64" CFLAGS_FOR_TARGET="-O0 -w -g
-gdwarf -maix64"'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121">gmake check-single</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"># of expected passes 11</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121">/current_gdb/binutils-gdb/gdb/gdb version 15.0.50.20240325-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /current_gdb/binutils-gdb/gdb/data-directory</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Output of program 1(Program 1 Pasted below this email)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Reading symbols from testsuite/gdb.threads/thread_events...</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) b main</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Breakpoint 1 at 0x100007dc: file gdb.threads/thread_events.c, line 41.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) r</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Starting program: /current_gdb/binutils-gdb/gdb/testsuite/gdb.threads/thread_events<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Breakpoint 1, main (argc=1, argv=0x2ff22940) at gdb.threads/thread_events.c:41</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">41 if (pthread_create (&thread, NULL, threadfunc, NULL) != 0)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) b threadfunc<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Breakpoint 2 at 0x10000718: file gdb.threads/thread_events.c, line 27.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) b after_join_func<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Breakpoint 3 at 0x10000778: file gdb.threads/thread_events.c, line 34.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) c</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Continuing.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[New Thread 258 (tid 24969631)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Switching to Thread 258 (tid 24969631)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Thread 2 hit Breakpoint 2, threadfunc (arg=0x0) at gdb.threads/thread_events.c:27</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">27 printf ("in threadfunc\n");</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb)<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Continuing.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">in threadfunc</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Thread 258 (tid 24969631) exited]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Switching to Thread 1 (tid 34341137)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Thread 1 hit Breakpoint 3, after_join_func () at gdb.threads/thread_events.c:34</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">34 printf ("finished\n");</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) info threads</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> Id Target Id Frame<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">* 1 Thread 1 (tid 34341137) ([running]) after_join_func () at gdb.threads/thread_events.c:34</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) c</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Continuing.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">finished</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Thread 1 (tid 34341137) exited]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Inferior 1 (process 11338122) exited normally]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) q</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Program 1:</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">/* This file was written by Chris Demetriou (<a href="mailto:cgd@google.com" title="mailto:cgd@google.com"><span style="color:#0078D7">cgd@google.com</span></a>). */</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">/* Simple test to trigger thread events (thread start, thread exit). */</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#include <pthread.h></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#include <stdlib.h></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#include <stdio.h></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">static void *</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">threadfunc (void *arg)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">{</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> printf ("in threadfunc\n");</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> return NULL;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">}</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">static void</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">after_join_func (void)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">{</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> printf ("finished\n");</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">}</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">int main (int argc, char *argv[])</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">{</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> pthread_t thread;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> if (pthread_create (&thread, NULL, threadfunc, NULL) != 0)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> {</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> printf ("pthread_create failed\n");</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> exit (1);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> }</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> if (pthread_join (thread, NULL) != 0)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> {</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> printf ("pthread_join failed\n");</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> exit (1);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> }</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> after_join_func ();</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> return 0;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">}</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Output of program 2 [Program 2 pasted below]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Reading symbols from<span class="apple-converted-space"> </span>//gdb_tests/continue-pending-status_exit_test...</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) r <span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Starting program: /gdb_tests/continue-pending-status_exit_test<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Hello World<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Hello World<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">More threads<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Hello World<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Hello World<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Hello World<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Hello World<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[New Thread 258 (tid 24969633)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Thread 258 (tid 24969633) exited]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[New Thread 515 (tid 30540067)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Thread 515 (tid 30540067) exited]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[New Thread 772 (tid 30671107)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Thread 772 (tid 30671107) exited]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[New Thread 1029 (tid 31588767)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Thread 1029 (tid 31588767) exited]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[New Thread 1286 (tid 30998947)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Thread 1286 (tid 30998947) exited]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[New Thread 1543 (tid 28967413)]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">[Thread 1543 (tid 28967413) exited]</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Thread 1 received signal SIGINT, Interrupt.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) info threads</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> Id Target Id Frame<span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">* 1 Thread 1 (tid 34341139) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">(gdb) q</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">A debugging session is active.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> Inferior 1 [process 11338126] will be killed.</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Quit anyway? (y or n) y</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">Program 2:</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#include <stdio.h></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#include <unistd.h></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#include <stdlib.h></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#include <pthread.h></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#include <assert.h></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">pthread_barrier_t barrier;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">#define NUM_THREADS 3 <span class="apple-converted-space"> </span></span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">void *</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">thread_function (void *arg)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">{</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> /* This ensures that the breakpoint is only hit after both threads</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> are created, so the test can always switch to the non-event</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> thread when the breakpoint triggers. */</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">// pthread_barrier_wait (&barrier);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> printf ("Hello World \n"); /* break here */</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">}</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">int</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">main (void)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">{</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> int i;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> alarm (300);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> pthread_barrier_init (&barrier, NULL, NUM_THREADS);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> for (i = 0; i < NUM_THREADS; i++)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> {</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> pthread_t thread;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> int res;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> res = pthread_create (&thread, NULL,</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> thread_function, NULL);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> assert (res == 0);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> }</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> printf ("More threads \n");</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> for (i = 0; i < NUM_THREADS; i++)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> {</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> pthread_t thread;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> int res;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> res = pthread_create (&thread, NULL,</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> thread_function, NULL);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> assert (res == 0);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> }</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> while (1)</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> sleep (1);</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> </span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121"> return 0;</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="caret-color: rgb(33, 33, 33);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:11.0pt;color:#212121">}</span><span style="color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">Aditya Vidyadhar Kamath <akamath996@gmail.com><br>
<b>Date: </b>Friday, 3 May 2024 at 8:41</span><span style="font-family:"Arial",sans-serif;color:black"> </span><span style="color:black">PM<br>
<b>To: </b>tom@tromey.com <tom@tromey.com><br>
<b>Cc: </b>Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>, jhb@freebsd.org <jhb@freebsd.org><br>
<b>Subject: </b>[EXTERNAL] [PATCH v5] Fix AIX thread exit events not being reported and UI to show kernel thread ID.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com><br>
<br>
In AIX when a thread exits we were not showing that a thread exit event happened<br>
and GDB continued to keep the terminated threads.<br>
<br>
If we have terminated threads then the UI on info threads command will look like<br>
(gdb) info threads<br>
Id Target Id Frame<br>
* 1 Thread 1 (tid 26607979, running) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)<br>
2 Thread 258 (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)<br>
<br>
If we see the frame is not getting displayed correctly.<br>
<br>
The reason for the same is that in AIX we were not managing thread states. In particular we do not know<br>
when a thread terminates.<br>
<br>
The reason being in sync_threadlists () the pbuf and gbuf lists remain the same though certain threads exit.<br>
<br>
This patch is a fix to the same.<br>
<br>
Also certain UI is changed.<br>
<br>
On a new thread born and exit the UI in AIX will be similar to Linux with both user and kernel thread information.<br>
<br>
[New Thread 258 (tid 32178533)]<br>
[New Thread 515 (tid 30343651)]<br>
[New Thread 772 (tid 33554909)]<br>
[New Thread 1029 (tid 24969489)]<br>
[New Thread 1286 (tid 18153945)]<br>
[New Thread 1543 (tid 30736739)]<br>
[Thread 258 (tid 32178533) exited]<br>
[Thread 515 (tid 30343651) exited]<br>
[Thread 772 (tid 33554909) exited]<br>
[Thread 1029 (tid 24969489) exited]<br>
[Thread 1286 (tid 18153945) exited]<br>
[Thread 1543 (tid 30736739) exited]<br>
<br>
and info threads will look like<br>
(gdb) info threads<br>
Id Target Id Frame<br>
* 1 Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)<br>
<br>
Also a small change to testcase gdb.threads/thread_events.exp to make sure this test runs on AIX as well.<br>
---<br>
gdb/aix-thread.c | 242 ++++++--------------<br>
gdb/testsuite/gdb.threads/thread_events.exp | 6 +-<br>
2 files changed, 78 insertions(+), 170 deletions(-)<br>
<br>
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c<br>
index c70bd82bc24..a699a539598 100644<br>
--- a/gdb/aix-thread.c<br>
+++ b/gdb/aix-thread.c<br>
@@ -55,6 +55,7 @@<br>
#include <sys/reg.h><br>
#include <sched.h><br>
#include <sys/pthdebug.h><br>
+#include <unordered_set><br>
<br>
#if !HAVE_DECL_GETTHRDS<br>
extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);<br>
@@ -190,6 +191,9 @@ struct aix_thread_variables<br>
/* Whether the current architecture is 64-bit.<br>
Only valid when pd_able is true. */<br>
int arch64;<br>
+<br>
+ /* Describes the number of thread exit events reported. */<br>
+ std::unordered_set<pthdb_pthread_t> exited_threads;<br>
};<br>
<br>
/* Key to our per-inferior data. */<br>
@@ -737,47 +741,6 @@ state2str (pthdb_state_t state)<br>
}<br>
}<br>
<br>
-/* qsort() comparison function for sorting pd_thread structs by pthid. */<br>
-<br>
-static int<br>
-pcmp (const void *p1v, const void *p2v)<br>
-{<br>
- struct pd_thread *p1 = (struct pd_thread *) p1v;<br>
- struct pd_thread *p2 = (struct pd_thread *) p2v;<br>
- return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;<br>
-}<br>
-<br>
-/* ptid comparison function */<br>
-<br>
-static int<br>
-ptid_cmp (ptid_t ptid1, ptid_t ptid2)<br>
-{<br>
- if (ptid1.pid () < ptid2.pid ())<br>
- return -1;<br>
- else if (ptid1.pid () > ptid2.pid ())<br>
- return 1;<br>
- else if (ptid1.tid () < ptid2.tid ())<br>
- return -1;<br>
- else if (ptid1.tid () > ptid2.tid ())<br>
- return 1;<br>
- else if (ptid1.lwp () < ptid2.lwp ())<br>
- return -1;<br>
- else if (ptid1.lwp () > ptid2.lwp ())<br>
- return 1;<br>
- else<br>
- return 0;<br>
-}<br>
-<br>
-/* qsort() comparison function for sorting thread_info structs by pid. */<br>
-<br>
-static int<br>
-gcmp (const void *t1v, const void *t2v)<br>
-{<br>
- struct thread_info *t1 = *(struct thread_info **) t1v;<br>
- struct thread_info *t2 = *(struct thread_info **) t2v;<br>
- return ptid_cmp (t1->ptid, t2->ptid);<br>
-}<br>
-<br>
/* Search through the list of all kernel threads for the thread<br>
that has stopped on a SIGTRAP signal, and return its TID.<br>
Return 0 if none found. */<br>
@@ -822,22 +785,17 @@ static void<br>
sync_threadlists (pid_t pid)<br>
{<br>
int cmd, status;<br>
- int pcount, psize, pi, gcount, gi;<br>
- struct pd_thread *pbuf;<br>
- struct thread_info **gbuf, **g, *thread;<br>
pthdb_pthread_t pdtid;<br>
pthread_t pthid;<br>
pthdb_tid_t tid;<br>
process_stratum_target *proc_target = current_inferior ()->process_target ();<br>
struct aix_thread_variables *data;<br>
data = get_thread_data_helper_for_pid (pid);<br>
+ pthdb_state_t state;<br>
+ std::set<pthdb_pthread_t> in_queue_threads;<br>
<br>
/* Accumulate an array of libpthdebug threads sorted by pthread id. */<br>
<br>
- pcount = 0;<br>
- psize = 1;<br>
- pbuf = XNEWVEC (struct pd_thread, psize);<br>
-<br>
for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)<br>
{<br>
status = pthdb_pthread (data->pd_session, &pdtid, cmd);<br>
@@ -848,118 +806,66 @@ sync_threadlists (pid_t pid)<br>
if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)<br>
continue;<br>
<br>
- if (pcount == psize)<br>
- {<br>
- psize *= 2;<br>
- pbuf = (struct pd_thread *) xrealloc (pbuf, <br>
- psize * sizeof *pbuf);<br>
- }<br>
- pbuf[pcount].pdtid = pdtid;<br>
- pbuf[pcount].pthid = pthid;<br>
- pcount++;<br>
- }<br>
-<br>
- for (pi = 0; pi < pcount; pi++)<br>
- {<br>
- status = pthdb_pthread_tid (data->pd_session, pbuf[pi].pdtid, &tid);<br>
- if (status != PTHDB_SUCCESS)<br>
- tid = PTHDB_INVALID_TID;<br>
- pbuf[pi].tid = tid;<br>
- }<br>
-<br>
- qsort (pbuf, pcount, sizeof *pbuf, pcmp);<br>
-<br>
- /* Accumulate an array of GDB threads sorted by pid. */<br>
-<br>
- /* gcount is GDB thread count and pcount is pthreadlib thread count. */<br>
-<br>
- gcount = 0;<br>
- for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))<br>
- gcount++;<br>
- g = gbuf = XNEWVEC (struct thread_info *, gcount);<br>
- for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))<br>
- *g++ = tp;<br>
- qsort (gbuf, gcount, sizeof *gbuf, gcmp);<br>
+ ptid_t ptid (pid, 0, pthid);<br>
+ status = pthdb_pthread_state (data->pd_session, pdtid, &state);<br>
+ in_queue_threads.insert (pdtid);<br>
<br>
- /* Apply differences between the two arrays to GDB's thread list. */<br>
-<br>
- for (pi = gi = 0; pi < pcount || gi < gcount;)<br>
- {<br>
- if (pi == pcount)<br>
+ /* If this thread has reported and exited, do not add it again. */<br>
+ if (state == PST_TERM)<br>
{<br>
- delete_thread (gbuf[gi]);<br>
- gi++;<br>
+ if (data->exited_threads.count (pdtid) != 0)<br>
+ continue;<br>
}<br>
- else if (gi == gcount)<br>
- {<br>
- aix_thread_info *priv = new aix_thread_info;<br>
- priv->pdtid = pbuf[pi].pdtid;<br>
- priv->tid = pbuf[pi].tid;<br>
<br>
- thread = add_thread_with_info (proc_target,<br>
- ptid_t (pid, 0, pbuf[pi].pthid),<br>
- private_thread_info_up (priv));<br>
-<br>
- pi++;<br>
- }<br>
- else<br>
+ /* If this thread has never been reported to GDB, add it. */<br>
+ if (!in_thread_list (proc_target, ptid))<br>
{<br>
- ptid_t pptid, gptid;<br>
- int cmp_result;<br>
-<br>
- pptid = ptid_t (pid, 0, pbuf[pi].pthid);<br>
- gptid = gbuf[gi]->ptid;<br>
- pdtid = pbuf[pi].pdtid;<br>
- tid = pbuf[pi].tid;<br>
-<br>
- cmp_result = ptid_cmp (pptid, gptid);<br>
-<br>
- if (cmp_result == 0)<br>
- {<br>
- aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);<br>
-<br>
- priv->pdtid = pdtid;<br>
- priv->tid = tid;<br>
- pi++;<br>
- gi++;<br>
- }<br>
- else if (cmp_result > 0)<br>
+ aix_thread_info *priv = new aix_thread_info;<br>
+ /* init priv */<br>
+ priv->pdtid = pdtid;<br>
+ status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);<br>
+ priv->tid = tid;<br>
+ /* Check if this is the main thread. If it is, then change<br>
+ its ptid and add its private data. */<br>
+ if (in_thread_list (proc_target, ptid_t (pid)))<br>
{<br>
- /* This is to make the main process thread now look<br>
- like a thread. */<br>
-<br>
- if (gptid.is_pid ())<br>
- {<br>
- thread_info *tp = proc_target->find_thread (gptid);<br>
- thread_change_ptid (proc_target, gptid, pptid);<br>
- aix_thread_info *priv = new aix_thread_info;<br>
- priv->pdtid = pbuf[pi].pdtid;<br>
- priv->tid = pbuf[pi].tid;<br>
- tp->priv.reset (priv);<br>
- gi++;<br>
- pi++;<br>
- }<br>
- else<br>
- {<br>
- delete_thread (gbuf[gi]);<br>
- gi++;<br>
- }<br>
+ thread_info *tp = proc_target->find_thread (ptid_t (pid));<br>
+ thread_change_ptid (proc_target, ptid_t (pid), ptid);<br>
+ tp->priv.reset (priv);<br>
}<br>
else<br>
- {<br>
- thread = add_thread (proc_target, pptid);<br>
+ add_thread_with_info (proc_target, ptid,<br>
+ private_thread_info_up (priv));<br>
+ }<br>
<br>
- aix_thread_info *priv = new aix_thread_info;<br>
- thread->priv.reset (priv);<br>
- priv->pdtid = pdtid;<br>
- priv->tid = tid;<br>
- pi++;<br>
- }<br>
+ /* The thread is terminated. Remove it. */<br>
+ if (state == PST_TERM)<br>
+ {<br>
+ thread_info *thr = proc_target->find_thread (ptid);<br>
+ gdb_assert (thr != nullptr);<br>
+ delete_thread (thr);<br>
+ data->exited_threads.insert (pdtid);<br>
}<br>
}<br>
<br>
- xfree (pbuf);<br>
- xfree (gbuf);<br>
+ /* Sometimes there can be scenarios where the thread status is<br>
+ unknown and we it will never iterate in the for loop above,<br>
+ since cmd will be no longer be pointing to that threads. One<br>
+ such scenario is the gdb.threads/thread_events.exp testcase<br>
+ where in the end after the threadfunc breakpoint is hit, the<br>
+ thread exits and gets into a PST_UNKNOWN state. So this thread<br>
+ will not run in the above for loop. Therefore the below for loop<br>
+ is to manually delete such threads. */<br>
+ for (struct thread_info *it : all_threads ())<br>
+ {<br>
+ aix_thread_info *priv = get_aix_thread_info (it);<br>
+ if (in_queue_threads.count (priv->pdtid) == 0<br>
+ && in_thread_list (proc_target, it->ptid))<br>
+ {<br>
+ delete_thread (it);<br>
+ data->exited_threads.insert (priv->pdtid);<br>
+ }<br>
+ }<br>
}<br>
<br>
/* Iterate_over_threads() callback for locating a thread, using<br>
@@ -1013,8 +919,8 @@ pd_update (pid_t pid)<br>
}<br>
<br>
/* Try to start debugging threads in the current process.<br>
- If successful and there exists and we can find an event thread, return a ptid<br>
- for that thread. Otherwise, return a ptid-only ptid using PID. */<br>
+ If successful and there exists and we can find an event thread, set<br>
+ pd_active for that thread. Otherwise, return. */<br>
<br>
static void<br>
pd_activate (pid_t pid)<br>
@@ -2084,10 +1990,17 @@ aix_thread_target::thread_alive (ptid_t ptid)<br>
std::string<br>
aix_thread_target::pid_to_str (ptid_t ptid)<br>
{<br>
- if (ptid.tid () == 0)<br>
- return beneath ()->pid_to_str (ptid);<br>
+ thread_info *thread_info = current_inferior ()->find_thread (ptid);<br>
<br>
- return string_printf (_("Thread %s"), pulongest (ptid.tid ()));<br>
+ if (thread_info != NULL && thread_info->priv != NULL)<br>
+ {<br>
+ aix_thread_info *priv = get_aix_thread_info (thread_info);<br>
+<br>
+ return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),<br>
+ pulongest (priv->tid));<br>
+ }<br>
+<br>
+ return beneath ()->pid_to_str (ptid);<br>
}<br>
<br>
/* Return a printable representation of extra information about<br>
@@ -2098,7 +2011,6 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)<br>
{<br>
int status;<br>
pthdb_pthread_t pdtid;<br>
- pthdb_tid_t tid;<br>
pthdb_state_t state;<br>
pthdb_suspendstate_t suspendstate;<br>
pthdb_detachstate_t detachstate;<br>
@@ -2115,33 +2027,31 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)<br>
aix_thread_info *priv = get_aix_thread_info (thread);<br>
<br>
pdtid = priv->pdtid;<br>
- tid = priv->tid;<br>
-<br>
- if (tid != PTHDB_INVALID_TID)<br>
- /* i18n: Like "thread-identifier %d, [state] running, suspended" */<br>
- buf.printf (_("tid %d"), (int)tid);<br>
<br>
status = pthdb_pthread_state (data->pd_session, pdtid, &state);<br>
+<br>
+ /* Output should look like Thread %d (tid %d) ([state]). */<br>
+ /* Example:- Thread 1 (tid 34144587) ([running]). */<br>
+ /* where state can be running, idle, sleeping, finished,<br>
+ suspended, detached, cancel pending, ready or unknown. */<br>
+<br>
if (status != PTHDB_SUCCESS)<br>
state = PST_NOTSUP;<br>
- buf.printf (", %s", state2str (state));<br>
+ buf.printf ("[%s]", state2str (state));<br>
<br>
status = pthdb_pthread_suspendstate (data->pd_session, pdtid,<br>
&suspendstate);<br>
if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)<br>
- /* i18n: Like "Thread-Id %d, [state] running, suspended" */<br>
- buf.printf (_(", suspended"));<br>
+ buf.printf (_("[suspended]"));<br>
<br>
status = pthdb_pthread_detachstate (data->pd_session, pdtid,<br>
&detachstate);<br>
if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)<br>
- /* i18n: Like "Thread-Id %d, [state] running, detached" */<br>
- buf.printf (_(", detached"));<br>
+ buf.printf (_("[detached]"));<br>
<br>
pthdb_pthread_cancelpend (data->pd_session, pdtid, &cancelpend);<br>
if (status == PTHDB_SUCCESS && cancelpend)<br>
- /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */<br>
- buf.printf (_(", cancel pending"));<br>
+ buf.printf (_("[cancel pending]"));<br>
<br>
buf.write ("", 1);<br>
<br>
diff --git a/gdb/testsuite/gdb.threads/thread_events.exp b/gdb/testsuite/gdb.threads/thread_events.exp<br>
index 100205e5f58..ca51abeb545 100644<br>
--- a/gdb/testsuite/gdb.threads/thread_events.exp<br>
+++ b/gdb/testsuite/gdb.threads/thread_events.exp<br>
@@ -21,11 +21,9 @@<br>
# messages are printed and can be disabled) is dependent on the target<br>
# thread support code.<br>
<br>
-# This test has only been verified with Linux targets, and would need<br>
+# This test has been verified with Linux targets and AIX target, and would need<br>
# to be generalized to support other targets<br>
-if {![istarget *-*-linux*]} {<br>
- return<br>
-}<br>
+require {is_any_target "*-*-linux*" "*-*-aix*"}<br>
<br>
# When using the RSP, we don't get notifications about new threads.<br>
# This is expected, so don't test for that.<br>
-- <br>
2.41.0<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>