public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Felix Willgerodt <felix.willgerodt@intel.com>
To: markus.t.metzger@intel.com, gdb-patches@sourceware.org
Subject: [PATCH v3 11/12] gdb, testsuite, lib: Add libipt version check.
Date: Wed, 16 Jun 2021 09:42:04 +0200	[thread overview]
Message-ID: <20210616074205.1129553-12-felix.willgerodt@intel.com> (raw)
In-Reply-To: <20210616074205.1129553-1-felix.willgerodt@intel.com>

This adds a version test for libipt, which is needed by future commits.

gdb/testsuite/ChangeLog:
2021-06-14  Felix Willgerodt  <felix.willgerodt@intel.com>

	* lib/gdb.exp (version_at_least): Add revision args.
	(tcl_version_at_least): Adjust call of version_at_least.
	(readelf_prints_pie): Same.
	(require_libipt_version): New function.
---
 gdb/testsuite/lib/gdb.exp | 69 +++++++++++++++++++++++++++++++++++----
 1 file changed, 63 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 4bb2da31c1f..a060b1767e5 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1313,12 +1313,18 @@ proc gdb_test { args } {
     return [gdb_test_multiple $command $message $user_code]
 }
 
-# Return 1 if version MAJOR.MINOR is at least AT_LEAST_MAJOR.AT_LEAST_MINOR.
-proc version_at_least { major minor at_least_major at_least_minor} {
+# Return 1 if version MAJOR.MINOR.REVISION is at least
+# AT_LEAST_MAJOR.AT_LEAST_MINOR.AT_LEAST_REVISION.
+proc version_at_least { major minor revision at_least_major at_least_minor \
+			at_least_revision } {
     if { $major > $at_least_major } {
         return 1
     } elseif { $major == $at_least_major \
-		   && $minor >= $at_least_minor } {
+		   && $minor > $at_least_minor } {
+        return 1
+    } elseif { $major == $at_least_major \
+		   && $minor == $at_least_minor \
+		   && $revision >= $at_least_revision } {
         return 1
     } else {
         return 0
@@ -1330,8 +1336,8 @@ proc tcl_version_at_least { major minor } {
     global tcl_version
     regexp {^([0-9]+)\.([0-9]+)$} $tcl_version \
 	dummy tcl_version_major tcl_version_minor
-    return [version_at_least $tcl_version_major $tcl_version_minor \
-		$major $minor]
+    return [version_at_least $tcl_version_major $tcl_version_minor 0 \
+		$major $minor 0]
 }
 
 if { [tcl_version_at_least 8 5] == 0 } {
@@ -3451,6 +3457,57 @@ gdb_caching_proc skip_btrace_pt_tests {
     return $skip_btrace_tests
 }
 
+# Run a test on the target to see if we have a minimum libipt version.
+# Return 0 if so, 1 if it does not.
+
+proc require_libipt_version { major minor revision } {
+    global srcdir subdir gdb_prompt inferior_exited_re
+
+    set me "libipt_version_tests"
+    if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
+        verbose "$me:  target does not support btrace, returning 1" 2
+        return 1
+    }
+
+    # Compile a test program.
+    set src { int main() { return 0; } }
+    if {![gdb_simple_compile $me $src executable]} {
+        return 1
+    }
+
+    # No error message, compilation succeeded so now run it via gdb.
+
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load $obj
+    if ![runto_main] {
+        return 1
+    }
+
+    gdb_test_no_output "record btrace pt" "$me: record btrace pt"
+    set actual_major ""
+    set actual_minor ""
+    set actual_revision ""
+    gdb_test_multiple "maint info btrace" "$me: maint info btrace" {
+	-re ".*Version: (\[0-9\]+)\.(\[0-9\]+)\.(\[0-9\]+).*$gdb_prompt $" {
+	    append actual_major $expect_out(1,string)
+	    append actual_minor $expect_out(2,string)
+	    append actual_revision $expect_out(3,string)
+	}
+	default {}
+    }
+
+    gdb_exit
+    remote_file build delete $obj
+
+    verbose "$me: Using version: $actual_major.$actual_minor.$actual_revision" 2
+    verbose "$me: Required minimum version: $major.$minor.$revision" 2
+
+    return [expr ![version_at_least $actual_major $actual_minor \
+		   $actual_revision $major $minor $revision]]
+}
+
 # Run a test on the target to see if it supports Aarch64 SVE hardware.
 # Return 0 if so, 1 if it does not.  Note this causes a restart of GDB.
 
@@ -6059,7 +6116,7 @@ proc readelf_prints_pie { } {
     # flag is printed by readelf, but we cannot reliably construct a PIE
     # executable if the multilib_flags dictate otherwise
     # (--target_board=unix/-no-pie/-fno-PIE).
-    return [version_at_least $major $minor 2 26]
+    return [version_at_least $major $minor 0 2 26 0]
 }
 
 # Return 1 if EXECUTABLE is a Position Independent Executable, 0 if it is not,
-- 
2.25.4

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  parent reply	other threads:[~2021-06-16  7:46 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16  7:41 [PATCH v3 00/12] Extensions for PTWRITE Felix Willgerodt
2021-06-16  7:41 ` [PATCH v3 01/12] btrace: Introduce auxiliary instructions Felix Willgerodt
2021-08-12 11:06   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix
2021-06-16  7:41 ` [PATCH v3 02/12] btrace: Enable auxiliary instructions in record instruction-history Felix Willgerodt
2021-08-12 11:06   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix
2021-06-16  7:41 ` [PATCH v3 03/12] btrace: Enable auxiliary instructions in record function-call-history Felix Willgerodt
2021-08-12 11:14   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix
2021-06-16  7:41 ` [PATCH v3 04/12] btrace: Handle stepping and goto for auxiliary instructions Felix Willgerodt
2021-08-12 11:07   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix
2021-06-16  7:41 ` [PATCH v3 05/12] python: Introduce gdb.RecordAuxiliary class Felix Willgerodt
2021-08-12 11:07   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix
2021-06-16  7:41 ` [PATCH v3 06/12] python: Add clear() to gdb.Record Felix Willgerodt
2021-08-12 11:07   ` Metzger, Markus T
2021-06-16  7:42 ` [PATCH v3 07/12] btrace, gdbserver: Add ptwrite to btrace_config_pt Felix Willgerodt
2021-08-12 11:07   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix
2022-05-10 13:59       ` Metzger, Markus T
2022-06-24  6:57         ` Willgerodt, Felix
2021-06-16  7:42 ` [PATCH v3 08/12] btrace, linux: Enable ptwrite packets Felix Willgerodt
2021-08-12 11:07   ` Metzger, Markus T
2021-06-16  7:42 ` [PATCH v3 09/12] btrace, python: Enable ptwrite listener registration Felix Willgerodt
2021-08-13 10:36   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix
2022-05-30 14:55       ` Metzger, Markus T
2022-05-31 11:26         ` Willgerodt, Felix
2022-05-31 11:50           ` Eli Zaretskii
2021-06-16  7:42 ` [PATCH v3 10/12] btrace, python: Enable calling the ptwrite listener Felix Willgerodt
2021-08-13 10:36   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix
2022-05-30 15:01       ` Metzger, Markus T
2021-06-16  7:42 ` Felix Willgerodt [this message]
2021-08-13 10:36   ` [PATCH v3 11/12] gdb, testsuite, lib: Add libipt version check Metzger, Markus T
2022-05-02  9:55     ` Willgerodt, Felix
2021-06-16  7:42 ` [PATCH v3 12/12] btrace: Extend ptwrite event decoding Felix Willgerodt
2021-06-17  7:00   ` Eli Zaretskii
2021-06-17 11:51     ` Willgerodt, Felix
2021-08-13 13:36   ` Metzger, Markus T
2022-05-06 11:26     ` Willgerodt, Felix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210616074205.1129553-12-felix.willgerodt@intel.com \
    --to=felix.willgerodt@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).