From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kNOyApEHR2gLNQcAWB0awg (envelope-from ) for ; Mon, 09 Jun 2025 12:10:57 -0400 Received: by simark.ca (Postfix, from userid 112) id 078F51E11C; Mon, 9 Jun 2025 12:10:57 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 7BD001E0C2 for ; Mon, 9 Jun 2025 12:10:56 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E69738306B8 for ; Mon, 9 Jun 2025 16:10:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E69738306B8 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 34A6A382D283 for ; Mon, 9 Jun 2025 16:10:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34A6A382D283 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 34A6A382D283 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749485414; cv=none; b=WbNzE4T5rmGjJ6WEGblEAVpQx0vl66XdaRCN9DqilPVZkVXznPS02mYhOsYM7huysjKW5kYY7/GexX1vsJnqgM8Qg+tpGMVgrEqmonrZeE1g3PoJMijftEnGyYT/kKofuD7hphTka9gzGv206QOxuQrudwZMG7qZjCLndkC+jVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749485414; c=relaxed/simple; bh=tIFMgEJs31nNXV4/Bydz5dV4MaazH9YNQxY/epeZCe0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Fq4XEs10J9MitNeV60rwMuUOgPtsmUrF5I3NeoEEZOyCXhwx8ga6wMRPeVedvCQT0vXrNuGeJdhrTHdve4rreiDTSyLlN0Asjwv09kLDljoKzEfOrdXZjepO4OO+cqRMy1QWxuXYTV7zHpPan2APt0PRRhscsvH02Ll8dZhE4Kg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34A6A382D283 Received: by simark.ca (Postfix, from userid 112) id E3CB61E12B; Mon, 9 Jun 2025 12:10:13 -0400 (EDT) Received: from smarchi-efficios.internal.efficios.com (192-222-132-26.qc.cable.ebox.net [192.222.132.26]) (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 ESMTPSA id 4EDFE1E11E; Mon, 9 Jun 2025 12:10:07 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Lancelot Six , Simon Marchi Subject: [PATCH v2 4/6] gdb/amd-dbgapi: pass amd_dbgapi_inferior_info to process_one_event Date: Mon, 9 Jun 2025 12:09:00 -0400 Message-ID: <20250609161004.97787-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161004.97787-1-simon.marchi@efficios.com> References: <20250609161004.97787-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 New in v2: this patch is new Pass the amd_dbgapi_inferior_info object from process_event_queue to process_one_event. Since process_event_queue pulls events for one specific inferior, we know for which inferior the event is. This removes the need for process_one_event to do two dbgapi calls to get the relevant pid. If also removes one inferior lookup. Change-Id: I22927e4b6251513eb3be95785082058aa3d09954 --- gdb/amd-dbgapi-target.c | 58 +++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c index 888552e00d3e..80111359c8cd 100644 --- a/gdb/amd-dbgapi-target.c +++ b/gdb/amd-dbgapi-target.c @@ -1143,32 +1143,14 @@ add_gpu_thread (inferior *inf, ptid_t wave_ptid) /* Process an event that was just pulled out of the amd-dbgapi library. */ static void -process_one_event (amd_dbgapi_event_id_t event_id, +process_one_event (amd_dbgapi_inferior_info &info, + amd_dbgapi_event_id_t event_id, amd_dbgapi_event_kind_t event_kind) { /* Automatically mark this event processed when going out of scope. */ scoped_amd_dbgapi_event_processed mark_event_processed (event_id); - amd_dbgapi_process_id_t process_id; - amd_dbgapi_status_t status - = amd_dbgapi_event_get_info (event_id, AMD_DBGAPI_EVENT_INFO_PROCESS, - sizeof (process_id), &process_id); - if (status != AMD_DBGAPI_STATUS_SUCCESS) - error (_("event_get_info for event_%ld failed (%s)"), event_id.handle, - get_status_string (status)); - - amd_dbgapi_os_process_id_t pid; - status = amd_dbgapi_process_get_info (process_id, - AMD_DBGAPI_PROCESS_INFO_OS_ID, - sizeof (pid), &pid); - if (status != AMD_DBGAPI_STATUS_SUCCESS) - error (_("process_get_info for process_%ld failed (%s)"), - process_id.handle, get_status_string (status)); - - auto *proc_target = current_inferior ()->process_target (); - inferior *inf = find_inferior_pid (proc_target, pid); - gdb_assert (inf != nullptr); - amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf); + gdb_assert (info.inf != nullptr); switch (event_kind) { @@ -1176,14 +1158,14 @@ process_one_event (amd_dbgapi_event_id_t event_id, case AMD_DBGAPI_EVENT_KIND_WAVE_STOP: { amd_dbgapi_wave_id_t wave_id; - status + amd_dbgapi_status_t status = amd_dbgapi_event_get_info (event_id, AMD_DBGAPI_EVENT_INFO_WAVE, sizeof (wave_id), &wave_id); if (status != AMD_DBGAPI_STATUS_SUCCESS) error (_("event_get_info for event_%ld failed (%s)"), event_id.handle, get_status_string (status)); - ptid_t event_ptid = make_gpu_ptid (pid, wave_id); + ptid_t event_ptid = make_gpu_ptid (info.inf->pid, wave_id); target_waitstatus ws; amd_dbgapi_wave_stop_reasons_t stop_reason; @@ -1224,9 +1206,10 @@ process_one_event (amd_dbgapi_event_id_t event_id, else ws.set_stopped (GDB_SIGNAL_0); - thread_info *thread = proc_target->find_thread (event_ptid); - if (thread == nullptr) - thread = add_gpu_thread (inf, event_ptid); + thread_info *thread = + info.inf->process_target()->find_thread(event_ptid); + if (thread == nullptr) + thread = add_gpu_thread (info.inf, event_ptid); /* If the wave is stopped because of a software breakpoint, the program counter needs to be adjusted so that it points to the @@ -1248,7 +1231,7 @@ process_one_event (amd_dbgapi_event_id_t event_id, error (_("wave_get_info for wave_%ld failed (%s)"), wave_id.handle, get_status_string (status)); - info->wave_events.emplace_back (event_ptid, ws); + info.wave_events.emplace_back (event_ptid, ws); break; } @@ -1266,7 +1249,7 @@ process_one_event (amd_dbgapi_event_id_t event_id, When amd_dbgapi_target_breakpoint::check_status is called, the current inferior is the inferior that hit the breakpoint, which should still be the case now. */ - gdb_assert (inf == current_inferior ()); + gdb_assert (info.inf == current_inferior ()); handle_solib_event (); break; @@ -1280,22 +1263,23 @@ process_one_event (amd_dbgapi_event_id_t event_id, { amd_dbgapi_runtime_state_t runtime_state; - status = amd_dbgapi_event_get_info (event_id, - AMD_DBGAPI_EVENT_INFO_RUNTIME_STATE, - sizeof (runtime_state), - &runtime_state); + amd_dbgapi_status_t status + = amd_dbgapi_event_get_info (event_id, + AMD_DBGAPI_EVENT_INFO_RUNTIME_STATE, + sizeof (runtime_state), + &runtime_state); if (status != AMD_DBGAPI_STATUS_SUCCESS) error (_("event_get_info for event_%ld failed (%s)"), event_id.handle, get_status_string (status)); gdb_assert (runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED); gdb_assert - (info->runtime_state == AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS); + (info.runtime_state == AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS); - info->runtime_state = runtime_state; + info.runtime_state = runtime_state; - gdb_assert (inf->target_is_pushed (&the_amd_dbgapi_target)); - inf->unpush_target (&the_amd_dbgapi_target); + gdb_assert (info.inf->target_is_pushed (&the_amd_dbgapi_target)); + info.inf->unpush_target (&the_amd_dbgapi_target); } break; @@ -1367,7 +1351,7 @@ process_event_queue (amd_dbgapi_inferior_info &info, if (event_id == AMD_DBGAPI_EVENT_NONE || event_kind == until_event_kind) return event_id; - process_one_event (event_id, event_kind); + process_one_event (info, event_id, event_kind); } } -- 2.49.0