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>
CMD_FILE="$(common-objpfx)debugglibc.gdb"
CONTAINER=false
DIRECT=true
+STATIC=false
SYMBOLSFILE=true
unset TESTCASE
unset BREAKPOINTS
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
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
# 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;