tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Base GDB tracing 32bit applications on amd64 kernel (with 64bit debugger) part 1)



test case

Index: t_regress.sh
===================================================================
RCS file: /cvsroot/src/tests/usr.bin/gdb/t_regress.sh,v
retrieving revision 1.2
diff -u -r1.2 t_regress.sh
--- t_regress.sh	7 Jun 2019 19:05:15 -0000	1.2
+++ t_regress.sh	25 Jun 2019 06:00:44 -0000
@@ -91,7 +91,42 @@
 	atf_check -s exit:1 -o ignore -e ignore grep "Can not parse XML" gdb.out
 }
 
+atf_test_case incompat_tracee
+incompat_tracee_head() {
+	atf_set "descr" "Test that 64bit GDB works with 32bit programs"
+	atf_set "require.progs" "cc gdb"
+}
+incompat_tracee_body() {
+	if ! cc -dM -E - < /dev/null | fgrep -q _LP64; then
+		atf_skip "this is not a 64 bit architecture"
+	fi
+	if ! cc -m32 -dM -E - >/dev/null; then
+		atf_skip "Cannot build 32-bit binaries with -m32"
+	fi
+	cat <<EOF >hello.c
+#include <stdio.h>
+int main(int argc, char **argv) { printf ("hello\n"); return 0; }
+EOF
+	atf_check -s exit:0 -o ignore -e ignore cc -m32 -o test hello.c -g
+
+	cat <<EOF >test.gdb
+break main
+run
+bt
+continue
+EOF
+
+	gdb --batch -x test.gdb ./test >gdb.out 2>&1
+	# No crashes
+	atf_check -s exit:1 -o ignore -e ignore grep "SIGSEGV" gdb.out
+	# output includes the printf
+	atf_check -s exit:0 -o ignore -e ignore grep "hello" gdb.out
+	# ...and a backtrace.
+	atf_check -s exit:0 -o ignore -e ignore grep "#0.*main.*hello.c" gdb.out
+}
+
 atf_init_test_cases() {
+	atf_add_test_case incompat_tracee
 	atf_add_test_case threads
 	atf_add_test_case pie
 	atf_add_test_case xml



Home | Main Index | Thread Index | Old Index