From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id zBnFFD+tdGn9wRIAWB0awg (envelope-from ) for ; Sat, 24 Jan 2026 06:30:07 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FZrUTNvw; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 320151E0AD; Sat, 24 Jan 2026 06:30:07 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 353DE1E093 for ; Sat, 24 Jan 2026 06:30:06 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id A05D24BA9006 for ; Sat, 24 Jan 2026 11:30:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A05D24BA9006 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FZrUTNvw Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 844E14BA901B for ; Sat, 24 Jan 2026 11:29:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 844E14BA901B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 844E14BA901B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769254169; cv=none; b=qOUQ71oEVPpB48Uvo/FwlUEkCgNK4mY29lubHWoj601R9itl4wa3baENjpvK65EhuWBw4pZmwXC9UG3l7xm3Wr1zz5rJD9/xb315Z+Dfqpwza5H0z5jwqu0ud8fqjrRtGPu4t3JK7KUotViQc2uZG2fg9fWiEejZBbqeDk0F59U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769254169; c=relaxed/simple; bh=wdC7WmGJpzkWWbLeLg8n52Z9xbdOG1AqC+Wa2GrbZU0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=wAjXY4DKcaQtzf9gtf5mgIALkGTaeZVWUZbIQRYcVxqY5eObhVnMHQirRFDbh1EJlVvk6BBP2+eeEfQVFt2ENofgAocKnyiOa56ZHoP2fHLAeQiw3D8OKAYxfQpeZlx581WM8MwMAQn80UvAcBRVh9tIwuJmqVWid92eF3XU/TQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 844E14BA901B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769254169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kCS5MN0ndnmeDReChn+/PgP80E/d3ad3CoiqmRgQzyQ=; b=FZrUTNvwmScWcPBnXG1la4a4KpsbbMTfgsYFGmQ0WRLw93dioHX3jkcKidf2W6G0yfeHNA molsZ1Lw/Zro3IDlLP+W7BJjwbn64PG9GP87Lp3CaIEvHN+vllAXV6rpzrrYH3kyQIiDeh svcncuHUbawwPT4YvJ8aCT16qpppqO8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-7YBxRPDWPzWHJy-ro5h_ZQ-1; Sat, 24 Jan 2026 06:29:27 -0500 X-MC-Unique: 7YBxRPDWPzWHJy-ro5h_ZQ-1 X-Mimecast-MFC-AGG-ID: 7YBxRPDWPzWHJy-ro5h_ZQ_1769254166 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4801e9e7159so27087515e9.1 for ; Sat, 24 Jan 2026 03:29:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769254166; x=1769858966; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kCS5MN0ndnmeDReChn+/PgP80E/d3ad3CoiqmRgQzyQ=; b=NBRQ0NS2bRDdN1qP5NiE5xWj0oacaOW2Dxz9YvtxrDnZCF3m+DPuezokLeee54KSWZ 2kbGG6AR5BfjpEjWyCgF0YgA9hnD+Vk06U+QrC5fWJNRmC8ci7FInhOcPECa/hPPXStz UV35icPjIDa4yADSeGriQt3t9eBdNPe4Z9ykeW1HG3ZWFXH2F/L+pXJFm1jPZIIMdGQd wFNRis10vDPTDG8Zym0HorL2lEydmyHPglmYfvbZy6hxfHskl0HMW4W6f4V8ui+EhYTV GPPDPIXBK9WFFBAK4WBjiHRPMX8rrGH20AmShZ0VnnioRXGFI1GmN1lNCinAnwWAsPqN ldCQ== X-Gm-Message-State: AOJu0YyB83auKetL1bQvhMRLYijfAtCYRojUO55XducovKXC4dV2UdrY 6N41X0pf37CoEXEzAtP6aE22e8UAhUyuCb6bt0uOpDD9SQcFVUJIwyJ5oQTd07wLNui2rvEUf9A JHrhvmVCbOyVjEPlbQw2Bq++1nuEIIQNLMvZTwl3qXEmOQyBSgDHifPrHPl2J3TZQjrXhhwyLRi k/wMgSxvQ5WEYAi3TScPCbkOdjcZXa0EW5+qDZnlmCHv4WilY= X-Gm-Gg: AZuq6aIifVhdw7VZlxFVrmKDhwcumR/wlTnzFkcY/3jQVhIda7e2/7y3iKmQ86Ik3HG XVPiNOXPd78lZi7UMOD34uF0zKUFxEARrtM3Dp4YeaGXfMJiZX0SQZMWHPmaop2BM6zhNhuVfXU 4QfvUFkEbf756lXNfKG+1GrfGREANXILesPrGLtW+lk246+TYlx/ygNf86eCSs6fLXXOfIRZTZC ccdMLGSEgUsj+mj3whPSEwb+siiAyv5BIJsk+pJRPbwtpj9GpNr2MvP0fPgrDqmh79OC9QKAe1j CiHmSwyZvmAEanHGZvOmU+j839rnLnCGvaL2eNDSwJpWBHcNLbs2jlL00VPX7pFAjkdUYuBybfy 3dDMG8WN6yThYCVZdO1Pze1GDEpIEWpU= X-Received: by 2002:a05:600c:8b09:b0:480:1e9e:f9b with SMTP id 5b1f17b1804b1-4804c960f04mr106571275e9.16.1769254165845; Sat, 24 Jan 2026 03:29:25 -0800 (PST) X-Received: by 2002:a05:600c:8b09:b0:480:1e9e:f9b with SMTP id 5b1f17b1804b1-4804c960f04mr106571015e9.16.1769254165288; Sat, 24 Jan 2026 03:29:25 -0800 (PST) Received: from localhost (92.40.184.43.threembb.co.uk. [92.40.184.43]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4804d85cff5sm116669295e9.7.2026.01.24.03.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jan 2026 03:29:24 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/4] gdb/python: fix FinishBreakpoint.return_value for tail call functions Date: Sat, 24 Jan 2026 11:29:12 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: FTMkp7JEaidFl13hopRZc7VFNHNcZj4NfZuBS7tB1tk_1769254166 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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~public-inbox=simark.ca@sourceware.org The FinishBreakpoint.return_value attribute will not be populated correctly for tail call functions. In bpfinishpy_init (python/py-finishbreakpoint.c) we use the function get_frame_pc_if_available to return an address, and then use this address to lookup a function symbol. The problem is that, for tail call functions, the address returned by get_frame_pc_if_available can be outside the bounds of the function, as a result GDB might find no function symbol at all, or might find the wrong function symbol, if the tail call function is immediately adjacent to the next function. Fix this by using get_frame_address_in_block_if_available instead. For tail call functions this will return an address within the bounds of the function, which means that GDB should find the correct function symbol, and from this the correct return type. I've extended the existing FinishBreakpoint with tail call test case to include printing the return value, this test fails without this patch, but now works. --- gdb/python/py-finishbreakpoint.c | 6 +++--- .../gdb.python/py-finish-breakpoint-tailcall.exp | 8 +++++++- gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.py | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 14e9f18c863..84d2abeb433 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -174,7 +174,6 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) struct frame_id frame_id; PyObject *internal = NULL; int internal_bp = 0; - std::optional pc; if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords, &frame_obj, &internal)) @@ -248,9 +247,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) try { - if ((pc = get_frame_pc_if_available (frame))) + CORE_ADDR pc; + if (get_frame_address_in_block_if_available (frame, &pc)) { - struct symbol *function = find_symbol_for_pc (*pc); + struct symbol *function = find_symbol_for_pc (pc); if (function != nullptr) { struct type *ret_type = diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.exp index e5b5ebc5183..2ae61f389ef 100644 --- a/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.exp +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.exp @@ -66,11 +66,16 @@ proc run_test {} { set saw_stopped_message false set saw_breakpoint_line false set saw_source_line false + set saw_return_value false gdb_test_multiple "continue" "" { -re "^Stopped at MyFinishBreakpoint\r\n" { set saw_stopped_message true exp_continue } + -re "^Return value is 43\r\n" { + set saw_return_value true + exp_continue + } -re "^Breakpoint $::decimal, main \\(\\) at \[^\r\n\]+/$::srcfile:$lineno\r\n" { set saw_breakpoint_line true exp_continue @@ -82,7 +87,8 @@ proc run_test {} { -re "^$::gdb_prompt $" { gdb_assert { $saw_stopped_message \ && $saw_breakpoint_line \ - && $saw_source_line } $gdb_test_name + && $saw_source_line \ + && $saw_return_value } $gdb_test_name } -re "^\[^\r\n\]*\r\n" { exp_continue diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.py b/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.py index bd10109a3dc..e493dfa4017 100644 --- a/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.py +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.py @@ -20,6 +20,7 @@ import gdb class MyFinishBreakpoint(gdb.FinishBreakpoint): def stop(self): print("Stopped at MyFinishBreakpoint") + print("Return value is {}".format(self.return_value)) return True -- 2.25.4