From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id HwX3KlFZQmYd1RAAWB0awg (envelope-from ) for ; Mon, 13 May 2024 14:17:53 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=lfktHcGk; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9D71F1E0C1; Mon, 13 May 2024 14:17:53 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8CFAA1E030 for ; Mon, 13 May 2024 14:17:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D0DA438708B9 for ; Mon, 13 May 2024 18:17:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0DA438708B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1715624270; bh=fPfFqFEBhPUu+8mAyNsbs7i/Rkt82cmnxk6zowCY+xw=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=lfktHcGkOyU5/bUbATpvNeFTy2IXLGt9rtRs6T5Azl65QRNb7Y1FxgSDKu7S72pMS +TMGTNcZ4YvrLVcPNvsrD1racvAohC+a+lXb1ma4p5WJKxOaLlGwViQzdr3kY9DcbR CcVu0mApXzLXW8LppEP8zG/l6th9IllK2JSvf7Lw= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 378533858432 for ; Mon, 13 May 2024 18:17:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 378533858432 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 378533858432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715624234; cv=none; b=l3245Ia240u+aJUJznz37hyL3JscgcGW/wE87/O0nZzdRFL1nYNbCL/9Yu+UbR8aMGHXvryIDOAw6k1SBSCwyIwOazFiUEFD1FcBabOeKG0Ss7YSYYFh27blCgutcRDEpO8Wee66JGGlL6EWndIeJi2GtGkeHH/xYkFU2dSyMbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715624234; c=relaxed/simple; bh=CJt03SZMoBPLmUKPRRnqwEQwp60lCK7A9qZeCtJNn9c=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=lf8NeZCTEMa920tJAF1u/CmF8/yr/Us3oq3bgFrZnvZwQYL3fCcQZ3Wa2BXO5nM0+1EMxTHoUjs2HCMfCAY+uP5ldh56xWtM8sMCTpGWYIJ7a3hUXTHGNRI3Ha1nrvQcw6KD7RK1SFgjA/azzOQQK2uRIG3vFSrj8UEBkSI2OAs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-LiBo7gWiNOqL36k4wnOgTw-1; Mon, 13 May 2024 14:17:10 -0400 X-MC-Unique: LiBo7gWiNOqL36k4wnOgTw-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-61be1fcf9abso70677787b3.1 for ; Mon, 13 May 2024 11:17:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715624230; x=1716229030; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fPfFqFEBhPUu+8mAyNsbs7i/Rkt82cmnxk6zowCY+xw=; b=tqqRUymomZpW2bOfU+h2dZBgrtanmj5+IT7BcpTb1y9VjaGEPCytGjfsGhRRUQnmr2 ASnjtbIMK1JTe479nlnTajUmYDMdpgSuKS5s5b9JR+wSDyZjeHnAOOim6N1AGfFpb75Y Z04xZRkLXUexZXXDnXyWWZvGFtFOPl7Thk2w6ZZ0YSdRkT9MDI0Sg9xLDomqNg0M1rIt wu8rz/RtHcigQ41zvcyNJ+IRTGe9po7CfqJV9wEkwBa6cwkDH+VCKPUlEsWEuuq9j9T9 8VaMpuXKGL1fkQzreSR9sY/mPUh8tLb91ANquZnWZwzARLRbRlSwDw8sMts5w+Id+mn1 fFHA== X-Forwarded-Encrypted: i=1; AJvYcCVXKvT6HeHGJGpfm6Q4MWLYx4tjhFy7nBJP+mi3+g5sJZ063b+60+cjHN9ol01h4cROxEBWEplxh96uinx3tGXBokU= X-Gm-Message-State: AOJu0YxRH9c0VH0EdCPMqzZxDXDqnDeu9D1Xi/7b7/NJtzA9wbPNx3Ks hlrt1hnP88EK84o3hav6TAFmcOGk3vilcFUWMACKXnByVZ9hyhGRR52M6LzSvMY0CJ5NrPbKs1v aUpPUzQ8CUMj9Rb54tGhgSm8WdVuDQogEls7ZiIrEkMtR8Xb4 X-Received: by 2002:a0d:d94f:0:b0:61a:e48c:38b7 with SMTP id 00721157ae682-622b0147a99mr104407357b3.41.1715624229735; Mon, 13 May 2024 11:17:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGa0jqCHaSATEapCdXy73K6vAAKuAWAD7F3c9p7yaJOqCbIErRacrkeJtwgW6iapP2qufy6A== X-Received: by 2002:a0d:d94f:0:b0:61a:e48c:38b7 with SMTP id 00721157ae682-622b0147a99mr104407077b3.41.1715624229293; Mon, 13 May 2024 11:17:09 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:92c5::1000? ([2804:14d:8084:92c5::1000]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43e09f7862asm33371611cf.91.2024.05.13.11.17.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 May 2024 11:17:08 -0700 (PDT) Message-ID: <56759b21-f854-4cd8-84ce-3fd11246e84a@redhat.com> Date: Mon, 13 May 2024 15:17:05 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Error record and replay target doesn't support syscall number 435 To: Navin P , gdb@sourceware.org References: <1eba5c31-adc1-4b2b-a2a6-8f6a086d1a82@redhat.com> In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Guinevere Larsen via Gdb Reply-To: Guinevere Larsen Errors-To: gdb-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb" Re-adding gdb list, since you mentioned you dropped on accident On 5/13/24 12:13, Navin P wrote: > On Mon, May 13, 2024 at 6:40 PM Guinevere Larsen wrote: >> On 5/13/24 08:06, Navin P wrote: >>> Hi, >> Hi! :) >>> On Fri, May 10, 2024 at 7:29 PM Guinevere Larsen wrote: >>>> On 5/10/24 05:07, Navin P via Gdb wrote: >>>>> Hi, >>>>> I tried to record a program calling C++ threads and then did a >>>>> break on main , then record and continue it throws the error message >>>>> "record and replay target doesn't support syscall number 435" . What >>>>> should I do to support syscall number 435 ? >>>> Hi! >>>> >>>> I can't answer everything, since I'm not too familiar with syscalls >>>> specifically, but I'll do my best! >>>> >>>> My first road bump with this is that we record that a clone has >>>> happened, but we can only record the process that GDB is following >>>> (parent or child, depending on follow-fork-mode). This is >>>> counter-intuitive to me, since I would have expected the full inferior >>>> to be replayed. >>> To get this working you need minimum changes of current_inferior to >>> for each inferior in all_inferiors() and execute that function for >>> each inferior. >>> return values have to be captured in a list. Similarly for each return value >>> you have to perform the actions in a loop. >> There is an extra complication, the recording subsystem was added before >> GDB could handle multiple inferiors, so it works on the assumption that >> you only need one global history. Meaning if we did record for all >> inferiors or all processes, the history would be mangled, jumping from >> one inferior to the next. It is already a problem in handling >> multi-threaded inferiors, so a proper fix would require having a >> per-thread history, and possibly some way to serialize the execution. >> >> I added the explanation more as a motivator to why I think we should >> warn the user of the counter-intuitive behavior, at least in the >> documentation. >> >>> It is going to definitely slow down execution by orders of magnitude. >> Absolutely! I'm almost wondering if we should try to spawn a recording >> thread per process or thread, to at least make multi-threaded recording >> not worse. But that is far in the future, unrelated to this change > static void > record_full_core_open_1 () > { > regcache *regcache = get_thread_regcache (inferior_thread ()) > > In record-full.c we have inferior_thread() which is the current thread, > so only 1 thread is recorded ? That is my observation too. I am not sure if only thread 1 is recorded, or if it is mixing instructions from all threads, but only changing register values for one of the threads. You can disassemble thread 1, then reverse-stepi to see if the PC changes wildly or if phantom instructions show up. > If so, what is required to fix it for all threads. I haven't fully accounted for everything that is required to make record work for multi-threaded inferiors. What I know we strictly need to either double-check or improve is:     * If you check gdb/record-full.c:197, you'll see how we store the full history. Its a single global variable for everything that is recorded. This needs to be turned into a thread specific member.     * I think the way GDB handles step means multiple threads will all be handled by a single record target, in a single thread. This needs to be verified, and if I'm right, we need to find a way to serialize the threads, so that we can replay thread in the correct order.     * There's an open bug for gdb not properly handling (at least) sigtrap when an inferior is added: https://sourceware.org/bugzilla/show_bug.cgi?id=30025. We need to fix that if multiple processes are handled like multiple inferiors as you mentioned. Properly handling multi-threaded has been in my backlog for a bit, but I have one task for record that's much more important - adding support to AVX instructions - and I have limited time for record stuff, unfortunately. > Here there is only > one process > with multiple threads. I expect it to catch the segfault in thread 2 > but it fails > and goes into an infinite loop. Instead of a global variable, try using a counter on the while loops, and set it to a small value like 3-4. The current slowdown for execution is unbelievable (was also a backlogged thing for me). Also, I don't know if your system doesn't use a libc++ that's very optimized, but I can't record the creation of std::thread objects. That's because std::thread::_M_start_thread uses memset somewhere, and my glibc has the optimized avx512 version of memset, an instruction gdb can't disassemble yet. So we can add "supporting newer x86_64 instructions" to the list of tasks to do if we want to _properly_ support multi-threading. And if you want to double check what I mentioned above, I'd also recommend not printing, because that's also libc++, so likely to be using optimized instructions. -- Cheers, Guinevere Larsen She/Her/Hers > > #include > #include > #include > using namespace std; > bool run=true; > int i=6; > int *p=&i,g; > > void t1() { > while(run){ > g++; > if(g>=16) > p=nullptr; > cout <<"t1 "< } > } > > void t2(){ > int t=0; > while(run){ > g++; > t=*p + 5; > cout <<"t2 "< } > } > > > int main(){ > thread x1{t1},x2{t2}; > sleep(5); > run=false; > x1.join();x2.join(); > } > > > Regards, > Navin >