From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4fqzG9ei5GoseBQAWB0awg (envelope-from ) for ; Fri, 30 Oct 2026 09:59:51 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hLkPyHkr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 672EF1E023; Fri, 30 Oct 2026 09:59:51 -0400 (EDT) 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 690671E023 for ; Fri, 30 Oct 2026 09:59:48 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 29C3A4BA2E1E for ; Fri, 30 Oct 2026 13:59:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29C3A4BA2E1E Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hLkPyHkr Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by sourceware.org (Postfix) with ESMTPS id 432AE4BAE7CE for ; Fri, 30 Oct 2026 13:57:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 432AE4BAE7CE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 432AE4BAE7CE Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793368672; cv=none; b=JhRTerC0ESJbspZHey50MI56C+tAKDUTMCcIETFuNzJC/enpZ4TsE1du6PrQKf6MAxrqU0BNpf/HtcW9bltEMvun/AA7I1UWAzsDh+ygLhuuRsbgpddjXtTDbr/Kz0xFvLNgS0L8kNc8SoetymKUqxHW0Wyf7aGHhhMfDiSX3OM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793368672; c=relaxed/simple; bh=uzuvjxU7PTmbG3+1VyTXveADKyXVTlXS6gGJoLLdWmk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ku0TTR4D+PlVrfahxFf/n6Z//a5TZdzqvDD1izQvEzepDwFf0EQ2i8iWI12kxyZ45iap0irK9rdWg8mWlxPIazUYA3ewF+uzFPKsosHRS+r5TNkyRUwS7oPBDBGuBEzveGrDSSHfGwekuFIH5QCi4HPM3cuU+UW/5INW95Yjj64= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hLkPyHkr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 432AE4BAE7CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1793368672; x=1824904672; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=uzuvjxU7PTmbG3+1VyTXveADKyXVTlXS6gGJoLLdWmk=; b=hLkPyHkrmf6igJlNeiy/P8XXKfmHzh2m73SlfGU+zbWy5v5UbnZzLfDc pXHSI81QEb0Sg1+YitVzQ+Ybz9fzzodpIUUSRjole2zI5uliMalIaUz4z rLo82pXMoS3ZuvzInbcl504Dyr3g0dMAuxSOFhihXIozEq5CzJQLBATLp LZ7d/JHQSLnOfFgHncYt+54grYSh0ZAYiXP6nPE+PSfkGLNKssbckizJo /Vsy/myLLLh+I+6KmTsPYODlibdKbjdCXcyfqXU0qlmnnAERUPoqqQShT DvbE7MYN1ve19jHvXdi4LMR6oIk3YoZMRzjE8mamb/VDNvLr1EV3fHtIG Q==; X-CSE-ConnectionGUID: 6eVl5hnuSSWZPU1G3IlStw== X-CSE-MsgGUID: mnW+Pr5gT8i1Gjjt4ItWqA== X-IronPort-AV: E=McAfee;i="6800,10657,11951"; a="2011294" X-IronPort-AV: E=Sophos;i="6.27,186,1787036400"; d="scan'208";a="2011294" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2026 06:57:51 -0700 X-CSE-ConnectionGUID: +WnQCTiuSgmu1AVGywiohQ== X-CSE-MsgGUID: ETh85MO6SiW3th33GkKHhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,186,1787036400"; d="scan'208";a="5331810" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2026 06:57:50 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 1/5] gdb, btrace: refactor handle_pt_insn_events() Date: Fri, 30 Oct 2026 14:57:40 +0100 Message-ID: <20261030135744.921562-2-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030135744.921562-1-markus.t.metzger@intel.com> References: <20261030135744.921562-1-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 Make handle_pt_insn_events() only handle a single event and move the while loop that checks for pending events into the caller to prepare for a subsequent patch. To reflect that change, rename it to handle_pt_insn_event(). Also move declarations closer to their actual use, thereby duplicating them as needed. This is supposed to be a refactoring with no functional changes. --- gdb/btrace.c | 560 ++++++++++++++++++++++++++------------------------- 1 file changed, 284 insertions(+), 276 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index f5f2d6da972..ddc7b2551df 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1285,379 +1285,384 @@ decode_interrupt_vector (const uint8_t vector) } #endif /* (LIBIPT_VERSION >= 0x201) */ -/* Handle instruction decode events (libipt-v2). */ +#if defined (HAVE_PT_INSN_EVENT) +/* Handle an instruction decode event (libipt-v2). */ static int -handle_pt_insn_events (struct btrace_thread_info *btinfo, - struct pt_insn_decoder *decoder, - std::vector &gaps, int status) +handle_pt_insn_event (btrace_thread_info *btinfo, pt_insn_decoder *decoder, + std::vector &gaps) { -#if defined (HAVE_PT_INSN_EVENT) - while (status & pts_event_pending) + pt_event event; + int status = pt_insn_event (decoder, &event, sizeof (event)); + if (status < 0) + return status; + + switch (event.type) { - struct pt_event event; - uint64_t offset; - std::optional pc; + default: + break; - status = pt_insn_event (decoder, &event, sizeof (event)); - if (status < 0) + case ptev_enabled: + if (event.status_update != 0) break; - switch (event.type) + /* Only create a new gap if there are non-aux instructions in the + trace since the last gap. We could be at the beginning of the + recording and could already have handled one or more events, like + ptev_iret, that created aux insns. In that case we don't want to + create a gap or print a warning. */ + if (event.variant.enabled.resumed == 0 + && ftrace_contains_non_aux_since_last_gap (btinfo)) { - default: - break; - - case ptev_enabled: - { - if (event.status_update != 0) - break; - - /* Only create a new gap if there are non-aux instructions in - the trace since the last gap. We could be at the beginning - of the recording and could already have handled one or more - events, like ptev_iret, that created aux insns. In that - case we don't want to create a gap or print a warning. */ - if (event.variant.enabled.resumed == 0 - && ftrace_contains_non_aux_since_last_gap (btinfo)) - { - struct btrace_function *bfun - = ftrace_new_gap (btinfo, BDE_PT_NON_CONTIGUOUS, gaps); + btrace_function *bfun + = ftrace_new_gap (btinfo, BDE_PT_NON_CONTIGUOUS, gaps); - pt_insn_get_offset (decoder, &offset); + uint64_t offset; + pt_insn_get_offset (decoder, &offset); - warning - (_("Non-contiguous trace at instruction %u (offset = 0x%" - PRIx64 ")."), bfun->insn_offset - 1, offset); - } + warning + (_("Non-contiguous trace at instruction %u (offset = 0x%" + PRIx64 ")."), bfun->insn_offset - 1, offset); + } - break; - } + break; - case ptev_overflow: - { - struct btrace_function *bfun - = ftrace_new_gap (btinfo, BDE_PT_OVERFLOW, gaps); + case ptev_overflow: + { + btrace_function *bfun + = ftrace_new_gap (btinfo, BDE_PT_OVERFLOW, gaps); - pt_insn_get_offset (decoder, &offset); + uint64_t offset; + pt_insn_get_offset (decoder, &offset); - warning (_("Overflow at instruction %u (offset = 0x%" PRIx64 ")."), - bfun->insn_offset - 1, offset); + warning (_("Overflow at instruction %u (offset = 0x%" PRIx64 ")."), + bfun->insn_offset - 1, offset); - break; - } + break; + } #if defined (HAVE_STRUCT_PT_EVENT_VARIANT_PTWRITE) - case ptev_ptwrite: + case ptev_ptwrite: + { + std::optional ptw_string; + std::optional pc; + + /* Lookup the PC if available. The event often doesn't provide + one, so we look into the last function segment as well. + Looking further back makes limited sense for ptwrite. */ + if (event.ip_suppressed == 0) + pc = event.variant.ptwrite.ip; + else if (!btinfo->functions.empty ()) { - std::optional ptw_string; - - /* Lookup the PC if available. The event often doesn't provide - one, so we look into the last function segment as well. - Looking further back makes limited sense for ptwrite. */ - if (event.ip_suppressed == 0) - pc = event.variant.ptwrite.ip; - else if (!btinfo->functions.empty ()) + std::vector &insns = btinfo->functions.back ().insn; + for (auto insn = insns.rbegin (); insn != insns.rend (); ++insn) { - std::vector &insns - = btinfo->functions.back ().insn; - for (auto insn = insns.rbegin (); insn != insns.rend (); - ++insn) + switch (insn->iclass) { - switch (insn->iclass) - { - case BTRACE_INSN_AUX: - continue; - - case BTRACE_INSN_OTHER: - case BTRACE_INSN_CALL: - case BTRACE_INSN_RETURN: - case BTRACE_INSN_JUMP: - pc = insn->pc; - break; - /* No default to rely on compiler warnings. */ - } + case BTRACE_INSN_AUX: + continue; + + case BTRACE_INSN_OTHER: + case BTRACE_INSN_CALL: + case BTRACE_INSN_RETURN: + case BTRACE_INSN_JUMP: + pc = insn->pc; break; + /* No default to rely on compiler warnings. */ } + break; } + } - if (!pc.has_value ()) - warning (_("Failed to determine the PC for ptwrite.")); - + if (!pc.has_value ()) + warning (_("Failed to determine the PC for ptwrite.")); - if (btinfo->ptw_callback_fun != nullptr) - ptw_string - = btinfo->ptw_callback_fun (event.variant.ptwrite.payload, - pc, btinfo->ptw_context); + if (btinfo->ptw_callback_fun != nullptr) + ptw_string + = btinfo->ptw_callback_fun (event.variant.ptwrite.payload, + pc, btinfo->ptw_context); - if (ptw_string.has_value () && (*ptw_string).empty ()) - continue; + if (ptw_string.has_value () && (*ptw_string).empty ()) + break; - if (!ptw_string.has_value ()) - ptw_string = hex_string (event.variant.ptwrite.payload); + if (!ptw_string.has_value ()) + ptw_string = hex_string (event.variant.ptwrite.payload); - handle_pt_aux_insn (btinfo, *ptw_string, pc); + handle_pt_aux_insn (btinfo, *ptw_string, pc); - break; - } + break; + } #endif /* defined (HAVE_STRUCT_PT_EVENT_VARIANT_PTWRITE) */ #if (LIBIPT_VERSION >= 0x201) - case ptev_interrupt: - { - std::string aux_string = std::string (_("interrupt: vector = ")) - + hex_string (event.variant.interrupt.vector); - - const char *decoded - = decode_interrupt_vector (event.variant.interrupt.vector); - if (decoded != nullptr) - aux_string += std::string (" (") + decoded + ")"; + case ptev_interrupt: + { + std::string aux_string = std::string (_("interrupt: vector = ")) + + hex_string (event.variant.interrupt.vector); + std::optional pc; - if (event.variant.interrupt.has_cr2 != 0) - { - aux_string += std::string (", cr2 = ") - + hex_string (event.variant.interrupt.cr2); - } + const char *decoded + = decode_interrupt_vector (event.variant.interrupt.vector); + if (decoded != nullptr) + aux_string += std::string (" (") + decoded + ")"; - if (event.ip_suppressed == 0) - { - pc = event.variant.interrupt.ip; - aux_string += std::string (", ip = ") + hex_string (*pc); - } - - handle_pt_aux_insn (btinfo, aux_string, pc); - break; + if (event.variant.interrupt.has_cr2 != 0) + { + aux_string += std::string (", cr2 = ") + + hex_string (event.variant.interrupt.cr2); } - case ptev_iret: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("iret")); + pc = event.variant.interrupt.ip; + aux_string += std::string (", ip = ") + hex_string (*pc); + } - if (event.ip_suppressed == 0) - { - pc = event.variant.iret.ip; - aux_string += std::string (": ip = ") + hex_string (*pc); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } + case ptev_iret: + { + std::string aux_string = std::string (_("iret")); + std::optional pc; - case ptev_smi: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("smi")); + pc = event.variant.iret.ip; + aux_string += std::string (": ip = ") + hex_string (*pc); + } - if (event.ip_suppressed == 0) - { - pc = event.variant.smi.ip; - aux_string += std::string (": ip = ") + hex_string (*pc); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } + case ptev_smi: + { + std::string aux_string = std::string (_("smi")); + std::optional pc; - case ptev_rsm: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("rsm")); + pc = event.variant.smi.ip; + aux_string += std::string (": ip = ") + hex_string (*pc); + } - if (event.ip_suppressed == 0) - { - pc = event.variant.rsm.ip; - aux_string += std::string (": ip = ") + hex_string (*pc); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } + case ptev_rsm: + { + std::string aux_string = std::string (_("rsm")); + std::optional pc; - case ptev_sipi: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("sipi: vector = ")) - + hex_string (event.variant.sipi.vector); - - handle_pt_aux_insn (btinfo, aux_string, pc); - break; + pc = event.variant.rsm.ip; + aux_string += std::string (": ip = ") + hex_string (*pc); } - case ptev_init: - { - std::string aux_string = std::string (_("init")); + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - if (event.ip_suppressed == 0) - { - pc = event.variant.init.ip; - aux_string += std::string (": ip = ") + hex_string (*pc); - } + case ptev_sipi: + { + std::string aux_string = std::string (_("sipi: vector = ")) + + hex_string (event.variant.sipi.vector); + std::optional pc; - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - case ptev_vmentry: + case ptev_init: + { + std::string aux_string = std::string (_("init")); + std::optional pc; + + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("vmentry")); + pc = event.variant.init.ip; + aux_string += std::string (": ip = ") + hex_string (*pc); + } - if (event.ip_suppressed == 0) - { - pc = event.variant.vmentry.ip; - aux_string += std::string (": ip = ") + hex_string (*pc); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } + case ptev_vmentry: + { + std::string aux_string = std::string (_("vmentry")); + std::optional pc; - case ptev_vmexit: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("vmexit")); + pc = event.variant.vmentry.ip; + aux_string += std::string (": ip = ") + hex_string (*pc); + } - if (event.variant.vmexit.has_vector != 0 - || event.variant.vmexit.has_vmxr != 0 - || event.variant.vmexit.has_vmxq != 0 - || event.ip_suppressed != 0) - aux_string += std::string (":"); + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - if (event.variant.vmexit.has_vector != 0) - { - aux_string += std::string (_(" vector = ")) - + hex_string (event.variant.vmexit.vector); + case ptev_vmexit: + { + std::string aux_string = std::string (_("vmexit")); + std::optional pc; - const char* decoded = decode_interrupt_vector - (event.variant.vmexit.vector); - if (decoded != nullptr) - aux_string += std::string (" (") + decoded + ")"; - } + if (event.variant.vmexit.has_vector != 0 + || event.variant.vmexit.has_vmxr != 0 + || event.variant.vmexit.has_vmxq != 0 + || event.ip_suppressed != 0) + aux_string += std::string (":"); - if (event.variant.vmexit.has_vmxr != 0) - { - std::string separator = aux_string.back () == ':' ? "" : ","; - aux_string += separator + std::string (" vmxr = ") - + hex_string (event.variant.vmexit.vmxr); - } + if (event.variant.vmexit.has_vector != 0) + { + aux_string += std::string (_(" vector = ")) + + hex_string (event.variant.vmexit.vector); - if (event.variant.vmexit.has_vmxq != 0) - { - std::string separator = aux_string.back () == ':' ? "" : ","; - aux_string += separator + std::string (" vmxq = ") - + hex_string (event.variant.vmexit.vmxq); - } + const char* decoded = decode_interrupt_vector + (event.variant.vmexit.vector); + if (decoded != nullptr) + aux_string += std::string (" (") + decoded + ")"; + } - if (event.ip_suppressed == 0) - { - pc = event.variant.vmexit.ip; - std::string separator = aux_string.back () == ':' ? "" : ","; - aux_string += separator + std::string (" ip = ") - + hex_string (*pc); - } + if (event.variant.vmexit.has_vmxr != 0) + { + std::string separator = aux_string.back () == ':' ? "" : ","; + aux_string += separator + std::string (" vmxr = ") + + hex_string (event.variant.vmexit.vmxr); + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; + if (event.variant.vmexit.has_vmxq != 0) + { + std::string separator = aux_string.back () == ':' ? "" : ","; + aux_string += separator + std::string (" vmxq = ") + + hex_string (event.variant.vmexit.vmxq); } - case ptev_shutdown: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("shutdown")); + pc = event.variant.vmexit.ip; + std::string separator = aux_string.back () == ':' ? "" : ","; + aux_string += separator + std::string (" ip = ") + + hex_string (*pc); + } - if (event.ip_suppressed == 0) - { - pc = event.variant.shutdown.ip; - aux_string += std::string (": ip = ") + hex_string (*pc); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } + case ptev_shutdown: + { + std::string aux_string = std::string (_("shutdown")); + std::optional pc; - case ptev_uintr: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("uintr: vector = ")) - + hex_string (event.variant.uintr.vector); + pc = event.variant.shutdown.ip; + aux_string += std::string (": ip = ") + hex_string (*pc); + } - if (event.ip_suppressed == 0) - { - pc = event.variant.uintr.ip; - aux_string += std::string (", ip = ") + hex_string (*pc); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } + case ptev_uintr: + { + std::string aux_string = std::string (_("uintr: vector = ")) + + hex_string (event.variant.uintr.vector); + std::optional pc; - case ptev_uiret: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("uiret")); + pc = event.variant.uintr.ip; + aux_string += std::string (", ip = ") + hex_string (*pc); + } - if (event.ip_suppressed == 0) - { - pc = event.variant.uiret.ip; - aux_string += std::string (": ip = ") + hex_string (*pc); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } -#endif /* (LIBIPT_VERSION >= 0x201) */ + case ptev_uiret: + { + std::string aux_string = std::string (_("uiret")); + std::optional pc; -#if (LIBIPT_VERSION >= 0x202) - case ptev_trig: + if (event.ip_suppressed == 0) { - std::string aux_string - = (std::string (_("trig: trbv = ")) - + hex_string (event.variant.trig.trbv)); + pc = event.variant.uiret.ip; + aux_string += std::string (": ip = ") + hex_string (*pc); + } - if (event.variant.trig.mult != 0) - aux_string += std::string (", mult"); + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } +#endif /* (LIBIPT_VERSION >= 0x201) */ - if (event.ip_suppressed == 0) - { - pc = event.variant.trig.ip; - aux_string += (std::string (", ip = ") + hex_string (*pc)); - } +#if (LIBIPT_VERSION >= 0x202) + case ptev_trig: + { + std::string aux_string + = (std::string (_("trig: trbv = ")) + + hex_string (event.variant.trig.trbv)); + std::optional pc; - if (event.variant.trig.icnt != 0) - aux_string += (std::string (", icnt = ") - + hex_string (event.variant.trig.icnt)); + if (event.variant.trig.mult != 0) + aux_string += std::string (", mult"); - handle_pt_aux_insn (btinfo, aux_string, pc); - break; + if (event.ip_suppressed == 0) + { + pc = event.variant.trig.ip; + aux_string += (std::string (", ip = ") + hex_string (*pc)); } - case ptev_swintr: - { - std::string aux_string - = (std::string (_("swintr: vector = ")) - + hex_string (event.variant.swintr.vector)); + if (event.variant.trig.icnt != 0) + aux_string += (std::string (", icnt = ") + + hex_string (event.variant.trig.icnt)); - if (event.ip_suppressed == 0) - { - pc = event.variant.swintr.ip; - aux_string += (std::string (", ip = ") + hex_string (*pc)); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; - } + case ptev_swintr: + { + std::string aux_string + = (std::string (_("swintr: vector = ")) + + hex_string (event.variant.swintr.vector)); + std::optional pc; - case ptev_syscall: + if (event.ip_suppressed == 0) { - std::string aux_string = std::string (_("syscall")); + pc = event.variant.swintr.ip; + aux_string += (std::string (", ip = ") + hex_string (*pc)); + } - if (event.ip_suppressed == 0) - { - pc = event.variant.syscall.ip; - aux_string += (std::string (": ip = ") + hex_string (*pc)); - } + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } - handle_pt_aux_insn (btinfo, aux_string, pc); - break; + case ptev_syscall: + { + std::string aux_string = std::string (_("syscall")); + std::optional pc; + + if (event.ip_suppressed == 0) + { + pc = event.variant.syscall.ip; + aux_string += (std::string (": ip = ") + hex_string (*pc)); } + + handle_pt_aux_insn (btinfo, aux_string, pc); + break; + } #endif /* (LIBIPT_VERSION >= 0x202) */ - } } -#endif /* defined (HAVE_PT_INSN_EVENT) */ return status; } +#endif /* defined (HAVE_PT_INSN_EVENT) */ /* Handle events indicated by flags in INSN (libipt-v1). */ @@ -1735,8 +1740,11 @@ ftrace_add_pt (struct btrace_thread_info *btinfo, for (;;) { +#if defined (HAVE_PT_INSN_EVENT) /* Handle events from the previous iteration or synchronization. */ - status = handle_pt_insn_events (btinfo, decoder, gaps, status); + while ((status != 0) && (status & pts_event_pending)) + status = handle_pt_insn_event (btinfo, decoder, gaps); +#endif if (status < 0) break; -- 2.53.0 ________________________________________ Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 (89) 99143-0 www.intel.de Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman Chairperson of the Supervisory Board: Sonja Pierer Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.