public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [RFC PATCH 3/3] gdb: add test for shared library without .text section
Date: Tue, 19 May 2020 12:14:31 -0400	[thread overview]
Message-ID: <20200519161431.1577904-4-simon.marchi@efficios.com> (raw)
In-Reply-To: <20200519161431.1577904-1-simon.marchi@efficios.com>

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

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"
-- 
2.26.2


      parent reply	other threads:[~2020-05-19 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19 16:14 [RFC PATCH 0/3] What to do with objfiles with no .text section? Simon Marchi
2020-05-19 16:14 ` [RFC PATCH 1/3] gdb: remove symfile_find_segment_sections and part of init_objfile_sect_indices Simon Marchi
2020-05-19 16:14 ` [RFC PATCH 2/3] gdb: fix a few spots to not assume that we have a .text section Simon Marchi
2020-05-19 16:14 ` Simon Marchi [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=20200519161431.1577904-4-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).