| Message ID | 20260430112428.1537534-1-markus.t.metzger@intel.com |
|---|---|
| State | New |
| Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 7737E436F3FC for <patchwork@sourceware.org>; Thu, 30 Apr 2026 11:25:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7737E436F3FC 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=IWM19xs0 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by sourceware.org (Postfix) with ESMTPS id 3E948436F7EC for <gdb-patches@sourceware.org>; Thu, 30 Apr 2026 11:24:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E948436F7EC 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 3E948436F7EC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777548272; cv=none; b=picgM37pa4XHQMaR6can48ZTRMEUpZnV4t5zJMl5c4GNc9z3G+aUU/OWrVrrVHErmUU+aivvpOfx9u/VbJmHKer0QQsSZnsuTbvG+118Ov88XTHWH/QmJEfpfvacCNqJ/6TIjeaMRD39kdpDED/mRI6XBojLvNOjkqsNCcobAFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777548272; c=relaxed/simple; bh=5weyFUjVPCHyY7AlzhK60LKQ3UkzfQyg56/B5b25X5o=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XRlsCfITQr+bjTDYCgKoDU93tvpQuHT8ywiQfBbFoMF6ssGs1rE2E4dyFLgdkj5blHdhxA3Cm54SVdMjOtK0cuIbAGxZeXBdj2+lHDSxJ1QD+vegJXqXbdlMvaQ4beB3NfPfRBfBAkl2JptwBMNWBxcCXCsm2pTyWMZASR3nP2E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E948436F7EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777548273; x=1809084273; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=5weyFUjVPCHyY7AlzhK60LKQ3UkzfQyg56/B5b25X5o=; b=IWM19xs0/Dp50yvJInTg/NizDSjP/m2DITGvUjjmTXifof76w3zCFp+2 flttFm9J60CXP9XZypQESsztMzmYhwEIz0gS7Eeu5wlWPOrieuzSLv+TF +dprIgTb31H+O5Pcarv2A/v/g0Y8u2+jvSohtUeRX/FTeYpWEuJ+imCi5 2eilR+ab+LfoPl4OsUQ/K6hDWbPey3GFY1KVT4GEsDrXUVA1nbyH2zX/j sviGEvOzgGHPEktoLtY6+PbfAqM2+ggONxCTJTElfvettnbMFOfBNV+Ty PymEePPyHvIniWQx9L+l0LSJVqDqrJp0yY/d0R5BRGHsERxykp/7AegEC g==; X-CSE-ConnectionGUID: ls1JO3FORGC2PQGhits8FA== X-CSE-MsgGUID: JH94p1h8RaG06/o8n5flhw== X-IronPort-AV: E=McAfee;i="6800,10657,11771"; a="78417808" X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="78417808" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2026 04:24:32 -0700 X-CSE-ConnectionGUID: Sa357xBCRuicvgCEZ43CmA== X-CSE-MsgGUID: vJio65j4SEWVyKXiEM2qKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="231428482" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2026 04:24:30 -0700 From: Markus Metzger <markus.t.metzger@intel.com> To: gdb-patches@sourceware.org Subject: [PATCH] gdb, btrace: support libipt v2.2 events Date: Thu, 30 Apr 2026 11:24:28 +0000 Message-Id: <20260430112428.1537534-1-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
gdb, btrace: support libipt v2.2 events
|
|
Commit Message
Metzger, Markus T
April 30, 2026, 11:24 a.m. UTC
--- gdb/btrace.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
Comments
Hi, On 4/30/26 4:24 AM, Markus Metzger wrote: > --- > gdb/btrace.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) There appears to be no commit message other than the (admittedly rather complete) title? I think a brief NEWS entry is warranted, too. There is one tiny nit (below), but otherwise, I think you should approve your patch. ;-) Reviewed-By: Keith Seitz <keiths@redhat.com> Keith > > diff --git a/gdb/btrace.c b/gdb/btrace.c > index 6a8f0f549d1..f9c6f0e5b6a 100644 > --- a/gdb/btrace.c > +++ b/gdb/btrace.c > @@ -1597,6 +1597,59 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo, > break; > } > #endif /* defined (LIBIPT_VERSION >= 0x201) */ > + > +#if (LIBIPT_VERSION >= 0x202) > + case ptev_trig: > + { > + std::string aux_string = std::string (_("trig: trbv = ")) > + + hex_string (event.variant.trig.trbv); > + > + if (event.variant.trig.mult != 0) > + aux_string += std::string (", mult"); > + > + if (event.ip_suppressed == 0) > + { > + pc = event.variant.trig.ip; > + aux_string += std::string (", ip = ") + hex_string (*pc); > + } > + > + if (event.variant.trig.icnt != 0) > + aux_string += std::string (", icnt = ") > + + hex_string (event.variant.trig.icnt); > + > + 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); > + > + 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; > + } > + > + case ptev_syscall: > + { > + std::string aux_string = std::string (_("syscall")); > + > + 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) */ Elsewhere in the file, this comment includes "defined". > } > } > #endif /* defined (HAVE_PT_INSN_EVENT) */
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes: >> + std::string aux_string = std::string (_("trig: trbv = ")) >> + + hex_string (event.variant.trig.trbv); Normally here we'd wrap the RSH in parens, per the coding standards. >> +#endif /* (LIBIPT_VERSION >= 0x202) */ Keith> Elsewhere in the file, this comment includes "defined". True but those spots seem to be in error. Tom
Hello Tom, >>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes: > >>> + std::string aux_string = std::string (_("trig: trbv = ")) >>> + + hex_string (event.variant.trig.trbv); > >Normally here we'd wrap the RSH in parens, per the coding standards. I'd need to break at the =, then, like this: std::string aux_string = (std::string (_("trig: trbv = ")) + hex_string (event.variant.trig.trbv)); The patch matches the surrounding style, so if you want this fixed, I'd need to fix it everywhere in a separate patch. >>> +#endif /* (LIBIPT_VERSION >= 0x202) */ > >Keith> Elsewhere in the file, this comment includes "defined". > >True but those spots seem to be in error. I fixed those in a separate obvious patch: diff --git a/gdb/btrace.c b/gdb/btrace.c index f9c6f0e5b6a..ef152c531fb 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1283,7 +1283,7 @@ decode_interrupt_vector (const uint8_t vector) return nullptr; } -#endif /* defined (LIBIPT_VERSION >= 0x201) */ +#endif /* (LIBIPT_VERSION >= 0x201) */ /* Handle instruction decode events (libipt-v2). */ @@ -1596,7 +1596,7 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo, handle_pt_aux_insn (btinfo, aux_string, pc); break; } -#endif /* defined (LIBIPT_VERSION >= 0x201) */ +#endif /* (LIBIPT_VERSION >= 0x201) */ #if (LIBIPT_VERSION >= 0x202) case ptev_trig: @@ -3064,7 +3064,7 @@ pt_print_packet (const struct pt_packet *packet) packet->payload.ptw.payload, packet->payload.ptw.ip ? (" ip") : ("")); break; -#endif /* defined (LIBIPT_VERSION >= 0x200) */ +#endif /* (LIBIPT_VERSION >= 0x200) */ #if (LIBIPT_VERSION >= 0x201) case ppt_cfe: @@ -3077,7 +3077,7 @@ pt_print_packet (const struct pt_packet *packet) gdb_printf (("evd %u: 0x%" PRIx64 ""), packet->payload.evd.type, packet->payload.evd.payload); break; -#endif /* defined (LIBIPT_VERSION >= 0x201) */ +#endif /* (LIBIPT_VERSION >= 0x201) */ } } Markus. Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928
Hello Keith, >On 4/30/26 4:24 AM, Markus Metzger wrote: >> --- >> gdb/btrace.c | 53 >++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 53 insertions(+) > >There appears to be no commit message other than the (admittedly >rather complete) title? > >I think a brief NEWS entry is warranted, too. I extended the former and added the latter. Will send a v2 so we can review the NEWS wording. >Reviewed-By: Keith Seitz <keiths@redhat.com> Thanks for your review, Makus. Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928
On 5/4/26 3:16 AM, Metzger, Markus T wrote: > Hello Tom, > >>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes: >> >>>> + std::string aux_string = std::string (_("trig: trbv = ")) >>>> + + hex_string (event.variant.trig.trbv); >> >> Normally here we'd wrap the RSH in parens, per the coding standards. > > I'd need to break at the =, then, like this: > > std::string aux_string > = (std::string (_("trig: trbv = ")) > + hex_string (event.variant.trig.trbv)); > > The patch matches the surrounding style, so if you want this fixed, I'd need > to fix it everywhere in a separate patch. Just noting that you could also use `string_printf` for this, which sometimes gives more readable code than using concatenation (and perhaps one day we'll use {fmt}/std::format, one can dream). Simon
> I'd need to break at the =, then, like this: > std::string aux_string > = (std::string (_("trig: trbv = ")) > + hex_string (event.variant.trig.trbv)); > The patch matches the surrounding style, so if you want this fixed, I'd need > to fix it everywhere in a separate patch. In gdb it's pretty normal for some code to be weird or wrong. For example tdep files are less reviewed than others. However the presence of some code that isn't standards-conformant doesn't mean that new code should be. You see this a lot with things like NULL/nullptr -- using nullptr in new code doesn't imply that all the old code has to be updated at the same time. So IMO new code should follow the relevant coding standards, even if other code in the same function does not. thanks, Tom
Hello Tom, >> I'd need to break at the =, then, like this: > >> std::string aux_string >> = (std::string (_("trig: trbv = ")) >> + hex_string (event.variant.trig.trbv)); > >> The patch matches the surrounding style, so if you want this fixed, I'd need >> to fix it everywhere in a separate patch. > >In gdb it's pretty normal for some code to be weird or wrong. >For example tdep files are less reviewed than others. > >However the presence of some code that isn't standards-conformant >doesn't mean that new code should be. You see this a lot with things >like NULL/nullptr -- using nullptr in new code doesn't imply that all >the old code has to be updated at the same time. > >So IMO new code should follow the relevant coding standards, even if >other code in the same function does not. I changed this in v5 [1]. [1]: https://sourceware.org/pipermail/gdb-patches/2026-May/227179.html Regards, Markus. Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928
diff --git a/gdb/btrace.c b/gdb/btrace.c index 6a8f0f549d1..f9c6f0e5b6a 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1597,6 +1597,59 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo, break; } #endif /* defined (LIBIPT_VERSION >= 0x201) */ + +#if (LIBIPT_VERSION >= 0x202) + case ptev_trig: + { + std::string aux_string = std::string (_("trig: trbv = ")) + + hex_string (event.variant.trig.trbv); + + if (event.variant.trig.mult != 0) + aux_string += std::string (", mult"); + + if (event.ip_suppressed == 0) + { + pc = event.variant.trig.ip; + aux_string += std::string (", ip = ") + hex_string (*pc); + } + + if (event.variant.trig.icnt != 0) + aux_string += std::string (", icnt = ") + + hex_string (event.variant.trig.icnt); + + 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); + + 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; + } + + case ptev_syscall: + { + std::string aux_string = std::string (_("syscall")); + + 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) */