From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MUzZGDWHqWlhjxYAWB0awg (envelope-from ) for ; Thu, 05 Mar 2026 08:37:57 -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=FbjPVidL; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 616D71E089; Thu, 05 Mar 2026 08:37:57 -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 C4FA21E089 for ; Thu, 05 Mar 2026 08:37:56 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 55E4B4BA23F5 for ; Thu, 5 Mar 2026 13:37:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55E4B4BA23F5 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=FbjPVidL Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 0F7944BA2E0F for ; Thu, 5 Mar 2026 13:37:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F7944BA2E0F 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 0F7944BA2E0F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772717849; cv=none; b=g20/kcP0G6YvhGQXIg6jalToOzLOTAS1QZLGsRd7OHBoIcR+FYTdE0Izg7F74J0nzVWOnvYMzJrJwkyXK7LCD5jsKawngrBspRRI3uPiY3GtvJiLSQweSEBkfKJUrWPjy6lCh8TL1Ja6Mu+uURXJM2WmxtHjhbUzvUkrjMIsW/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772717849; c=relaxed/simple; bh=GyMvJKw9IzLG6ljAjz8Pp2oqdArEgOT85FeFvoINvFw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fSy8tk2/jAu/gdoQxrtumwjOJb9cbx/rbV2v4ZzY85LTQeJ2xZ6xMUOVug8ko54DxOt/ZrwwiNy4FWyqGaiqkXoOmFRwVnfcp250LWXSWPNvd3r9UVl+5mi7fSwHOU6aTGI+6jh85P4sJilGwAw59OniQpE3pHvyw1zuQKGOWAU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F7944BA2E0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772717848; 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=S9c205gbKQQtZbulpgjK8o+cEQ/jxBBcwRh4wLBv+9k=; b=FbjPVidLtDM6hBaTFNO1T7macg9t2FLHJZDlDleXqQF9p82bcAnBfDN05J6OhhQMw54lIc nitjW3/1Dno/LvvxM/xQmAlfYNA2GvgEt5OFSUfBSymd0rqbfFVupqlil00u+/VbWKd/Jt IPCoZxI8sir/wqNS/fO0J7o7UqOoTsE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-369-rq7bJLwyPQKSV_IZjSoF2Q-1; Thu, 05 Mar 2026 08:37:27 -0500 X-MC-Unique: rq7bJLwyPQKSV_IZjSoF2Q-1 X-Mimecast-MFC-AGG-ID: rq7bJLwyPQKSV_IZjSoF2Q_1772717846 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-439c794ec8eso2205577f8f.1 for ; Thu, 05 Mar 2026 05:37:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772717846; x=1773322646; 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=S9c205gbKQQtZbulpgjK8o+cEQ/jxBBcwRh4wLBv+9k=; b=AFuHu2NV10ulw5XJWxEEBFSo0tIWmq2HTDy414b3VntsSaOb+st9iBu+qSHP5ekWtQ Yb53J45TnPjfVqb0WYVBUB/w/bGW04vmDZ8pEfBO1UWVfSFF1upgA4arYC6+Wxq78uNr H8kaJHx0Ierx0fpmoci+gtOFA17/R7HDunvSXy8FTnJVy2ARI7V+MjOnTKCSulbufeEm Cz96/WNJ4eg4GG1HsfSbpv6/CC2fzq5AtyJJDblzgBmlGbj7oC0wziC5uwYfr/iIB3ty 6apzcOnYE/kvz+PdXHHdCQ6QL1UYKNQwJFaX3u7Bz3sp9/4imvFYGZnHoZyZ8ifN85WR L5GA== X-Gm-Message-State: AOJu0YxB5vMmQQ+TfLX0TebRIsp+d/i5FR2A5TRC6lLym1nDnFuQBOxJ iwnp4JsTb0cg30z03azckOZBoRI109eRMOodmawGWioYHyy9mEjYlU4w7QXNeRLWICXytKr4xmG CKL0OUY1eZ1HaHQHB4nJauDrqWfGC2m0ge0R+8TsVVNFuKvMmt2kEAOSN1c12mctoiGbxcBy3mr JkbUXQhwdvJDtwRMZsGr3APgu7ocR5h8UIlPkzU0+hZJGohMY= X-Gm-Gg: ATEYQzyKVHq8340exHX5iHWr421xbM+1a9NHws5fgBPMQN5BqbDbFXSoQek+189zJWn IUMhP6Rrfsgp8HFgXJjUiuLSV8sWFeMeZDdWlTcppTQwQ38c2RFGbmwbGEFbErYAdldd0X7c79F 2nqQQIfV6ZB4e9wt/oV07ooBN7+NieH38tJ0pTUjzJiHAlOflffOFLkLAc5J5+/ArQiZ78ailwH 3qnAaRmYhgPCpZdRaC8I+QeeXYja5EvLRLbM/al9hG3RJ4z5tJ8oIWJprg3zaSESodivQro9kl2 bGj3kGPbj+FjoePX0zSCUKni2yjxkcARAC2VgENBL7uhQkKVX50miwKeAi9iVD41o3PTc/H2rBP YFaX4Xol3VvyVZrar X-Received: by 2002:a5d:5d07:0:b0:439:b046:2044 with SMTP id ffacd0b85a97d-439c7f6a303mr11030884f8f.12.1772717845832; Thu, 05 Mar 2026 05:37:25 -0800 (PST) X-Received: by 2002:a5d:5d07:0:b0:439:b046:2044 with SMTP id ffacd0b85a97d-439c7f6a303mr11030831f8f.12.1772717845239; Thu, 05 Mar 2026 05:37:25 -0800 (PST) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439af926c53sm44167054f8f.8.2026.03.05.05.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 05:37:24 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 2/4] gdb/python: fix FinishBreakpoint.return_value for tail call functions Date: Thu, 5 Mar 2026 13:37:16 +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: aI4tJqQyPtU9-fIWKatK1c21_Bt48HdYIj5qaKJbpT0_1772717846 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 3370bb02580..4af8ec6c75f 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