public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-rmoseley-demo-merge: Merge branch 'archer-sergio-catch-syscall' of ssh://sources.redhat.com/git/archer into archer-rmoseley-demo-merge
@ 2008-12-16 20:42 rmoseley
  0 siblings, 0 replies; only message in thread
From: rmoseley @ 2008-12-16 20:42 UTC (permalink / raw)
  To: archer-commits

The branch, archer-rmoseley-demo-merge has been updated
       via  cd8b25df41e5a4b25e15e6a3e3c9f71f60be613a (commit)
       via  b5e88c13ee74b014e19ed041de2f5401e004500a (commit)
       via  82515f8fd7c029b317ba6382f01563d5a5c983fc (commit)
       via  b0c8f2c058e6fe37f9043a3a08b8e5ad03cbcd3b (commit)
       via  75dc609b948dee91e8a5e9f36dc883a504d3f456 (commit)
       via  01b88af28154a60c8daef238c95d4ccb0552d0ba (commit)
       via  19b2f7c625ef197434cc49818986cac0af65d0b8 (commit)
       via  c427af7ab3ae178c0583f15300189624e39cd6c1 (commit)
       via  bc9ef2204c96b940e15426c1bab5f427c2a39f1c (commit)
       via  e1f6f05e59910a6f78d2acf01987de6662995058 (commit)
       via  ccaa0ba4b4077936dfa4a4597ae3f989e55110e7 (commit)
       via  589b9ef4c57807e3a2f5038f841b55b600bd9036 (commit)
       via  443ed1699101789baaf5f4aed9fa428421c55d6a (commit)
       via  f80eb55f788e6182342e426ee637180c7acd35c4 (commit)
       via  c7c93be2ade609b28ac7131f4885d1e2f25e7f92 (commit)
       via  505a054d0c8817668cc30397690ad75fe1204113 (commit)
       via  23412d6f076483ffda183d445829cd78b3bafeba (commit)
       via  7d98d128a66cec99ae3b4b3719baac14fde0c5b9 (commit)
       via  95b1172ca749910802eb3953ec518be218ac49e9 (commit)
       via  1d82da27ebbab15fe196e4842a9777b20fb34cd8 (commit)
       via  2301d0cb9d31763ca28460c9fecc308120149c0a (commit)
       via  0556ccec219d1ee71dd00fc437752571e6c2ddb3 (commit)
       via  45bfa25cb8c3331572259aa50990f1d84556c143 (commit)
       via  2a8237355930e086f714244714ce7671df5c0445 (commit)
       via  82a12cecafabe86cf2de05a3527ecd5586047178 (commit)
       via  86feee00847ba8d42f748577352b85f72623d055 (commit)
       via  bcb748e1454ad464f022d83ad7de68c2b7065694 (commit)
       via  3eb1fc3b7f294ffbd7dd4cc64fe98d810126d3aa (commit)
       via  32e1823097e320ff2f696957f848cabc1ec8f4f1 (commit)
       via  ed29bce753f03df6578850571e4024ef9b529a7d (commit)
       via  daeb967f0c8ac343e062fac35dbb40002c81e5e3 (commit)
       via  cace0464a1fbe84631ea9d942e254de3c952d4bb (commit)
       via  76b97a53c4181d9625fb7114e91e52f27558901b (commit)
       via  6fbe6501c357343c554121fda7c62c79199aea7b (commit)
       via  300abe9c08a65b6643d8320ffe1c747e4522651f (commit)
       via  824f24fc30e52e4b5e16b44e8ce16c276192e209 (commit)
       via  be86499811e692f37208234fd75ed89bcf38e03c (commit)
       via  0cc6ce815c1261fae430f13032092af2731d002e (commit)
       via  cd41a9746511873b35e82b91ab95b652c9596e5e (commit)
       via  07be317399905f65d906c6ec06595926acd5bf39 (commit)
       via  92f67f613f5b299023a61fad3240a0922b0dd5bb (commit)
       via  2bbebf86c79626ac6a0d138aac0bb670069a5ef8 (commit)
       via  c2561969d8817281b1a37ae39bb12b03fc33ba6a (commit)
       via  218d7b4c938ea0efbb17beb76eb722c924c184da (commit)
       via  3ffe049f16390a40a86128e92ac2b0e292d6ee0c (commit)
       via  eeac9d8e327e9caab80cb56471db480fd5134036 (commit)
       via  6246916d9afa43dc0824d50f901460b0aba75981 (commit)
       via  5f43f8a37f78045fa7b811e161beaa03cf878d9a (commit)
       via  3ee439ec917733b22f538543d5920db97f85e8c0 (commit)
       via  bb69b7a144c77139e792f08d482584e73152d1d1 (commit)
       via  fbff0210f2b17e756df58e985e76053620945a00 (commit)
       via  9d3eebbfe4c765907b6adf1130be05c49ffbc08b (commit)
       via  4d41fcdaba62d6a890ad8502237fb40468b4ab88 (commit)
       via  fde7f166db784a2671c24e50cfb63eebb5133ab7 (commit)
       via  46c751ac1108639610a81f14adbab17e477b04a0 (commit)
       via  42f701979134b8c09361fe45e7d46ce52815be84 (commit)
       via  d98646453a820491a48f8d90a6f33a8c98d9008f (commit)
       via  89a830780b82da92474e17436e07e92cd9152332 (commit)
       via  ad246b76456e228a9c11491167e3b6723ef6bb15 (commit)
       via  1e479430a05afad5b90420daf43b0efbd086aaaa (commit)
       via  6e0ba1b339ab9f68425168c102e815f69fbddd24 (commit)
       via  9670f2fb2586bdcb2391594b328f10ecf43502e2 (commit)
       via  91c7dba10492a2a45359a9fce21fc966b990d28b (commit)
       via  247521fa8bab8f0be50b8a64c490b6ffc7a75d05 (commit)
       via  55d01afd12b5748695582c5d8bf734e98f6c7eba (commit)
       via  7b1ace122e9b05be16e06cbb585dcd73833350b0 (commit)
       via  3bbdb4b7b9f081c121b9821ac6860fac87e2be48 (commit)
       via  6bd66588101ab869814511073dbdfca8d43a40e0 (commit)
       via  d9311bace7f2c5bf0ac8c4b71eaa4efb9a759783 (commit)
       via  db78972235d5e6f56aaea73b9b8f4a41aa918ef9 (commit)
      from  17e2fe2f5e5729fde29f6a66c9cb84ca1fa3fb31 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit cd8b25df41e5a4b25e15e6a3e3c9f71f60be613a
Merge: 17e2fe2f5e5729fde29f6a66c9cb84ca1fa3fb31 b5e88c13ee74b014e19ed041de2f5401e004500a
Author: Rick Moseley <rmoseley@dhcp-215.hsv.redhat.com>
Date:   Tue Dec 16 14:37:37 2008 -0600

    Merge branch 'archer-sergio-catch-syscall' of ssh://sources.redhat.com/git/archer into archer-rmoseley-demo-merge
    
    Conflicts:
    
    	gdb/Makefile.in
    	gdb/breakpoint.c
    	gdb/breakpoint.h

-----------------------------------------------------------------------

Summary of changes:
 gdb/Makefile.in                          |   55 +++-
 gdb/amd64-linux-tdep.c                   |   32 ++
 gdb/breakpoint.c                         |  561 +++++++++++++++++++++++++++++-
 gdb/breakpoint.h                         |   63 ++++-
 gdb/cli/cli-decode.c                     |    2 +-
 gdb/configure.tgt                        |   38 ++-
 gdb/doc/gdb.texinfo                      |   82 +++++
 gdb/gdbarch.c                            |  155 ++++++++
 gdb/gdbarch.h                            |   45 +++
 gdb/gdbarch.sh                           |   24 ++
 gdb/i386-linux-nat.c                     |    8 +-
 gdb/i386-linux-tdep.c                    |   32 ++
 gdb/inf-child.c                          |   10 +
 gdb/inf-ptrace.c                         |    8 +-
 gdb/infcmd.c                             |    5 +
 gdb/infrun.c                             |   97 +++++-
 gdb/linux-nat.c                          |  138 +++++++-
 gdb/linux-nat.h                          |    7 +
 gdb/linux-tdep.c                         |  117 +++++++
 gdb/linux-tdep.h                         |   27 ++
 gdb/ppc-linux-tdep.c                     |   48 +++
 gdb/syscalls/amd64-linux.xml             |  299 ++++++++++++++++
 gdb/syscalls/gdb-syscalls.dtd            |   21 ++
 gdb/syscalls/i386-linux.xml              |  337 ++++++++++++++++++
 gdb/syscalls/ppc-linux.xml               |  312 +++++++++++++++++
 gdb/syscalls/ppc64-linux.xml             |  306 ++++++++++++++++
 gdb/target.c                             |   18 +
 gdb/target.h                             |   46 +++-
 gdb/testsuite/gdb.base/Makefile.in       |    2 +-
 gdb/testsuite/gdb.base/catch-syscall.c   |   25 ++
 gdb/testsuite/gdb.base/catch-syscall.exp |  385 ++++++++++++++++++++
 gdb/xml-syscall.c                        |  423 ++++++++++++++++++++++
 gdb/xml-syscall.h                        |   64 ++++
 33 files changed, 3730 insertions(+), 62 deletions(-)
 create mode 100644 gdb/linux-tdep.c
 create mode 100644 gdb/linux-tdep.h
 create mode 100644 gdb/syscalls/amd64-linux.xml
 create mode 100644 gdb/syscalls/gdb-syscalls.dtd
 create mode 100644 gdb/syscalls/i386-linux.xml
 create mode 100644 gdb/syscalls/ppc-linux.xml
 create mode 100644 gdb/syscalls/ppc64-linux.xml
 create mode 100644 gdb/testsuite/gdb.base/catch-syscall.c
 create mode 100644 gdb/testsuite/gdb.base/catch-syscall.exp
 create mode 100644 gdb/xml-syscall.c
 create mode 100644 gdb/xml-syscall.h

First 500 lines of diff:
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 836e2ba..c8d6b73 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -482,6 +482,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-linux-tdep.o amd64nbsd-tdep.o amd64obsd-tdep.o \
@@ -493,6 +494,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 \
@@ -682,6 +684,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
 
 LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
@@ -692,7 +696,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 \
@@ -752,8 +756,8 @@ config/sparc/nm-sol2.h config/nm-linux.h config/mips/nm-irix5.h	\
 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 \
-python/python.h python/python-internal.h
+python/python.h python/python-internal.h \
+sentinel-frame.h bcache.h symfile.h xml-syscall.h
 
 # Header files that already have srcdir in them, or which are in objdir.
 
@@ -832,10 +836,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
 
+# 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@
@@ -869,11 +879,38 @@ generated_files = config.h observer.h observer.inc ada-lex.c \
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-all: gdb$(EXEEXT) $(CONFIG_ALL) .gdbinit
+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)
 
+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.
+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
@@ -927,8 +964,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 \
@@ -1290,6 +1330,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/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index b900c9d..e9e3f65 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -33,6 +33,10 @@
 
 #include "amd64-tdep.h"
 #include "solib-svr4.h"
+#include "linux-tdep.h"
+
+/* The syscall's XML filename for amd64.  */
+#define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml"
 
 /* Mapping between the general-purpose registers in `struct user'
    format and GDB's register cache layout.  */
@@ -167,6 +171,26 @@ amd64_linux_sigcontext_addr (struct frame_info *this_frame)
 }
 \f
 
+static LONGEST
+amd64_linux_get_syscall_number (struct gdbarch *gdbarch,
+                                ptid_t ptid)
+{
+  struct regcache *regcache = get_thread_regcache (ptid);
+  /* The content of a register.  */
+  gdb_byte buf[8];
+  /* The result.  */
+  LONGEST ret;
+
+  /* Getting the system call number from the register.
+     When dealing with x86_64 architecture, this information
+     is stored at %rax register.  */
+  regcache_cooked_read (regcache, AMD64_LINUX_ORIG_RAX_REGNUM, buf);
+
+  ret = extract_signed_integer (buf, 8);
+
+  return ret;
+}
+
 /* From <asm/sigcontext.h>.  */
 static int amd64_linux_sc_reg_offset[] =
 {
@@ -261,6 +285,9 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
+   /* Initializing common functions.  */
+  linux_tdep_init (gdbarch);
+
   tdep->gregset_reg_offset = amd64_linux_gregset_reg_offset;
   tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset);
   tdep->sizeof_gregset = 27 * 8;
@@ -286,6 +313,11 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* Enable TLS support.  */
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
                                              svr4_fetch_objfile_link_map);
+
+  /* Functions for 'catch syscall'.  */
+  set_gdbarch_xml_syscall_filename (gdbarch, XML_SYSCALL_FILENAME_AMD64);
+  set_gdbarch_get_syscall_number (gdbarch,
+                                  amd64_linux_get_syscall_number);
 }
 \f
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 853fb20..bd8fba3 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -192,6 +192,8 @@ static int is_hardware_watchpoint (struct breakpoint *bpt);
 
 static void insert_breakpoint_locations (void);
 
+static int syscall_catchpoint_p (struct breakpoint *b);
+
 static const char *
 bpdisp_text (enum bpdisp disp)
 {
@@ -342,6 +344,18 @@ set_breakpoint_count (int num)
 		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
+/* Used in run_command to reset syscall catchpoints fields.  */
+
+void
+clear_syscall_catchpoints_info (void)
+{
+  struct breakpoint *b;
+
+  ALL_BREAKPOINTS (b)
+    if (syscall_catchpoint_p (b))
+      b->syscall_number = UNKNOWN_SYSCALL;
+}
+
 /* Used in run_command to zero the hit count when a new run starts. */
 
 void
@@ -2250,6 +2264,14 @@ print_it_typical (bpstat bs)
       return PRINT_NOTHING;
       break;
 
+    case bp_entry_breakpoint:
+       /* Not sure how we will get here. 
+	 GDB should not stop for these breakpoints.  */
+      internal_error (__FILE__, __LINE__,
+                      _("Entry Breakpoint: gdb should not stop!\n"));
+      return PRINT_NOTHING;
+      break;    
+
     case bp_overlay_event:
       /* By analogy with the thread event, GDB should not stop for these. */
       printf_filtered (_("Overlay Event Breakpoint: gdb should not stop!\n"));
@@ -3054,6 +3076,13 @@ bpstat_what (bpstat bs)
       /* We hit the shared library event breakpoint.  */
       shlib_event,
 
+      /* We caught a shared library event.  */
+      catch_shlib_event,
+
+      /* We are in a entry breakpoint.  It means we have stopped
+         at the inferior's entrypoint (AT_ENTRY).  */
+      entry_breakpoint,
+
       /* This is just used to count how many enums there are.  */
       class_last
     };
@@ -3069,6 +3098,8 @@ bpstat_what (bpstat bs)
 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
 #define sr BPSTAT_WHAT_STEP_RESUME
 #define shl BPSTAT_WHAT_CHECK_SHLIBS
+#define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
+#define entrybp BPSTAT_WHAT_ENTRY_BREAKPOINT
 
 /* "Can't happen."  Might want to print an error message.
    abort() is not out of the question, but chances are GDB is just
@@ -3112,28 +3143,34 @@ bpstat_what (bpstat bs)
     table[(int) class_last][(int) BPSTAT_WHAT_LAST] =
   {
   /*                              old action */
-  /*       kc    ss    sn    sgl    slr   clr   sr   shl
+  /*       kc    ss    sn    sgl    slr   clr   sr   shl   shlr   entrybp
    */
 /*no_effect */
-    {kc, ss, sn, sgl, slr, clr, sr, shl},
+
+    {kc, ss, sn, sgl, slr, clr, sr, shl, shlr, shlr},
 /*wp_silent */
-    {ss, ss, sn, ss, ss, ss, sr, shl},
+    {ss, ss, sn, ss, ss, ss, sr, shl, shlr, shlr},
 /*wp_noisy */
-    {sn, sn, sn, sn, sn, sn, sr, shl},
+    {sn, sn, sn, sn, sn, sn, sr, shl, shlr, shlr},
 /*bp_nostop */
-    {sgl, ss, sn, sgl, slr, slr, sr, shl},
+    {sgl, ss, sn, sgl, slr, slr, sr, shl, shlr, shlr},
 /*bp_silent */
-    {ss, ss, sn, ss, ss, ss, sr, shl},
+    {ss, ss, sn, ss, ss, ss, sr, shl, shlr, shlr},
 /*bp_noisy */
-    {sn, sn, sn, sn, sn, sn, sr, shl},
+    {sn, sn, sn, sn, sn, sn, sr, shl, shlr, shlr},
 /*long_jump */
-    {slr, ss, sn, slr, slr, err, sr, shl},
+    {slr, ss, sn, slr, slr, err, sr, shl, shlr, shlr},
 /*long_resume */
-    {clr, ss, sn, err, err, err, sr, shl},
+    {clr, ss, sn, err, err, err, sr, shl, shlr, shlr},
 /*step_resume */
-    {sr, sr, sr, sr, sr, sr, sr, sr},
+    {sr, sr, sr, sr, sr, sr, sr, sr, sr, sr},
 /*shlib */
-    {shl, shl, shl, shl, shl, shl, sr, shl}
+    {shl, shl, shl, shl, shl, shl, sr, shl, shlr, shl},
+/*catch_shlib */
+    {shlr, shlr, shlr, shlr, shlr, shlr, sr, shlr, shlr, shlr},
+/* entry_breakpoint */
+    {entrybp, entrybp, entrybp, entrybp, entrybp, entrybp, sr, entrybp,
+      entrybp, entrybp}
   };
 
 #undef kc
@@ -3146,6 +3183,8 @@ bpstat_what (bpstat bs)
 #undef sr
 #undef ts
 #undef shl
+#undef shlr
+#undef entrybp
   enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
   struct bpstat_what retval;
 
@@ -3239,6 +3278,12 @@ bpstat_what (bpstat bs)
 	  bs_class = bp_silent;
 	  retval.call_dummy = 1;
 	  break;
+        case bp_entry_breakpoint:
+          if (bs->stop)
+            bs_class = entry_breakpoint;
+          else
+            bs_class = no_effect;
+          break;
 	}
       current_action = table[(int) bs_class][(int) current_action];
     }
@@ -3338,6 +3383,7 @@ print_one_breakpoint_location (struct breakpoint *b,
     {bp_thread_event, "thread events"},
     {bp_overlay_event, "overlay events"},
     {bp_catchpoint, "catchpoint"},
+    {bp_entry_breakpoint, "entry breakpoint"}
   };
   
   static char bpenables[] = "nynny";
@@ -3465,6 +3511,7 @@ print_one_breakpoint_location (struct breakpoint *b,
       case bp_shlib_event:
       case bp_thread_event:
       case bp_overlay_event:
+      case bp_entry_breakpoint:
 	if (opts.addressprint)
 	  {
 	    annotate_field (4);
@@ -4036,6 +4083,7 @@ allocate_bp_location (struct breakpoint *bpt, enum bptype bp_type)
     case bp_watchpoint_scope:
     case bp_call_dummy:
     case bp_shlib_event:
+    case bp_entry_breakpoint:
     case bp_thread_event:
     case bp_overlay_event:
       loc->loc_type = bp_loc_software_breakpoint;
@@ -4093,6 +4141,8 @@ set_raw_breakpoint_without_location (enum bptype bptype)
   b->frame_id = null_frame_id;
   b->forked_inferior_pid = null_ptid;
   b->exec_pathname = NULL;
+  b->syscalls_to_be_caught = NULL;
+  b->syscall_number = UNKNOWN_SYSCALL;
   b->ops = NULL;
   b->condition_not_parsed = 0;
 
@@ -4315,6 +4365,31 @@ disable_overlay_breakpoints (void)
     }
 }
 
+int
+create_entry_breakpoint ()
+{
+  CORE_ADDR taddr, entry_addr;
+  struct breakpoint *b;
+
+  taddr = entry_point_address ();
+  /* Make certain that the address points at real code, and not a
+     function descriptor.  */
+  entry_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, taddr,
+                                                   &current_target);
+
+  /* Setting the breakpoint.  */
+  b = create_internal_breakpoint (entry_addr, bp_entry_breakpoint);
+
+  b->enable_state = bp_enabled;
+  b->disposition = disp_del;
+  /* addr_string has to be used or breakpoint_re_set will delete me.  */
+  b->addr_string = xstrprintf ("AT_ENTRY (0x%s)", paddr (entry_addr));
+
+  update_global_location_list (1);
+
+  return 1;
+}
+
 struct breakpoint *
 create_thread_event_breakpoint (CORE_ADDR address)
 {
@@ -4612,7 +4687,238 @@ static struct breakpoint_ops catch_vfork_breakpoint_ops =
   print_mention_catch_vfork
 };
 
-/* Create a new breakpoint of the bp_catchpoint kind and return it.
+/* We keep a count of the number of times the user has requested a
+   particular syscall to be tracked, and pass this information to the
+   target.  This lets capable targets implement filtering directly.  */
+
+/* Number of times that "any" syscall is requested.  */
+static int any_syscall_count;
+
+/* Count of each system call.  */
+static int *syscalls_counts;
+
+/* Number of system entries in SYSCALLS_COUNTS.  */
+static int syscalls_size;
+
+/* This counts all syscall catch requests, so we can readily determine
+   if any catching is necessary.  */
+static int total_syscalls_count;
+
+/* Implement the "insert" breakpoint_ops method for syscall
+   catchpoints.  */
+
+static void
+insert_catch_syscall (struct breakpoint *b)
+{
+  ++total_syscalls_count;
+  if (!b->syscalls_to_be_caught)
+    ++any_syscall_count;
+  else
+    {
+      struct syscall_filter *iter;
+      for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
+	{
+	  if (iter->syscall >= syscalls_size)
+	    {
+	      syscalls_counts = xrealloc (syscalls_counts,
+					  (iter->syscall + 1) * sizeof (int));
+	      memset (&syscalls_counts[syscalls_size], 0,
+		      (iter->syscall + 1 - syscalls_size) * sizeof (int));
+	    }
+	  ++syscalls_counts[iter->syscall];
+	}
+    }
+
+  target_set_syscall_catchpoint (PIDGET (inferior_ptid),
+				 total_syscalls_count != 0,
+				 any_syscall_count,
+				 syscalls_size,
+				 syscalls_counts);
+}
+
+/* Implement the "remove" breakpoint_ops method for syscall
+   catchpoints.  */
+
+static int
+remove_catch_syscall (struct breakpoint *b)
+{
+  --total_syscalls_count;
+  if (!b->syscalls_to_be_caught)
+    --any_syscall_count;
+  else
+    {
+      struct syscall_filter *iter;
+      for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
+	{
+	  if (iter->syscall >= syscalls_size)
+	    {
+	      /* Shouldn't happen.  */
+	      continue;
+	    }
+	  --syscalls_counts[iter->syscall];
+	}
+    }
+
+  return target_set_syscall_catchpoint (PIDGET (inferior_ptid),
+					total_syscalls_count != 0,
+					any_syscall_count,
+					syscalls_size,
+					syscalls_counts);
+}
+
+/* Implement the "breakpoint_hit" breakpoint_ops method for syscall
+   catchpoints.  */
+
+static int
+breakpoint_hit_catch_syscall (struct breakpoint *b)
+{
+  /* We must check if we are catching specific syscalls in this breakpoint.
+     If we are, then we must guarantee that the called syscall is the same
+     syscall we are catching.  */
+  int syscall_number = 0;
+
+  if (!inferior_has_called_syscall (inferior_ptid, &syscall_number))
+    return 0;
+
+  /* Now, checking if the syscall is the same.  */
+  if (b->syscalls_to_be_caught)
+    {
+      struct syscall_filter *iter;
+      for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
+	if (syscall_number == iter->syscall)


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-12-16 20:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 20:42 [SCM] archer-rmoseley-demo-merge: Merge branch 'archer-sergio-catch-syscall' of ssh://sources.redhat.com/git/archer into archer-rmoseley-demo-merge rmoseley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).