Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ilya Leoshkevich via Gdb-patches <gdb-patches@sourceware.org>
To: Tom Tromey <tromey@adacore.com>, Andrew Burgess <aburgess@redhat.com>
Cc: Ulrich Weigand <ulrich.weigand@de.ibm.com>,
	Andreas Arnez <arnez@linux.ibm.com>,
	gdb-patches@sourceware.org, Pedro Alves <pedro@palves.net>,
	Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH v2 3/7] gdb.perf/: Allow adjusting GenPerfTest compile options
Date: Tue, 31 May 2022 00:11:43 +0200	[thread overview]
Message-ID: <20220530221147.1991835-4-iii@linux.ibm.com> (raw)
In-Reply-To: <20220530221147.1991835-1-iii@linux.ibm.com>

Introduce new callbacks to adjust the compile options based on
certain criteria: the total number of shared objects for the binary and
the shared object index for shared objects (no criteria are defined for
the tail shared object at the moment).  This is useful for setting
shared objects' load addresses in performance tests.
---
 gdb/testsuite/lib/gen-perf-test.exp | 32 ++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/lib/gen-perf-test.exp b/gdb/testsuite/lib/gen-perf-test.exp
index 07007db0834..eab6b5499d4 100644
--- a/gdb/testsuite/lib/gen-perf-test.exp
+++ b/gdb/testsuite/lib/gen-perf-test.exp
@@ -76,6 +76,9 @@ namespace eval GenPerfTest {
     # Header files used by generated files and extra sources.
     set DEFAULT_BINARY_EXTRA_HEADERS {}
 
+    # The name of the function that adjusts binary's compile options.
+    set DEFAULT_BINARY_ADJUST_COMPILE_OPTIONS GenPerfTest::default_adjust_compile_options
+
     # Extra source files for each generated shlib.
     # The compiler passes -DSHLIB=NNN which the source can use, for example,
     # to define unique symbols for each shlib.
@@ -84,6 +87,10 @@ namespace eval GenPerfTest {
     # Header files used by generated files and extra sources.
     set DEFAULT_GEN_SHLIB_EXTRA_HEADERS {}
 
+    # The name of the function that adjusts each generated shlib's compile
+    # options.
+    set DEFAULT_GEN_SHLIB_ADJUST_COMPILE_OPTIONS GenPerfTest::default_adjust_compile_options
+
     # Source files for a tail shlib, or empty if none.
     # This library is loaded after all other shlibs (except any system shlibs
     # like libstdc++).  It is useful for exercising issues that can appear
@@ -94,6 +101,9 @@ namespace eval GenPerfTest {
     # Header files for the tail shlib.
     set DEFAULT_TAIL_SHLIB_HEADERS {}
 
+    # The name of the function that adjusts tail shlib's compile options.
+    set DEFAULT_TAIL_SHLIB_ADJUST_COMPILE_OPTIONS GenPerfTest::default_adjust_compile_options
+
     # The number of shared libraries to create.
     set DEFAULT_NR_GEN_SHLIBS 0
 
@@ -184,6 +194,12 @@ namespace eval GenPerfTest {
     set source_suffixes(c) "c"
     set source_suffixes(c++) "cc"
 
+    # Do not adjust any compile options by default.
+
+    proc default_adjust_compile_options { options args } {
+	return $options
+    }
+
     # Generate .worker files that control building all the "pieces" of the
     # testcase.  This doesn't include "main" or any test-specific stuff.
     # This mostly consists of the "bulk" (aka "crap" :-)) of the testcase to
@@ -251,10 +267,13 @@ namespace eval GenPerfTest {
 	set testcase(run_names) [list $name]
 	set testcase(binary_extra_sources) $GenPerfTest::DEFAULT_BINARY_EXTRA_SOURCES
 	set testcase(binary_extra_headers) $GenPerfTest::DEFAULT_BINARY_EXTRA_HEADERS
+	set testcase(binary_adjust_compile_options) $GenPerfTest::DEFAULT_BINARY_ADJUST_COMPILE_OPTIONS
 	set testcase(gen_shlib_extra_sources) $GenPerfTest::DEFAULT_GEN_SHLIB_EXTRA_SOURCES
 	set testcase(gen_shlib_extra_headers) $GenPerfTest::DEFAULT_GEN_SHLIB_EXTRA_HEADERS
+	set testcase(gen_shlib_adjust_compile_options) $GenPerfTest::DEFAULT_GEN_SHLIB_ADJUST_COMPILE_OPTIONS
 	set testcase(tail_shlib_sources) $GenPerfTest::DEFAULT_TAIL_SHLIB_SOURCES
 	set testcase(tail_shlib_headers) $GenPerfTest::DEFAULT_TAIL_SHLIB_HEADERS
+	set testcase(tail_shlib_adjust_compile_options) $GenPerfTest::DEFAULT_TAIL_SHLIB_ADJUST_COMPILE_OPTIONS
 	set testcase(nr_gen_shlibs) $GenPerfTest::DEFAULT_NR_GEN_SHLIBS
 	set testcase(nr_compunits) $GenPerfTest::DEFAULT_NR_COMPUNITS
 	set testcase(binary_link_with_shlibs) $GenPerfTest::DEFAULT_BINARY_LINK_WITH_SHLIBS
@@ -282,9 +301,9 @@ namespace eval GenPerfTest {
     proc _verify_parameter_lengths { self_var } {
 	upvar 1 $self_var self
 	set params {
-	    binary_extra_sources binary_extra_headers
-	    gen_shlib_extra_sources gen_shlib_extra_headers
-	    tail_shlib_sources tail_shlib_headers
+	    binary_extra_sources binary_extra_headers binary_adjust_compile_options
+	    gen_shlib_extra_sources gen_shlib_extra_headers gen_shlib_adjust_compile_options
+	    tail_shlib_sources tail_shlib_headers tail_shlib_adjust_compile_options
 	    nr_gen_shlibs nr_compunits binary_link_with_shlibs
 	    nr_extern_globals nr_static_globals
 	    nr_extern_functions nr_static_functions
@@ -1174,6 +1193,8 @@ namespace eval GenPerfTest {
 	set extra_headers [_get_param $self(gen_shlib_extra_headers) $run_nr]
 	set shlib_file [_make_shlib_name self $static $run_nr $so_nr]
 	set compile_options "[_compile_options self] additional_flags=-DSHLIB=$so_nr"
+	set adjust_compile_options [_get_param $self(gen_shlib_adjust_compile_options) $run_nr]
+	set compile_options [$adjust_compile_options $compile_options [expr $so_nr + 1]]
 	set all_header_files $header_files
 	append all_header_files $extra_headers
 	set compile_result [_perftest_compile self $source_files $all_header_files $shlib_file shlib $compile_options]
@@ -1218,6 +1239,8 @@ namespace eval GenPerfTest {
 	set header_files [_get_param $self(tail_shlib_headers) $run_nr]
 	set shlib_file [_make_tail_shlib_name self $static $run_nr]
 	set compile_options [_compile_options self]
+	set adjust_compile_options [_get_param $self(tail_shlib_adjust_compile_options) $run_nr]
+	set compile_options [$adjust_compile_options $compile_options]
 	set compile_result [_perftest_compile self $source_files $header_files $shlib_file shlib $compile_options]
 	if { $compile_result != "" } {
 	    verbose -log "_compile_tail_shlib failed: $compile_result"
@@ -1322,6 +1345,9 @@ namespace eval GenPerfTest {
 	set extra_headers [_get_param $self(binary_extra_headers) $run_nr]
 	set binary_file [_make_binary_name self $run_nr]
 	set compile_options [_compile_options self]
+	set adjust_compile_options [_get_param $self(binary_adjust_compile_options) $run_nr]
+	set nr_gen_shlibs [_get_param $self(nr_gen_shlibs) $run_nr]
+	set compile_options [$adjust_compile_options $compile_options $nr_gen_shlibs]
 	set shlib_options [_make_shlib_options self $static $run_nr]
 	if { [llength $shlib_options] > 0 } {
 	    append compile_options " " $shlib_options
-- 
2.35.3


  parent reply	other threads:[~2022-05-30 22:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-30 22:11 [PATCH v2 0/7] gdb.perf/: Add JIT performance test Ilya Leoshkevich via Gdb-patches
2022-05-30 22:11 ` [PATCH v2 1/7] gdb.perf/: Fix tcl_string_list_to_python_list {x} Ilya Leoshkevich via Gdb-patches
2022-05-30 22:11 ` [PATCH v2 2/7] gdb.perf/: Add binary_link_with_shlibs setting to GenPerfTest Ilya Leoshkevich via Gdb-patches
2022-05-30 22:11 ` Ilya Leoshkevich via Gdb-patches [this message]
2022-05-30 22:11 ` [PATCH v2 4/7] gdb.base/: Introduce jit-protocol-util.h Ilya Leoshkevich via Gdb-patches
2022-05-30 22:11 ` [PATCH v2 5/7] gdb.base/: Introduce jit_compile_options Ilya Leoshkevich via Gdb-patches
2022-05-30 22:11 ` [PATCH v2 6/7] gdb.base/: Introduce n_jit_so_address Ilya Leoshkevich via Gdb-patches
2022-05-30 22:11 ` [PATCH v2 7/7] gdb.perf/: Add JIT performance test Ilya Leoshkevich via Gdb-patches
2022-06-22  8:48 ` [PING] [PATCH v2 0/7] " Ilya Leoshkevich via Gdb-patches
2022-08-03 10:52 ` [PING^2] " Ilya Leoshkevich via Gdb-patches

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=20220530221147.1991835-4-iii@linux.ibm.com \
    --to=gdb-patches@sourceware.org \
    --cc=aburgess@redhat.com \
    --cc=arnez@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=pedro@palves.net \
    --cc=tromey@adacore.com \
    --cc=ulrich.weigand@de.ibm.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