* [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command
@ 2009-04-23 0:34 Sérgio Durigan Júnior
2009-04-25 8:44 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Sérgio Durigan Júnior @ 2009-04-23 0:34 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1227 bytes --]
This is the part of the patch which adds build-system, testcase and
documentation changes. It also adds the extra command "maint set
data-directory".
Regards,
--
Sérgio Durigan Júnior
Linux on Power Toolchain - Software Engineer
Linux Technology Center - LTC
IBM Brazil
gdb/ChangeLog:
2009-04-22 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
* Makefile.in: Support for relocatable GDB datadir and XML
syscall.
* NEWS: Added information about the catch syscall feature.
* configure, config.in: Regenerate.
* configure.ac: Support for relocatable GDB datadir.
* defs.h (data_directory): New variable used for relocatable GDB
datadir.
* main.c: Add gdb_datadir variable to store the current GDB datadir.
(captured_main): Add the GDB datadir relocatable handler.
* maint.c: Create the "maintenance set gdb_datadir" command.
gdb/doc/ChangeLog:
2009-04-22 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
* gdb.texinfo (catch syscall): Documentation about the new
feature.
gdb/testsuite/ChangeLog:
2009-04-22 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
* Makefile.in: Inclusion of catch-syscall object.
* gdb.base/catch-syscall.c: New file.
* gdb.base/catch-syscall.exp: New file.
[-- Attachment #2: catch-syscall-build-test-doc.patch --]
[-- Type: text/x-patch, Size: 43681 bytes --]
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 8a58425..5d6b1dd 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -166,6 +166,9 @@ INTL_CFLAGS = @INCINTL@
TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
+# Did the user give us a --with-gdb-datadir option?
+GDB_DATADIR_PATH = @GDB_DATADIR_PATH@
+
# Helper code from gnulib.
LIBGNU = gnulib/libgnu.a
INCGNU = -I$(srcdir)/gnulib -Ignulib
@@ -458,6 +461,7 @@ TARGET_OBS = @TARGET_OBS@
# All target-dependent objects files that require 64-bit CORE_ADDR
# (used with --enable-targets=all --enable-64-bit-bfd).
ALL_64_TARGET_OBS = \
+ linux-tdep.o \
alphabsd-tdep.o alphafbsd-tdep.o alpha-linux-tdep.o alpha-mdebug-tdep.o \
alphanbsd-tdep.o alphaobsd-tdep.o alpha-osf1-tdep.o alpha-tdep.o \
amd64fbsd-tdep.o amd64-dicos-tdep.o amd64-linux-tdep.o amd64nbsd-tdep.o \
@@ -469,6 +473,7 @@ ALL_64_TARGET_OBS = \
# All other target-dependent objects files (used with --enable-targets=all).
ALL_TARGET_OBS = \
+ linux-tdep.o \
armbsd-tdep.o arm-linux-tdep.o armnbsd-tdep.o armobsd-tdep.o \
arm-tdep.o arm-wince-tdep.o \
avr-tdep.o \
@@ -664,6 +669,8 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
valarith.c valops.c valprint.c value.c varobj.c vec.c \
wrapper.c \
xml-tdesc.c xml-support.c \
+ linux-tdep.c \
+ xml-syscall.c \
inferior.c gdb_usleep.c
LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
@@ -674,7 +681,7 @@ LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
# wrong if TAGS has files twice). Because this is tricky to get
# right, it is probably easiest just to list .h files here directly.
-HFILES_NO_SRCDIR = osf-share/cma_debug_client.h \
+HFILES_NO_SRCDIR = osf-share/cma_debug_client.h linux-tdep.h \
osf-share/HP800/cma_thread_io.h osf-share/cma_sequence.h \
osf-share/cma_mutex.h osf-share/cma_semaphore_defs.h \
osf-share/cma_list.h osf-share/cma_handle.h osf-share/cma_stack.h \
@@ -735,7 +742,7 @@ config/rs6000/nm-rs6000.h top.h bsd-kvm.h gdb-stabs.h reggroups.h \
annotate.h sim-regno.h dictionary.h dfp.h main.h frame-unwind.h \
remote-fileio.h i386-linux-tdep.h vax-tdep.h objc-lang.h \
sentinel-frame.h bcache.h symfile.h windows-tdep.h linux-tdep.h \
-gdb_usleep.h
+xml-syscall.h gdb_usleep.h
# Header files that already have srcdir in them, or which are in objdir.
@@ -814,10 +821,16 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
trad-frame.o \
tramp-frame.o \
solib.o solib-null.o \
- prologue-value.o memory-map.o xml-support.o \
+ prologue-value.o memory-map.o xml-support.o xml-syscall.o \
target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \
inferior.o osdata.o gdb_usleep.o
+# Definitions for the syscall's XML files and dir
+XML_SYSCALLS_DIR = syscalls/
+XML_SYSCALLS_FILES = gdb-syscalls.dtd \
+ ppc-linux.xml ppc64-linux.xml \
+ i386-linux.xml amd64-linux.xml
+
TSOBS = inflow.o
SUBDIRS = @subdirs@
@@ -851,11 +864,41 @@ generated_files = config.h observer.h observer.inc ada-lex.c \
$(COMPILE) $<
$(POSTCOMPILE)
-all: gdb$(EXEEXT) $(CONFIG_ALL)
+all: gdb$(EXEEXT) $(CONFIG_ALL) xml-syscall-copy
@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
.PHONY: all-tui
all-tui: $(TUI)$(EXEEXT)
+# This is needed for running GDB from the build directory
+.PHONY: xml-syscall-copy
+xml-syscall-copy:
+ if [ "`cd $(srcdir) && pwd`" != "`pwd`" ] ; then \
+ mkdir -p ./$(XML_SYSCALLS_DIR) ; \
+ list='$(XML_SYSCALLS_FILES)' ; \
+ for file in $$list ; do \
+ f=$(srcdir)/$(XML_SYSCALLS_DIR)/$$file ; \
+ if test -f $$f ; then \
+ $(INSTALL_DATA) $$f \
+ ./$(XML_SYSCALLS_DIR) ; \
+ fi ; \
+ done ; \
+ fi ;
+
+# This target is responsible for properly installing the syscalls'
+# XML files in the system.
+.PHONY: xml-syscall-install
+xml-syscall-install:
+ $(SHELL) $(srcdir)/../mkinstalldirs \
+ $(DESTDIR)$(GDB_DATADIR_PATH)/$(XML_SYSCALLS_DIR) ; \
+ list='$(XML_SYSCALLS_FILES)' ; \
+ for file in $$list ; do \
+ f=$(srcdir)/$(XML_SYSCALLS_DIR)/$$file ; \
+ if test -f $$f ; then \
+ $(INSTALL_DATA) $$f \
+ $(DESTDIR)$(GDB_DATADIR_PATH)/$(XML_SYSCALLS_DIR) ; \
+ fi ; \
+ done ;
+
installcheck:
# The check target can not use subdir_do, because subdir_do does not
@@ -909,8 +952,11 @@ gdb.z:gdb.1
# source file and doesn't care about rebuilding or just wants to save the
# time it takes for make to check that all is up to date.
# install-only is intended to address that need.
-install: all install-only
-install-only: $(CONFIG_INSTALL)
+install: all install-only
+
+# The "install-only" target also installs the syscalls' XML files in
+# the system.
+install-only: $(CONFIG_INSTALL) xml-syscall-install
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e "$$t"` ; \
if test "x$$transformed_name" = x; then \
@@ -1268,6 +1314,7 @@ force_update:
MAKEOVERRIDES=
ALLDEPFILES = \
+ linux-tdep.c \
aix-thread.c \
alpha-nat.c alphabsd-nat.c alpha-linux-nat.c \
alpha-tdep.c alpha-mdebug-tdep.c \
diff --git a/gdb/NEWS b/gdb/NEWS
index 8382026..1eee0bf 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,18 @@
*** Changes since GDB 6.8
+* GDB now has the new command `catch syscall'. It can be used to
+catch when the inferior calls a system call, or when the system call
+returns. Also, you can specify which system calls you would like GDB
+to catch (or issue only a `catch syscall' without arguments, which will
+make GDB catch every system call). For instance, if you would like to
+catch the system call close, you would issue a:
+
+ (gdb) catch syscall close
+
+This feature is available with a native GDB running on the following
+architectures: x86, PowerPC and PowerPC64.
+
* GDB now supports hardware watchpoints on MIPS/Linux systems. This
feature is available with a native GDB running on kernel version
2.6.28 or later.
diff --git a/gdb/config.in b/gdb/config.in
index 1bfd837..fb9c970 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -26,6 +26,12 @@
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
+/* Global directory for GDB data files. */
+#undef DATA_DIRECTORY
+
+/* Define if GDB data directory should be relocated when GDB is moved. */
+#undef DATA_DIRECTORY_RELOCATABLE
+
/* Global directory for separate debug files. */
#undef DEBUGDIR
diff --git a/gdb/configure b/gdb/configure
index d709727..4884e22 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -314,7 +314,7 @@ ac_subdirs_all="$ac_subdirs_all doc testsuite"
ac_subdirs_all="$ac_subdirs_all gdbtk"
ac_subdirs_all="$ac_subdirs_all multi-ice"
ac_subdirs_all="$ac_subdirs_all gdbserver"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os am__leading_dot DEPDIR CCDEPMODE MAKE GMAKE_TRUE GMAKE_FALSE SET_MAKE USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT localedir GL_COND_LIBTOOL_TRUE GL_COND_LIBTOOL_FALSE GNULIB_MEMMEM GNULIB_MEMPCPY GNULIB_MEMRCHR GNULIB_STPCPY GNULIB_STPNCPY GNULIB_STRCHRNUL GNULIB_STRDUP GNULIB_STRNDUP GNULIB_STRNLEN GNULIB_STRPBRK GNULIB_STRSEP GNULIB_STRSTR GNULIB_STRCASESTR GNULIB_STRTOK_R GNULIB_MBSLEN GNULIB_MBSNLEN GNULIB_MBSCHR GNULIB_MBSRCHR GNULIB_MBSSTR GNULIB_MBSCASECMP GNULIB_MBSNCASECMP GNULIB_MBSPCASECMP GNULIB_MBSCASESTR GNULIB_MBSCSPN GNULIB_MBSPBRK GNULIB_MBSSPN GNULIB_MBSSEP GNULIB_MBSTOK_R GNULIB_STRERROR GNULIB_STRSIGNAL HAVE_DECL_MEMMEM HAVE_MEMPCPY HAVE_DECL_MEMRCHR HAVE_STPCPY HAVE_STPNCPY HAVE_STRCHRNUL HAVE_DECL_STRDUP HAVE_STRNDUP HAVE_DECL_STRNDUP HAVE_DECL_STRNLEN HAVE_STRPBRK HAVE_STRSEP HAVE_STRCASESTR HAVE_DECL_STRTOK_R HAVE_DECL_STRERROR HAVE_DECL_STRSIGNAL REPLACE_STRERROR REPLACE_STRSIGNAL REPLACE_MEMMEM REPLACE_STRCASESTR REPLACE_STRSTR HAVE_LONG_LONG_INT HAVE_UNSIGNED_LONG_LONG_INT HAVE_INTTYPES_H HAVE_SYS_TYPES_H INCLUDE_NEXT NEXT_STDINT_H HAVE_STDINT_H HAVE_SYS_INTTYPES_H HAVE_SYS_BITYPES_H BITSIZEOF_PTRDIFF_T BITSIZEOF_SIG_ATOMIC_T BITSIZEOF_SIZE_T BITSIZEOF_WCHAR_T BITSIZEOF_WINT_T HAVE_SIGNED_SIG_ATOMIC_T HAVE_SIGNED_WCHAR_T HAVE_SIGNED_WINT_T PTRDIFF_T_SUFFIX SIG_ATOMIC_T_SUFFIX SIZE_T_SUFFIX WCHAR_T_SUFFIX WINT_T_SUFFIX STDINT_H NEXT_STRING_H GNULIB_WCWIDTH HAVE_DECL_WCWIDTH REPLACE_WCWIDTH WCHAR_H HAVE_WCHAR_H NEXT_WCHAR_H LIBGNU_LIBDEPS LIBGNU_LTLIBDEPS GNULIB_STDINT_H PACKAGE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK AMTAR am__tar am__untar am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH am__fastdepCC_TRUE am__fastdepCC_FALSE subdirs TARGET_OBS PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI LN_S YACC AR ac_ct_AR DLLTOOL ac_ct_DLLTOOL WINDRES ac_ct_WINDRES MIG ac_ct_MIG READLINE READLINE_DEPS READLINE_CFLAGS HAVE_LIBEXPAT LIBEXPAT LTLIBEXPAT PYTHON_CFLAGS ALLOCA CONFIG_LDFLAGS TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS WERROR_CFLAGS SER_HARDWIRE WIN32LIBS LIBGUI GUI_CFLAGS_X WIN32LDAPP TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCL_INCLUDE TCL_LIBRARY TCL_DEPS TK_VERSION TK_BIN_DIR TK_SRC_DIR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_INCLUDE TK_LIBRARY TK_DEPS TK_XINCLUDES X_CFLAGS X_LDFLAGS X_LIBS GDBTKLIBS GDBTK_CFLAGS GDBTK_SRC_DIR SIM SIM_OBS ENABLE_CFLAGS PROFILE_CFLAGS CONFIG_OBS CONFIG_DEPS CONFIG_SRCS CONFIG_ALL CONFIG_CLEAN CONFIG_INSTALL CONFIG_UNINSTALL target_subdir frags GDB_NM_FILE datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS gl_LIBOBJS gl_LTLIBOBJS gltests_LIBOBJS gltests_LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os am__leading_dot DEPDIR CCDEPMODE MAKE GMAKE_TRUE GMAKE_FALSE SET_MAKE USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT localedir GL_COND_LIBTOOL_TRUE GL_COND_LIBTOOL_FALSE GNULIB_MEMMEM GNULIB_MEMPCPY GNULIB_MEMRCHR GNULIB_STPCPY GNULIB_STPNCPY GNULIB_STRCHRNUL GNULIB_STRDUP GNULIB_STRNDUP GNULIB_STRNLEN GNULIB_STRPBRK GNULIB_STRSEP GNULIB_STRSTR GNULIB_STRCASESTR GNULIB_STRTOK_R GNULIB_MBSLEN GNULIB_MBSNLEN GNULIB_MBSCHR GNULIB_MBSRCHR GNULIB_MBSSTR GNULIB_MBSCASECMP GNULIB_MBSNCASECMP GNULIB_MBSPCASECMP GNULIB_MBSCASESTR GNULIB_MBSCSPN GNULIB_MBSPBRK GNULIB_MBSSPN GNULIB_MBSSEP GNULIB_MBSTOK_R GNULIB_STRERROR GNULIB_STRSIGNAL HAVE_DECL_MEMMEM HAVE_MEMPCPY HAVE_DECL_MEMRCHR HAVE_STPCPY HAVE_STPNCPY HAVE_STRCHRNUL HAVE_DECL_STRDUP HAVE_STRNDUP HAVE_DECL_STRNDUP HAVE_DECL_STRNLEN HAVE_STRPBRK HAVE_STRSEP HAVE_STRCASESTR HAVE_DECL_STRTOK_R HAVE_DECL_STRERROR HAVE_DECL_STRSIGNAL REPLACE_STRERROR REPLACE_STRSIGNAL REPLACE_MEMMEM REPLACE_STRCASESTR REPLACE_STRSTR HAVE_LONG_LONG_INT HAVE_UNSIGNED_LONG_LONG_INT HAVE_INTTYPES_H HAVE_SYS_TYPES_H INCLUDE_NEXT NEXT_STDINT_H HAVE_STDINT_H HAVE_SYS_INTTYPES_H HAVE_SYS_BITYPES_H BITSIZEOF_PTRDIFF_T BITSIZEOF_SIG_ATOMIC_T BITSIZEOF_SIZE_T BITSIZEOF_WCHAR_T BITSIZEOF_WINT_T HAVE_SIGNED_SIG_ATOMIC_T HAVE_SIGNED_WCHAR_T HAVE_SIGNED_WINT_T PTRDIFF_T_SUFFIX SIG_ATOMIC_T_SUFFIX SIZE_T_SUFFIX WCHAR_T_SUFFIX WINT_T_SUFFIX STDINT_H NEXT_STRING_H GNULIB_WCWIDTH HAVE_DECL_WCWIDTH REPLACE_WCWIDTH WCHAR_H HAVE_WCHAR_H NEXT_WCHAR_H LIBGNU_LIBDEPS LIBGNU_LTLIBDEPS GNULIB_STDINT_H PACKAGE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK AMTAR am__tar am__untar am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH am__fastdepCC_TRUE am__fastdepCC_FALSE DATA_DIRECTORY_PATH subdirs TARGET_OBS PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI LN_S YACC AR ac_ct_AR DLLTOOL ac_ct_DLLTOOL WINDRES ac_ct_WINDRES MIG ac_ct_MIG READLINE READLINE_DEPS READLINE_CFLAGS HAVE_LIBEXPAT LIBEXPAT LTLIBEXPAT PYTHON_CFLAGS ALLOCA CONFIG_LDFLAGS TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS WERROR_CFLAGS SER_HARDWIRE WIN32LIBS LIBGUI GUI_CFLAGS_X WIN32LDAPP TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCL_INCLUDE TCL_LIBRARY TCL_DEPS TK_VERSION TK_BIN_DIR TK_SRC_DIR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_INCLUDE TK_LIBRARY TK_DEPS TK_XINCLUDES X_CFLAGS X_LDFLAGS X_LIBS GDBTKLIBS GDBTK_CFLAGS GDBTK_SRC_DIR SIM SIM_OBS ENABLE_CFLAGS PROFILE_CFLAGS CONFIG_OBS CONFIG_DEPS CONFIG_SRCS CONFIG_ALL CONFIG_CLEAN CONFIG_INSTALL CONFIG_UNINSTALL target_subdir frags GDB_NM_FILE datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS gl_LIBOBJS gl_LTLIBOBJS gltests_LIBOBJS gltests_LTLIBOBJS'
ac_subst_files='host_makefile_frag'
ac_pwd=`pwd`
@@ -887,6 +887,8 @@ Optional Packages:
--with-separate-debug-dir=PATH
look for global separate debug info in this path
[LIBDIR/debug]
+ --with-data-directory look for global separate data files in this path
+ [DATADIR/gdb]
--with-relocated-sources=PATH
automatically relocate this path for source files
--with-libunwind use libunwind frame unwinding support
@@ -6569,7 +6571,6 @@ am__api_version="1.9"
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
@@ -6603,18 +6604,8 @@ case $as_dir/ in
# program-specific install script used by HP pwplus--don't use.
:
else
- rm -rf conftest.one conftest.two conftest.dir
- echo one > conftest.one
- echo two > conftest.two
- mkdir conftest.dir
- if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
- test -s conftest.one && test -s conftest.two &&
- test -s conftest.dir/conftest.one &&
- test -s conftest.dir/conftest.two
- then
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
fi
fi
done
@@ -6623,16 +6614,15 @@ case $as_dir/ in
esac
done
-rm -rf conftest.one conftest.two conftest.dir
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_cv_path_install
else
- # As a last resort, use the slow shell script. Don't cache a
- # value for INSTALL within a source directory, because that will
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
- # removed, or if the value is a relative name.
+ # removed, or if the path is relative.
INSTALL=$ac_install_sh
fi
fi
@@ -7147,6 +7137,52 @@ _ACEOF
;;
esac
+# GDB's data directory relocation
+
+data_directory=${datadir}/gdb
+
+
+# Check whether --with-data-directory or --without-data-directory was given.
+if test "${with_data_directory+set}" = set; then
+ withval="$with_data_directory"
+ data_directory="${withval}"
+fi;
+
+
+ test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+ ac_define_dir=`eval echo $data_directory`
+ ac_define_dir=`eval echo $ac_define_dir`
+
+cat >>confdefs.h <<_ACEOF
+#define DATA_DIRECTORY "$ac_define_dir"
+_ACEOF
+
+
+
+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+ if test "x$prefix" = xNONE; then
+ test_prefix=/usr/local
+ else
+ test_prefix=$prefix
+ fi
+else
+ test_prefix=$exec_prefix
+fi
+
+case ${data_directory} in
+ "${test_prefix}"|"${test_prefix}/"*|\
+ '${exec_prefix}'|'${exec_prefix}/'*)
+
+cat >>confdefs.h <<\_ACEOF
+#define DATA_DIRECTORY_RELOCATABLE 1
+_ACEOF
+
+ ;;
+esac
+DATA_DIRECTORY_PATH=${data_directory}
+
+
# Check whether --with-relocated-sources or --without-relocated-sources was given.
if test "${with_relocated_sources+set}" = set; then
@@ -8599,7 +8635,6 @@ done
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
@@ -8633,18 +8668,8 @@ case $as_dir/ in
# program-specific install script used by HP pwplus--don't use.
:
else
- rm -rf conftest.one conftest.two conftest.dir
- echo one > conftest.one
- echo two > conftest.two
- mkdir conftest.dir
- if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
- test -s conftest.one && test -s conftest.two &&
- test -s conftest.dir/conftest.one &&
- test -s conftest.dir/conftest.two
- then
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
fi
fi
done
@@ -8653,16 +8678,15 @@ case $as_dir/ in
esac
done
-rm -rf conftest.one conftest.two conftest.dir
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_cv_path_install
else
- # As a last resort, use the slow shell script. Don't cache a
- # value for INSTALL within a source directory, because that will
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
- # removed, or if the value is a relative name.
+ # removed, or if the path is relative.
INSTALL=$ac_install_sh
fi
fi
@@ -22112,6 +22136,7 @@ s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t
s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
+s,@DATA_DIRECTORY_PATH@,$DATA_DIRECTORY_PATH,;t t
s,@subdirs@,$subdirs,;t t
s,@TARGET_OBS@,$TARGET_OBS,;t t
s,@PKGVERSION@,$PKGVERSION,;t t
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 4c2768d..0718b94 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -118,6 +118,36 @@ case ${debugdir} in
;;
esac
+# GDB's data directory relocation
+
+data_directory=${datadir}/gdb
+
+AC_ARG_WITH([data-directory],
+ [AS_HELP_STRING([--with-data-directory],
+ [look for global separate data files in this path [DATADIR/gdb]])], [data_directory="${withval}"])
+
+AC_DEFINE_DIR(DATA_DIRECTORY, data_directory,
+ [Global directory for GDB data files. ])
+
+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+ if test "x$prefix" = xNONE; then
+ test_prefix=/usr/local
+ else
+ test_prefix=$prefix
+ fi
+else
+ test_prefix=$exec_prefix
+fi
+
+case ${data_directory} in
+ "${test_prefix}"|"${test_prefix}/"*|\
+ '${exec_prefix}'|'${exec_prefix}/'*)
+ AC_DEFINE(DATA_DIRECTORY_RELOCATABLE, 1, [Define if GDB data directory should be relocated when GDB is moved.])
+ ;;
+esac
+DATA_DIRECTORY_PATH=${data_directory}
+AC_SUBST(DATA_DIRECTORY_PATH)
+
AC_ARG_WITH(relocated-sources,
AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this path for source files]),
[reloc_srcdir="${withval}"
diff --git a/gdb/defs.h b/gdb/defs.h
index 882a844..ddd3e82 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -153,6 +153,9 @@ extern int dbx_commands;
/* System root path, used to find libraries etc. */
extern char *gdb_sysroot;
+/* GDB datadir, used to store data files. */
+extern char *data_directory;
+
/* Search path for separate debug files. */
extern char *debug_file_directory;
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 2cdac20..27e12a3 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -3640,6 +3640,106 @@ A failed Ada assertion.
A call to @code{exec}. This is currently only available for HP-UX
and @sc{gnu}/Linux.
+@item syscall
+@itemx syscall @r{[}@var{name} @r{|} @var{number}@r{]} @r{...}
+@cindex break on a system call.
+A call to or return from a @code{syscall}. If no argument is specified,
+then it catches a call to or return from any system call.
+
+@var{name} can be any valid system call name in the system. You can
+use the @value{GDBN} command-line completion facilities to list the
+available choices. @xref{Completion,, Command Completion}, for
+details on how to do this.
+
+You may also specify the system call numerically. This may be useful
+if @value{GDBN} does not fully support your system's list of system
+calls.
+
+The example below illustrates how this command works if you don't provide
+arguments to it:
+
+@smallexample
+(@value{GDBP}) catch syscall
+Catchpoint 1 (syscall)
+(@value{GDBP}) r
+Starting program: /tmp/catch-syscall
+
+Catchpoint 1 (call to syscall 'close'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP}) c
+Continuing.
+
+Catchpoint 1 (returned from syscall 'close'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP})
+@end smallexample
+
+Here is an example of catching a system call by name:
+
+@smallexample
+(@value{GDBP}) catch syscall chroot
+Catchpoint 1 (syscall(s) 'chroot')
+(@value{GDBP}) r
+Starting program: /tmp/catch-syscall
+
+Catchpoint 1 (call to syscall 'chroot'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP}) c
+Continuing.
+
+Catchpoint 1 (returned from syscall 'chroot'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP})
+@end smallexample
+
+And last but not least, an example of specifying a system call
+numerically:
+
+@smallexample
+(@value{GDBP}) catch syscall 252
+Catchpoint 1 (syscall(s) 'exit_group')
+(@value{GDBP}) r
+Starting program: /tmp/catch-syscall
+
+Catchpoint 1 (call to syscall 'exit_group'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP}) c
+Continuing.
+
+Program exited normally.
+(@value{GDBP})
+@end smallexample
+
+
+
+If you configure @value{GDBN} using the @samp{--without-expat} option,
+it will not be able to display syscall names. Also, if your
+architecture does not have an XML file describing its system calls,
+you will not be able to see the syscall names. It is important to
+notice that these two features are used for accessing the syscall
+name database. In either case, you will see a warning like this:
+
+@smallexample
+(@value{GDBP}) catch syscall
+warning: Could not open "syscalls/i386-linux.xml"
+warning: Could not load the syscall XML file 'syscalls/i386-linux.xml'.
+GDB will not be able to display syscall names.
+Catchpoint 1 (syscall)
+(@value{GDBP})
+@end smallexample
+
+Of course, the file name will change depending on your architecture and system.
+
+Still using the example above, you can also try to catch a syscall by its
+number. In this case, you would see something like:
+
+@smallexample
+(@value{GDBP}) catch syscall 252
+Catchpoint 1 (syscall(s) 252)
+@end smallexample
+
+Again, in this case @value{GDBN} would not be able to display syscall's names.
+
@item fork
A call to @code{fork}. This is currently only available for HP-UX
and @sc{gnu}/Linux.
diff --git a/gdb/main.c b/gdb/main.c
index 86607d3..6c7acf5 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -64,6 +64,9 @@ int dbx_commands = 0;
/* System root path, used to find libraries etc. */
char *gdb_sysroot = 0;
+/* GDB datadir, used to store data files. */
+char *data_directory = 0;
+
struct ui_file *gdb_stdout;
struct ui_file *gdb_stderr;
struct ui_file *gdb_stdlog;
@@ -359,6 +362,39 @@ captured_main (void *data)
}
}
+#ifdef DATA_DIRECTORY_RELOCATABLE
+ data_directory = make_relative_prefix (argv[0], BINDIR, DATA_DIRECTORY);
+ if (data_directory)
+ {
+ struct stat s;
+ int res = 0;
+
+ if (stat (data_directory, &s) == 0)
+ if (S_ISDIR (s.st_mode))
+ res = 1;
+
+ if (res == 0)
+ {
+ xfree (data_directory);
+ data_directory = xstrdup (DATA_DIRECTORY);
+ }
+ }
+ else
+ data_directory = xstrdup (DATA_DIRECTORY);
+#else
+ data_directory = xstrdup (DATA_DIRECTORY);
+#endif /* DATA_DIRECTORY_RELOCATABLE */
+
+ /* Canonicalize the GDB's datadir path. */
+ if (*data_directory)
+ {
+ char *canon_debug = lrealpath (data_directory);
+ if (canon_debug)
+ {
+ xfree (data_directory);
+ data_directory = canon_debug;
+ }
+ }
get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit);
#ifdef RELOC_SRCDIR
diff --git a/gdb/maint.c b/gdb/maint.c
index 56cafe9..69beff9 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -906,4 +906,12 @@ When enabled GDB is profiled."),
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+ add_setshow_filename_cmd ("data-directory", class_maintenance,
+ &data_directory, _("Set GDB's data directory path."),
+ _("Show GDB's data directory path."),
+ _("\
+When set, GDB uses the specified path to search for data files."),
+ NULL, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
}
diff --git a/gdb/testsuite/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in
index 9f382db..12db521 100644
--- a/gdb/testsuite/gdb.base/Makefile.in
+++ b/gdb/testsuite/gdb.base/Makefile.in
@@ -12,7 +12,7 @@ EXECUTABLES = all-types annota1 bitfields break \
scope section_command setshow setvar shmain sigall signals \
solib solib_sl so-impl-ld so-indr-cl \
step-line step-test structs structs2 \
- twice-tmp varargs vforked-prog watchpoint whatis
+ twice-tmp varargs vforked-prog watchpoint whatis catch-syscall
MISCELLANEOUS = coremmap.data ../foobar.baz \
shr1.sl shr2.sl solib_sl.sl solib1.sl solib2.sl
diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.base/catch-syscall.c
new file mode 100644
index 0000000..64850de
--- /dev/null
+++ b/gdb/testsuite/gdb.base/catch-syscall.c
@@ -0,0 +1,25 @@
+/* This file is used to test the 'catch syscall' feature on GDB.
+
+ Please, if you are going to edit this file DO NOT change the syscalls
+ being called (nor the order of them). If you really must do this, then
+ take a look at catch-syscall.exp and modify there too.
+
+ Written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
+ September, 2008 */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+int
+main (void)
+{
+ /* A close() with a wrong argument. We are only
+ interested in the syscall. */
+ close (-1);
+
+ chroot (".");
+
+ /* The last syscall. Do not change this. */
+ _exit (0);
+}
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
new file mode 100644
index 0000000..ac529c6
--- /dev/null
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -0,0 +1,431 @@
+# Copyright 1997, 1999, 2007, 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# This program tests the 'catch syscall' functionality.
+#
+# It was written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
+# on September/2008.
+
+if { [is_remote target] || ![isnative] } then {
+ continue
+}
+
+set prms_id 0
+set bug_id 0
+
+global srcfile
+set testfile "catch-syscall"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+# All (but the last) syscalls from the example code
+# They are ordered according to the file, so do not change this.
+set all_syscalls { "close" "chroot" }
+# The last syscall (exit()) does not return, so
+# we cannot expect the catchpoint to be triggered
+# twice. It is a special case.
+set last_syscall "exit_group"
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested catch-syscall.exp
+ return -1
+}
+
+# Until "catch syscall" is implemented on other targets...
+if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
+ continue
+}
+
+# This shall be updated whenever 'catch syscall' is implemented
+# on some architecture.
+#if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
+if { ![istarget "i\[34567\]86-*-linux*"]
+ && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"] } {
+ continue
+}
+
+# Internal procedure used to check if, after issuing a 'catch syscall'
+# command (without arguments), the 'info breakpoints' command displays
+# that '"any syscall"' is to be caught.
+proc check_info_bp_any_syscall {} {
+ global gdb_prompt
+
+ # Verifying that the catchpoint appears in the 'info breakpoints'
+ # command, but with "<any syscall>".
+ set thistest "catch syscall appears in 'info breakpoints'"
+ gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall\[(\]s\[)\] \"<any syscall>\".*" $thistest
+}
+
+# Internal procedure used to check if, after issuing a 'catch syscall X'
+# command (with arguments), the 'info breakpoints' command displays
+# that the syscall 'X' is to be caught.
+proc check_info_bp_specific_syscall { syscall } {
+ global gdb_prompt
+
+ set thistest "syscall(s) $syscall appears in 'info breakpoints'"
+ gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall\[(\]s\[)\] (.)?${syscall}(.)?.*" $thistest
+}
+
+# Internal procedure used to check if, after issuing a 'catch syscall X'
+# command (with many arguments), the 'info breakpoints' command displays
+# that the syscalls 'X' are to be caught.
+proc check_info_bp_many_syscalls { syscalls } {
+ global gdb_prompt
+ set filter_str ""
+
+ foreach name $syscalls {
+ set filter_str "${filter_str}${name}, "
+ }
+
+ set filter_str [ string trimright $filter_str ", " ]
+
+ set thistest "syscalls $filter_str appears in 'info breakpoints'"
+ gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall\[(\]s\[)\] (.)?${filter_str}(.)?.*" $thistest
+}
+
+# This procedure checks if there was a call to a syscall.
+proc check_call_to_syscall { syscall } {
+ global gdb_prompt
+
+ set thistest "program has called $syscall"
+ gdb_test "continue" "Catchpoint .*(call to syscall .?${syscall}.?).*" $thistest
+}
+
+# This procedure checks if the syscall returned.
+proc check_return_from_syscall { syscall } {
+ global gdb_prompt
+
+ set thistest "syscall $syscall has returned"
+ gdb_test "continue" "Catchpoint .*(returned from syscall (.)?${syscall}(.)?).*" $thistest
+}
+
+# Internal procedure that performs two 'continue' commands and checks if
+# a syscall call AND return occur.
+proc check_continue { syscall } {
+ global gdb_prompt
+
+ # Testing if the 'continue' stops at the
+ # specified syscall_name. If it does, then it should
+ # first print that the infeior has called the syscall,
+ # and after print that the syscall has returned.
+
+ # Testing if the inferiorr has called the syscall.
+ check_call_to_syscall $syscall
+ # And now, that the syscall has returned.
+ check_return_from_syscall $syscall
+}
+
+# Inserts a syscall catchpoint with an argument.
+proc insert_catch_syscall_with_arg { syscall } {
+ global gdb_prompt
+
+ # Trying to set the catchpoint
+ set thistest "catch syscall with arguments ($syscall)"
+ gdb_test "catch syscall $syscall" "Catchpoint .*(syscall\[(\]s\[)\] (.)?${syscall}(.)?).*" $thistest
+
+ check_info_bp_specific_syscall $syscall
+}
+
+# Inserts a syscall catchpoint with many arguments.
+proc insert_catch_syscall_with_many_args { syscalls } {
+ global gdb_prompt
+ set catch [ join $syscalls " " ]
+ set filter_str ""
+
+ foreach name $syscalls {
+ set filter_str "${filter_str}'${name}' "
+ }
+
+ set filter_str [ string trimright $filter_str " " ]
+
+ # Trying to set the catchpoint
+ set thistest "catch syscall with arguments ($filter_str)"
+ gdb_test "catch syscall $catch" "Catchpoint .*(syscall\[(\]s\[)\] (.)?${filter_str}(.)?).*" $thistest
+
+ check_info_bp_many_syscalls $syscalls
+}
+
+proc check_for_program_end {} {
+ global gdb_prompt
+
+ # Deleting the catchpoints
+ delete_breakpoints
+
+ set thistest "successful program end"
+ gdb_test "continue" "Program exited normally.*" $thistest
+
+}
+
+proc test_catch_syscall_without_args {} {
+ global gdb_prompt all_syscalls last_syscall
+
+ # Trying to set the syscall
+ set thistest "setting catch syscall without arguments"
+ gdb_test "catch syscall" "Catchpoint .*(syscall).*" $thistest
+
+ check_info_bp_any_syscall
+
+ # We have to check every syscall
+ foreach name $all_syscalls {
+ check_continue $name
+ }
+
+ # At last but not least, we check if the inferior
+ # has called the last (exit) syscall.
+ check_call_to_syscall $last_syscall
+
+ # Now let's see if the inferior correctly finishes.
+ check_for_program_end
+}
+
+proc test_catch_syscall_with_args {} {
+ global gdb_prompt
+ set syscall_name "close"
+
+ insert_catch_syscall_with_arg $syscall_name
+
+ # Can we continue until we catch the syscall?
+ check_continue $syscall_name
+
+ # Now let's see if the inferior correctly finishes.
+ check_for_program_end
+}
+
+proc test_catch_syscall_with_many_args {} {
+ global gdb_prompt all_syscalls
+
+ insert_catch_syscall_with_many_args $all_syscalls
+
+ # Can we continue until we catch the syscalls?
+ foreach name $all_syscalls {
+ check_continue $name
+ }
+
+ # Now let's see if the inferior correctly finishes.
+ check_for_program_end
+}
+
+proc test_catch_syscall_with_wrong_args {} {
+ global gdb_prompt
+ # mlock is not called from the source
+ set syscall_name "mlock"
+
+ insert_catch_syscall_with_arg $syscall_name
+
+ # Now, we must verify if the program stops with a continue.
+ # If it doesn't, everything is right (since we don't have
+ # a syscall named "mlock" in it). Otherwise, this is a failure.
+ set thistest "catch syscall with unused syscall ($syscall_name)"
+ gdb_test "continue" "Program exited normally.*" $thistest
+}
+
+proc test_catch_syscall_restarting_inferior {} {
+ global gdb_prompt
+ set syscall_name "chroot"
+
+ insert_catch_syscall_with_arg $syscall_name
+
+ # Let's first reach the call of the syscall.
+ check_call_to_syscall $syscall_name
+
+ # Now, restart the program
+ rerun_to_main
+
+ # And check for call/return
+ check_continue $syscall_name
+
+ # Can we finish?
+ check_for_program_end
+}
+
+proc do_syscall_tests {} {
+ global gdb_prompt srcdir
+
+ # First, we need to set GDB datadir.
+ send_gdb "maintenance set data-directory $srcdir/..\n"
+ gdb_expect 10 {
+ -re "$gdb_prompt $" {
+ verbose "Setting GDB datadir to $srcdir/..." 2
+ }
+ timeout {
+ error "Couldn't set GDB datadir."
+ }
+ }
+
+ # Verify that the 'catch syscall' help is available
+ set thistest "help catch syscall"
+ gdb_test "help catch syscall" "Catch system calls.*" $thistest
+
+ # Try to set a catchpoint to a nonsense syscall
+ set thistest "catch syscall to a nonsense syscall is prohibited"
+ gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .*" $thistest
+
+ # Testing the 'catch syscall' command without arguments.
+ # This test should catch any syscalls.
+ if [runto_main] then { test_catch_syscall_without_args }
+
+ # Testing the 'catch syscall' command with arguments.
+ # This test should only catch the specified syscall.
+ if [runto_main] then { test_catch_syscall_with_args }
+
+ # Testing the 'catch syscall' command with many arguments.
+ # This test should catch $all_syscalls.
+ if [runto_main] then { test_catch_syscall_with_many_args }
+
+ # Testing the 'catch syscall' command with WRONG arguments.
+ # This test should not trigger any catchpoints.
+ if [runto_main] then { test_catch_syscall_with_wrong_args }
+
+ # Testing the 'catch' syscall command during a restart of
+ # the inferior.
+ if [runto_main] then { test_catch_syscall_restarting_inferior }
+}
+
+proc test_catch_syscall_fail_noxml {} {
+ global gdb_prompt
+
+ # Sanitizing.
+ delete_breakpoints
+
+ # Testing to see if we receive a warning when calling "catch syscall"
+ # without XML support.
+ set thistest "Catch syscall displays a warning when there is no XML support"
+ gdb_test "catch syscall" "warning: Could not open .*warning: Could not load the syscall XML file .*GDB will not be able to display syscall names.*Catchpoint .*(syscall).*" $thistest
+
+ # Since the catchpoint was set, we must check if it's present at
+ # "info breakpoints"
+ check_info_bp_any_syscall
+
+ # Sanitizing.
+ delete_breakpoints
+}
+
+proc test_catch_syscall_without_args_noxml {} {
+ # We will need the syscall names even not using it
+ # because we need to know know many syscalls are in
+ # the example file.
+ global gdb_prompt all_syscalls last_syscall
+
+ delete_breakpoints
+
+ set thistest "Catch syscall without arguments and without XML support"
+ gdb_test "catch syscall" "Catchpoint .*(syscall).*"
+
+ # Now, we should be able to set a catchpoint,
+ # and GDB shall not display the warning anymore.
+ foreach name $all_syscalls {
+ # Unfortunately, we don't know the syscall number
+ # that will be caught because this information is
+ # arch-dependent. Thus, we try to catch anything
+ # similar to a number.
+ check_continue "\[0-9\]*"
+ }
+
+ # At last but not least, we check if the inferior
+ # has called the last (exit) syscall.
+ check_call_to_syscall "\[0-9\]*"
+
+ delete_breakpoints
+}
+
+proc test_catch_syscall_with_args_noxml {} {
+ global gdb_prompt
+
+ # The number of the "close" syscall. This is our
+ # options for a "long-estabilished" syscall in all
+ # Linux architectures, but unfortunately x86_64 and
+ # a few other platforms don't "follow the convention".
+ # Because of this, we need this ugly check :-(.
+ set close_number ""
+ if { [istarget "x86_64-*-linux*"] } {
+ set close_number "3"
+ } else {
+ set close_number "6"
+ }
+
+ delete_breakpoints
+
+ insert_catch_syscall_with_arg $close_number
+
+ check_continue $close_number
+
+ delete_breakpoints
+}
+
+proc test_catch_syscall_with_wrong_args_noxml {} {
+ global gdb_prompt
+
+ delete_breakpoints
+
+ # Even without XML support, GDB should not accept unknown
+ # syscall names for the catchpoint.
+ set thistest "Catch a nonsense syscall without XML support"
+ gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .nonsense_syscall.*" $thistest
+
+ delete_breakpoints
+}
+
+proc do_syscall_tests_without_xml {} {
+ global gdb_prompt srcdir
+
+ # In this case, we don't need to set GDB's datadir because
+ # we want GDB to display only numbers, not names. So, let's
+ # begin with the tests.
+
+ # The first test is to see if GDB displays a warning when we
+ # try to catch syscalls without the XML support.
+ test_catch_syscall_fail_noxml
+
+ # Now, let's test if we can catch syscalls without XML support.
+ # We should succeed, but GDB is not supposed to print syscall names.
+ if [runto_main] then { test_catch_syscall_without_args_noxml }
+
+ # The only valid argument "catch syscall" should accept is the
+ # syscall number, and not the name (since it can't translate a
+ # name to a number).
+ #
+ # It's worth mentioning that we only try to catch the syscall
+ # close(). This is because the syscall number is an arch-dependent
+ # information, so we can't assume that we know every syscall number
+ # in this system. Therefore, we have decided to use a "long-estabilished"
+ # system call, and close() just sounded the right choice :-).
+ if [runto_main] then { test_catch_syscall_with_args_noxml }
+
+ # Now, we'll try to provide a syscall name (valid or not) to the command,
+ # and expect it to fail.
+ if [runto_main] then { test_catch_syscall_with_wrong_args_noxml }
+}
+
+# Start with a fresh gdb
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Execute the tests, using XML support
+do_syscall_tests
+
+# Restart gdb
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Execute the tests, without XML support. In this case, GDB will
+# only display syscall numbers, and not syscall names.
+do_syscall_tests_without_xml
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command
2009-04-23 0:34 [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command Sérgio Durigan Júnior
@ 2009-04-25 8:44 ` Eli Zaretskii
2009-04-26 7:32 ` Sérgio Durigan Júnior
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Eli Zaretskii @ 2009-04-25 8:44 UTC (permalink / raw)
To: Sérgio Durigan Júnior; +Cc: gdb-patches
> From: =?ISO-8859-1?Q?S=E9rgio?= Durigan =?ISO-8859-1?Q?J=FAnior?= <sergiodj@linux.vnet.ibm.com>
> Date: Wed, 22 Apr 2009 21:33:02 -0300
>
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -3,6 +3,18 @@
>
> *** Changes since GDB 6.8
>
> +* GDB now has the new command `catch syscall'. It can be used to
> +catch when the inferior calls a system call, or when the system call
> +returns. Also, you can specify which system calls you would like GDB
> +to catch (or issue only a `catch syscall' without arguments, which will
> +make GDB catch every system call). For instance, if you would like to
> +catch the system call close, you would issue a:
> +
> + (gdb) catch syscall close
> +
This part is approved, but I suggest to add a sentence or two saying
what happens when such a catchpoint is hit. Without such a
description, the reader will be left wondering why this feature is
useful.
> +This feature is available with a native GDB running on the following
> +architectures: x86, PowerPC and PowerPC64.
This makes it sound like system calls are a function of the hardware
architecture, which I think is not true. I think you want to add
"Linux" somewhere here.
> gdb/doc/ChangeLog:
>
> 2009-04-22 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
>
> * gdb.texinfo (catch syscall): Documentation about the new
> feature.
This ChangeLog entry should have "Set Catchpoints" in parentheses
(without the quotes), because we state node names there, and this is
the name of the node where you add the description of "set syscall".
The patch for the manual is approved as well, with the following
comments:
> +@item syscall
> +@itemx syscall @r{[}@var{name} @r{|} @var{number}@r{]} @r{...}
> +@cindex break on a system call.
> +A call to or return from a @code{syscall}.
You never explain what a syscall is. I suggest to rephrase and
expand:
A call to or return from a system call, a.k.a.@: @dfn{syscall}. A
syscall is a mechanism for application programs to request a service
from the operating system (OS) or one of the OS system services.
@value{GDBN} can catch some or all of the syscalls issued by the
debuggee, and show the related information for each syscall.
> If no argument is specified,
> +then it catches a call to or return from any system call.
"and", not "or":
If no argument is specified, calls to and returns from all system
calls will be caught.
> +@var{name} can be any valid system call name in the system. You can
> +use the @value{GDBN} command-line completion facilities to list the
> +available choices. @xref{Completion,, Command Completion}, for
> +details on how to do this.
> +
> +You may also specify the system call numerically. This may be useful
> +if @value{GDBN} does not fully support your system's list of system
> +calls.
This text is okay, but it could still leave the reader wondering about
too many things. How does GDB know which syscalls are available? what
are the possible syscall numbers, and how do I know which ones are
valid? what happens if I use a name or number that are invalid?
The examples you give below answer some of these questions, and hint
to answers to others, but I think we still need some general text
about these issues, and we need a text that is as system-independent
as possible. So I suggest this text instead:
@var{name} can be any system call name that is valid for the
underlying OS. Just what syscalls are valid depends on the OS. On
GNU and Unix systems, you can find the full list of valid syscall
names on <PUT HERE THE NAME OF SYSTEM FILE WHERE TO FIND THE LIST>.
@c For MS-Windows, the syscall names and the corresponding numbers
@c can be found, e.g., on this URL:
@c http://www.metasploit.com/users/opcode/syscalls.html
@c but we don't support Windows syscalls yet.
Normally, @value{GDBN} knows in advance which syscalls are valid for
each OS, so you can use the @value{GDBN} command-line completion
facilities (@pxref{Completion,, command completion}) to list the
available choices.
You may also specify the system call numerically. A syscall's
number is the value passed to the OS's syscall dispatcher to
identify the requested service. When you specify the syscall by its
name, @value{GDBN} uses its database of syscalls to convert the name
into the corresponding numeric code, but using the number directly
may be useful if @value{GDBN}'s database does not have the complete
list of syscalls on your system (e.g., because @value{GDBN} lags
behind the OS upgrades).
WDYT?
> +@smallexample
> +(@value{GDBP}) catch syscall chroot
> +Catchpoint 1 (syscall(s) 'chroot')
Why do you have the "(s)" part in this message? You are announcing a
catchpoint for a single syscall, right?
> +Catchpoint 1 (call to syscall 'close'), \
> + 0xffffe424 in __kernel_vsyscall ()
> +Catchpoint 1 (returned from syscall 'close'), \
> + 0xffffe424 in __kernel_vsyscall ()
Is this all GDB displays when a syscall is caught? I thought it also
displayed the return code and the syscall parameters, like strace
does. If we don't do that, this facility looks much less useful than
it sounds, doesn't it? I realize that the user could glean all that
information by using the normal GDB commands, but for that, she would
need to know the some intimate details of the syscall dispatched
(__kernel_vsyscall in this case), right?
Also, how about showing the syscall number together with its name?
> +And last but not least, an example of specifying a system call
> +numerically:
> +
> +@smallexample
> +(@value{GDBP}) catch syscall 252
> +Catchpoint 1 (syscall(s) 'exit_group')
> +(@value{GDBP}) r
> +Starting program: /tmp/catch-syscall
> +
> +Catchpoint 1 (call to syscall 'exit_group'), \
> + 0xffffe424 in __kernel_vsyscall ()
This example uses a number, but the XML database obviously has the
corresponding name of the syscall, right? It would be more
interesting to have an example for a syscall whose name is not in the
XML file.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command
2009-04-25 8:44 ` Eli Zaretskii
@ 2009-04-26 7:32 ` Sérgio Durigan Júnior
2009-04-26 17:48 ` Eli Zaretskii
2009-04-26 18:05 ` Sérgio Durigan Júnior
2009-04-26 21:29 ` Sérgio Durigan Júnior
2 siblings, 1 reply; 8+ messages in thread
From: Sérgio Durigan Júnior @ 2009-04-26 7:32 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
Hi Eli,
Thanks for the review. Comments below.
On Sat, 2009-04-25 at 11:44 +0300, Eli Zaretskii wrote:
> > From: =?ISO-8859-1?Q?S=E9rgio?= Durigan =?ISO-8859-1?Q?J=FAnior?= <sergiodj@linux.vnet.ibm.com>
> > Date: Wed, 22 Apr 2009 21:33:02 -0300
> > +@var{name} can be any valid system call name in the system. You can
> > +use the @value{GDBN} command-line completion facilities to list the
> > +available choices. @xref{Completion,, Command Completion}, for
> > +details on how to do this.
> > +
> > +You may also specify the system call numerically. This may be useful
> > +if @value{GDBN} does not fully support your system's list of system
> > +calls.
>
> This text is okay, but it could still leave the reader wondering about
> too many things. How does GDB know which syscalls are available? what
> are the possible syscall numbers, and how do I know which ones are
> valid? what happens if I use a name or number that are invalid?
>
> The examples you give below answer some of these questions, and hint
> to answers to others, but I think we still need some general text
> about these issues, and we need a text that is as system-independent
> as possible. So I suggest this text instead:
>
> @var{name} can be any system call name that is valid for the
> underlying OS. Just what syscalls are valid depends on the OS. On
> GNU and Unix systems, you can find the full list of valid syscall
> names on <PUT HERE THE NAME OF SYSTEM FILE WHERE TO FIND THE LIST>.
>
> @c For MS-Windows, the syscall names and the corresponding numbers
> @c can be found, e.g., on this URL:
> @c http://www.metasploit.com/users/opcode/syscalls.html
> @c but we don't support Windows syscalls yet.
>
> Normally, @value{GDBN} knows in advance which syscalls are valid for
> each OS, so you can use the @value{GDBN} command-line completion
> facilities (@pxref{Completion,, command completion}) to list the
> available choices.
>
> You may also specify the system call numerically. A syscall's
> number is the value passed to the OS's syscall dispatcher to
> identify the requested service. When you specify the syscall by its
> name, @value{GDBN} uses its database of syscalls to convert the name
> into the corresponding numeric code, but using the number directly
> may be useful if @value{GDBN}'s database does not have the complete
> list of syscalls on your system (e.g., because @value{GDBN} lags
> behind the OS upgrades).
>
> WDYT?
Well, it's fine by me. If you think the user will feel more comfortable
by reading this, then I'll modify the text as suggested.
> > +@smallexample
> > +(@value{GDBP}) catch syscall chroot
> > +Catchpoint 1 (syscall(s) 'chroot')
>
> Why do you have the "(s)" part in this message? You are announcing a
> catchpoint for a single syscall, right?
Yeah. I'll do a more selective filtering here, printing singular/plural
correctly.
> > +Catchpoint 1 (call to syscall 'close'), \
> > + 0xffffe424 in __kernel_vsyscall ()
>
> > +Catchpoint 1 (returned from syscall 'close'), \
> > + 0xffffe424 in __kernel_vsyscall ()
>
> Is this all GDB displays when a syscall is caught? I thought it also
> displayed the return code and the syscall parameters, like strace
> does. If we don't do that, this facility looks much less useful than
> it sounds, doesn't it? I realize that the user could glean all that
> information by using the normal GDB commands, but for that, she would
> need to know the some intimate details of the syscall dispatched
> (__kernel_vsyscall in this case), right?
I'm sorry, but this is how the "catch syscall" was implemented since the
beginning. For the moment, GDB only prints the syscall name when the
catchpoint is triggered; it's obviously my intention to expand this in
the future (by making GDB print the syscall arguments, or its return
value for example), but I unfortunately don't have time to do it now.
However, IMHO I don't think it's a "much less useful" feature just
because of that. As far as I know, everybody here knew that the catch
syscall was all about printing the syscall name (for now, at least), and
nonetheless I've seen people very enthusiastic about it.
If you think the feature should include more things than it actually
does, then I'd be very happy to accept some help from you in order to
make it more complete.
> Also, how about showing the syscall number together with its name?
This is a good idea. Do you have any preference about the printing
style? I was thinking in something like:
Catchpoint 1 (call to syscall 'xyz' [number], ...)
What do you think?
Regards,
--
Sérgio Durigan Júnior
Linux on Power Toolchain - Software Engineer
Linux Technology Center - LTC
IBM Brazil
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command
2009-04-26 7:32 ` Sérgio Durigan Júnior
@ 2009-04-26 17:48 ` Eli Zaretskii
2009-04-26 17:55 ` Sérgio Durigan Júnior
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2009-04-26 17:48 UTC (permalink / raw)
To: Sérgio Durigan Júnior; +Cc: gdb-patches
> From: =?ISO-8859-1?Q?S=E9rgio?= Durigan =?ISO-8859-1?Q?J=FAnior?= <sergiodj@linux.vnet.ibm.com>
> Cc: gdb-patches@sourceware.org
> Date: Sun, 26 Apr 2009 04:32:14 -0300
>
> > @var{name} can be any system call name that is valid for the
> > underlying OS. Just what syscalls are valid depends on the OS. On
> > GNU and Unix systems, you can find the full list of valid syscall
> > names on <PUT HERE THE NAME OF SYSTEM FILE WHERE TO FIND THE LIST>.
> >
> > @c For MS-Windows, the syscall names and the corresponding numbers
> > @c can be found, e.g., on this URL:
> > @c http://www.metasploit.com/users/opcode/syscalls.html
> > @c but we don't support Windows syscalls yet.
> >
> > Normally, @value{GDBN} knows in advance which syscalls are valid for
> > each OS, so you can use the @value{GDBN} command-line completion
> > facilities (@pxref{Completion,, command completion}) to list the
> > available choices.
> >
> > You may also specify the system call numerically. A syscall's
> > number is the value passed to the OS's syscall dispatcher to
> > identify the requested service. When you specify the syscall by its
> > name, @value{GDBN} uses its database of syscalls to convert the name
> > into the corresponding numeric code, but using the number directly
> > may be useful if @value{GDBN}'s database does not have the complete
> > list of syscalls on your system (e.g., because @value{GDBN} lags
> > behind the OS upgrades).
> >
> > WDYT?
>
> Well, it's fine by me. If you think the user will feel more comfortable
> by reading this, then I'll modify the text as suggested.
I'm open to other opinions, if there are any. Anyone?
> > > +Catchpoint 1 (call to syscall 'close'), \
> > > + 0xffffe424 in __kernel_vsyscall ()
> >
> > > +Catchpoint 1 (returned from syscall 'close'), \
> > > + 0xffffe424 in __kernel_vsyscall ()
> >
> > Is this all GDB displays when a syscall is caught? I thought it also
> > displayed the return code and the syscall parameters, like strace
> > does. If we don't do that, this facility looks much less useful than
> > it sounds, doesn't it? I realize that the user could glean all that
> > information by using the normal GDB commands, but for that, she would
> > need to know the some intimate details of the syscall dispatched
> > (__kernel_vsyscall in this case), right?
>
> I'm sorry, but this is how the "catch syscall" was implemented since the
> beginning. For the moment, GDB only prints the syscall name when the
> catchpoint is triggered; it's obviously my intention to expand this in
> the future (by making GDB print the syscall arguments, or its return
> value for example), but I unfortunately don't have time to do it now.
That's fine with me. Please don't regard my comments as rejection of
what you've done.
> > Also, how about showing the syscall number together with its name?
>
> This is a good idea. Do you have any preference about the printing
> style? I was thinking in something like:
>
> Catchpoint 1 (call to syscall 'xyz' [number], ...)
Fine with me.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command
2009-04-26 17:48 ` Eli Zaretskii
@ 2009-04-26 17:55 ` Sérgio Durigan Júnior
0 siblings, 0 replies; 8+ messages in thread
From: Sérgio Durigan Júnior @ 2009-04-26 17:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
Hi Eli,
On Sun, 2009-04-26 at 20:48 +0300, Eli Zaretskii wrote:
> > > > +Catchpoint 1 (call to syscall 'close'), \
> > > > + 0xffffe424 in __kernel_vsyscall ()
> > >
> > > > +Catchpoint 1 (returned from syscall 'close'), \
> > > > + 0xffffe424 in __kernel_vsyscall ()
> > >
> > > Is this all GDB displays when a syscall is caught? I thought it also
> > > displayed the return code and the syscall parameters, like strace
> > > does. If we don't do that, this facility looks much less useful than
> > > it sounds, doesn't it? I realize that the user could glean all that
> > > information by using the normal GDB commands, but for that, she would
> > > need to know the some intimate details of the syscall dispatched
> > > (__kernel_vsyscall in this case), right?
> >
> > I'm sorry, but this is how the "catch syscall" was implemented since the
> > beginning. For the moment, GDB only prints the syscall name when the
> > catchpoint is triggered; it's obviously my intention to expand this in
> > the future (by making GDB print the syscall arguments, or its return
> > value for example), but I unfortunately don't have time to do it now.
>
> That's fine with me. Please don't regard my comments as rejection of
> what you've done.
Sorry if this sounded too personal. It was not my intention.
Thanks for the review, I'll send a refreshed patch probably today.
Regards,
--
Sérgio Durigan Júnior
Linux on Power Toolchain - Software Engineer
Linux Technology Center - LTC
IBM Brazil
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command
2009-04-25 8:44 ` Eli Zaretskii
2009-04-26 7:32 ` Sérgio Durigan Júnior
@ 2009-04-26 18:05 ` Sérgio Durigan Júnior
2009-04-26 18:52 ` Eli Zaretskii
2009-04-26 21:29 ` Sérgio Durigan Júnior
2 siblings, 1 reply; 8+ messages in thread
From: Sérgio Durigan Júnior @ 2009-04-26 18:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
Hi Eli,
Just one question that I forgot to ask.
On Sat, 2009-04-25 at 11:44 +0300, Eli Zaretskii wrote:
> @var{name} can be any system call name that is valid for the
> underlying OS. Just what syscalls are valid depends on the OS. On
> GNU and Unix systems, you can find the full list of valid syscall
> names on <PUT HERE THE NAME OF SYSTEM FILE WHERE TO FIND THE LIST>.
I'm having a hard time trying to figure out what to put in "<PUT HERE
THE NAME OF SYSTEM FILE WHERE TO FIND THE LIST>". Basically, I'd like
to write something like "... valid syscall names on the XML files inside
@file{syscalls/} directory.", but I should mention where the syscalls/
directory is located, right? Do you have any ideas on how to write
this?
Thanks,
--
Sérgio Durigan Júnior
Linux on Power Toolchain - Software Engineer
Linux Technology Center - LTC
IBM Brazil
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command
2009-04-26 18:05 ` Sérgio Durigan Júnior
@ 2009-04-26 18:52 ` Eli Zaretskii
0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2009-04-26 18:52 UTC (permalink / raw)
To: Sérgio Durigan Júnior; +Cc: gdb-patches
> From: =?ISO-8859-1?Q?S=E9rgio?= Durigan =?ISO-8859-1?Q?J=FAnior?= <sergiodj@linux.vnet.ibm.com>
> Cc: gdb-patches@sourceware.org
> Date: Sun, 26 Apr 2009 15:04:54 -0300
>
> > @var{name} can be any system call name that is valid for the
> > underlying OS. Just what syscalls are valid depends on the OS. On
> > GNU and Unix systems, you can find the full list of valid syscall
> > names on <PUT HERE THE NAME OF SYSTEM FILE WHERE TO FIND THE LIST>.
>
> I'm having a hard time trying to figure out what to put in "<PUT HERE
> THE NAME OF SYSTEM FILE WHERE TO FIND THE LIST>".
How about the header file from the kernel sources which you mentioned
in the XML files? Like this one, from x86 Linux:
/usr/src/linux/arch/x86/include/asm/unistd_32.h
Unless there's a better place to point the readers, that is. Maybe
some URL?
If there's no good place to look for that on your garden-variety
system, just delete that sentence.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command
2009-04-25 8:44 ` Eli Zaretskii
2009-04-26 7:32 ` Sérgio Durigan Júnior
2009-04-26 18:05 ` Sérgio Durigan Júnior
@ 2009-04-26 21:29 ` Sérgio Durigan Júnior
2 siblings, 0 replies; 8+ messages in thread
From: Sérgio Durigan Júnior @ 2009-04-26 21:29 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1336 bytes --]
Hi Eli,
On Sat, 2009-04-25 at 11:44 +0300, Eli Zaretskii wrote:
> > From: =?ISO-8859-1?Q?S=E9rgio?= Durigan =?ISO-8859-1?Q?J=FAnior?= <sergiodj@linux.vnet.ibm.com>
> > Date: Wed, 22 Apr 2009 21:33:02 -0300
Here goes the new version of the patch. Please take a look.
--
Sérgio Durigan Júnior
Linux on Power Toolchain - Software Engineer
Linux Technology Center - LTC
IBM Brazil
gdb/ChangeLog:
2009-04-26 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
* Makefile.in: Support for relocatable GDB datadir and XML
syscall.
* NEWS: Added information about the catch syscall feature.
* configure, config.in: Regenerate.
* configure.ac: Support for relocatable GDB datadir.
* defs.h (data_directory): New variable used for relocatable GDB
datadir.
* main.c: Add gdb_datadir variable to store the current GDB datadir.
(captured_main): Add the GDB datadir relocatable handler.
* maint.c: Create the "maintenance set gdb_datadir" command.
gdb/doc/ChangeLog:
2009-04-26 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
* gdb.texinfo (Set Catchpoints): Documentation about the new
feature.
gdb/testsuite/ChangeLog:
2009-04-26 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
* Makefile.in: Inclusion of catch-syscall object.
* gdb.base/catch-syscall.c: New file.
* gdb.base/catch-syscall.exp: New file.
[-- Attachment #2: catch-syscall-build-test-doc.patch --]
[-- Type: text/x-patch, Size: 37014 bytes --]
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 35c3813..df29e50 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -166,6 +166,9 @@ INTL_CFLAGS = @INCINTL@
TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
+# Did the user give us a --with-gdb-datadir option?
+GDB_DATADIR_PATH = @GDB_DATADIR_PATH@
+
# Helper code from gnulib.
LIBGNU = gnulib/libgnu.a
INCGNU = -I$(srcdir)/gnulib -Ignulib
@@ -458,6 +461,7 @@ TARGET_OBS = @TARGET_OBS@
# All target-dependent objects files that require 64-bit CORE_ADDR
# (used with --enable-targets=all --enable-64-bit-bfd).
ALL_64_TARGET_OBS = \
+ linux-tdep.o \
alphabsd-tdep.o alphafbsd-tdep.o alpha-linux-tdep.o alpha-mdebug-tdep.o \
alphanbsd-tdep.o alphaobsd-tdep.o alpha-osf1-tdep.o alpha-tdep.o \
amd64fbsd-tdep.o amd64-dicos-tdep.o amd64-linux-tdep.o amd64nbsd-tdep.o \
@@ -469,6 +473,7 @@ ALL_64_TARGET_OBS = \
# All other target-dependent objects files (used with --enable-targets=all).
ALL_TARGET_OBS = \
+ linux-tdep.o \
armbsd-tdep.o arm-linux-tdep.o armnbsd-tdep.o armobsd-tdep.o \
arm-tdep.o arm-wince-tdep.o \
avr-tdep.o \
@@ -664,6 +669,8 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
valarith.c valops.c valprint.c value.c varobj.c vec.c \
wrapper.c \
xml-tdesc.c xml-support.c \
+ linux-tdep.c \
+ xml-syscall.c \
inferior.c gdb_usleep.c
LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
@@ -674,7 +681,7 @@ LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
# wrong if TAGS has files twice). Because this is tricky to get
# right, it is probably easiest just to list .h files here directly.
-HFILES_NO_SRCDIR = osf-share/cma_debug_client.h \
+HFILES_NO_SRCDIR = osf-share/cma_debug_client.h linux-tdep.h \
osf-share/HP800/cma_thread_io.h osf-share/cma_sequence.h \
osf-share/cma_mutex.h osf-share/cma_semaphore_defs.h \
osf-share/cma_list.h osf-share/cma_handle.h osf-share/cma_stack.h \
@@ -735,7 +742,7 @@ config/rs6000/nm-rs6000.h top.h bsd-kvm.h gdb-stabs.h reggroups.h \
annotate.h sim-regno.h dictionary.h dfp.h main.h frame-unwind.h \
remote-fileio.h i386-linux-tdep.h vax-tdep.h objc-lang.h \
sentinel-frame.h bcache.h symfile.h windows-tdep.h linux-tdep.h \
-gdb_usleep.h
+xml-syscall.h gdb_usleep.h
# Header files that already have srcdir in them, or which are in objdir.
@@ -814,10 +821,16 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
trad-frame.o \
tramp-frame.o \
solib.o solib-null.o \
- prologue-value.o memory-map.o xml-support.o \
+ prologue-value.o memory-map.o xml-support.o xml-syscall.o \
target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \
inferior.o osdata.o gdb_usleep.o
+# Definitions for the syscall's XML files and dir
+XML_SYSCALLS_DIR = syscalls/
+XML_SYSCALLS_FILES = gdb-syscalls.dtd \
+ ppc-linux.xml ppc64-linux.xml \
+ i386-linux.xml amd64-linux.xml
+
TSOBS = inflow.o
SUBDIRS = @subdirs@
@@ -851,11 +864,41 @@ generated_files = config.h observer.h observer.inc ada-lex.c \
$(COMPILE) $<
$(POSTCOMPILE)
-all: gdb$(EXEEXT) $(CONFIG_ALL)
+all: gdb$(EXEEXT) $(CONFIG_ALL) xml-syscall-copy
@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
.PHONY: all-tui
all-tui: $(TUI)$(EXEEXT)
+# This is needed for running GDB from the build directory
+.PHONY: xml-syscall-copy
+xml-syscall-copy:
+ if [ "`cd $(srcdir) && pwd`" != "`pwd`" ] ; then \
+ mkdir -p ./$(XML_SYSCALLS_DIR) ; \
+ list='$(XML_SYSCALLS_FILES)' ; \
+ for file in $$list ; do \
+ f=$(srcdir)/$(XML_SYSCALLS_DIR)/$$file ; \
+ if test -f $$f ; then \
+ $(INSTALL_DATA) $$f \
+ ./$(XML_SYSCALLS_DIR) ; \
+ fi ; \
+ done ; \
+ fi ;
+
+# This target is responsible for properly installing the syscalls'
+# XML files in the system.
+.PHONY: xml-syscall-install
+xml-syscall-install:
+ $(SHELL) $(srcdir)/../mkinstalldirs \
+ $(DESTDIR)$(GDB_DATADIR_PATH)/$(XML_SYSCALLS_DIR) ; \
+ list='$(XML_SYSCALLS_FILES)' ; \
+ for file in $$list ; do \
+ f=$(srcdir)/$(XML_SYSCALLS_DIR)/$$file ; \
+ if test -f $$f ; then \
+ $(INSTALL_DATA) $$f \
+ $(DESTDIR)$(GDB_DATADIR_PATH)/$(XML_SYSCALLS_DIR) ; \
+ fi ; \
+ done ;
+
installcheck:
# The check target can not use subdir_do, because subdir_do does not
@@ -909,8 +952,11 @@ gdb.z:gdb.1
# source file and doesn't care about rebuilding or just wants to save the
# time it takes for make to check that all is up to date.
# install-only is intended to address that need.
-install: all install-only
-install-only: $(CONFIG_INSTALL)
+install: all install-only
+
+# The "install-only" target also installs the syscalls' XML files in
+# the system.
+install-only: $(CONFIG_INSTALL) xml-syscall-install
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e "$$t"` ; \
if test "x$$transformed_name" = x; then \
@@ -1268,6 +1314,7 @@ force_update:
MAKEOVERRIDES=
ALLDEPFILES = \
+ linux-tdep.c \
aix-thread.c \
alpha-nat.c alphabsd-nat.c alpha-linux-nat.c \
alpha-tdep.c alpha-mdebug-tdep.c \
diff --git a/gdb/NEWS b/gdb/NEWS
index 8382026..e045551 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,35 @@
*** Changes since GDB 6.8
+* GDB now has the new command `catch syscall'. It can be used to
+catch when the inferior calls a system call, or when the system call
+returns. Also, you can specify which system calls you would like GDB
+to catch (or issue only a `catch syscall' without arguments, which will
+make GDB catch every system call). For instance, if you would like to
+catch the system call close, you would issue a:
+
+ (gdb) catch syscall close
+
+Then, when the program is running again, GDB will keep track of all
+the system calls the inferior is calling, and will stop the execution
+if the system call called or returned is equal to the system call
+that you asked it to catch (note that if you did not provide any system
+call, then GDB would stop on any system call). After stopping the
+inferior, GDB will print something like:
+
+ Catchpoint 1 (call to syscall 'close'),
+ 0xb7ff831d in ?? () from /lib/ld-linux.so.2
+
+It indicates that the correct system call was caught. If you choose
+to continue the execution of the inferior from this point, then you
+should see GDB catching the return of this system call, like that:
+
+ Catchpoint 1 (returned from syscall 'close'),
+ 0xb7ff831d in ?? () from /lib/ld-linux.so.2
+
+This feature is available with a native GDB running on the Linux Kernel,
+under the following architectures: x86, PowerPC and PowerPC64.
+
* GDB now supports hardware watchpoints on MIPS/Linux systems. This
feature is available with a native GDB running on kernel version
2.6.28 or later.
diff --git a/gdb/configure b/gdb/configure
index 4444ffa..cc0e809 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -6571,7 +6571,6 @@ am__api_version="1.9"
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
@@ -6605,18 +6604,8 @@ case $as_dir/ in
# program-specific install script used by HP pwplus--don't use.
:
else
- rm -rf conftest.one conftest.two conftest.dir
- echo one > conftest.one
- echo two > conftest.two
- mkdir conftest.dir
- if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
- test -s conftest.one && test -s conftest.two &&
- test -s conftest.dir/conftest.one &&
- test -s conftest.dir/conftest.two
- then
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
fi
fi
done
@@ -6625,16 +6614,15 @@ case $as_dir/ in
esac
done
-rm -rf conftest.one conftest.two conftest.dir
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_cv_path_install
else
- # As a last resort, use the slow shell script. Don't cache a
- # value for INSTALL within a source directory, because that will
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
- # removed, or if the value is a relative name.
+ # removed, or if the path is relative.
INSTALL=$ac_install_sh
fi
fi
@@ -8651,7 +8639,6 @@ done
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
@@ -8685,18 +8672,8 @@ case $as_dir/ in
# program-specific install script used by HP pwplus--don't use.
:
else
- rm -rf conftest.one conftest.two conftest.dir
- echo one > conftest.one
- echo two > conftest.two
- mkdir conftest.dir
- if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
- test -s conftest.one && test -s conftest.two &&
- test -s conftest.dir/conftest.one &&
- test -s conftest.dir/conftest.two
- then
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
fi
fi
done
@@ -8705,16 +8682,15 @@ case $as_dir/ in
esac
done
-rm -rf conftest.one conftest.two conftest.dir
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_cv_path_install
else
- # As a last resort, use the slow shell script. Don't cache a
- # value for INSTALL within a source directory, because that will
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
- # removed, or if the value is a relative name.
+ # removed, or if the path is relative.
INSTALL=$ac_install_sh
fi
fi
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index f06f5f0..4d8907e 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -36,7 +36,7 @@ alpha*-*-osf*)
alpha*-*-linux*)
# Target: Little-endian Alpha running Linux
gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-linux-tdep.o \
- solib.o solib-svr4.o"
+ solib.o solib-svr4.o linux-tdep.o"
;;
alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
# Target: FreeBSD/alpha
@@ -63,7 +63,7 @@ alpha*-*-*)
am33_2.0*-*-linux*)
# Target: Matsushita mn10300 (AM33) running Linux
gdb_target_obs="mn10300-tdep.o mn10300-linux-tdep.o corelow.o \
- solib.o solib-svr4.o"
+ solib.o solib-svr4.o linux-tdep.o"
;;
arm*-wince-pe | arm*-*-mingw32ce*)
@@ -75,7 +75,8 @@ arm*-wince-pe | arm*-*-mingw32ce*)
arm*-*-linux*)
# Target: ARM based machine running GNU/Linux
gdb_target_obs="arm-tdep.o arm-linux-tdep.o glibc-tdep.o \
- solib.o solib-svr4.o symfile-mem.o corelow.o linux-tdep.o"
+ solib.o solib-svr4.o symfile-mem.o corelow.o \
+ linux-tdep.o"
build_gdbserver=yes
;;
arm*-*-netbsd* | arm*-*-knetbsd*-gnu)
@@ -134,7 +135,7 @@ hppa*-*-hpux*)
hppa*-*-linux*)
# Target: HP PA-RISC running Linux
gdb_target_obs="hppa-tdep.o hppa-linux-tdep.o glibc-tdep.o \
- solib.o solib-svr4.o symfile-mem.o"
+ solib.o solib-svr4.o symfile-mem.o linux-tdep.o"
;;
hppa*-*-netbsd*)
# Target: NetBSD/hppa
@@ -228,7 +229,7 @@ i[34567]86-*-*)
ia64-*-linux*)
# Target: Intel IA-64 running GNU/Linux
gdb_target_obs="ia64-tdep.o ia64-linux-tdep.o \
- solib.o solib-svr4.o symfile-mem.o"
+ solib.o solib-svr4.o symfile-mem.o linux-tdep.o"
build_gdbserver=yes
;;
ia64*-*-*)
@@ -252,7 +253,8 @@ m32c-*-*)
m32r*-*-linux*)
# Target: Renesas M32R running GNU/Linux
gdb_target_obs="m32r-tdep.o m32r-linux-tdep.o remote-m32r-sdi.o \
- glibc-tdep.o solib.o solib-svr4.o symfile-mem.o"
+ glibc-tdep.o solib.o solib-svr4.o symfile-mem.o \
+ linux-tdep.o"
gdb_sim=../sim/m32r/libsim.a
build_gdbserver=yes
;;
@@ -277,7 +279,7 @@ fido-*-elf*)
m68*-*-linux*)
# Target: Motorola m68k with a.out and ELF
gdb_target_obs="m68k-tdep.o m68klinux-tdep.o solib.o solib-svr4.o \
- glibc-tdep.o symfile-mem.o"
+ glibc-tdep.o symfile-mem.o linux-tdep.o"
build_gdbserver=yes
;;
m68*-*-netbsd* | m68*-*-knetbsd*-gnu)
@@ -313,7 +315,8 @@ mips*-sgi-irix6*)
mips*-*-linux*)
# Target: Linux/MIPS
gdb_target_obs="mips-tdep.o mips-linux-tdep.o glibc-tdep.o \
- corelow.o solib.o solib-svr4.o symfile-mem.o"
+ corelow.o solib.o solib-svr4.o symfile-mem.o \
+ linux-tdep.o"
gdb_sim=../sim/mips/libsim.a
build_gdbserver=yes
;;
@@ -364,7 +367,8 @@ powerpc-*-aix* | rs6000-*-*)
powerpc-*-linux* | powerpc64-*-linux*)
# Target: PowerPC running Linux
gdb_target_obs="rs6000-tdep.o ppc-linux-tdep.o ppc-sysv-tdep.o \
- solib.o solib-svr4.o corelow.o symfile-mem.o"
+ solib.o solib-svr4.o corelow.o symfile-mem.o \
+ linux-tdep.o"
gdb_sim=../sim/ppc/libsim.a
build_gdbserver=yes
;;
@@ -391,7 +395,8 @@ score-*-*)
sh*-*-linux*)
# Target: GNU/Linux Super-H
gdb_target_obs="sh-tdep.o sh64-tdep.o sh-linux-tdep.o monitor.o \
- dsrec.o solib.o solib-svr4.o symfile-mem.o glibc-tdep.o"
+ dsrec.o solib.o solib-svr4.o symfile-mem.o glibc-tdep.o \
+ linux-tdep.o"
gdb_sim=../sim/sh/libsim.a
build_gdbserver=yes
;;
@@ -419,7 +424,8 @@ sh*)
sparc-*-linux*)
# Target: GNU/Linux SPARC
gdb_target_obs="sparc-tdep.o sparc-sol2-tdep.o sol2-tdep.o \
- sparc-linux-tdep.o solib.o solib-svr4.o symfile-mem.o"
+ sparc-linux-tdep.o solib.o solib-svr4.o symfile-mem.o \
+ linux-tdep.o"
if test "x$enable_64_bit_bfd" = "xyes"; then
# Target: GNU/Linux UltraSPARC
gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o \
@@ -430,7 +436,7 @@ sparc64-*-linux*)
# Target: GNU/Linux UltraSPARC
gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o sol2-tdep.o \
sparc64-linux-tdep.o sparc-tdep.o sparc-sol2-tdep.o \
- sparc-linux-tdep.o solib.o solib-svr4.o"
+ sparc-linux-tdep.o solib.o solib-svr4.o linux-tdep.o"
build_gdbserver=yes
;;
sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
@@ -528,7 +534,8 @@ x86_64-*-linux*)
# Target: GNU/Linux x86-64
gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o i386-tdep.o \
i387-tdep.o i386-linux-tdep.o glibc-tdep.o \
- solib.o solib-svr4.o corelow.o symfile-mem.o linux-tdep.o"
+ solib.o solib-svr4.o corelow.o symfile-mem.o \
+ linux-tdep.o"
build_gdbserver=yes
;;
x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
@@ -557,7 +564,8 @@ x86_64-*-openbsd*)
xtensa*-*-linux*) gdb_target=linux
# Target: GNU/Linux Xtensa
gdb_target_obs="xtensa-tdep.o xtensa-config.o xtensa-linux-tdep.o \
- solib.o solib-svr4.o corelow.o symfile-mem.o"
+ solib.o solib-svr4.o corelow.o symfile-mem.o \
+ linux-tdep.o"
build_gdbserver=yes
;;
xtensa*)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 7ae9e1c..2fb46b2 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -3640,6 +3640,137 @@ A failed Ada assertion.
A call to @code{exec}. This is currently only available for HP-UX
and @sc{gnu}/Linux.
+@item syscall
+@itemx syscall @r{[}@var{name} @r{|} @var{number}@r{]} @r{...}
+@cindex break on a system call.
+A call to or return from a system call, a.k.a.@: @dfn{syscall}. A
+syscall is a mechanism for application programs to request a service
+from the operating system (OS) or one of the OS system services.
+@value{GDBN} can catch some or all of the syscalls issued by the
+debuggee, and show the related information for each syscall. If no
+argument is specified, calls to and returns from all system calls
+will be caught.
+
+@var{name} can be any system call name that is valid for the
+underlying OS. Just what syscalls are valid depends on the OS. On
+GNU and Unix systems, you can find the full list of valid syscall
+names on @file{/usr/include/asm/unistd.h}.
+
+@c For MS-Windows, the syscall names and the corresponding numbers
+@c can be found, e.g., on this URL:
+@c http://www.metasploit.com/users/opcode/syscalls.html
+@c but we don't support Windows syscalls yet.
+
+Normally, @value{GDBN} knows in advance which syscalls are valid for
+each OS, so you can use the @value{GDBN} command-line completion
+facilities (@pxref{Completion,, command completion}) to list the
+available choices.
+
+You may also specify the system call numerically. A syscall's
+number is the value passed to the OS's syscall dispatcher to
+identify the requested service. When you specify the syscall by its
+name, @value{GDBN} uses its database of syscalls to convert the name
+into the corresponding numeric code, but using the number directly
+may be useful if @value{GDBN}'s database does not have the complete
+list of syscalls on your system (e.g., because @value{GDBN} lags
+behind the OS upgrades).
+
+The example below illustrates how this command works if you don't provide
+arguments to it:
+
+@smallexample
+(@value{GDBP}) catch syscall
+Catchpoint 1 (syscall)
+(@value{GDBP}) r
+Starting program: /tmp/catch-syscall
+
+Catchpoint 1 (call to syscall 'close'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP}) c
+Continuing.
+
+Catchpoint 1 (returned from syscall 'close'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP})
+@end smallexample
+
+Here is an example of catching a system call by name:
+
+@smallexample
+(@value{GDBP}) catch syscall chroot
+Catchpoint 1 (syscall 'chroot' [61])
+(@value{GDBP}) r
+Starting program: /tmp/catch-syscall
+
+Catchpoint 1 (call to syscall 'chroot'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP}) c
+Continuing.
+
+Catchpoint 1 (returned from syscall 'chroot'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP})
+@end smallexample
+
+An example of specifying a system call numerically. In the case
+below, the syscall number has a corresponding entry in the XML
+file, so @value{GDBN} finds its name and prints it:
+
+@smallexample
+(@value{GDBP}) catch syscall 252
+Catchpoint 1 (syscall(s) 'exit_group')
+(@value{GDBP}) r
+Starting program: /tmp/catch-syscall
+
+Catchpoint 1 (call to syscall 'exit_group'), \
+ 0xffffe424 in __kernel_vsyscall ()
+(@value{GDBP}) c
+Continuing.
+
+Program exited normally.
+(@value{GDBP})
+@end smallexample
+
+However, there can be situations when there is no corresponding name
+in XML file for that syscall number. In this case, @value{GDBN} prints
+a warning message saying that it was not able to find the syscall name,
+but the catchpoint will be set anyway. See the example below:
+
+@smallexample
+(@value{GDBP}) catch syscall 764
+warning: The number '764' does not represent a known syscall.
+Catchpoint 2 (syscall 764)
+(@value{GDBP})
+@end smallexample
+
+If you configure @value{GDBN} using the @samp{--without-expat} option,
+it will not be able to display syscall names. Also, if your
+architecture does not have an XML file describing its system calls,
+you will not be able to see the syscall names. It is important to
+notice that these two features are used for accessing the syscall
+name database. In either case, you will see a warning like this:
+
+@smallexample
+(@value{GDBP}) catch syscall
+warning: Could not open "syscalls/i386-linux.xml"
+warning: Could not load the syscall XML file 'syscalls/i386-linux.xml'.
+GDB will not be able to display syscall names.
+Catchpoint 1 (syscall)
+(@value{GDBP})
+@end smallexample
+
+Of course, the file name will change depending on your architecture and system.
+
+Still using the example above, you can also try to catch a syscall by its
+number. In this case, you would see something like:
+
+@smallexample
+(@value{GDBP}) catch syscall 252
+Catchpoint 1 (syscall(s) 252)
+@end smallexample
+
+Again, in this case @value{GDBN} would not be able to display syscall's names.
+
@item fork
A call to @code{fork}. This is currently only available for HP-UX
and @sc{gnu}/Linux.
diff --git a/gdb/testsuite/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in
index 9f382db..12db521 100644
--- a/gdb/testsuite/gdb.base/Makefile.in
+++ b/gdb/testsuite/gdb.base/Makefile.in
@@ -12,7 +12,7 @@ EXECUTABLES = all-types annota1 bitfields break \
scope section_command setshow setvar shmain sigall signals \
solib solib_sl so-impl-ld so-indr-cl \
step-line step-test structs structs2 \
- twice-tmp varargs vforked-prog watchpoint whatis
+ twice-tmp varargs vforked-prog watchpoint whatis catch-syscall
MISCELLANEOUS = coremmap.data ../foobar.baz \
shr1.sl shr2.sl solib_sl.sl solib1.sl solib2.sl
diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.base/catch-syscall.c
new file mode 100644
index 0000000..64850de
--- /dev/null
+++ b/gdb/testsuite/gdb.base/catch-syscall.c
@@ -0,0 +1,25 @@
+/* This file is used to test the 'catch syscall' feature on GDB.
+
+ Please, if you are going to edit this file DO NOT change the syscalls
+ being called (nor the order of them). If you really must do this, then
+ take a look at catch-syscall.exp and modify there too.
+
+ Written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
+ September, 2008 */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+int
+main (void)
+{
+ /* A close() with a wrong argument. We are only
+ interested in the syscall. */
+ close (-1);
+
+ chroot (".");
+
+ /* The last syscall. Do not change this. */
+ _exit (0);
+}
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
new file mode 100644
index 0000000..ff56de7
--- /dev/null
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -0,0 +1,445 @@
+# Copyright 1997, 1999, 2007, 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# This program tests the 'catch syscall' functionality.
+#
+# It was written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
+# on September/2008.
+
+if { [is_remote target] || ![isnative] } then {
+ continue
+}
+
+set prms_id 0
+set bug_id 0
+
+global srcfile
+set testfile "catch-syscall"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+# All (but the last) syscalls from the example code
+# They are ordered according to the file, so do not change this.
+set all_syscalls { "close" "chroot" }
+set all_syscalls_numbers { }
+# The last syscall (exit()) does not return, so
+# we cannot expect the catchpoint to be triggered
+# twice. It is a special case.
+set last_syscall "exit_group"
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested catch-syscall.exp
+ return -1
+}
+
+# Until "catch syscall" is implemented on other targets...
+if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
+ continue
+}
+
+# This shall be updated whenever 'catch syscall' is implemented
+# on some architecture.
+#if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
+if { ![istarget "i\[34567\]86-*-linux*"]
+ && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"] } {
+ continue
+}
+
+# Internal procedure used to check if, after issuing a 'catch syscall'
+# command (without arguments), the 'info breakpoints' command displays
+# that '"any syscall"' is to be caught.
+proc check_info_bp_any_syscall {} {
+ global gdb_prompt
+
+ # Verifying that the catchpoint appears in the 'info breakpoints'
+ # command, but with "<any syscall>".
+ set thistest "catch syscall appears in 'info breakpoints'"
+ gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall \"<any syscall>\".*" $thistest
+}
+
+# Internal procedure used to check if, after issuing a 'catch syscall X'
+# command (with arguments), the 'info breakpoints' command displays
+# that the syscall 'X' is to be caught.
+proc check_info_bp_specific_syscall { syscall } {
+ global gdb_prompt
+
+ set thistest "syscall(s) $syscall appears in 'info breakpoints'"
+ gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall(\[(\]s\[)\])? (.)?${syscall}(.)?.*" $thistest
+}
+
+# Internal procedure used to check if, after issuing a 'catch syscall X'
+# command (with many arguments), the 'info breakpoints' command displays
+# that the syscalls 'X' are to be caught.
+proc check_info_bp_many_syscalls { syscalls } {
+ global gdb_prompt
+ set filter_str ""
+
+ foreach name $syscalls {
+ set filter_str "${filter_str}${name}, "
+ }
+
+ set filter_str [ string trimright $filter_str ", " ]
+
+ set thistest "syscalls $filter_str appears in 'info breakpoints'"
+ gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscalls (.)?${filter_str}(.)?.*" $thistest
+}
+
+# This procedure checks if there was a call to a syscall.
+proc check_call_to_syscall { syscall } {
+ global gdb_prompt
+
+ set thistest "program has called $syscall"
+ gdb_test "continue" "Catchpoint .*(call to syscall .?${syscall}.?).*" $thistest
+}
+
+# This procedure checks if the syscall returned.
+proc check_return_from_syscall { syscall } {
+ global gdb_prompt
+
+ set thistest "syscall $syscall has returned"
+ gdb_test "continue" "Catchpoint .*(returned from syscall (.)?${syscall}(.)?).*" $thistest
+}
+
+# Internal procedure that performs two 'continue' commands and checks if
+# a syscall call AND return occur.
+proc check_continue { syscall } {
+ global gdb_prompt
+
+ # Testing if the 'continue' stops at the
+ # specified syscall_name. If it does, then it should
+ # first print that the infeior has called the syscall,
+ # and after print that the syscall has returned.
+
+ # Testing if the inferiorr has called the syscall.
+ check_call_to_syscall $syscall
+ # And now, that the syscall has returned.
+ check_return_from_syscall $syscall
+}
+
+# Inserts a syscall catchpoint with an argument.
+proc insert_catch_syscall_with_arg { syscall } {
+ global gdb_prompt
+
+ # Trying to set the catchpoint
+ set thistest "catch syscall with arguments ($syscall)"
+ gdb_test "catch syscall $syscall" "Catchpoint .*(syscall (.)?${syscall}(.)?( \[\[0-9\]+\])?).*" $thistest
+
+ check_info_bp_specific_syscall $syscall
+}
+
+# Inserts a syscall catchpoint with many arguments.
+proc insert_catch_syscall_with_many_args { syscalls numbers } {
+ global gdb_prompt
+ set catch [ join $syscalls " " ]
+ set filter_str ""
+
+ foreach name $syscalls number $numbers {
+ set filter_str "${filter_str}'${name}' \[${number}\] "
+ }
+
+ set filter_str [ string trimright $filter_str " " ]
+
+ # Trying to set the catchpoint
+ set thistest "catch syscall with arguments ($filter_str)"
+ gdb_test "catch syscall $catch" "Catchpoint .*(syscalls (.)?${filter_str}(.)?).*" $thistest
+
+ check_info_bp_many_syscalls $syscalls
+}
+
+proc check_for_program_end {} {
+ global gdb_prompt
+
+ # Deleting the catchpoints
+ delete_breakpoints
+
+ set thistest "successful program end"
+ gdb_test "continue" "Program exited normally.*" $thistest
+
+}
+
+proc test_catch_syscall_without_args {} {
+ global gdb_prompt all_syscalls last_syscall
+
+ # Trying to set the syscall
+ set thistest "setting catch syscall without arguments"
+ gdb_test "catch syscall" "Catchpoint .*(syscall).*" $thistest
+
+ check_info_bp_any_syscall
+
+ # We have to check every syscall
+ foreach name $all_syscalls {
+ check_continue $name
+ }
+
+ # At last but not least, we check if the inferior
+ # has called the last (exit) syscall.
+ check_call_to_syscall $last_syscall
+
+ # Now let's see if the inferior correctly finishes.
+ check_for_program_end
+}
+
+proc test_catch_syscall_with_args {} {
+ global gdb_prompt
+ set syscall_name "close"
+
+ insert_catch_syscall_with_arg $syscall_name
+
+ # Can we continue until we catch the syscall?
+ check_continue $syscall_name
+
+ # Now let's see if the inferior correctly finishes.
+ check_for_program_end
+}
+
+proc test_catch_syscall_with_many_args {} {
+ global gdb_prompt all_syscalls all_syscalls_numbers
+
+ insert_catch_syscall_with_many_args $all_syscalls $all_syscalls_numbers
+
+ # Can we continue until we catch the syscalls?
+ foreach name $all_syscalls {
+ check_continue $name
+ }
+
+ # Now let's see if the inferior correctly finishes.
+ check_for_program_end
+}
+
+proc test_catch_syscall_with_wrong_args {} {
+ global gdb_prompt
+ # mlock is not called from the source
+ set syscall_name "mlock"
+
+ insert_catch_syscall_with_arg $syscall_name
+
+ # Now, we must verify if the program stops with a continue.
+ # If it doesn't, everything is right (since we don't have
+ # a syscall named "mlock" in it). Otherwise, this is a failure.
+ set thistest "catch syscall with unused syscall ($syscall_name)"
+ gdb_test "continue" "Program exited normally.*" $thistest
+}
+
+proc test_catch_syscall_restarting_inferior {} {
+ global gdb_prompt
+ set syscall_name "chroot"
+
+ insert_catch_syscall_with_arg $syscall_name
+
+ # Let's first reach the call of the syscall.
+ check_call_to_syscall $syscall_name
+
+ # Now, restart the program
+ rerun_to_main
+
+ # And check for call/return
+ check_continue $syscall_name
+
+ # Can we finish?
+ check_for_program_end
+}
+
+proc do_syscall_tests {} {
+ global gdb_prompt srcdir
+
+ # First, we need to set GDB datadir.
+ send_gdb "set data-directory $srcdir/..\n"
+ gdb_expect 10 {
+ -re "$gdb_prompt $" {
+ verbose "Setting GDB datadir to $srcdir/..." 2
+ }
+ timeout {
+ error "Couldn't set GDB datadir."
+ }
+ }
+
+ # Verify that the 'catch syscall' help is available
+ set thistest "help catch syscall"
+ gdb_test "help catch syscall" "Catch system calls.*" $thistest
+
+ # Try to set a catchpoint to a nonsense syscall
+ set thistest "catch syscall to a nonsense syscall is prohibited"
+ gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .*" $thistest
+
+ # Testing the 'catch syscall' command without arguments.
+ # This test should catch any syscalls.
+ if [runto_main] then { test_catch_syscall_without_args }
+
+ # Testing the 'catch syscall' command with arguments.
+ # This test should only catch the specified syscall.
+ if [runto_main] then { test_catch_syscall_with_args }
+
+ # Testing the 'catch syscall' command with many arguments.
+ # This test should catch $all_syscalls.
+ if [runto_main] then { test_catch_syscall_with_many_args }
+
+ # Testing the 'catch syscall' command with WRONG arguments.
+ # This test should not trigger any catchpoints.
+ if [runto_main] then { test_catch_syscall_with_wrong_args }
+
+ # Testing the 'catch' syscall command during a restart of
+ # the inferior.
+ if [runto_main] then { test_catch_syscall_restarting_inferior }
+}
+
+proc test_catch_syscall_fail_noxml {} {
+ global gdb_prompt
+
+ # Sanitizing.
+ delete_breakpoints
+
+ # Testing to see if we receive a warning when calling "catch syscall"
+ # without XML support.
+ set thistest "Catch syscall displays a warning when there is no XML support"
+ gdb_test "catch syscall" "warning: Could not open .*warning: Could not load the syscall XML file .*GDB will not be able to display syscall names.*Catchpoint .*(syscall).*" $thistest
+
+ # Since the catchpoint was set, we must check if it's present at
+ # "info breakpoints"
+ check_info_bp_any_syscall
+
+ # Sanitizing.
+ delete_breakpoints
+}
+
+proc test_catch_syscall_without_args_noxml {} {
+ # We will need the syscall names even not using it
+ # because we need to know know many syscalls are in
+ # the example file.
+ global gdb_prompt all_syscalls last_syscall
+
+ delete_breakpoints
+
+ set thistest "Catch syscall without arguments and without XML support"
+ gdb_test "catch syscall" "Catchpoint .*(syscall).*"
+
+ # Now, we should be able to set a catchpoint,
+ # and GDB shall not display the warning anymore.
+ foreach name $all_syscalls {
+ # Unfortunately, we don't know the syscall number
+ # that will be caught because this information is
+ # arch-dependent. Thus, we try to catch anything
+ # similar to a number.
+ check_continue "\[0-9\]*"
+ }
+
+ # At last but not least, we check if the inferior
+ # has called the last (exit) syscall.
+ check_call_to_syscall "\[0-9\]*"
+
+ delete_breakpoints
+}
+
+proc test_catch_syscall_with_args_noxml {} {
+ global gdb_prompt
+
+ # The number of the "close" syscall. This is our
+ # option for a "long-estabilished" syscall in all
+ # Linux architectures, but unfortunately x86_64 and
+ # a few other platforms don't "follow the convention".
+ # Because of this, we need this ugly check :-(.
+ set close_number ""
+ if { [istarget "x86_64-*-linux*"] } {
+ set close_number "3"
+ } else {
+ set close_number "6"
+ }
+
+ delete_breakpoints
+
+ insert_catch_syscall_with_arg $close_number
+
+ check_continue $close_number
+
+ delete_breakpoints
+}
+
+proc test_catch_syscall_with_wrong_args_noxml {} {
+ global gdb_prompt
+
+ delete_breakpoints
+
+ # Even without XML support, GDB should not accept unknown
+ # syscall names for the catchpoint.
+ set thistest "Catch a nonsense syscall without XML support"
+ gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .nonsense_syscall.*" $thistest
+
+ delete_breakpoints
+}
+
+proc do_syscall_tests_without_xml {} {
+ global gdb_prompt srcdir
+
+ # In this case, we don't need to set GDB's datadir because
+ # we want GDB to display only numbers, not names. So, let's
+ # begin with the tests.
+
+ # The first test is to see if GDB displays a warning when we
+ # try to catch syscalls without the XML support.
+ test_catch_syscall_fail_noxml
+
+ # Now, let's test if we can catch syscalls without XML support.
+ # We should succeed, but GDB is not supposed to print syscall names.
+ if [runto_main] then { test_catch_syscall_without_args_noxml }
+
+ # The only valid argument "catch syscall" should accept is the
+ # syscall number, and not the name (since it can't translate a
+ # name to a number).
+ #
+ # It's worth mentioning that we only try to catch the syscall
+ # close(). This is because the syscall number is an arch-dependent
+ # information, so we can't assume that we know every syscall number
+ # in this system. Therefore, we have decided to use a "long-estabilished"
+ # system call, and close() just sounded the right choice :-).
+ if [runto_main] then { test_catch_syscall_with_args_noxml }
+
+ # Now, we'll try to provide a syscall name (valid or not) to the command,
+ # and expect it to fail.
+ if [runto_main] then { test_catch_syscall_with_wrong_args_noxml }
+}
+
+# This procedure fills the vector "all_syscalls_numbers" with the proper
+# numbers for the used syscalls according to the architecture.
+proc fill_all_syscalls_numbers {} {
+ global all_syscalls_numbers
+
+ # For Linux on x86, PPC and PPC64, the numbers for the syscalls "close" and
+ # "chroot" are the same.
+ if { ![istarget "i\[34567\]86-*-linux*"]
+ || ![istarget "powerpc-*-linux*"] || ![istarget "powerpc64-*-linux*"] } {
+ set all_syscalls_numbers { "6" "61" }
+ }
+}
+
+# Start with a fresh gdb
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Execute the tests, using XML support
+do_syscall_tests
+
+# Restart gdb
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Execute the tests, without XML support. In this case, GDB will
+# only display syscall numbers, and not syscall names.
+do_syscall_tests_without_xml
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-04-26 21:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-23 0:34 [PATCH 3/3] catch syscall -- try 5 -- Build-system, testcase, documentation and extra command Sérgio Durigan Júnior
2009-04-25 8:44 ` Eli Zaretskii
2009-04-26 7:32 ` Sérgio Durigan Júnior
2009-04-26 17:48 ` Eli Zaretskii
2009-04-26 17:55 ` Sérgio Durigan Júnior
2009-04-26 18:05 ` Sérgio Durigan Júnior
2009-04-26 18:52 ` Eli Zaretskii
2009-04-26 21:29 ` Sérgio Durigan Júnior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox