[RFC,3/3] gdb: add test for shared library without .text section

Message ID 20200519161431.1577904-4-simon.marchi@efficios.com
State New
Headers show
Series
  • What to do with objfiles with no .text section?
Related show

Commit Message

Simon Marchi via Gdb-patches May 19, 2020, 4:14 p.m.
This is just a raw test to help test the previous patch.
---
 gdb/testsuite/gdb.base/solib-no-text-lib.c  |  1 +
 gdb/testsuite/gdb.base/solib-no-text-main.c |  7 +++++
 gdb/testsuite/gdb.base/solib-no-text.exp    | 30 +++++++++++++++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 gdb/testsuite/gdb.base/solib-no-text-lib.c
 create mode 100644 gdb/testsuite/gdb.base/solib-no-text-main.c
 create mode 100644 gdb/testsuite/gdb.base/solib-no-text.exp

-- 
2.26.2

Patch

diff --git a/gdb/testsuite/gdb.base/solib-no-text-lib.c b/gdb/testsuite/gdb.base/solib-no-text-lib.c
new file mode 100644
index 000000000000..b0d865137ad2
--- /dev/null
+++ b/gdb/testsuite/gdb.base/solib-no-text-lib.c
@@ -0,0 +1 @@ 
+int hello = 1;
diff --git a/gdb/testsuite/gdb.base/solib-no-text-main.c b/gdb/testsuite/gdb.base/solib-no-text-main.c
new file mode 100644
index 000000000000..15e093704f76
--- /dev/null
+++ b/gdb/testsuite/gdb.base/solib-no-text-main.c
@@ -0,0 +1,7 @@ 
+/* Defined in the shared library.  */
+extern int hello;
+
+int main (void)
+{
+  return hello;
+}
diff --git a/gdb/testsuite/gdb.base/solib-no-text.exp b/gdb/testsuite/gdb.base/solib-no-text.exp
new file mode 100644
index 000000000000..b8de1e76e192
--- /dev/null
+++ b/gdb/testsuite/gdb.base/solib-no-text.exp
@@ -0,0 +1,30 @@ 
+# Library file.
+set libname "solib-no-text-lib"
+set srcfile_lib ${srcdir}/${subdir}/${libname}.c
+set binfile_lib [standard_output_file ${libname}.so]
+set lib_flags {debug ldflags=-nodefaultlibs ldflags=-nostdlib}
+
+# Binary file.
+set testfile "solib-no-text-main"
+set srcfile ${srcdir}/${subdir}/${testfile}.c
+set binfile [standard_output_file ${testfile}]
+set bin_flags [list debug shlib=${binfile_lib}]
+
+if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} ${lib_flags}] != "" } {
+    untested "failed to compile shared library"
+    return -1
+}
+
+if { [gdb_compile ${srcfile} ${binfile} executable ${bin_flags}] != "" } {
+    untested "failed to compile executable"
+    return -1
+}
+
+clean_restart ${binfile}
+
+# `message` is important here, if there's an internal error, it will produce a
+# failure.
+runto main message
+
+gdb_test "print hello"
+gdb_test "bt"