| OLD | NEW |
| 1 /* GNU/Linux native-dependent code common to multiple platforms. | 1 /* GNU/Linux native-dependent code common to multiple platforms. |
| 2 | 2 |
| 3 Copyright (C) 2001-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2001-2013 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GDB. | 5 This file is part of GDB. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| 11 | 11 |
| 12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
| 16 | 16 |
| 17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
| 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 | 19 |
| 20 #include "defs.h" | 20 #include "defs.h" |
| 21 #include "inferior.h" | 21 #include "inferior.h" |
| 22 #include "target.h" | 22 #include "target.h" |
| 23 #include "gdb_string.h" | 23 #include "nat/linux-nat.h" |
| 24 #include "nat/linux-waitpid.h" |
| 25 #include <string.h> |
| 24 #include "gdb_wait.h" | 26 #include "gdb_wait.h" |
| 25 #include "gdb_assert.h" | 27 #include "gdb_assert.h" |
| 26 #ifdef HAVE_TKILL_SYSCALL | 28 #ifdef HAVE_TKILL_SYSCALL |
| 27 #include <unistd.h> | 29 #include <unistd.h> |
| 28 #include <sys/syscall.h> | 30 #include <sys/syscall.h> |
| 29 #endif | 31 #endif |
| 30 #include <sys/ptrace.h> | 32 #include <sys/ptrace.h> |
| 31 #include "linux-nat.h" | 33 #include "linux-nat.h" |
| 32 #include "linux-ptrace.h" | 34 #include "linux-ptrace.h" |
| 33 #include "linux-procfs.h" | 35 #include "linux-procfs.h" |
| 34 #include "linux-fork.h" | 36 #include "linux-fork.h" |
| 35 #include "gdbthread.h" | 37 #include "gdbthread.h" |
| 36 #include "gdbcmd.h" | 38 #include "gdbcmd.h" |
| 37 #include "regcache.h" | 39 #include "regcache.h" |
| 38 #include "regset.h" | 40 #include "regset.h" |
| 39 #include "inf-child.h" | 41 #include "inf-child.h" |
| 40 #include "inf-ptrace.h" | 42 #include "inf-ptrace.h" |
| 41 #include "auxv.h" | 43 #include "auxv.h" |
| 42 #include <sys/param.h> /* for MAXPATHLEN */ | |
| 43 #include <sys/procfs.h> /* for elf_gregset etc. */ | 44 #include <sys/procfs.h> /* for elf_gregset etc. */ |
| 44 #include "elf-bfd.h" /* for elfcore_write_* */ | 45 #include "elf-bfd.h" /* for elfcore_write_* */ |
| 45 #include "gregset.h" /* for gregset */ | 46 #include "gregset.h" /* for gregset */ |
| 46 #include "gdbcore.h" /* for get_exec_file */ | 47 #include "gdbcore.h" /* for get_exec_file */ |
| 47 #include <ctype.h> /* for isdigit */ | 48 #include <ctype.h> /* for isdigit */ |
| 48 #include "gdbthread.h" /* for struct thread_info etc. */ | 49 #include "gdbthread.h" /* for struct thread_info etc. */ |
| 49 #include "gdb_stat.h"» » /* for struct stat */ | 50 #include <sys/stat.h>» » /* for struct stat */ |
| 50 #include <fcntl.h> /* for O_RDONLY */ | 51 #include <fcntl.h> /* for O_RDONLY */ |
| 51 #include "inf-loop.h" | 52 #include "inf-loop.h" |
| 52 #include "event-loop.h" | 53 #include "event-loop.h" |
| 53 #include "event-top.h" | 54 #include "event-top.h" |
| 54 #include <pwd.h> | 55 #include <pwd.h> |
| 55 #include <sys/types.h> | 56 #include <sys/types.h> |
| 56 #include "gdb_dirent.h" | 57 #include <dirent.h> |
| 57 #include "xml-support.h" | 58 #include "xml-support.h" |
| 58 #include "terminal.h" | 59 #include "terminal.h" |
| 59 #include <sys/vfs.h> | 60 #include <sys/vfs.h> |
| 60 #include "solib.h" | 61 #include "solib.h" |
| 61 #include "linux-osdata.h" | 62 #include "linux-osdata.h" |
| 62 #include "linux-tdep.h" | 63 #include "linux-tdep.h" |
| 63 #include "symfile.h" | 64 #include "symfile.h" |
| 64 #include "agent.h" | 65 #include "agent.h" |
| 65 #include "tracepoint.h" | 66 #include "tracepoint.h" |
| 66 #include "exceptions.h" | 67 #include "exceptions.h" |
| 67 #include "linux-ptrace.h" | 68 #include "linux-ptrace.h" |
| 68 #include "buffer.h" | 69 #include "buffer.h" |
| 70 #include "target-descriptions.h" |
| 71 #include "filestuff.h" |
| 69 | 72 |
| 70 #ifndef SPUFS_MAGIC | 73 #ifndef SPUFS_MAGIC |
| 71 #define SPUFS_MAGIC 0x23c9b64e | 74 #define SPUFS_MAGIC 0x23c9b64e |
| 72 #endif | 75 #endif |
| 73 | 76 |
| 74 #ifdef HAVE_PERSONALITY | 77 #ifdef HAVE_PERSONALITY |
| 75 # include <sys/personality.h> | 78 # include <sys/personality.h> |
| 76 # if !HAVE_DECL_ADDR_NO_RANDOMIZE | 79 # if !HAVE_DECL_ADDR_NO_RANDOMIZE |
| 77 # define ADDR_NO_RANDOMIZE 0x0040000 | 80 # define ADDR_NO_RANDOMIZE 0x0040000 |
| 78 # endif | 81 # endif |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 We could use a real-time signal instead. This would solve those problems; we | 166 We could use a real-time signal instead. This would solve those problems; we |
| 164 could use PTRACE_GETSIGINFO to locate the specific stop signals sent by GDB. | 167 could use PTRACE_GETSIGINFO to locate the specific stop signals sent by GDB. |
| 165 But we would still have to have some support for SIGSTOP, since PTRACE_ATTACH | 168 But we would still have to have some support for SIGSTOP, since PTRACE_ATTACH |
| 166 generates it, and there are races with trying to find a signal that is not | 169 generates it, and there are races with trying to find a signal that is not |
| 167 blocked. */ | 170 blocked. */ |
| 168 | 171 |
| 169 #ifndef O_LARGEFILE | 172 #ifndef O_LARGEFILE |
| 170 #define O_LARGEFILE 0 | 173 #define O_LARGEFILE 0 |
| 171 #endif | 174 #endif |
| 172 | 175 |
| 173 /* Unlike other extended result codes, WSTOPSIG (status) on | |
| 174 PTRACE_O_TRACESYSGOOD syscall events doesn't return SIGTRAP, but | |
| 175 instead SIGTRAP with bit 7 set. */ | |
| 176 #define SYSCALL_SIGTRAP (SIGTRAP | 0x80) | |
| 177 | |
| 178 /* The single-threaded native GNU/Linux target_ops. We save a pointer for | 176 /* The single-threaded native GNU/Linux target_ops. We save a pointer for |
| 179 the use of the multi-threaded target. */ | 177 the use of the multi-threaded target. */ |
| 180 static struct target_ops *linux_ops; | 178 static struct target_ops *linux_ops; |
| 181 static struct target_ops linux_ops_saved; | 179 static struct target_ops linux_ops_saved; |
| 182 | 180 |
| 183 /* The method to call, if any, when a new thread is attached. */ | 181 /* The method to call, if any, when a new thread is attached. */ |
| 184 static void (*linux_nat_new_thread) (struct lwp_info *); | 182 static void (*linux_nat_new_thread) (struct lwp_info *); |
| 185 | 183 |
| 184 /* The method to call, if any, when a new fork is attached. */ |
| 185 static linux_nat_new_fork_ftype *linux_nat_new_fork; |
| 186 |
| 187 /* The method to call, if any, when a process is no longer |
| 188 attached. */ |
| 189 static linux_nat_forget_process_ftype *linux_nat_forget_process_hook; |
| 190 |
| 186 /* Hook to call prior to resuming a thread. */ | 191 /* Hook to call prior to resuming a thread. */ |
| 187 static void (*linux_nat_prepare_to_resume) (struct lwp_info *); | 192 static void (*linux_nat_prepare_to_resume) (struct lwp_info *); |
| 188 | 193 |
| 189 /* The method to call, if any, when the siginfo object needs to be | 194 /* The method to call, if any, when the siginfo object needs to be |
| 190 converted between the layout returned by ptrace, and the layout in | 195 converted between the layout returned by ptrace, and the layout in |
| 191 the architecture of the inferior. */ | 196 the architecture of the inferior. */ |
| 192 static int (*linux_nat_siginfo_fixup) (siginfo_t *, | 197 static int (*linux_nat_siginfo_fixup) (siginfo_t *, |
| 193 gdb_byte *, | 198 gdb_byte *, |
| 194 int); | 199 int); |
| 195 | 200 |
| 196 /* The saved to_xfer_partial method, inherited from inf-ptrace.c. | 201 /* The saved to_xfer_partial method, inherited from inf-ptrace.c. |
| 197 Called by our to_xfer_partial. */ | 202 Called by our to_xfer_partial. */ |
| 198 static LONGEST (*super_xfer_partial) (struct target_ops *, | 203 static LONGEST (*super_xfer_partial) (struct target_ops *, |
| 199 enum target_object, | 204 enum target_object, |
| 200 const char *, gdb_byte *, | 205 const char *, gdb_byte *, |
| 201 const gdb_byte *, | 206 const gdb_byte *, |
| 202 ULONGEST, LONGEST); | 207 ULONGEST, LONGEST); |
| 203 | 208 |
| 204 static int debug_linux_nat; | 209 static unsigned int debug_linux_nat; |
| 205 static void | 210 static void |
| 206 show_debug_linux_nat (struct ui_file *file, int from_tty, | 211 show_debug_linux_nat (struct ui_file *file, int from_tty, |
| 207 struct cmd_list_element *c, const char *value) | 212 struct cmd_list_element *c, const char *value) |
| 208 { | 213 { |
| 209 fprintf_filtered (file, _("Debugging of GNU/Linux lwp module is %s.\n"), | 214 fprintf_filtered (file, _("Debugging of GNU/Linux lwp module is %s.\n"), |
| 210 value); | 215 value); |
| 211 } | 216 } |
| 212 | 217 |
| 213 struct simple_pid_list | 218 struct simple_pid_list |
| 214 { | 219 { |
| 215 int pid; | 220 int pid; |
| 216 int status; | 221 int status; |
| 217 struct simple_pid_list *next; | 222 struct simple_pid_list *next; |
| 218 }; | 223 }; |
| 219 struct simple_pid_list *stopped_pids; | 224 struct simple_pid_list *stopped_pids; |
| 220 | 225 |
| 221 /* This variable is a tri-state flag: -1 for unknown, 0 if PTRACE_O_TRACEFORK | |
| 222 can not be used, 1 if it can. */ | |
| 223 | |
| 224 static int linux_supports_tracefork_flag = -1; | |
| 225 | |
| 226 /* This variable is a tri-state flag: -1 for unknown, 0 if | |
| 227 PTRACE_O_TRACESYSGOOD can not be used, 1 if it can. */ | |
| 228 | |
| 229 static int linux_supports_tracesysgood_flag = -1; | |
| 230 | |
| 231 /* If we have PTRACE_O_TRACEFORK, this flag indicates whether we also have | |
| 232 PTRACE_O_TRACEVFORKDONE. */ | |
| 233 | |
| 234 static int linux_supports_tracevforkdone_flag = -1; | |
| 235 | |
| 236 /* Stores the current used ptrace() options. */ | |
| 237 static int current_ptrace_options = 0; | |
| 238 | |
| 239 /* Async mode support. */ | 226 /* Async mode support. */ |
| 240 | 227 |
| 241 /* The read/write ends of the pipe registered as waitable file in the | 228 /* The read/write ends of the pipe registered as waitable file in the |
| 242 event loop. */ | 229 event loop. */ |
| 243 static int linux_nat_event_pipe[2] = { -1, -1 }; | 230 static int linux_nat_event_pipe[2] = { -1, -1 }; |
| 244 | 231 |
| 245 /* Flush the event pipe. */ | 232 /* Flush the event pipe. */ |
| 246 | 233 |
| 247 static void | 234 static void |
| 248 async_file_flush (void) | 235 async_file_flush (void) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 318 |
| 332 for (p = listp; *p != NULL; p = &(*p)->next) | 319 for (p = listp; *p != NULL; p = &(*p)->next) |
| 333 if ((*p)->pid == pid) | 320 if ((*p)->pid == pid) |
| 334 { | 321 { |
| 335 struct simple_pid_list *next = (*p)->next; | 322 struct simple_pid_list *next = (*p)->next; |
| 336 | 323 |
| 337 *statusp = (*p)->status; | 324 *statusp = (*p)->status; |
| 338 xfree (*p); | 325 xfree (*p); |
| 339 *p = next; | 326 *p = next; |
| 340 return 1; | 327 return 1; |
error: old chunk mismatch |
None
| OLD | NEW |