public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Gabriel F.T.Gomes <gftg@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] Do not use ld.so to open statically linked programs in debugglibc.sh
Date: Wed, 04 Dec 2019 17:01:00 -0000	[thread overview]
Message-ID: <20191204170147.97647.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d0bc5b725dac852764b98b9b3e0560c003bd000a

commit d0bc5b725dac852764b98b9b3e0560c003bd000a
Author: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Date:   Tue Dec 3 22:40:38 2019 -0300

    Do not use ld.so to open statically linked programs in debugglibc.sh
    
    Debugging programs that have been dynamically linked against an
    uninstalled glibc requires unusual steps, such as letting gdb know where
    the thread db library is located and explicitly calling the loader.
    However, when the program under test is statically linked, these steps
    are not required (as a matter of fact, using the dynamic loader to run a
    statically linked program is wrong and will fail), and gdb should be
    called the usual way.
    
    This patch modifies debugglibc.sh so that it checks if the program under
    test is statically linked, then runs the debugger appropriately.
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>

Diff:
---
 Makefile | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 924fdb6..b43226c 100644
--- a/Makefile
+++ b/Makefile
@@ -209,6 +209,7 @@ BUILD_DIR="$(common-objpfx)"
 CMD_FILE="$(common-objpfx)debugglibc.gdb"
 CONTAINER=false
 DIRECT=true
+STATIC=false
 SYMBOLSFILE=true
 unset TESTCASE
 unset BREAKPOINTS
@@ -297,8 +298,8 @@ do
   shift
 done
 
-# Check for required argument
-if [ ! -v TESTCASE ]
+# Check for required argument and if the testcase exists
+if [ ! -v TESTCASE ] || [ ! -f $${TESTCASE} ]
 then
   usage
   exit 1
@@ -318,6 +319,14 @@ else
   DIRECT=""
 fi
 
+# Check if the test case is static
+if file $${TESTCASE} | grep "statically linked" >/dev/null
+then
+  STATIC=true
+else
+  STATIC=false
+fi
+
 # Expand symbols loading command
 if [ "$$SYMBOLSFILE" == true ]
 then
@@ -366,6 +375,9 @@ then
 # automatically attach GDB to it.
 WAIT_FOR_DEBUGGER=1 $(common-objpfx)testrun.sh --tool=container $${TESTCASE} &
 gdb -x $${TESTCASE}.gdb
+elif [ "$$STATIC" == true ]
+then
+gdb $${TESTCASE}
 else
 # Start the test case debugging in two steps:
 #   1. the following command invokes gdb to run the loader;


                 reply	other threads:[~2019-12-04 17:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20191204170147.97647.qmail@sourceware.org \
    --to=gftg@sourceware.org \
    --cc=glibc-cvs@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).