From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simon.marchi@polymtl.ca>,
Simon Marchi <simark@simark.ca>,
gdb-patches@sourceware.org
Subject: [committed][gdb/testsuite] Add save_target_board_info
Date: Sun, 20 Dec 2020 09:37:02 +0100 [thread overview]
Message-ID: <ad1fe4f9-9dbf-f21d-c8c8-d005ee121e6f@suse.de> (raw)
In-Reply-To: <0ddc6cbe-880e-7cb7-5754-6a503dcaf80d@polymtl.ca>
[-- Attachment #1: Type: text/plain, Size: 587 bytes --]
[ was: Re: [PATCH][gdb/testsuite] Fix shlib compilation with target
board unix/-pie/-fPIE ]
On 12/20/20 3:29 AM, Simon Marchi wrote:
>
>
> On 2020-12-19 12:44 p.m., Tom de Vries wrote:
>> I thought this over a bit more, and came to the realization that what
>> this does is similar to save_vars, only for target board_info.
>>
>> So, how about this refactoring?
>
> Makes sense, but I would opt for a separate save_target_board_info proc
> instead, it's a bit easier to remember how to use, and will keep each
> implementation simple.
>
Done, committed as attached.
Thanks,
- Tom
[-- Attachment #2: 0001-gdb-testsuite-Add-save_target_board_info.patch --]
[-- Type: text/x-patch, Size: 3687 bytes --]
[gdb/testsuite] Add save_target_board_info
Add a proc save_target_board_info, similar to save_vars, such that we can do:
...
save_target_board_info { multilib_flags } {
global board
set board [target_info name]
unset_board_info multilib_flags
set_board_info multilib_flags "$override_multilib_flags"
...
}
...
and use it in gdb_compile_shlib.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-12-19 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (save_target_board_info): New proc.
(gdb_compile_shlib): Use save_target_board_info.
---
gdb/testsuite/lib/gdb.exp | 75 +++++++++++++++++++++++++++++++++++------------
1 file changed, 56 insertions(+), 19 deletions(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e91023093e..5bdc7ff8ee 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2427,6 +2427,53 @@ proc save_vars { vars body } {
}
}
+# As save_vars, but for variables stored in the board_info for the
+# target board.
+#
+# Usage example:
+#
+# save_target_board_info { multilib_flags } {
+# global board
+# set board [target_info name]
+# unset_board_info multilib_flags
+# set_board_info multilib_flags "$multilib_flags"
+# ...
+# }
+
+proc save_target_board_info { vars body } {
+ global board board_info
+ set board [target_info name]
+
+ array set saved_target_board_info { }
+ set unset_target_board_info { }
+
+ foreach var $vars {
+ if { [info exists board_info($board,$var)] } {
+ set saved_target_board_info($var) [board_info $board $var]
+ } else {
+ lappend unset_target_board_info $var
+ }
+ }
+
+ set code [catch {uplevel 1 $body} result]
+
+ foreach {var value} [array get saved_target_board_info] {
+ unset_board_info $var
+ set_board_info $var $value
+ }
+
+ foreach var $unset_target_board_info {
+ unset_board_info $var
+ }
+
+ if {$code == 1} {
+ global errorInfo errorCode
+ return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
+ } else {
+ return -code $code $result
+ }
+}
+
# Run tests in BODY with the current working directory (CWD) set to
# DIR. When BODY is finished, restore the original CWD. Return the
# result of BODY.
@@ -4422,32 +4469,22 @@ proc gdb_compile_shlib_1 {sources dest options} {
proc gdb_compile_shlib {sources dest options} {
global board
- # Save multilib_flags.
- set board [target_info name]
- set save_multilib_flag [board_info $board multilib_flags]
-
# Ignore PIE-related setting in multilib_flags.
- set multilib_flag ""
- foreach op $save_multilib_flag {
+ set board [target_info name]
+ set multilib_flags_orig [board_info $board multilib_flags]
+ set multilib_flags ""
+ foreach op $multilib_flags_orig {
if { $op == "-pie" || $op == "-no-pie" \
|| $op == "-fPIE" || $op == "-fno-PIE"} {
} else {
- append multilib_flag " $op"
+ append multilib_flags " $op"
}
}
- unset_board_info "multilib_flags"
- set_board_info multilib_flags "$multilib_flag"
- set code [catch {gdb_compile_shlib_1 $sources $dest $options} result]
- # Restore multilib_flags.
- unset_board_info "multilib_flags"
- set_board_info multilib_flags $save_multilib_flag
-
- if {$code == 1} {
- global errorInfo errorCode
- return -code error -errorinfo $errorInfo -errorcode $errorCode $result
- } elseif {$code > 1} {
- return -code $code $result
+ save_target_board_info { multilib_flags } {
+ unset_board_info multilib_flags
+ set_board_info multilib_flags "$multilib_flags"
+ set result [gdb_compile_shlib_1 $sources $dest $options]
}
return $result
prev parent reply other threads:[~2020-12-20 8:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-13 16:41 [PATCH][gdb/testsuite] Fix shlib compilation with target board unix/-pie/-fPIE Tom de Vries
2020-12-14 17:21 ` Simon Marchi
2020-12-16 17:22 ` Tom de Vries
2020-12-19 17:44 ` Tom de Vries
2020-12-20 2:29 ` Simon Marchi via Gdb-patches
2020-12-20 8:37 ` Tom de Vries [this message]
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=ad1fe4f9-9dbf-f21d-c8c8-d005ee121e6f@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
--cc=simon.marchi@polymtl.ca \
/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