From patchwork Sat Aug 31 00:56:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 824403 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c1:0:b0:367:895a:4699 with SMTP id p1csp1034946wrs; Fri, 30 Aug 2024 17:56:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXR1wGcOEs1DgekXgIEP1vVod/sScqRWPEkQj0EmqJiTuaMqBhOSrevxY6mVR1Ka6oNqy1CPA==@linaro.org X-Google-Smtp-Source: AGHT+IGMaCGDprmW0YX8XyhCl/hDTreEWCVXeAOKXoAFQd0HB5aCj6WVXkKXFdOPhF+2Dlv00wDH X-Received: by 2002:a05:620a:31a0:b0:79d:5503:a925 with SMTP id af79cd13be357-7a8f6bd6d69mr116584285a.35.1725065797102; Fri, 30 Aug 2024 17:56:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1725065797; cv=pass; d=google.com; s=arc-20160816; b=fH1VvnONVLs3YS6+qtL1X3QjqJGbJbx0S6zeIUzVqfvdjOx82WztS1vqFGkSI1VKby msF0o+2VVLcLtrnHwTGwef7Nc8NS99YKg9KX2FZxMHzHpos4a9oR68+QNaFxNfBfczXF 9SDwqArK2fnlPKb9Uadvx178yz0cFPq88mI9Uw/l0S/pS3MW4b/sLNFrM2czGjeXRMzp 166d4e2kjVLhtk0I7CGqLCVYGic2cr1SIGKKCGTNSmkWgXPNFr3r4dRleos/ZFdJZroV BI4XECNEEfz3jmU01u5ooGrFYXFxCFoGnoKTdSEt1BofJ92oylSemFPGPKe4vXeb0Wft hvKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=NdgjSt2sIx9RR2r1VuidfGpWR8S9QBhJ4oIFmI6toiI=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=VE73o26hmkxyDZ/rP7WB0OFZzoxP3EkcVTr1PBvZQ/uBwJrwElgC6rd3XT/Sw1ICWY cz04xd/TioJpCBmW2Q2UCX64wWbkbLQhMuKMYg2rgb0wBY8NRQK3VGxcrJw3/qKx68J6 MI+LhHEgf+mOuo/TnnOmS9WGNx6Wys902s7BEdjU3Y7I3HOWvPzUVoP0Csr+Iw3i92vr nLe9Cx4c422OjH7DgVNrLVve/jdNyCgfZ7eG3EfAC+1ocBA4Lv0xT8rjbCe4jk+2Akyo /avod7Mij0eEuV7ruv0GvPLUQp/VNpBhz2qpGGOrhZaxCL0mIPxgyBmAk17TuUsj5erP XA/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ROKzDufX; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id af79cd13be357-7a806d51436si522507485a.370.2024.08.30.17.56.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 17:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ROKzDufX; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B217A3864C15 for ; Sat, 31 Aug 2024 00:56:36 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) by sourceware.org (Postfix) with ESMTPS id 4DE9F384F4BF for ; Sat, 31 Aug 2024 00:56:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DE9F384F4BF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4DE9F384F4BF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725065774; cv=none; b=eiNZTnOvZQlJDRrmIgIlu/yIQ6kGtXJhgFA+yCOeJK3fxMJdecjGKnYusYAkpJhCC7KKr+bP+igGu3IaQ0OfttxefE5Q2kMOFyFTn2qliCzsbaddSnXinBPaf6dQVRhCrPm5i73x5pzEP2RFRhgiy4DEamf5/aN9Ghs7FjL8Osg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725065774; c=relaxed/simple; bh=KO7StLgCLhX+mmwFRQAdrDf3UY5BoN1y3Mg7iQcLPhA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=K2pSWRd24UGQ/ZvdnterVauhzn3Bs88JYo0mBTYBW3wBSmfudyUAePZhp2RDxEfz8zQp/dmRGZsGoxO63QVDbvMsj/WZb9YZnWnPQm4uV/44Ys21JA+jkxOJnEmPO3DBZ1/mXPPFLHpCd5jJo/BUX16fe8I1tK0L6yJyE39vwvY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5d5c7f24372so1471194eaf.0 for ; Fri, 30 Aug 2024 17:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725065770; x=1725670570; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=NdgjSt2sIx9RR2r1VuidfGpWR8S9QBhJ4oIFmI6toiI=; b=ROKzDufX+l2EJn9D7E/mNegOov6irn7otmKOMuCMRgBeYA76aMk62cXxBi+c+xznNB Sb7D/aNNbVSSo7YjJ3cB6z2bskhSKX4kk75gkXhBA4+ownmYjjhDWsY5YMfxuP6ehiXZ 3DYliWUQNSV2hzzwWb56ZZvRAQeqM2QgQ75uLK6anwgcwrPas0aCQ3zVH0fmdQL98kUC 2bec7Y0VCOoor9/gLvapuXx5ge0Hc1u41ojcrMPVBcwxtCNdUVhplrg6cX0iHPu7JKbK UWNQiV/VRkMJ8N0BmkPxQNnBXCBpiR0/QwJWIXP6k/uQGa21ZrfSKLM/Sa3vgNisfS6k zIEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725065770; x=1725670570; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NdgjSt2sIx9RR2r1VuidfGpWR8S9QBhJ4oIFmI6toiI=; b=JKfVhla0QsBwV0jQs82dDxLOt+xTDJKalvHKqVOR5USR41OreDm4U75x9XNF9IFTy9 86NZSBJ1uplaXhSku0YnW8WDGlW2vQmL8MOKnHZRT5UDu1mW7HPZPyZ1sLgcmbv+/NdP Hm2xX5xhair6csk3rN9OodvCQEhu+zJaaWlsTufxw0jx2SSbJOs38zaWPCT/Qo2G8EId kttNTKWb+1FjiLQT0Vz/rJhjYf6xbrWgxH0W8YYn7h4TcUt2NiFch+vhynddDzvuQRDO 5m5ZStXLGKhBVGnWg47wLuTInZIofOcdLSAfNGtZusJhXfxYHcc3rpYkyV2GtQDrWYPs R2gQ== X-Gm-Message-State: AOJu0YxzI7oFT+41dO05Ee3fkxSk2CDrt9OaMCP2Z+410Lzm2A2q4XWP 1fLVnvtHO+tKWDpleqncvlhlFeZU5njHa7ssSA16c6dRG7/BzpMpdAG0uIIOcWrGcLV4P011qdT W X-Received: by 2002:a05:6871:2b10:b0:261:360:746c with SMTP id 586e51a60fabf-277901159fcmr8533335fac.19.1725065770517; Fri, 30 Aug 2024 17:56:10 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:1244:2c60:42b9:1830]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e569ecc8sm3433390b3a.140.2024.08.30.17.56.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 17:56:09 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [PATCH 1/2] gdbserver: aarch64: Fix expedited registers list Date: Fri, 30 Aug 2024 21:56:06 -0300 Message-ID: <20240831005607.2478217-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patch=linaro.org@sourceware.org Since this commit: commit a8651ef51822f91ec86d0d5caffbf2e50b174c23 CommitDate: Fri Jun 14 14:47:38 2024 +0100 gdb/aarch64: prevent crash from in process agent gdbserver isn't sending expedited registers with its stop reply packets anymore. The problem is with how the constructor of the expedited_registers std::vector is called: The intent of the expedited_registers initialization in aarch64_linux_read_description is to create a vector with capacity for 6 elements, but that's not how the std::vector constructor works. Instead it creates a vector pre-populated with 6 elements initialized with the default value for the type of the elements, and thus the first 6 elements are null pointers. The actual expedited registers are added starting at the 7th element. This causes init_target_desc to consider that the expedite_regs list is empty, since it stops checking at the first nullptr element. The end result is that gdbserver doesn't send any expedited registers to GDB in its stop replies. Fix by not specifying an element count when declaring the vector. Tested for regressions on aarch64-linux-gnu native-extended-remote. --- gdbserver/linux-aarch64-tdesc.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) base-commit: a253bea8995323201b016fe477280c1782688ab4 diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc index 5d3b6ddffffa..31ec7854cc0b 100644 --- a/gdbserver/linux-aarch64-tdesc.cc +++ b/gdbserver/linux-aarch64-tdesc.cc @@ -52,14 +52,10 @@ aarch64_linux_read_description (const aarch64_features &features) { tdesc = aarch64_create_target_description (features); - /* Configure the expedited registers. By default we include x29, sp - and pc, but we allow for up to 6 pointers as this is (currently) - the most that we push. - - Calling init_target_desc takes a copy of all the strings pointed - to by expedited_registers so this vector only needs to live for - the scope of this function. */ - std::vector expedited_registers (6); + /* Configure the expedited registers. Calling init_target_desc takes + a copy of all the strings pointed to by expedited_registers so this + vector only needs to live for the scope of this function. */ + std::vector expedited_registers; expedited_registers.push_back ("x29"); expedited_registers.push_back ("sp"); expedited_registers.push_back ("pc");