From patchwork Fri Jan 10 17:32:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 856274 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp348079wrc; Fri, 10 Jan 2025 09:38:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUweoPPScezAjR9EXp0uv5aNs1Lr9TUFS1irP2SUnjyxq7lUFfyVQ4OPJSEQtdXMt4KNGNZKQ==@linaro.org X-Google-Smtp-Source: AGHT+IFzK8fkb5NgQ9dh8l67ibtqLnUVkVCtNpEd/E4qV0EvVGWoHg2s6rL1HpZA+xipCNJFu9X8 X-Received: by 2002:a05:6214:e6c:b0:6d8:7a85:59ca with SMTP id 6a1803df08f44-6dfa3ace7a9mr123179686d6.16.1736530726426; Fri, 10 Jan 2025 09:38:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736530726; cv=pass; d=google.com; s=arc-20240605; b=I+pgWPwj/EfSDcw62u1EHWIknljahkWsiaLCg9HA9K04KvDojAPIK0jiDWPlLn4efA hxx0UcIZ5cMQ7H/KG5W1MgbAq4u8YtJO4LZgdYnPe3CRZLH1x0hzkse86rYgmFi5Jc2g ZHIDlSPA6R1lXlO2zacbSr+6HSHBgkCJkf+01KmsnbjzqqCcQjAyNITnFtDwRl1eAqY8 wpK4jhR6cDV7APWEX7MrqLwWNQJ+KdT/ZXhGkB9lHHteb2uYJZhRtdZJcfc87Di+e39I qZaT/oyywaudlt9ztuN0qO/cvX0Kj2BYcvjd5OrvKJyNBi91CEALECc/hJ7IVYs8aGUJ TYmw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=T+DZfh6UMWO06upInnZA1GHnZfvOyU1wGD6Gebhbnho=; fh=kWOBmNXMnl2mYWQahcXIAti2uKu35NtzCoiCz+mThOQ=; b=digYEFHl22AN4JIVVDIp+UkYKbB0oFu8L1Ch/lsIshVFOclExBtNkJdpZfKWO1UX3h xTdujKq08nWTP+ZNPl+9LuO7rHw5Sajw3Zk67gfoJ01S1fkkpjDgornJ6LKsSN+S0jdn hFhdTzdFpfoQVMLGaq9qoqo5dfJcuZVsydBq1E/zVcxD9zB8gxl85cQUzBrGka+MEVdQ LUrmaLDopHs1NrSqd9UvGWahKLSSzcf4o63Iv830Z3qShCMpWLHOuZ2OliyPtSSNOLj6 pEO9F2Z/C93cctGxWIvAxF2GrMn+hUkGLrqOG/vK7mM4WpBlMD9V/EPPtSwJA6qBqT8+ THYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NrWWAQxL; 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 6a1803df08f44-6dfad9cf332si26864136d6.112.2025.01.10.09.38.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 09:38:46 -0800 (PST) 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=NrWWAQxL; 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 05B143858402 for ; Fri, 10 Jan 2025 17:38:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05B143858402 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NrWWAQxL X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by sourceware.org (Postfix) with ESMTPS id 1A9C13858039 for ; Fri, 10 Jan 2025 17:32:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A9C13858039 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 1A9C13858039 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::832 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736530368; cv=none; b=o+rcJwuR0+uKGLmmUMk10aK1zSJiVn+iCFFt3l8VShrLJUl6G7gWqo9BJLWHzPZWGaNo5dSibf5EetGdaMOiGmL1f7NUooimFG6myc95+LQR/gE6HTQiOIjU5RTbefhzjhl5kQc68Nds8fNtes4gpyglWl/kZNrVdaGY+KFD60A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736530368; c=relaxed/simple; bh=kcTNPYeETMXPsl2cbtSpvmOY5Ja2oY3ZOJf3Xd6nyCI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wT5Ci1Q4CH8m8N5ktggDQ/vz0l6xIbxj3Yu8e9B2MS26YKLGRcbhe3qDreRfKFqhUn/lmfSj8szzk1G8mYB+A7SxebwtyXS9YLCw7XIA6bo4deSkdY3LoWr3Ul8XeUuoTiK+ECWyaOOEe+GxXgq3NNo312tZElecvL2ceubkq2g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A9C13858039 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-4678afeb133so29499901cf.0 for ; Fri, 10 Jan 2025 09:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736530367; x=1737135167; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T+DZfh6UMWO06upInnZA1GHnZfvOyU1wGD6Gebhbnho=; b=NrWWAQxLbEDAli0711puhvQTJNn+1ffTXRGVsxl3hFH/VSY/NxD9a0KuQUxCT76GCc wK1XeXXotAGV7QeZG8+Yh2PZ9wfumlaiDJ6hyj7XCtNsPwSc8Z+mOadFUjdG1xs2erNY kOLnGyRyxygtdHYZ6iS47clmtQQID+WhbTk7P2tvIEP1V+c4kpTt3UzSkMwfDk1zkeza TTbJDXK8ppn4m4xJeEpguGNyfeqkz1inHNT5A8yxSe8jpHTLgWZO2I7yOBtLHpRgzB+A 1z/xjqgolhadXPibP2glBXUK/TRnGK3NZy8y4SF8X0rKW4JvK/4QBhB/pI9JZD24/IVt 963A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736530367; x=1737135167; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T+DZfh6UMWO06upInnZA1GHnZfvOyU1wGD6Gebhbnho=; b=fx21P35YyOW62QddjZeusrk3wcTyk/K/uvcBzrCgFZgpLLAco9pDAHkyrc6Rg1E2Lz HcX04DnJVJeddXioE+SIUOGooOqkA5hhnRJyc4E0Uqsz/P9BRDGoZN3NQ0a3cq89ENjz r31JN/LBGUSc4KPmvPt/SIaa0w/GPhuAsJ86UwmXIbzN+KT1os1HjWx8cQsXY25c4ZhM eNmB0C9uCyf5eEp0U+m9Ki2aPDdsqQAYp69i4yTCNJRqO6U36k+bvlAse1/hftBA6c85 3cCQdJxJ+eLg8K4uUEiQ43HFITX/MVW1dlWMRT5bngyvNfU23PZ2RuPa14LlASGj/RW5 ZYNg== X-Gm-Message-State: AOJu0YwK+EuD9uNifntuwvss3weY4WAS77cfEWUf481CWc60ydkho4AM q+bIv2Q7DungZVMprYonJM/yTB/Fey8rRPHSvhgIn7zQ9N3lHSDWwJoxWLAlyogknI0wwFUSSpP N X-Gm-Gg: ASbGncsayenssxcAthAaRhxqOBvsoEp6wv/OwuMDyC5HfcmZhZcuYAjB/Ic/hq0hMiv 9LlTt7WxssMzYdvfWlMFNQAOduSumXvLw+evVXul9K47mgjjMaKRYbTYgAW1/1i7A2sGn/5wMF1 6xHMVmQp51FazV+WNSncfMWqG4xKDZ7Z+4fuRKabJ5p6X1p6U/tSrcm1RqnW36ty4eIbAxSvyl0 Z0CuioPl361KGeq+aBLaKEyr6FrJzvTahLn6JTQA6SK2EBrUrpK+cYV1xJ5vQuDqQ== X-Received: by 2002:a05:622a:1488:b0:467:5cb7:588 with SMTP id d75a77b69052e-46c7b0893bdmr108053311cf.28.1736530367417; Fri, 10 Jan 2025 09:32:47 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:1b99:f53f:5bf8:21c]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-8623154b562sm3048601241.25.2025.01.10.09.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 09:32:46 -0800 (PST) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Tankut Baris Aktemur , Simon Marchi Subject: [pushed 1/2] GDB: remote: Print total bytes received in debug message Date: Fri, 10 Jan 2025 14:32:36 -0300 Message-ID: <20250110173240.3382817-2-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250110173240.3382817-1-thiago.bauermann@linaro.org> References: <20250110173240.3382817-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 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 This is useful information I missed while debugging issues with the g packet reply. Reviewed-By: Tankut Baris Aktemur Approved-By: Simon Marchi --- gdb/remote.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Change from last posted version: - Adopted message wording suggested by Baris. diff --git a/gdb/remote.c b/gdb/remote.c index d9ad6974366a..8cb9050eaeda 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -10539,8 +10539,8 @@ remote_target::getpkt (gdb::char_vector *buf, bool forever, bool *is_notif) if (val > max_chars) remote_debug_printf_nofunc - ("Packet received: %s [%d bytes omitted]", str.c_str (), - val - max_chars); + ("Packet received: %s [%d of %d bytes omitted]", str.c_str (), + val - max_chars, val); else remote_debug_printf_nofunc ("Packet received: %s", str.c_str ()); From patchwork Fri Jan 10 17:32:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 856272 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp345798wrc; Fri, 10 Jan 2025 09:33:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVXs+euRhiVVoDIYnLeKLZfVWMi5bV5K8VdSuYwBDZvTdJs5xeUQ8Ia530mWXDK0zXzX8ROsQ==@linaro.org X-Google-Smtp-Source: AGHT+IE2U60wU9Zru3cbcdJeS6uwqyLQmLuSUqsT8vO5RS7KMNCoY62tBQK5wKJTXTfiDAqFgOPi X-Received: by 2002:a05:6214:20ce:b0:6d8:812e:1fd0 with SMTP id 6a1803df08f44-6df9b1da95amr170729996d6.15.1736530418513; Fri, 10 Jan 2025 09:33:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736530418; cv=pass; d=google.com; s=arc-20240605; b=PiDGVGKuLE6Z6E7f1cZBLM3USm1EUtWkXtxJUem6b0bws+HcrOXV1ybWiJi9VbYO3W kfkkeebx37JQaqUpAT8sK+gfCh//MUgzgy87q7KgjIs8EIaI531LrcCCDrJ6yhS18clT 3rn+IWD34u5RTydAfodgiLxbDXKldLCDhhYXMDC3//zMVzMAuEVqiwckSXEkPD8HyiIa B+2X+CxibMHJFCWS7qQG/IUv91vQ7k/Ymxe3noKTViLUCIGhKEh5P+bJ3miGLWT8Hzyq 8NVKUr244MVh5Q4iD4rywdRbWgTr891AAWzMU+0tVKmKUgsF4yNqvIv+S0eyYV7Mu9cv D/Eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=SIafC1mQr77fxebWEkK5Vk/FoJ9ACCSO+8k2p6fYC2o=; fh=1wVi7R6rz+ts6QmjkM3hjMRJ9GAO4QI/fyggc1hYLLU=; b=WSZOSQxjeHcj7qyrjeSnE2J1YeSJ6SJLxdOINDPOqdgNWP8HNKsHQnjK6w8+JbIzQJ D9buQ3L6sDtnfYEomw6mofg2rbJkEgbrsqjhn3pZes32s45UIAD92mbCk/0hSQDrsP8m u4X1DI1UYTYq/A8XKVJG9/Ui2EquVCjum1SVZ3BwfgSzFqjJqVJEKTTTkL2e60SkQiwC q26VKkMuQtrh4GsM0669GN+SP7ybP+oHM5uVZMCrIXFfCJxHZ99XxbaFAi3wZmJQPhC0 /LQry/H0tW9pE72jy16a6efF0VJxaqVdxAnmRnKxXd9W9Mrnd6fV+2GyA53ubv7Do27U kqKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1XwJVsC; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 6a1803df08f44-6dfadff047csi24477086d6.410.2025.01.10.09.33.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 09:33:38 -0800 (PST) Received-SPF: pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1XwJVsC; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 06F86385828B for ; Fri, 10 Jan 2025 17:33:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06F86385828B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=H1XwJVsC X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com [IPv6:2607:f8b0:4864:20::e2c]) by sourceware.org (Postfix) with ESMTPS id 456A53858023 for ; Fri, 10 Jan 2025 17:32:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 456A53858023 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 456A53858023 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::e2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736530371; cv=none; b=xjf/DJqwA+6ObAYGJZUgnmtMXamLJcVYps7eG6gaoCQrZUsn8LZBfwrSaB4aI/XfqI2SaK26IvLHkrtS5RGEOJpauW+kzlTN3LABu+7Gkc9nw9WRoJ6UR3M6ZsQipMHCEgYKDm8x4g2dIBUU3b1SaLzyWxEy17000a7m/6Tr1EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736530371; c=relaxed/simple; bh=HOPpTorSvgCPLnlSdwb+tnR/Fkjt+yiBCj9R4b9M9XU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IhASSW0bjUI1xdNlb2M9B5OlKgrB1NMqNavY7SNritv9MTxECKZOpsaIMTH+mZBegB/N0v5gMHHWNdCjQcwCyoVBUBF9GuEuBklVMOpY/lxSszYvvJJr8K3o/FRgJ51ehGJhYXpk06Wm/6nJe8WSd82REsZlPaHfz8z1zaXjWIk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 456A53858023 Received: by mail-vs1-xe2c.google.com with SMTP id ada2fe7eead31-4afd56903b7so751042137.1 for ; Fri, 10 Jan 2025 09:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736530370; x=1737135170; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SIafC1mQr77fxebWEkK5Vk/FoJ9ACCSO+8k2p6fYC2o=; b=H1XwJVsCdDlWn0k8RLmKDlsULV/IkZEWoQnSeCCvTzzMWufV1YJE5SV1xA+2+0gCpU wF+WqAiILC2CnYWfmqV/LHC/0nRtD8TASOVF9v7f1eJrzTM/bFiYQCs6z/H8c2X3S1vk zYobe1CI/MCkwXjpjQPCmxb3+UeUcl9/wMnopwMfW61mO4p5IfenTWV+owOQyAv2HUlc Ex6w1YgxhNdn1UAiUCGVj7OD1z0MtaVCmj5QrItVlj9ecamJHtoLJboIQP3UcbWNryQE 3Y+Tg1OYlk9/eWYF7KtCG7OwyOp/2FvP3XIFaYeJPoFcBdbmH5fjzcK2CKwDfXs65qT4 cU8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736530370; x=1737135170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SIafC1mQr77fxebWEkK5Vk/FoJ9ACCSO+8k2p6fYC2o=; b=DYTlND5TFHhQhirbeiKlBee2KZtLIDD6NXPueSrhPNZ+YYnb1etJW6zdgYHCSsch+p pZNPk01RHH+yaWn8i+Ps8kvkb9ZRmQFoY7cbXLfd9AUN7dYFdB9csEvVQFRJ2/2EuYd7 f7/ECNvaoIwXWrhXHl0gB/Kt9UgwD6hwnxla/A2IpU/8XJAz4UAfND/Zoo9X9pI8jg0d 1fv5oPxGl6O3RxlahaYeUp6mRpH+6WL9Fuofmlz6IYhIZoI/GJZQjci1e35ig7WthqIA M8hnFTHw8W3L9Yru7d+nR+IV+IuX5AWE21OcXf7cWKh+t7eiVgGlCcROCcQFZGVWwWUA Hdfw== X-Gm-Message-State: AOJu0YxRMJACNOIQJEECxHHZfhUa/79I3qoF5Lfzq3OhKRiszyoeU7v9 obHRulCw3PxRIki98nDQPY1Fq1LKSjsfxEkdtAhakonoqPZJi8lxb8CHuWvqRN0F5yYKp7ar/D+ 5 X-Gm-Gg: ASbGncupP/Ec/99UBseyb0BskARLKledykjs6hQyQWxsaGuLo8NgH27fc1NgG/HUR1F 3cOUux/xkZ0ILXxBZ9vWDEbDxE3t7AjKePPEw4MwxcisrCvFUIGp8qvB48i6rDCdXzQWfeZksN2 FWctbJ0Odlo8OntD5OSlouOQdp4DIc6Ijup5T5Aspn10ftYxnIwwyiInDjeCfJgJxHNa/+KopU/ xReDOY6h0R+3PO70IlbrIuB0mn2nqhis6HKJMk7dlH0VckOtCeP7PIyRtwptYI1mA== X-Received: by 2002:a05:6102:50a9:b0:4b1:1b24:7241 with SMTP id ada2fe7eead31-4b3d0dd8699mr11724611137.15.1736530370493; Fri, 10 Jan 2025 09:32:50 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:1b99:f53f:5bf8:21c]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f51192sm2711571137.14.2025.01.10.09.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 09:32:49 -0800 (PST) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [pushed 2/2] GDB: trad-frame: Store length of value_bytes in trad_frame_saved_reg Date: Fri, 10 Jan 2025 14:32:37 -0300 Message-ID: <20250110173240.3382817-3-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250110173240.3382817-1-thiago.bauermann@linaro.org> References: <20250110173240.3382817-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 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 The goal is to ensure that it is available in frame_unwind_got_bytes () to make sure that the provided buf isn't larger than the size of the register being provisioned. In the process, regcache's cached_reg_t::data also needed to be converted to a gdb::byte_vector, so that the register contents' size can be tracked. Approved-By: Simon Marchi --- gdb/frame-unwind.c | 18 +++++++++++++++--- gdb/frame-unwind.h | 2 +- gdb/jit.c | 2 +- gdb/python/py-unwind.c | 7 ++++--- gdb/regcache.h | 5 +---- gdb/remote.c | 13 ++++++------- gdb/trad-frame.h | 10 +++++++--- 7 files changed, 35 insertions(+), 22 deletions(-) Change from last posted version: - Removed explicit default constructors from cached_reg_t, as suggested by Simon. - Factored out the register_size calls, saving the result to a reg_size local, as suggested by Simon. diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index 352779fcdcc6..6c6ca46be437 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -313,14 +313,26 @@ frame_unwind_got_constant (const frame_info_ptr &frame, int regnum, } struct value * -frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum, const gdb_byte *buf) +frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum, + gdb::array_view buf) { struct gdbarch *gdbarch = frame_unwind_arch (frame); struct value *reg_val; reg_val = value::zero (register_type (gdbarch, regnum), not_lval); - memcpy (reg_val->contents_raw ().data (), buf, - register_size (gdbarch, regnum)); + gdb::array_view val_contents = reg_val->contents_raw (); + + /* The value's contents buffer is zeroed on allocation so if buf is + smaller, the remaining space will be filled with zero. + + This can happen when unwinding through signal frames. For example, if + an AArch64 program doesn't use SVE, then the Linux kernel will only + save in the signal frame the first 128 bits of the vector registers, + which is their minimum size, even if the vector length says they're + bigger. */ + gdb_assert (buf.size () <= val_contents.size ()); + + memcpy (val_contents.data (), buf.data (), buf.size ()); return reg_val; } diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h index 1799d3625bd1..480c9c81ace8 100644 --- a/gdb/frame-unwind.h +++ b/gdb/frame-unwind.h @@ -226,7 +226,7 @@ value *frame_unwind_got_constant (const frame_info_ptr &frame, int regnum, inside BUF. */ value *frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum, - const gdb_byte *buf); + gdb::array_view buf); /* Return a value which indicates that FRAME's saved version of REGNUM has a known constant (computed) value of ADDR. Convert the diff --git a/gdb/jit.c b/gdb/jit.c index 77d41bf86bad..4b9400ab2f8e 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -1096,7 +1096,7 @@ jit_frame_prev_register (const frame_info_ptr &this_frame, void **cache, int reg return frame_unwind_got_optimized (this_frame, reg); gdbarch = priv->regcache->arch (); - gdb_byte *buf = (gdb_byte *) alloca (register_size (gdbarch, reg)); + gdb::byte_vector buf (register_size (gdbarch, reg)); enum register_status status = priv->regcache->cooked_read (reg, buf); if (status == REG_VALID) diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 68deaf98d81f..c1a01bf7cfe4 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -812,7 +812,7 @@ pyuw_prev_register (const frame_info_ptr &this_frame, void **cache_ptr, for (; reg_info < reg_info_end; ++reg_info) { if (regnum == reg_info->num) - return frame_unwind_got_bytes (this_frame, regnum, reg_info->data.get ()); + return frame_unwind_got_bytes (this_frame, regnum, reg_info->data); } return frame_unwind_got_optimized (this_frame, regnum); @@ -936,8 +936,9 @@ pyuw_sniffer (const struct frame_unwind *self, const frame_info_ptr &this_frame, cached_reg_t *cached = new (&cached_frame->reg[i]) cached_reg_t (); cached->num = reg->number; - cached->data.reset ((gdb_byte *) xmalloc (data_size)); - memcpy (cached->data.get (), value->contents ().data (), data_size); + cached->data.resize (data_size); + gdb::array_view contents = value->contents (); + cached->data.assign (contents.begin (), contents.end ()); } } diff --git a/gdb/regcache.h b/gdb/regcache.h index 347c2b8ce9fb..bbb17c81adb6 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -178,10 +178,7 @@ using register_read_ftype struct cached_reg_t { int num; - gdb::unique_xmalloc_ptr data; - - cached_reg_t () = default; - cached_reg_t (cached_reg_t &&rhs) = default; + gdb::byte_vector data; }; /* Buffer of registers. */ diff --git a/gdb/remote.c b/gdb/remote.c index 8cb9050eaeda..79d91d6251ab 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8224,16 +8224,15 @@ Packet: '%s'\n"), Packet: '%s'\n"), hex_string (pnum), p, buf); + int reg_size = register_size (event->arch, reg->regnum); cached_reg.num = reg->regnum; - cached_reg.data.reset ((gdb_byte *) - xmalloc (register_size (event->arch, - reg->regnum))); + cached_reg.data.resize (reg_size); p = p1 + 1; - fieldsize = hex2bin (p, cached_reg.data.get (), - register_size (event->arch, reg->regnum)); + fieldsize = hex2bin (p, cached_reg.data.data (), + cached_reg.data.size ()); p += 2 * fieldsize; - if (fieldsize < register_size (event->arch, reg->regnum)) + if (fieldsize < reg_size) warning (_("Remote reply is too short: %s"), buf); event->regcache.push_back (std::move (cached_reg)); @@ -8572,7 +8571,7 @@ remote_target::process_stop_reply (stop_reply_up stop_reply, for (cached_reg_t ® : stop_reply->regcache) { - regcache->raw_supply (reg.num, reg.data.get ()); + regcache->raw_supply (reg.num, reg.data); rs->last_seen_expedited_registers.insert (reg.num); } } diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h index 40a3f74d44a4..abbc631b6119 100644 --- a/gdb/trad-frame.h +++ b/gdb/trad-frame.h @@ -122,6 +122,7 @@ struct trad_frame_saved_reg m_kind = trad_frame_saved_reg_kind::VALUE_BYTES; m_reg.value_bytes = data; + m_reg.bytes_len = bytes.size (); } /* Getters */ @@ -144,10 +145,10 @@ struct trad_frame_saved_reg return m_reg.addr; } - const gdb_byte *value_bytes () const + gdb::array_view value_bytes () const { gdb_assert (m_kind == trad_frame_saved_reg_kind::VALUE_BYTES); - return m_reg.value_bytes; + return { m_reg.value_bytes, m_reg.bytes_len }; } /* Convenience functions, return true if the register has been @@ -185,7 +186,10 @@ struct trad_frame_saved_reg LONGEST value; int realreg; LONGEST addr; - const gdb_byte *value_bytes; + struct { + const gdb_byte *value_bytes; + size_t bytes_len; + }; } m_reg; };