Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: gdb/nto-procfs.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/nios2-tdep.c ('k') | gdb/nto-tdep.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Machine independent support for QNX Neutrino /proc (process file system) 1 /* Machine independent support for QNX Neutrino /proc (process file system)
2 for GDB. Written by Colin Burgess at QNX Software Systems Limited. 2 for GDB. Written by Colin Burgess at QNX Software Systems Limited.
3 3
4 Copyright (C) 2003, 2006-2012 Free Software Foundation, Inc. 4 Copyright (C) 2003-2013 Free Software Foundation, Inc.
5 5
6 Contributed by QNX Software Systems Ltd. 6 Contributed by QNX Software Systems Ltd.
7 7
8 This file is part of GDB. 8 This file is part of GDB.
9 9
10 This program is free software; you can redistribute it and/or modify 10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by 11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or 12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version. 13 (at your option) any later version.
14 14
15 This program is distributed in the hope that it will be useful, 15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details. 18 GNU General Public License for more details.
19 19
20 You should have received a copy of the GNU General Public License 20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 22
23 #include "defs.h" 23 #include "defs.h"
24 24
25 #include <fcntl.h> 25 #include <fcntl.h>
26 #include <spawn.h> 26 #include <spawn.h>
27 #include <sys/debug.h> 27 #include <sys/debug.h>
28 #include <sys/procfs.h> 28 #include <sys/procfs.h>
29 #include <sys/neutrino.h> 29 #include <sys/neutrino.h>
30 #include <sys/syspage.h> 30 #include <sys/syspage.h>
31 #include "gdb_dirent.h" 31 #include <dirent.h>
32 #include <sys/netmgr.h> 32 #include <sys/netmgr.h>
33 33
34 #include "exceptions.h" 34 #include "exceptions.h"
35 #include "gdb_string.h" 35 #include <string.h>
36 #include "gdbcore.h" 36 #include "gdbcore.h"
37 #include "inferior.h" 37 #include "inferior.h"
38 #include "target.h" 38 #include "target.h"
39 #include "objfiles.h" 39 #include "objfiles.h"
40 #include "gdbthread.h" 40 #include "gdbthread.h"
41 #include "nto-tdep.h" 41 #include "nto-tdep.h"
42 #include "command.h" 42 #include "command.h"
43 #include "regcache.h" 43 #include "regcache.h"
44 #include "solib.h" 44 #include "solib.h"
45 45
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (devctl (fd, DCMD_PROC_SYSINFO, sysinfo, total_size, 0) != EOK) 190 if (devctl (fd, DCMD_PROC_SYSINFO, sysinfo, total_size, 0) != EOK)
191 { 191 {
192 printf_filtered ("Error getting sysinfo: %d (%s)\n", errno, 192 printf_filtered ("Error getting sysinfo: %d (%s)\n", errno,
193 safe_strerror (errno)); 193 safe_strerror (errno));
194 error (_("Devctl failed.")); 194 error (_("Devctl failed."));
195 } 195 }
196 else 196 else
197 { 197 {
198 if (sysinfo->type != 198 if (sysinfo->type !=
199 nto_map_arch_to_cputype (gdbarch_bfd_arch_info 199 nto_map_arch_to_cputype (gdbarch_bfd_arch_info
200 » » » » » (target_gdbarch)->arch_name)) 200 » » » » » (target_gdbarch ())->arch_name))
201 error (_("Invalid target CPU.")); 201 error (_("Invalid target CPU."));
202 } 202 }
203 } 203 }
204 } 204 }
205 do_cleanups (cleanups); 205 do_cleanups (cleanups);
206 printf_filtered ("Debugging using %s\n", nto_procfs_path); 206 printf_filtered ("Debugging using %s\n", nto_procfs_path);
207 } 207 }
208 208
209 static void 209 static void
210 procfs_set_thread (ptid_t ptid) 210 procfs_set_thread (ptid_t ptid)
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 solib_create_inferior_hook (0); 654 solib_create_inferior_hook (0);
655 } 655 }
656 656
657 static ptid_t 657 static ptid_t
658 do_attach (ptid_t ptid) 658 do_attach (ptid_t ptid)
659 { 659 {
660 procfs_status status; 660 procfs_status status;
661 struct sigevent event; 661 struct sigevent event;
662 char path[PATH_MAX]; 662 char path[PATH_MAX];
663 663
664 snprintf (path, PATH_MAX - 1, "%s/%d/as", nto_procfs_path, PIDGET (ptid)); 664 snprintf (path, PATH_MAX - 1, "%s/%d/as", nto_procfs_path,
665 » ptid_get_pid (ptid));
665 ctl_fd = open (path, O_RDWR); 666 ctl_fd = open (path, O_RDWR);
666 if (ctl_fd == -1) 667 if (ctl_fd == -1)
667 error (_("Couldn't open proc file %s, error %d (%s)"), path, errno, 668 error (_("Couldn't open proc file %s, error %d (%s)"), path, errno,
668 safe_strerror (errno)); 669 safe_strerror (errno));
669 if (devctl (ctl_fd, DCMD_PROC_STOP, &status, sizeof (status), 0) != EOK) 670 if (devctl (ctl_fd, DCMD_PROC_STOP, &status, sizeof (status), 0) != EOK)
670 error (_("Couldn't stop process")); 671 error (_("Couldn't stop process"));
671 672
672 /* Define a sigevent for process stopped notification. */ 673 /* Define a sigevent for process stopped notification. */
673 event.sigev_notify = SIGEV_SIGNAL_THREAD; 674 event.sigev_notify = SIGEV_SIGNAL_THREAD;
674 event.sigev_signo = SIGUSR1; 675 event.sigev_signo = SIGUSR1;
675 event.sigev_code = 0; 676 event.sigev_code = 0;
676 event.sigev_value.sival_ptr = NULL; 677 event.sigev_value.sival_ptr = NULL;
677 event.sigev_priority = -1; 678 event.sigev_priority = -1;
678 devctl (ctl_fd, DCMD_PROC_EVENT, &event, sizeof (event), 0); 679 devctl (ctl_fd, DCMD_PROC_EVENT, &event, sizeof (event), 0);
679 680
680 if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK 681 if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK
681 && status.flags & _DEBUG_FLAG_STOPPED) 682 && status.flags & _DEBUG_FLAG_STOPPED)
682 SignalKill (nto_node (), PIDGET (ptid), 0, SIGCONT, 0, 0); 683 SignalKill (nto_node (), ptid_get_pid (ptid), 0, SIGCONT, 0, 0);
683 nto_init_solib_absolute_prefix (); 684 nto_init_solib_absolute_prefix ();
684 return ptid_build (PIDGET (ptid), 0, status.tid); 685 return ptid_build (ptid_get_pid (ptid), 0, status.tid);
685 } 686 }
686 687
687 /* Ask the user what to do when an interrupt is received. */ 688 /* Ask the user what to do when an interrupt is received. */
688 static void 689 static void
689 interrupt_query (void) 690 interrupt_query (void)
690 { 691 {
691 target_terminal_ours (); 692 target_terminal_ours ();
692 693
693 if (query (_("Interrupted while waiting for the program.\n\ 694 if (query (_("Interrupted while waiting for the program.\n\
694 Give up (and stop debugging it)? "))) 695 Give up (and stop debugging it)? ")))
695 { 696 {
696 target_mourn_inferior (); 697 target_mourn_inferior ();
697 deprecated_throw_reason (RETURN_QUIT); 698 quit ();
698 } 699 }
699 700
700 target_terminal_inferior (); 701 target_terminal_inferior ();
701 } 702 }
702 703
703 /* The user typed ^C twice. */ 704 /* The user typed ^C twice. */
704 static void 705 static void
705 nto_interrupt_twice (int signo) 706 nto_interrupt_twice (int signo)
706 { 707 {
707 signal (signo, ofunc); 708 signal (signo, ofunc);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 ourstatus->value.sig = 783 ourstatus->value.sig =
783 gdb_signal_from_host (status.info.si_signo); 784 gdb_signal_from_host (status.info.si_signo);
784 exit_signo = ourstatus->value.sig; 785 exit_signo = ourstatus->value.sig;
785 } 786 }
786 break; 787 break;
787 788
788 case _DEBUG_WHY_TERMINATED: 789 case _DEBUG_WHY_TERMINATED:
789 { 790 {
790 int waitval = 0; 791 int waitval = 0;
791 792
792 » waitpid (PIDGET (inferior_ptid), &waitval, WNOHANG); 793 » waitpid (ptid_get_pid (inferior_ptid), &waitval, WNOHANG);
793 if (exit_signo) 794 if (exit_signo)
794 { 795 {
795 /* Abnormal death. */ 796 /* Abnormal death. */
796 ourstatus->kind = TARGET_WAITKIND_SIGNALLED; 797 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
797 ourstatus->value.sig = exit_signo; 798 ourstatus->value.sig = exit_signo;
798 } 799 }
799 else 800 else
800 { 801 {
801 /* Normal death. */ 802 /* Normal death. */
802 ourstatus->kind = TARGET_WAITKIND_EXITED; 803 ourstatus->kind = TARGET_WAITKIND_EXITED;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 nbytes = 0; 870 nbytes = 0;
870 } 871 }
871 return (nbytes); 872 return (nbytes);
872 } 873 }
873 874
874 /* Take a program previously attached to and detaches it. 875 /* Take a program previously attached to and detaches it.
875 The program resumes execution and will no longer stop 876 The program resumes execution and will no longer stop
876 on signals, etc. We'd better not have left any breakpoints 877 on signals, etc. We'd better not have left any breakpoints
877 in the program or it'll die when it hits one. */ 878 in the program or it'll die when it hits one. */
878 static void 879 static void
879 procfs_detach (struct target_ops *ops, char *args, int from_tty) 880 procfs_detach (struct target_ops *ops, const char *args, int from_tty)
880 { 881 {
881 int siggnal = 0; 882 int siggnal = 0;
882 int pid; 883 int pid;
883 884
884 if (from_tty) 885 if (from_tty)
885 { 886 {
886 char *exec_file = get_exec_file (0); 887 char *exec_file = get_exec_file (0);
887 if (exec_file == 0) 888 if (exec_file == 0)
888 exec_file = ""; 889 exec_file = "";
889 printf_unfiltered ("Detaching from program: %s %s\n", 890 printf_unfiltered ("Detaching from program: %s %s\n",
890 exec_file, target_pid_to_str (inferior_ptid)); 891 exec_file, target_pid_to_str (inferior_ptid));
891 gdb_flush (gdb_stdout); 892 gdb_flush (gdb_stdout);
892 } 893 }
893 if (args) 894 if (args)
894 siggnal = atoi (args); 895 siggnal = atoi (args);
895 896
896 if (siggnal) 897 if (siggnal)
897 SignalKill (nto_node (), PIDGET (inferior_ptid), 0, siggnal, 0, 0); 898 SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0, siggnal, 0, 0);
898 899
899 close (ctl_fd); 900 close (ctl_fd);
900 ctl_fd = -1; 901 ctl_fd = -1;
901 902
902 pid = ptid_get_pid (inferior_ptid); 903 pid = ptid_get_pid (inferior_ptid);
903 inferior_ptid = null_ptid; 904 inferior_ptid = null_ptid;
904 detach_inferior (pid); 905 detach_inferior (pid);
905 init_thread_list (); 906 init_thread_list ();
906 unpush_target (&procfs_ops); /* Pop out of handling an inferior. */ 907 unpush_target (&procfs_ops); /* Pop out of handling an inferior. */
907 } 908 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 signal_to_pass = gdb_signal_to_host (signo); 986 signal_to_pass = gdb_signal_to_host (signo);
986 987
987 if (signal_to_pass) 988 if (signal_to_pass)
988 { 989 {
989 devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0); 990 devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);
990 signal_to_pass = gdb_signal_to_host (signo); 991 signal_to_pass = gdb_signal_to_host (signo);
991 if (status.why & (_DEBUG_WHY_SIGNALLED | _DEBUG_WHY_FAULTED)) 992 if (status.why & (_DEBUG_WHY_SIGNALLED | _DEBUG_WHY_FAULTED))
992 { 993 {
993 if (signal_to_pass != status.info.si_signo) 994 if (signal_to_pass != status.info.si_signo)
994 { 995 {
995 » SignalKill (nto_node (), PIDGET (inferior_ptid), 0, 996 » SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0,
996 signal_to_pass, 0, 0); 997 signal_to_pass, 0, 0);
997 run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG; 998 run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;
998 } 999 }
999 else /* Let it kill the program without telling us. */ 1000 else /* Let it kill the program without telling us. */
1000 sigdelset (&run.trace, signal_to_pass); 1001 sigdelset (&run.trace, signal_to_pass);
1001 } 1002 }
1002 } 1003 }
1003 else 1004 else
1004 run.flags |= _DEBUG_RUN_CLRSIG | _DEBUG_RUN_CLRFLT; 1005 run.flags |= _DEBUG_RUN_CLRSIG | _DEBUG_RUN_CLRFLT;
1005 1006
1006 errno = devctl (ctl_fd, DCMD_PROC_RUN, &run, sizeof (run), 0); 1007 errno = devctl (ctl_fd, DCMD_PROC_RUN, &run, sizeof (run), 0);
1007 if (errno != EOK) 1008 if (errno != EOK)
1008 { 1009 {
1009 perror (_("run error!\n")); 1010 perror (_("run error!\n"));
1010 return; 1011 return;
1011 } 1012 }
1012 } 1013 }
1013 1014
1014 static void 1015 static void
1015 procfs_mourn_inferior (struct target_ops *ops) 1016 procfs_mourn_inferior (struct target_ops *ops)
1016 { 1017 {
1017 if (!ptid_equal (inferior_ptid, null_ptid)) 1018 if (!ptid_equal (inferior_ptid, null_ptid))
1018 { 1019 {
1019 SignalKill (nto_node (), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0); 1020 SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0, SIGKILL, 0, 0);
1020 close (ctl_fd); 1021 close (ctl_fd);
1021 } 1022 }
1022 inferior_ptid = null_ptid; 1023 inferior_ptid = null_ptid;
1023 init_thread_list (); 1024 init_thread_list ();
1024 unpush_target (&procfs_ops); 1025 unpush_target (&procfs_ops);
1025 generic_mourn_inferior (); 1026 generic_mourn_inferior ();
1026 } 1027 }
1027 1028
1028 /* This function breaks up an argument string into an argument 1029 /* This function breaks up an argument string into an argument
1029 vector suitable for passing to execvp(). 1030 vector suitable for passing to execvp().
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 struct expression *cond) 1505 struct expression *cond)
1505 { 1506 {
1506 return procfs_hw_watchpoint (addr, len, type); 1507 return procfs_hw_watchpoint (addr, len, type);
1507 } 1508 }
1508 1509
1509 static int 1510 static int
1510 procfs_stopped_by_watchpoint (void) 1511 procfs_stopped_by_watchpoint (void)
1511 { 1512 {
1512 return 0; 1513 return 0;
1513 } 1514 }
OLDNEW
« no previous file with comments | « gdb/nios2-tdep.c ('k') | gdb/nto-tdep.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698