From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UO7GBEPR+mEjXAAAWB0awg (envelope-from ) for ; Wed, 02 Feb 2022 13:45:23 -0500 Received: by simark.ca (Postfix, from userid 112) id 115B61F3BA; Wed, 2 Feb 2022 13:45:23 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 44B401ECEB for ; Wed, 2 Feb 2022 13:45:22 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A9E3F385C405 for ; Wed, 2 Feb 2022 18:45:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9E3F385C405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1643827521; bh=ba0PThw+DGqDL0jNIwYGDwk/HejcMLnZMRg1iItXrno=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bu3n7WPiudWmVuXsXTOcOMpH2tp13S3mWMi7Kux2zcp6ydJhDOHAquChlFLKMvP67 tNxFCb2dkc4f7iH6y+oTTW1serk0YgPQRtTFjEl/AiMA/+L9jDqnDUv/alb8NMNrny 4ViCCnXldxdr/TFn+kiG6jca19DVSx7osUh6rOSY= Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2055.outbound.protection.outlook.com [40.107.223.55]) by sourceware.org (Postfix) with ESMTPS id 5BCD73858014 for ; Wed, 2 Feb 2022 18:44:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5BCD73858014 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mau7JrgZxYaQgEdfDBkv/E/y7Q9Na0+2IugX5a7pxTJa9gV2LauGMIJ/i/I+7a37OWI6JRuG1mLHb2vv8Y/zyQ7RtNZxE9+Vh5oXbuE2e7Oa7LHcZetSHj6ojSkaQBuXos8azj/gtIUGLrm4w3L80yhRMOOIeHe2mdPny9R/03KFXhvvgvEdbAVr0hfZBqlY3xW/buR0RmjA+wDQ6Jmq/QT1QCjmC06d+J3wBIKmkErr5RkwT7bj9lZ0gS7qM/eq08FMdNbqIHyrBbS5pOLGBWHGL3S8KGx+EcDwbsrN2Ao5qJ1TYEVRYNQv+WQOzhiR6ZSHtrVG4302fLawikEOiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ba0PThw+DGqDL0jNIwYGDwk/HejcMLnZMRg1iItXrno=; b=SKTKFueYgzbox09K6+Lil/PP2vqcgRfVriIOUI/ukW6EJtjX9E7l1oiwqmNoPIWL+jeLe592msywSl7E3rHJMgTk7Qx3wyIN9w2SFXhFBTeuBIsH+mRgLaWHtyt1pSZKPuQS6sGnuYbXF97IbEu+3yRh1xToWpquFIhjFamAP6K0f4VUFfg0PJ+4aXf2xTD3jbFjR0825gDmJn2Ls01lmdk02vBpSCpE3vUUKZrM+LB/QFL/V6e8WMH0DUueSUySgCl/0e310JpDFNkN/Za7hjsIcwfWXOOnryTxDiwxPzkATpB2KX0gj9VLOnK91lwlIHdPHiT1Q1SBDGdshKnSwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from MW4PR02CA0015.namprd02.prod.outlook.com (2603:10b6:303:16d::6) by BY5PR12MB4920.namprd12.prod.outlook.com (2603:10b6:a03:1d3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 2 Feb 2022 18:44:31 +0000 Received: from CO1NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::e5) by MW4PR02CA0015.outlook.office365.com (2603:10b6:303:16d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 2 Feb 2022 18:44:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT034.mail.protection.outlook.com (10.13.174.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 2 Feb 2022 18:44:31 +0000 Received: from node-bp126-r03c.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 2 Feb 2022 12:44:27 -0600 To: Subject: [PATCH v3 1/2] gdb: add a symbol* argument to get_return_value Date: Wed, 2 Feb 2022 12:41:14 -0600 Message-ID: <20220202184115.83396-2-lancelot.six@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220202184115.83396-1-lancelot.six@amd.com> References: <20220202184115.83396-1-lancelot.six@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68736393-3c92-4665-d940-08d9e67c0cb9 X-MS-TrafficTypeDiagnostic: BY5PR12MB4920:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fZM0GFordh7A72A4Pu0GhqY/DL8qEidOQgVaU/HVBEw5KTOwK1hElYLuP9/wR3s+nCe3Vf4ujWxcji2JZ0ip9BiufhSHrNR3jQ92M0Vg47XeY8gSgufJ4UfLHUuR1AlqerowRkZq5i0eYWvVKCvH/sI/80UJ+1J/4LTRxD1vsgMXjA8KwRub7V8AhbFpKR/S/elcznZXBp/fuGvCUurcjB+t9qUlJBCr1z5CQ05EzG/SQHhX3pK0hBZs5dKBkGrU2dsxgkh2qepEIN+32HXtFQmhm+Ks/oHfrbP7IOorXn0vfb/yuJSyV3WrZDOLHM/3FmOTX1wKr0smuxV9+i5w/tUd9NWmVEEkCJNiMdC80Z6sVCD25VVAi3Jc8R5POq6wj2H9U1hECvNEEA3phuoeR9Uw7UDkMM2g15izWmLJGn54vUv9OBYO8gpoUVcH7oujAaoNigzlkUMTZemx0kDVF9ODuxsDA3IxQITrSWlxgq+7w5JD/qBULYTN9+OpWuwDxtXp9GLTocf6EaD+gs1eKVsjly9+386I7/TkyDg6dVVrvksmYAjjjY/Q+Fnimn7qNDYZGb9HkVbfUMz6HY0qFupImK2EIJ4lpmEQobMSeWuMSKsMEZEDrHLzn/JxcQxI6cWoHjRbmII60c9t0pngqY/a87JXas+N3jPcF9j1SZPj3HbBWdQorbtY4YHy2nV0ZstbmMVgJt+7djdyyUwu/A== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(40460700003)(36860700001)(6916009)(508600001)(82310400004)(7696005)(86362001)(54906003)(5660300002)(2906002)(6666004)(26005)(83380400001)(186003)(1076003)(70206006)(70586007)(316002)(8936002)(2616005)(8676002)(36756003)(16526019)(4326008)(81166007)(47076005)(336012)(426003)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2022 18:44:31.1444 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68736393-3c92-4665-d940-08d9e67c0cb9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4920 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Cc: lsix@lancelotsix.com, Lancelot SIX Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Add an argument to the get_return_value function to indicate the symbol of the function the debuggee is returning from. This will be used by the following patch. No user visible change after this patch. Tested on x86_64-linux. Change-Id: Idf1279f1f7199f5022738a6679e0fa63fbd22edc --- gdb/infcmd.c | 5 +++-- gdb/inferior.h | 3 ++- gdb/python/py-finishbreakpoint.c | 29 ++++++++++++++++++++--------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 994dd5b32a3..66667d67b21 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1410,7 +1410,8 @@ advance_command (const char *arg, int from_tty) right after an inferior call has finished. */ struct value * -get_return_value (struct value *function, struct type *value_type) +get_return_value (struct symbol *func_symbol, struct value *function, + struct type *value_type) { regcache *stop_regs = get_current_regcache (); struct gdbarch *gdbarch = stop_regs->arch (); @@ -1577,7 +1578,7 @@ finish_command_fsm::should_stop (struct thread_info *tp) struct value *func; func = read_var_value (function, NULL, get_current_frame ()); - rv->value = get_return_value (func, rv->type); + rv->value = get_return_value (function, func, rv->type); if (rv->value != NULL) rv->value_history_index = record_latest_value (rv->value); } diff --git a/gdb/inferior.h b/gdb/inferior.h index ec0fb6e8b16..5fdff0f9358 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -219,7 +219,8 @@ extern void detach_command (const char *, int); extern void notice_new_inferior (struct thread_info *, bool, int); -extern struct value *get_return_value (struct value *function, +extern struct value *get_return_value (struct symbol *func_symbol, + struct value *function, struct type *value_type); /* Prepare for execution command. TARGET is the target that will run diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 03bd4934506..a322918dfca 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -40,6 +40,8 @@ struct finish_breakpoint_object { /* gdb.Breakpoint base class. */ gdbpy_breakpoint_object py_bp; + /* gdb.Symbol object of the function finished by this breakpoint. */ + PyObject *func_symbol; /* gdb.Type object of the value return by the breakpointed function. May be NULL if no debug information was available or return type was VOID. */ @@ -80,6 +82,7 @@ bpfinishpy_dealloc (PyObject *self) struct finish_breakpoint_object *self_bpfinish = (struct finish_breakpoint_object *) self; + Py_XDECREF (self_bpfinish->func_symbol); Py_XDECREF (self_bpfinish->function_value); Py_XDECREF (self_bpfinish->return_type); Py_XDECREF (self_bpfinish->return_value); @@ -104,11 +107,14 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) try { + struct symbol *func_symbol = + symbol_object_to_symbol (self_finishbp->func_symbol); struct value *function = value_object_to_value (self_finishbp->function_value); struct type *value_type = type_object_to_type (self_finishbp->return_type); - struct value *ret = get_return_value (function, value_type); + struct value *ret = + get_return_value (func_symbol, function, value_type); if (ret) { @@ -165,7 +171,6 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) PyObject *internal = NULL; int internal_bp = 0; CORE_ADDR pc; - struct symbol *function; if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords, &frame_obj, &internal)) @@ -239,16 +244,18 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } /* Find the function we will return from. */ - self_bpfinish->return_type = NULL; - self_bpfinish->function_value = NULL; + self_bpfinish->func_symbol = nullptr; + self_bpfinish->return_type = nullptr; + self_bpfinish->function_value = nullptr; try { if (get_frame_pc_if_available (frame, &pc)) { - function = find_pc_function (pc); - if (function != NULL) + struct symbol *function = find_pc_function (pc); + if (function != nullptr) { + self_bpfinish->func_symbol = symbol_to_symbol_object (function); struct type *ret_type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (function))); @@ -274,14 +281,18 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) remain NULL. */ } - if (self_bpfinish->return_type == NULL || self_bpfinish->function_value == NULL) + if (self_bpfinish->func_symbol == nullptr + || self_bpfinish->return_type == nullptr + || self_bpfinish->function_value == nullptr) { /* Won't be able to compute return value. */ + Py_XDECREF (self_bpfinish->func_symbol); Py_XDECREF (self_bpfinish->return_type); Py_XDECREF (self_bpfinish->function_value); - self_bpfinish->return_type = NULL; - self_bpfinish->function_value = NULL; + self_bpfinish->func_symbol = nullptr; + self_bpfinish->return_type = nullptr; + self_bpfinish->function_value = nullptr; } bppy_pending_object = &self_bpfinish->py_bp; -- 2.25.1