aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2020-10-12 10:35:23 +0100
committerGary Benson <gbenson@redhat.com>2020-10-12 10:35:23 +0100
commit71e1b6b0ac9403d7fda91890f0d2881b6d1697d6 (patch)
tree85f3c5b9ab72187adc8b727393b7398ab877f16a /gdb
parent8a6e98c4a3049d7fb8ffc24b231e8cf3577fd90a (diff)
downloadgdb-71e1b6b0ac9403d7fda91890f0d2881b6d1697d6.zip
gdb-71e1b6b0ac9403d7fda91890f0d2881b6d1697d6.tar.gz
gdb-71e1b6b0ac9403d7fda91890f0d2881b6d1697d6.tar.bz2
Fix testcases with required but unreferenced functions and variables
A number of testcases define variables and/or functions which are referenced by GDB during the test, but which are not referenced from within the test executable. Clang correctly recognizes that these variables and functions are unused, and optimizes them out, causing the testcases in question to fail. This commit adds __attribute__ ((used)) in various places to prevent this. gdb/testsuite/ChangeLog: * gdb.base/msym-bp.c (foo): Add __attribute__ ((used)). * gdb.base/msym-bp-2.c (foo): Likewise. * gdb.base/msym-lang.c (foo): Likewise. * gdb.base/msym-lang-main.c (foo): Likewise. * gdb.base/symtab-search-order-1.c (static_global): Likewise. * gdb.guile/scm-pretty-print.c (eval_func): Likewise. * gdb.mi/mi-sym-info-1.c (global_f1): Likewise. * gdb.mi/mi-sym-info-2.c (global_f1, var1, var2): Likewise. * gdb.multi/watchpoint-multi-exit.c (globalvar): Likewise. * gdb.python/py-as-string.c (enum_valid, enum_invalid): Likewise. * gdb.python/py-objfile.c (static_var): Likewise. * gdb.python/py-symbol.c (rr): Likewise. * gdb.python/py-symbol-2.c (anon, rr): Likewise. * gdb.mi/mi-sym-info.exp (lineno1, lineno2): Updated.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog17
-rw-r--r--gdb/testsuite/gdb.base/msym-bp-2.c2
-rw-r--r--gdb/testsuite/gdb.base/msym-bp.c2
-rw-r--r--gdb/testsuite/gdb.base/msym-lang-main.c2
-rw-r--r--gdb/testsuite/gdb.base/msym-lang.c2
-rw-r--r--gdb/testsuite/gdb.base/symtab-search-order-1.c2
-rw-r--r--gdb/testsuite/gdb.guile/scm-pretty-print.c2
-rw-r--r--gdb/testsuite/gdb.mi/mi-sym-info-1.c2
-rw-r--r--gdb/testsuite/gdb.mi/mi-sym-info-2.c6
-rw-r--r--gdb/testsuite/gdb.mi/mi-sym-info.exp4
-rw-r--r--gdb/testsuite/gdb.multi/watchpoint-multi-exit.c2
-rw-r--r--gdb/testsuite/gdb.python/py-as-string.c4
-rw-r--r--gdb/testsuite/gdb.python/py-objfile.c2
-rw-r--r--gdb/testsuite/gdb.python/py-symbol-2.c2
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.c4
15 files changed, 36 insertions, 19 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2e8efd9..aefdcba 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,20 @@
+2020-10-12 Gary Benson <gbenson@redhat.com>
+
+ * gdb.base/msym-bp.c (foo): Add __attribute__ ((used)).
+ * gdb.base/msym-bp-2.c (foo): Likewise.
+ * gdb.base/msym-lang.c (foo): Likewise.
+ * gdb.base/msym-lang-main.c (foo): Likewise.
+ * gdb.base/symtab-search-order-1.c (static_global): Likewise.
+ * gdb.guile/scm-pretty-print.c (eval_func): Likewise.
+ * gdb.mi/mi-sym-info-1.c (global_f1): Likewise.
+ * gdb.mi/mi-sym-info-2.c (global_f1, var1, var2): Likewise.
+ * gdb.multi/watchpoint-multi-exit.c (globalvar): Likewise.
+ * gdb.python/py-as-string.c (enum_valid, enum_invalid): Likewise.
+ * gdb.python/py-objfile.c (static_var): Likewise.
+ * gdb.python/py-symbol.c (rr): Likewise.
+ * gdb.python/py-symbol-2.c (anon, rr): Likewise.
+ * gdb.mi/mi-sym-info.exp (lineno1, lineno2): Updated.
+
2020-10-11 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.fortran/mixed-lang-stack.exp (run_tests): Update expected
diff --git a/gdb/testsuite/gdb.base/msym-bp-2.c b/gdb/testsuite/gdb.base/msym-bp-2.c
index b5a399e..7cdf43c 100644
--- a/gdb/testsuite/gdb.base/msym-bp-2.c
+++ b/gdb/testsuite/gdb.base/msym-bp-2.c
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-void
+void __attribute__ ((used))
foo (void)
{
}
diff --git a/gdb/testsuite/gdb.base/msym-bp.c b/gdb/testsuite/gdb.base/msym-bp.c
index 2257d3f..80ffef0 100644
--- a/gdb/testsuite/gdb.base/msym-bp.c
+++ b/gdb/testsuite/gdb.base/msym-bp.c
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-static void
+static void __attribute__ ((used))
foo (void)
{
}
diff --git a/gdb/testsuite/gdb.base/msym-lang-main.c b/gdb/testsuite/gdb.base/msym-lang-main.c
index 180ba9d..192047d 100644
--- a/gdb/testsuite/gdb.base/msym-lang-main.c
+++ b/gdb/testsuite/gdb.base/msym-lang-main.c
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-static int
+static int __attribute__ ((used))
foo (void)
{
return 2;
diff --git a/gdb/testsuite/gdb.base/msym-lang.c b/gdb/testsuite/gdb.base/msym-lang.c
index 5820e0d..38e969d 100644
--- a/gdb/testsuite/gdb.base/msym-lang.c
+++ b/gdb/testsuite/gdb.base/msym-lang.c
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-static int
+static int __attribute__ ((used))
foo (void)
{
return 1;
diff --git a/gdb/testsuite/gdb.base/symtab-search-order-1.c b/gdb/testsuite/gdb.base/symtab-search-order-1.c
index 09e1006..a71d5f7 100644
--- a/gdb/testsuite/gdb.base/symtab-search-order-1.c
+++ b/gdb/testsuite/gdb.base/symtab-search-order-1.c
@@ -15,4 +15,4 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-static int static_global = 23;
+static int __attribute__ ((used)) static_global = 23;
diff --git a/gdb/testsuite/gdb.guile/scm-pretty-print.c b/gdb/testsuite/gdb.guile/scm-pretty-print.c
index 7072f26..7b453ff 100644
--- a/gdb/testsuite/gdb.guile/scm-pretty-print.c
+++ b/gdb/testsuite/gdb.guile/scm-pretty-print.c
@@ -230,7 +230,7 @@ struct nullstr
struct string_repr string_1 = { { "one" } };
struct string_repr string_2 = { { "two" } };
-static int
+static int __attribute__ ((used))
eval_func (int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8)
{
return p1;
diff --git a/gdb/testsuite/gdb.mi/mi-sym-info-1.c b/gdb/testsuite/gdb.mi/mi-sym-info-1.c
index c96a6be..33d355b 100644
--- a/gdb/testsuite/gdb.mi/mi-sym-info-1.c
+++ b/gdb/testsuite/gdb.mi/mi-sym-info-1.c
@@ -22,7 +22,7 @@ extern int global_i2;
extern float global_f2;
static int global_i1;
-static float global_f1;
+static float __attribute__ ((used)) global_f1;
typedef int my_int_t;
diff --git a/gdb/testsuite/gdb.mi/mi-sym-info-2.c b/gdb/testsuite/gdb.mi/mi-sym-info-2.c
index f514e42..8b17029 100644
--- a/gdb/testsuite/gdb.mi/mi-sym-info-2.c
+++ b/gdb/testsuite/gdb.mi/mi-sym-info-2.c
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
static int global_i1;
-static float global_f1;
+static float __attribute__ ((used)) global_f1;
int global_i2;
int global_f2;
@@ -44,5 +44,5 @@ f3 (another_int_t arg)
typedef char another_char_t;
typedef short another_short_t;
-static another_char_t var1;
-static another_short_t var2;
+static another_char_t __attribute__ ((used)) var1;
+static another_short_t __attribute__ ((used)) var2;
diff --git a/gdb/testsuite/gdb.mi/mi-sym-info.exp b/gdb/testsuite/gdb.mi/mi-sym-info.exp
index 859dabd..152a186 100644
--- a/gdb/testsuite/gdb.mi/mi-sym-info.exp
+++ b/gdb/testsuite/gdb.mi/mi-sym-info.exp
@@ -236,8 +236,8 @@ mi_gdb_test "118-symbol-info-variables --name global_f2" \
"118\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"21\",name=\"global_f2\",type=\"int\",description=\"int global_f2;\"\}\\\]\}\\\]\}" \
"List all variables matching pattern global_f2"
-set lineno1 [gdb_get_line_number "static float global_f1;" ${srcfile}]
-set lineno2 [gdb_get_line_number "static float global_f1;" ${srcfile2}]
+set lineno1 [gdb_get_line_number "static float __attribute__ ((used)) global_f1;" ${srcfile}]
+set lineno2 [gdb_get_line_number "static float __attribute__ ((used)) global_f1;" ${srcfile2}]
mi_gdb_test "119-symbol-info-variables --type float --name ^global_" \
"119\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[\{line=\"25\",name=\"global_f1\",type=\"float\",description=\"static float global_f1;\"\}\\\]\},\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"19\",name=\"global_f1\",type=\"float\",description=\"static float global_f1;\"\}\\\]\}\\\]\}" \
"List all variables matching type float"
diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi-exit.c b/gdb/testsuite/gdb.multi/watchpoint-multi-exit.c
index 3231b70..fb9a1f6 100644
--- a/gdb/testsuite/gdb.multi/watchpoint-multi-exit.c
+++ b/gdb/testsuite/gdb.multi/watchpoint-multi-exit.c
@@ -21,7 +21,7 @@
#include <sys/wait.h>
/* GDB sets watchpoint here. */
-static volatile int globalvar;
+static volatile int __attribute__ ((used)) globalvar;
/* Whether it's expected that the child exits with a signal, vs
exiting normally. GDB sets this. */
diff --git a/gdb/testsuite/gdb.python/py-as-string.c b/gdb/testsuite/gdb.python/py-as-string.c
index 245bcb2..0256336 100644
--- a/gdb/testsuite/gdb.python/py-as-string.c
+++ b/gdb/testsuite/gdb.python/py-as-string.c
@@ -22,8 +22,8 @@ enum EnumType {
ENUM_VALUE_D,
};
-static enum EnumType enum_valid = ENUM_VALUE_B;
-static enum EnumType enum_invalid = (enum EnumType) 20;
+static enum EnumType __attribute__ ((used)) enum_valid = ENUM_VALUE_B;
+static enum EnumType __attribute__ ((used)) enum_invalid = (enum EnumType) 20;
int
main ()
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index e8b9e83..326d9a0 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
int global_var = 42;
-static int static_var = 50;
+static int __attribute__ ((used)) static_var = 50;
int
main ()
diff --git a/gdb/testsuite/gdb.python/py-symbol-2.c b/gdb/testsuite/gdb.python/py-symbol-2.c
index 8bc78b9..fdc4efd 100644
--- a/gdb/testsuite/gdb.python/py-symbol-2.c
+++ b/gdb/testsuite/gdb.python/py-symbol-2.c
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-static int rr = 99; /* line of other rr */
+static int __attribute__ ((used)) rr = 99; /* line of other rr */
void
function_in_other_file (void)
diff --git a/gdb/testsuite/gdb.python/py-symbol.c b/gdb/testsuite/gdb.python/py-symbol.c
index 44f87bc..e04f6b8 100644
--- a/gdb/testsuite/gdb.python/py-symbol.c
+++ b/gdb/testsuite/gdb.python/py-symbol.c
@@ -34,7 +34,7 @@ class SimpleClass
};
namespace {
- int anon = 10;
+ int __attribute__ ((used)) anon = 10;
};
#endif
@@ -43,7 +43,7 @@ extern void function_in_other_file (void);
#endif
int qq = 72; /* line of qq */
-static int rr = 42; /* line of rr */
+static int __attribute__ ((used)) rr = 42; /* line of rr */
int func (int arg)
{