82075af2c1
This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
143 lines
3.9 KiB
C
143 lines
3.9 KiB
C
/* Common definitions for remote server for GDB.
|
|
Copyright (C) 1993-2016 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
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/>. */
|
|
|
|
#ifndef SERVER_H
|
|
#define SERVER_H
|
|
|
|
#include "common-defs.h"
|
|
|
|
gdb_static_assert (sizeof (CORE_ADDR) >= sizeof (void *));
|
|
|
|
#ifdef __MINGW32CE__
|
|
#include "wincecompat.h"
|
|
#endif
|
|
|
|
#include "version.h"
|
|
|
|
#if !HAVE_DECL_STRERROR
|
|
#ifndef strerror
|
|
extern char *strerror (int); /* X3.159-1989 4.11.6.2 */
|
|
#endif
|
|
#endif
|
|
|
|
#if !HAVE_DECL_PERROR
|
|
#ifndef perror
|
|
extern void perror (const char *);
|
|
#endif
|
|
#endif
|
|
|
|
#if !HAVE_DECL_VASPRINTF
|
|
extern int vasprintf(char **strp, const char *fmt, va_list ap);
|
|
#endif
|
|
#if !HAVE_DECL_VSNPRINTF
|
|
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
|
|
#endif
|
|
|
|
#ifdef IN_PROCESS_AGENT
|
|
# define PROG "ipa"
|
|
#else
|
|
# define PROG "gdbserver"
|
|
#endif
|
|
|
|
#include "buffer.h"
|
|
#include "xml-utils.h"
|
|
#include "regcache.h"
|
|
#include "gdb_signals.h"
|
|
#include "target.h"
|
|
#include "mem-break.h"
|
|
#include "gdbthread.h"
|
|
#include "inferiors.h"
|
|
|
|
/* Target-specific functions */
|
|
|
|
void initialize_low ();
|
|
|
|
/* Public variables in server.c */
|
|
|
|
extern ptid_t cont_thread;
|
|
extern ptid_t general_thread;
|
|
|
|
extern int server_waiting;
|
|
extern int pass_signals[];
|
|
extern int program_signals[];
|
|
extern int program_signals_p;
|
|
|
|
extern int disable_packet_vCont;
|
|
extern int disable_packet_Tthread;
|
|
extern int disable_packet_qC;
|
|
extern int disable_packet_qfThreadInfo;
|
|
|
|
extern int run_once;
|
|
extern int multi_process;
|
|
extern int report_fork_events;
|
|
extern int report_vfork_events;
|
|
extern int report_exec_events;
|
|
extern int report_thread_events;
|
|
extern int non_stop;
|
|
|
|
/* True if the "swbreak+" feature is active. In that case, GDB wants
|
|
us to report whether a trap is explained by a software breakpoint
|
|
and for the server to handle PC adjustment if necessary on this
|
|
target. Only enabled if the target supports it. */
|
|
extern int swbreak_feature;
|
|
|
|
/* True if the "hwbreak+" feature is active. In that case, GDB wants
|
|
us to report whether a trap is explained by a hardware breakpoint.
|
|
Only enabled if the target supports it. */
|
|
extern int hwbreak_feature;
|
|
|
|
extern int disable_randomization;
|
|
|
|
#if USE_WIN32API
|
|
#include <winsock2.h>
|
|
typedef SOCKET gdb_fildes_t;
|
|
#else
|
|
typedef int gdb_fildes_t;
|
|
#endif
|
|
|
|
#include "event-loop.h"
|
|
|
|
/* Functions from server.c. */
|
|
extern int handle_serial_event (int err, gdb_client_data client_data);
|
|
extern int handle_target_event (int err, gdb_client_data client_data);
|
|
|
|
/* Get rid of the currently pending stop replies that match PTID. */
|
|
extern void discard_queued_stop_replies (ptid_t ptid);
|
|
|
|
#include "remote-utils.h"
|
|
|
|
#include "utils.h"
|
|
#include "debug.h"
|
|
#include "gdb_vecs.h"
|
|
|
|
/* Maximum number of bytes to read/write at once. The value here
|
|
is chosen to fill up a packet (the headers account for the 32). */
|
|
#define MAXBUFBYTES(N) (((N)-32)/2)
|
|
|
|
/* Buffer sizes for transferring memory, registers, etc. Set to a constant
|
|
value to accomodate multiple register formats. This value must be at least
|
|
as large as the largest register set supported by gdbserver. */
|
|
#define PBUFSIZ 16384
|
|
|
|
/* Definition for an unknown syscall, used basically in error-cases. */
|
|
#define UNKNOWN_SYSCALL (-1)
|
|
|
|
/* Definition for any syscall, used for unfiltered syscall reporting. */
|
|
#define ANY_SYSCALL (-2)
|
|
|
|
#endif /* SERVER_H */
|