From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YXVKKzKj5GoseBQAWB0awg (envelope-from ) for ; Fri, 30 Oct 2026 10:01:22 -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=bU+3ITtC; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AC2891E023; Fri, 30 Oct 2026 10:01:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 886E51E023 for ; Fri, 30 Oct 2026 10:01:21 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E65FB4BA900D for ; Fri, 30 Oct 2026 14:01:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E65FB4BA900D 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=bU+3ITtC Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by sourceware.org (Postfix) with ESMTPS id 7EDC54BA9006 for ; Fri, 30 Oct 2026 13:58:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7EDC54BA9006 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 7EDC54BA9006 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=1793368681; cv=none; b=bIHonFtNSArUet+nOHbkE7i1uSugaWqpHeA6HK+2yQd4Mz8UzGTODbvDJJnd7DD6fT4blPn+DPHIpFcQRdnlyJZLI7BWsyIonYxdcvm9dRTHU/ghU6xNqZclCvvIxD8bB+A0hOL9Acx9javjvO6ZR3hk28bNFpVjYopOn7V7z40= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793368681; c=relaxed/simple; bh=WYrz0IYahHxlee2Y2YjTVZhTRbX4MhU1eXtl2ioFD/8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FLTyo1gG5uq2kd1fexBtTHCJMcDNHwbaraaLGPFdTIuObGd91Akuzb2TBgiTsAvgWCJXCEBlIReQ9Bocdl/kbfKkF0yeqla4zKtr3oSZGwCPRuoW/uZBCMNQtkae0+hPF+l2jFovaJqEkC0pM7tQavVVKrJEjpOAXQu59dXtWRI= 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=bU+3ITtC DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EDC54BA9006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1793368682; x=1824904682; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=WYrz0IYahHxlee2Y2YjTVZhTRbX4MhU1eXtl2ioFD/8=; b=bU+3ITtCh88byw6z3TE9iDJDIy0+5bWawjOQrc1UfKNNRTGuw/xA1dQR cWwtQ79djk7ULruYkkCtLHXZFYTgL0MvOBMOwUf9YzH0t02ysDkM2GZfV E8/qtaYcV4kTF9p+2teq4zGusYn9tNnj7KKxma2mi0B7fhVufnYfn5RkD TTLFIq4TmdoZxIHoygwYadkT2CRT5fGrYuSZrJdnmBveqYmSlTxMLmHIP 1hndxuAsgJIfK0xyma5xpJFNLZm2DLKs8KnIz5hNdLv/aOXfCMOdvEpsp weFAoV9CTSP1gi2RwXrevmKPUkcJkerNZcVFp3hu+fKe/cDs3frYXGbYD Q==; X-CSE-ConnectionGUID: ART06REbSnun+hSRXzhUZg== X-CSE-MsgGUID: 4AuzYdWIT7CLPpfMUwMLkQ== X-IronPort-AV: E=McAfee;i="6800,10657,11951"; a="2011310" X-IronPort-AV: E=Sophos;i="6.27,186,1787036400"; d="scan'208";a="2011310" 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:58:01 -0700 X-CSE-ConnectionGUID: 8F07M2UeThytu3l4KemW2Q== X-CSE-MsgGUID: hw7v22SYTmSt0LgyI2HMzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,186,1787036400"; d="scan'208";a="5331836" 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:58:00 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 4/5] gdb, gdbserver, btrace: allow disabling return compression Date: Fri, 30 Oct 2026 14:57:43 +0100 Message-ID: <20261030135744.921562-5-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 When recording with Intel Processor Trace, return compression is enabled by default and can be explicitly disabled. Add a new setting set record btrace pt return-compression on|off to expose that functionality and a new RSP packet Qbtrace-conf:pt:return-compression to configure this for remote targets. --- gdb/NEWS | 9 ++++++ gdb/doc/gdb.texinfo | 32 ++++++++++++++++++++ gdb/features/btrace-conf.dtd | 1 + gdb/nat/linux-btrace.c | 4 +++ gdb/record-btrace.c | 36 ++++++++++++++++++++++ gdb/remote.c | 58 ++++++++++++++++++++++++++++++++++-- gdbserver/linux-low.cc | 2 ++ gdbserver/server.cc | 15 ++++++++++ gdbsupport/btrace-common.h | 3 ++ 9 files changed, 158 insertions(+), 2 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 7303ec0e460..cddecf2040e 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -71,6 +71,10 @@ maintenance info source-tracking-context BPNUM Displays the captured source context that GDB uses to track and adjust a breakpoint when source changes. +set record btrace pt return-compression on|off +show record btrace pt return-compression + Enable or disable Intel Processor Trace return compression (default: on). + * Changed commands set stop-on-solib-events on|off @@ -83,6 +87,11 @@ info locals The new "-shadowed on|off" option overrides the "set print shadowed" setting for a single invocation of the command. +* New remote packets + +Qbtrace-conf:pt:return-compression + Configure Intel Processor Trace return-compression settings. + *** Changes in GDB 18 * Support for the Common Trace Format (CTF) has been removed. GDB now diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 66152d2582e..8cfaffd4fc7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -8422,6 +8422,17 @@ effect on an active recording. The default is off. @item show record btrace pt event-tracing Show the current setting of Intel Processor Trace event tracing. +@item set record btrace pt return-compression on|off +Enable or disable Intel Processor Trace return compression. This is a +hardware compression technique that represents a return to the natural +return address of a preceding call instruction with a single bit. The +trace decoder maintains a stack of active calls and can determine the +return address of such a compressed return. This reduces tracing +overhead and trace size. The default is on. + +@item show record btrace pt return-compression +Show the current setting of Intel Processor Trace return compression. + @kindex info record @item info record Show various statistics about the recording depending on the recording @@ -45843,6 +45854,11 @@ These are the currently defined stub features and their properties: @tab @samp{-} @tab Yes +@item @samp{Qbtrace-conf:pt:return-compression} +@tab Yes +@tab @samp{-} +@tab Yes + @item @samp{QNonStop} @tab No @tab @samp{-} @@ -46185,6 +46201,10 @@ The remote stub understands the @samp{Qbtrace-conf:pt:ptwrite} packet. @item Qbtrace-conf:pt:event-tracing The remote stub understands the @samp{Qbtrace-conf:pt:event-tracing} packet. +@item Qbtrace-conf:pt:return-compression +The remote stub understands the @samp{Qbtrace-conf:pt:return-compression} +packet. + @item swbreak The remote stub reports the @samp{swbreak} stop reason for memory breakpoints. @@ -46754,6 +46774,17 @@ The event-tracing config parameter has been set. A badly formed request or an error was encountered. @end table +@item Qbtrace-conf:pt:return-compression=@var{(yes|no)} +Configure Intel Processor Trace return-compression. + +Reply: +@table @samp +@item OK +The return-compression config parameter has been set. +@item E.errtext +A badly formed request or an error was encountered. +@end table + @end table @node Architecture-Specific Protocol Details @@ -49422,6 +49453,7 @@ The formal DTD for the branch trace configuration format is given below: + @end smallexample @include agentexpr.texi diff --git a/gdb/features/btrace-conf.dtd b/gdb/features/btrace-conf.dtd index 717da623d3e..94b18be63e2 100644 --- a/gdb/features/btrace-conf.dtd +++ b/gdb/features/btrace-conf.dtd @@ -14,3 +14,4 @@ + diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c index 2e0c2eedfbb..8f0c4c1b442 100644 --- a/gdb/nat/linux-btrace.c +++ b/gdb/nat/linux-btrace.c @@ -697,6 +697,10 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf) error (_("Event tracing for record btrace pt is not supported.")); } + tinfo->conf.pt.return_compression = conf->return_compression; + if (!tinfo->conf.pt.return_compression) + tinfo->attr.config |= linux_read_pt_config_bitmask ("noretcomp"); + errno = 0; scoped_fd fd (syscall (SYS_perf_event_open, &tinfo->attr, pid, -1, -1, 0)); if (fd.get () < 0) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index dae243ee2db..30cd8c8b2b6 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -3146,6 +3146,27 @@ set_record_pt_event_tracing_value (const char *args, int from_tty, #endif /* defined (LIBIPT_VERSION >= 0x201) */ } +static bool return_compression = true; + +/* The "record pt return-compression show value function. */ + +static void +show_record_pt_return_compression_value (ui_file *file, int from_tty, + cmd_list_element *c, + const char *value) +{ + gdb_printf (file, _("record pt return-compression is %s.\n"), value); +} + +/* The "record pt return-compression" set value function. */ + +static void +set_record_pt_return_compression_value (const char *args, int from_tty, + cmd_list_element *c) +{ + record_btrace_conf.pt.return_compression = return_compression; +} + /* Initialize btrace commands. */ INIT_GDB_FILE (record_btrace) @@ -3276,6 +3297,20 @@ effect on an active recording."), &set_record_btrace_pt_cmdlist, &show_record_btrace_pt_cmdlist); + add_setshow_boolean_cmd ("return-compression", no_class, + &return_compression, + _("Set return-compression for record pt."), + _("Show return-compression for record pt."), + _("\ +Use \"on\" to enable Intel Processor Trace return compression and \"off\" to\n\ +disable it.\n\ +Without an argument, return-compression is enabled. Changing this setting\n\ +has no effect on an active recording. The default is \"on\"."), + set_record_pt_return_compression_value, + show_record_pt_return_compression_value, + &set_record_btrace_pt_cmdlist, + &show_record_btrace_pt_cmdlist); + add_target (record_btrace_target_info, record_btrace_target_open); record_btrace_conf.bts.size = 64 * 1024; @@ -3286,4 +3321,5 @@ effect on an active recording."), record_btrace_conf.pt.ptwrite = false; #endif record_btrace_conf.pt.event_tracing = false; + record_btrace_conf.pt.return_compression = return_compression; } diff --git a/gdb/remote.c b/gdb/remote.c index e0e508bd0ce..3e564fdd91f 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -373,6 +373,9 @@ enum { /* Support for the Qbtrace-conf:pt:event-tracing packet. */ PACKET_Qbtrace_conf_pt_event_tracing, + /* Support for the Qbtrace-conf:pt:return-compression packet. */ + PACKET_Qbtrace_conf_pt_return_compression, + /* Support for exec events. */ PACKET_exec_event_feature, @@ -6181,6 +6184,8 @@ static const struct protocol_feature remote_protocol_features[] = { PACKET_Qbtrace_conf_pt_ptwrite }, { "Qbtrace-conf:pt:event-tracing", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_conf_pt_event_tracing }, + { "Qbtrace-conf:pt:return-compression", PACKET_DISABLE, + remote_supported_packet, PACKET_Qbtrace_conf_pt_return_compression }, { "vContSupported", PACKET_DISABLE, remote_supported_packet, PACKET_vContSupported }, { "QThreadEvents", PACKET_DISABLE, remote_supported_packet, PACKET_QThreadEvents }, { "QThreadOptions", PACKET_DISABLE, remote_supported_thread_options, @@ -15359,8 +15364,8 @@ parse_xml_btrace_conf_pt (struct gdb_xml_parser *parser, void *user_data, std::vector &attributes) { - struct btrace_config *conf; - struct gdb_xml_value *size, *ptwrite, *event_tracing; + btrace_config *conf; + gdb_xml_value *size, *ptwrite, *event_tracing, *return_compression; conf = (struct btrace_config *) user_data; conf->format = BTRACE_FORMAT_PT; @@ -15377,6 +15382,11 @@ parse_xml_btrace_conf_pt (struct gdb_xml_parser *parser, event_tracing = xml_find_attribute (attributes, "event-tracing"); if (event_tracing != nullptr) conf->pt.event_tracing = (bool) *(ULONGEST *) event_tracing->value.get (); + + return_compression = xml_find_attribute (attributes, "return-compression"); + if (return_compression != nullptr) + conf->pt.return_compression + = (bool) *(ULONGEST *) return_compression->value.get (); } static const struct gdb_xml_attribute btrace_conf_pt_attributes[] = { @@ -15385,6 +15395,8 @@ static const struct gdb_xml_attribute btrace_conf_pt_attributes[] = { gdb_xml_enums_boolean }, { "event-tracing", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum, gdb_xml_enums_boolean }, + { "return-compression", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum, + gdb_xml_enums_boolean }, { NULL, GDB_XML_AF_NONE, NULL, NULL } }; @@ -15551,6 +15563,44 @@ remote_target::btrace_sync_conf (const btrace_config *conf) rs->btrace_config.pt.event_tracing = conf->pt.event_tracing; } + + /* Return compression is a user setting, which is enabled by default on + older targets. Warn if it is set but the target doesn't support + it. */ + if ((m_features.packet_support (PACKET_Qbtrace_conf_pt_return_compression) + != PACKET_ENABLE) + && !conf->pt.return_compression) + warning (_("Target does not support disabling return-compression.")); + + if (m_features.packet_support (PACKET_Qbtrace_conf_pt_return_compression) + == PACKET_ENABLE) + { + pos = buf; + const char *return_compression + = conf->pt.return_compression ? "yes" : "no"; + const char *name + = packets_descriptions[PACKET_Qbtrace_conf_pt_return_compression] + .name; + pos += xsnprintf (pos, endbuf - pos, "%s=\"%s\"", name, + return_compression); + + putpkt (buf); + getpkt (&rs->buf, 0); + + packet_result result + = m_features.packet_ok (buf, + PACKET_Qbtrace_conf_pt_return_compression); + if (result.status () == PACKET_ERROR) + { + if (buf[0] == 'E' && buf[1] == '.') + error (_("Failed to sync return-compression config: %s"), + buf + 2); + else + error (_("Failed to sync return-compression config.")); + } + + rs->btrace_config.pt.return_compression = conf->pt.return_compression; + } } /* Read TP's btrace configuration from the target and store it into CONF. */ @@ -17014,6 +17064,10 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL, "Qbtrace-conf:pt:event-tracing", "btrace-conf-pt-event-tracing", 0); + add_packet_config_cmd (PACKET_Qbtrace_conf_pt_return_compression, + "Qbtrace-conf:pt:return-compression", + "btrace-conf-pt-return-compression", 0); + add_packet_config_cmd (PACKET_vContSupported, "vContSupported", "verbose-resume-supported", 0); diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index c4daba0bf40..7bcb85e641a 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -7025,6 +7025,8 @@ linux_process_target::read_btrace_conf (const btrace_target_info *tinfo, conf->pt.ptwrite ? "yes" : "no"); string_xml_appendf (*buffer, " event-tracing=\"%s\"", conf->pt.event_tracing ? "yes" : "no"); + string_xml_appendf (*buffer, " return-compression=\"%s\"", + conf->pt.return_compression ? "yes" : "no"); string_xml_appendf (*buffer, "/>\n"); break; } diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 74774fcde7c..26837225785 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -568,6 +568,20 @@ handle_btrace_conf_general_set (char *own_buf) return -1; } } + else if (strncmp (op, "pt:return-compression=", + strlen ("pt:return-compression=")) == 0) + { + op += strlen ("pt:return-compression="); + if (strncmp (op, "\"yes\"", strlen ("\"yes\"")) == 0) + current_btrace_conf.pt.return_compression = true; + else if (strncmp (op, "\"no\"", strlen ("\"no\"")) == 0) + current_btrace_conf.pt.return_compression = false; + else + { + strcpy (own_buf, "E.Bad return-compression value."); + return -1; + } + } else { strcpy (own_buf, "E.Bad Qbtrace configuration option."); @@ -2482,6 +2496,7 @@ supported_btrace_packets (char *buf) strcat (buf, ";Qbtrace-conf:pt:size+"); strcat (buf, ";Qbtrace-conf:pt:ptwrite+"); strcat (buf, ";Qbtrace-conf:pt:event-tracing+"); + strcat (buf, ";Qbtrace-conf:pt:return-compression+"); strcat (buf, ";Qbtrace:off+"); strcat (buf, ";qXfer:btrace:read+"); strcat (buf, ";qXfer:btrace-conf:read+"); diff --git a/gdbsupport/btrace-common.h b/gdbsupport/btrace-common.h index 928e471de8f..f2b274c79a7 100644 --- a/gdbsupport/btrace-common.h +++ b/gdbsupport/btrace-common.h @@ -126,6 +126,9 @@ struct btrace_config_pt /* Event tracing setting. */ bool event_tracing; + + /* Return compression setting. */ + bool return_compression; }; /* A branch tracing configuration. -- 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.