From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: Add prms_id and bug_id to the ARI?
Date: Sat, 08 May 2010 19:50:00 -0000 [thread overview]
Message-ID: <20100508195016.GA7479@adacore.com> (raw)
In-Reply-To: <m3eihnhd54.fsf@fleche.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 641 bytes --]
> You could try putting this into gdb.exp somewhere:
>
> proc gdb_trace_error {name ignore op} {
> error "Attempt to write to $name."
> }
>
> trace variable prms_id w gdb_trace_error
> trace variable bug_id w gdb_trace_error
Nice trick! Attached is a patch that implements something along those
lines... Ideally, we would really like to check any use of these
variables (including reads and unsets), but these variable do get
accessed during the run (computing some pass strings). In practice,
all the uses I've found were setting them, so it is probably going
to be good enough.
Tested on x86_64-linux.
--
Joel
[-- Attachment #2: verbotten.diff --]
[-- Type: text/x-diff, Size: 1906 bytes --]
commit 35e9b1f2ec01514d8455c0366f77ab4e196da8f8
Author: Joel Brobecker <brobecker@adacore.com>
Date: Sat May 8 12:20:36 2010 -0700
testsuite: Prevent writes to prms_id and bug_id.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (banned_variables): New variable/constant.
(gdb_init): Add write trace on variables listed in banned_variables.
(gdb_finish): Remove write traces on variables listed in
banned_variables.
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8be2a72..70df5ea 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2480,6 +2480,11 @@ if ![info exists gdb_test_timeout] {
set gdb_test_timeout $timeout
}
+# A list of global variables that GDB testcases should not use.
+# We try to prevent their use by monitoring write accesses and raising
+# an error when that happens.
+set banned_variables { bug_id prms_id }
+
proc gdb_init { args } {
# Reset the timeout value to the default. This way, any testcase
# that changes the timeout value without resetting it cannot affect
@@ -2488,6 +2493,13 @@ proc gdb_init { args } {
global timeout
set timeout $gdb_test_timeout
+ # Block writes to all banned variables...
+ global banned_variables
+ foreach banned_var $banned_variables {
+ global "$banned_var"
+ trace variable "$banned_var" w error
+ }
+
return [eval default_gdb_init $args];
}
@@ -2501,6 +2513,14 @@ proc gdb_finish { } {
eval remote_file target delete $cleanfiles
set cleanfiles {}
}
+
+ # Unblock write access to the banned variables. Dejagnu typically
+ # resets some of them between testcases.
+ global banned_variables
+ foreach banned_var $banned_variables {
+ global "$banned_var"
+ trace remove variable "$banned_var" write error
+ }
}
global debug_format
next prev parent reply other threads:[~2010-05-08 19:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 18:16 Joel Brobecker
2010-05-05 18:23 ` Pedro Alves
2010-05-05 18:29 ` Joel Brobecker
2010-05-05 18:32 ` Pedro Alves
2010-05-07 16:48 ` Tom Tromey
2010-05-08 19:50 ` Joel Brobecker [this message]
2010-05-17 17:20 ` Joel Brobecker
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=20100508195016.GA7479@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.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