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

Side by Side Diff: gdb/procfs.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 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/proc-utils.h ('k') | gdb/progspace.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 SVR4 /proc (process file system) for GDB. 1 /* Machine independent support for SVR4 /proc (process file system) for GDB.
2 2
3 Copyright (C) 1999-2003, 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 1999-2003, 2006-2012 Free Software Foundation, Inc.
4 4
5 Written by Michael Snyder at Cygnus Solutions. 5 Written by Michael Snyder at Cygnus Solutions.
6 Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others. 6 Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
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
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 /* Prototypes for supply_gregset etc. */ 105 /* Prototypes for supply_gregset etc. */
106 #include "gregset.h" 106 #include "gregset.h"
107 107
108 /* =================== TARGET_OPS "MODULE" =================== */ 108 /* =================== TARGET_OPS "MODULE" =================== */
109 109
110 /* This module defines the GDB target vector and its methods. */ 110 /* This module defines the GDB target vector and its methods. */
111 111
112 static void procfs_attach (struct target_ops *, char *, int); 112 static void procfs_attach (struct target_ops *, char *, int);
113 static void procfs_detach (struct target_ops *, char *, int); 113 static void procfs_detach (struct target_ops *, char *, int);
114 static void procfs_resume (struct target_ops *, 114 static void procfs_resume (struct target_ops *,
115 » » » ptid_t, int, enum target_signal); 115 » » » ptid_t, int, enum gdb_signal);
116 static void procfs_stop (ptid_t); 116 static void procfs_stop (ptid_t);
117 static void procfs_files_info (struct target_ops *); 117 static void procfs_files_info (struct target_ops *);
118 static void procfs_fetch_registers (struct target_ops *, 118 static void procfs_fetch_registers (struct target_ops *,
119 struct regcache *, int); 119 struct regcache *, int);
120 static void procfs_store_registers (struct target_ops *, 120 static void procfs_store_registers (struct target_ops *,
121 struct regcache *, int); 121 struct regcache *, int);
122 static void procfs_pass_signals (int, unsigned char *); 122 static void procfs_pass_signals (int, unsigned char *);
123 static void procfs_kill_inferior (struct target_ops *ops); 123 static void procfs_kill_inferior (struct target_ops *ops);
124 static void procfs_mourn_inferior (struct target_ops *ops); 124 static void procfs_mourn_inferior (struct target_ops *ops);
125 static void procfs_create_inferior (struct target_ops *, char *, 125 static void procfs_create_inferior (struct target_ops *, char *,
126 char *, char **, int); 126 char *, char **, int);
127 static ptid_t procfs_wait (struct target_ops *, 127 static ptid_t procfs_wait (struct target_ops *,
128 ptid_t, struct target_waitstatus *, int); 128 ptid_t, struct target_waitstatus *, int);
129 static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int, 129 static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
130 struct mem_attrib *attrib, 130 struct mem_attrib *attrib,
131 struct target_ops *); 131 struct target_ops *);
132 static LONGEST procfs_xfer_partial (struct target_ops *ops, 132 static LONGEST procfs_xfer_partial (struct target_ops *ops,
133 enum target_object object, 133 enum target_object object,
134 const char *annex, 134 const char *annex,
135 gdb_byte *readbuf, 135 gdb_byte *readbuf,
136 const gdb_byte *writebuf, 136 const gdb_byte *writebuf,
137 ULONGEST offset, LONGEST len); 137 ULONGEST offset, LONGEST len);
138 138
139 static int procfs_thread_alive (struct target_ops *ops, ptid_t); 139 static int procfs_thread_alive (struct target_ops *ops, ptid_t);
140 140
141 void procfs_find_new_threads (struct target_ops *ops); 141 static void procfs_find_new_threads (struct target_ops *ops);
142 char *procfs_pid_to_str (struct target_ops *, ptid_t); 142 static char *procfs_pid_to_str (struct target_ops *, ptid_t);
143 143
144 static int proc_find_memory_regions (int (*) (CORE_ADDR, 144 static int proc_find_memory_regions (int (*) (CORE_ADDR,
145 unsigned long, 145 unsigned long,
146 int, int, int, 146 int, int, int,
147 void *), 147 void *),
148 void *); 148 void *);
149 149
150 static char * procfs_make_note_section (bfd *, int *); 150 static char * procfs_make_note_section (bfd *, int *);
151 151
152 static int procfs_can_use_hw_breakpoint (int, int, int); 152 static int procfs_can_use_hw_breakpoint (int, int, int);
153 153
154 static void procfs_info_proc (struct target_ops *, char *,
155 enum info_proc_what);
156
154 #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) 157 #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
155 /* When GDB is built as 64-bit application on Solaris, the auxv data 158 /* When GDB is built as 64-bit application on Solaris, the auxv data
156 is presented in 64-bit format. We need to provide a custom parser 159 is presented in 64-bit format. We need to provide a custom parser
157 to handle that. */ 160 to handle that. */
158 static int 161 static int
159 procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr, 162 procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
160 gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) 163 gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
161 { 164 {
162 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch); 165 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
163 gdb_byte *ptr = *readptr; 166 gdb_byte *ptr = *readptr;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 t->to_files_info = procfs_files_info; 207 t->to_files_info = procfs_files_info;
205 t->to_stop = procfs_stop; 208 t->to_stop = procfs_stop;
206 209
207 t->to_find_new_threads = procfs_find_new_threads; 210 t->to_find_new_threads = procfs_find_new_threads;
208 t->to_thread_alive = procfs_thread_alive; 211 t->to_thread_alive = procfs_thread_alive;
209 t->to_pid_to_str = procfs_pid_to_str; 212 t->to_pid_to_str = procfs_pid_to_str;
210 213
211 t->to_has_thread_control = tc_schedlock; 214 t->to_has_thread_control = tc_schedlock;
212 t->to_find_memory_regions = proc_find_memory_regions; 215 t->to_find_memory_regions = proc_find_memory_regions;
213 t->to_make_corefile_notes = procfs_make_note_section; 216 t->to_make_corefile_notes = procfs_make_note_section;
217 t->to_info_proc = procfs_info_proc;
214 218
215 #if defined(PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) 219 #if defined(PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
216 t->to_auxv_parse = procfs_auxv_parse; 220 t->to_auxv_parse = procfs_auxv_parse;
217 #endif 221 #endif
218 222
219 t->to_magic = OPS_MAGIC; 223 t->to_magic = OPS_MAGIC;
220 224
221 return t; 225 return t;
222 } 226 }
223 227
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 #ifdef HAVE_PR_SIGACTION64_T 259 #ifdef HAVE_PR_SIGACTION64_T
256 typedef pr_sigaction64_t gdb_sigaction_t; 260 typedef pr_sigaction64_t gdb_sigaction_t;
257 #else 261 #else
258 typedef struct sigaction gdb_sigaction_t; 262 typedef struct sigaction gdb_sigaction_t;
259 #endif 263 #endif
260 264
261 /* siginfo */ 265 /* siginfo */
262 #ifdef HAVE_PR_SIGINFO64_T 266 #ifdef HAVE_PR_SIGINFO64_T
263 typedef pr_siginfo64_t gdb_siginfo_t; 267 typedef pr_siginfo64_t gdb_siginfo_t;
264 #else 268 #else
265 typedef struct siginfo gdb_siginfo_t; 269 typedef siginfo_t gdb_siginfo_t;
266 #endif 270 #endif
267 271
268 /* On mips-irix, praddset and prdelset are defined in such a way that 272 /* On mips-irix, praddset and prdelset are defined in such a way that
269 they return a value, which causes GCC to emit a -Wunused error 273 they return a value, which causes GCC to emit a -Wunused error
270 because the returned value is not used. Prevent this warning 274 because the returned value is not used. Prevent this warning
271 by casting the return value to void. On sparc-solaris, this issue 275 by casting the return value to void. On sparc-solaris, this issue
272 does not exist because the definition of these macros already include 276 does not exist because the definition of these macros already include
273 that cast to void. */ 277 that cast to void. */
274 #define gdb_praddset(sp, flag) ((void) praddset (sp, flag)) 278 #define gdb_praddset(sp, flag) ((void) praddset (sp, flag))
275 #define gdb_prdelset(sp, flag) ((void) prdelset (sp, flag)) 279 #define gdb_prdelset(sp, flag) ((void) prdelset (sp, flag))
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 /* This "module" is the interface layer between the /proc system API 1012 /* This "module" is the interface layer between the /proc system API
1009 and the gdb target vector functions. This layer consists of access 1013 and the gdb target vector functions. This layer consists of access
1010 functions that encapsulate each of the basic operations that we 1014 functions that encapsulate each of the basic operations that we
1011 need to use from the /proc API. 1015 need to use from the /proc API.
1012 1016
1013 The main motivation for this layer is to hide the fact that there 1017 The main motivation for this layer is to hide the fact that there
1014 are two very different implementations of the /proc API. Rather 1018 are two very different implementations of the /proc API. Rather
1015 than have a bunch of #ifdefs all thru the gdb target vector 1019 than have a bunch of #ifdefs all thru the gdb target vector
1016 functions, we do our best to hide them all in here. */ 1020 functions, we do our best to hide them all in here. */
1017 1021
1018 int proc_get_status (procinfo * pi); 1022 static long proc_flags (procinfo * pi);
1019 long proc_flags (procinfo * pi); 1023 static int proc_why (procinfo * pi);
1020 int proc_why (procinfo * pi); 1024 static int proc_what (procinfo * pi);
1021 int proc_what (procinfo * pi); 1025 static int proc_set_current_signal (procinfo * pi, int signo);
1022 int proc_set_run_on_last_close (procinfo * pi); 1026 static int proc_get_current_thread (procinfo * pi);
1023 int proc_unset_run_on_last_close (procinfo * pi); 1027 static int proc_iterate_over_threads
1024 int proc_set_inherit_on_fork (procinfo * pi); 1028 (procinfo * pi,
1025 int proc_unset_inherit_on_fork (procinfo * pi); 1029 int (*func) (procinfo *, procinfo *, void *),
1026 int proc_set_async (procinfo * pi); 1030 void *ptr);
1027 int proc_unset_async (procinfo * pi);
1028 int proc_stop_process (procinfo * pi);
1029 int proc_trace_signal (procinfo * pi, int signo);
1030 int proc_ignore_signal (procinfo * pi, int signo);
1031 int proc_clear_current_fault (procinfo * pi);
1032 int proc_set_current_signal (procinfo * pi, int signo);
1033 int proc_clear_current_signal (procinfo * pi);
1034 int proc_set_gregs (procinfo * pi);
1035 int proc_set_fpregs (procinfo * pi);
1036 int proc_wait_for_stop (procinfo * pi);
1037 int proc_run_process (procinfo * pi, int step, int signo);
1038 int proc_kill (procinfo * pi, int signo);
1039 int proc_parent_pid (procinfo * pi);
1040 int proc_get_nthreads (procinfo * pi);
1041 int proc_get_current_thread (procinfo * pi);
1042 int proc_set_held_signals (procinfo * pi, gdb_sigset_t * sighold);
1043 int proc_set_traced_sysexit (procinfo * pi, sysset_t * sysset);
1044 int proc_set_traced_sysentry (procinfo * pi, sysset_t * sysset);
1045 int proc_set_traced_faults (procinfo * pi, fltset_t * fltset);
1046 int proc_set_traced_signals (procinfo * pi, gdb_sigset_t * sigset);
1047 1031
1048 int proc_update_threads (procinfo * pi); 1032 static void
1049 int proc_iterate_over_threads (procinfo * pi,
1050 » » » int (*func) (procinfo *, procinfo *, void *),
1051 » » » void *ptr);
1052
1053 gdb_gregset_t *proc_get_gregs (procinfo * pi);
1054 gdb_fpregset_t *proc_get_fpregs (procinfo * pi);
1055 sysset_t *proc_get_traced_sysexit (procinfo * pi, sysset_t * save);
1056 sysset_t *proc_get_traced_sysentry (procinfo * pi, sysset_t * save);
1057 fltset_t *proc_get_traced_faults (procinfo * pi, fltset_t * save);
1058 gdb_sigset_t *proc_get_traced_signals (procinfo * pi, gdb_sigset_t * save);
1059 gdb_sigset_t *proc_get_held_signals (procinfo * pi, gdb_sigset_t * save);
1060 gdb_sigset_t *proc_get_pending_signals (procinfo * pi, gdb_sigset_t * save);
1061 gdb_sigaction_t *proc_get_signal_actions (procinfo * pi,
1062 » » » » » gdb_sigaction_t *save);
1063
1064 void proc_warn (procinfo * pi, char *func, int line);
1065 void proc_error (procinfo * pi, char *func, int line);
1066
1067 void
1068 proc_warn (procinfo *pi, char *func, int line) 1033 proc_warn (procinfo *pi, char *func, int line)
1069 { 1034 {
1070 sprintf (errmsg, "procfs: %s line %d, %s", func, line, pi->pathname); 1035 sprintf (errmsg, "procfs: %s line %d, %s", func, line, pi->pathname);
1071 print_sys_errmsg (errmsg, errno); 1036 print_sys_errmsg (errmsg, errno);
1072 } 1037 }
1073 1038
1074 void 1039 static void
1075 proc_error (procinfo *pi, char *func, int line) 1040 proc_error (procinfo *pi, char *func, int line)
1076 { 1041 {
1077 sprintf (errmsg, "procfs: %s line %d, %s", func, line, pi->pathname); 1042 sprintf (errmsg, "procfs: %s line %d, %s", func, line, pi->pathname);
1078 perror_with_name (errmsg); 1043 perror_with_name (errmsg);
1079 } 1044 }
1080 1045
1081 /* Updates the status struct in the procinfo. There is a 'valid' 1046 /* Updates the status struct in the procinfo. There is a 'valid'
1082 flag, to let other functions know when this function needs to be 1047 flag, to let other functions know when this function needs to be
1083 called (so the status is only read when it is needed). The status 1048 called (so the status is only read when it is needed). The status
1084 file descriptor is also only opened when it is needed. Returns 1049 file descriptor is also only opened when it is needed. Returns
1085 non-zero for success, zero for failure. */ 1050 non-zero for success, zero for failure. */
1086 1051
1087 int 1052 static int
1088 proc_get_status (procinfo *pi) 1053 proc_get_status (procinfo *pi)
1089 { 1054 {
1090 /* Status file descriptor is opened "lazily". */ 1055 /* Status file descriptor is opened "lazily". */
1091 if (pi->status_fd == 0 && 1056 if (pi->status_fd == 0 &&
1092 open_procinfo_files (pi, FD_STATUS) == 0) 1057 open_procinfo_files (pi, FD_STATUS) == 0)
1093 { 1058 {
1094 pi->status_valid = 0; 1059 pi->status_valid = 0;
1095 return 0; 1060 return 0;
1096 } 1061 }
1097 1062
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 #ifdef NEW_PROC_API 1136 #ifdef NEW_PROC_API
1172 /* In the read/write multiple-fd model, the status struct includes 1137 /* In the read/write multiple-fd model, the status struct includes
1173 the fp regs too, so mark them valid too. */ 1138 the fp regs too, so mark them valid too. */
1174 pi->fpregs_valid = pi->status_valid; 1139 pi->fpregs_valid = pi->status_valid;
1175 #endif 1140 #endif
1176 return pi->status_valid; /* True if success, false if failure. */ 1141 return pi->status_valid; /* True if success, false if failure. */
1177 } 1142 }
1178 1143
1179 /* Returns the process flags (pr_flags field). */ 1144 /* Returns the process flags (pr_flags field). */
1180 1145
1181 long 1146 static long
1182 proc_flags (procinfo *pi) 1147 proc_flags (procinfo *pi)
1183 { 1148 {
1184 if (!pi->status_valid) 1149 if (!pi->status_valid)
1185 if (!proc_get_status (pi)) 1150 if (!proc_get_status (pi))
1186 return 0; /* FIXME: not a good failure value (but what is?) */ 1151 return 0; /* FIXME: not a good failure value (but what is?) */
1187 1152
1188 #ifdef NEW_PROC_API 1153 #ifdef NEW_PROC_API
1189 # ifdef UNIXWARE 1154 # ifdef UNIXWARE
1190 /* UnixWare 7.1 puts process status flags, e.g. PR_ASYNC, in 1155 /* UnixWare 7.1 puts process status flags, e.g. PR_ASYNC, in
1191 pstatus_t and LWP status flags, e.g. PR_STOPPED, in lwpstatus_t. 1156 pstatus_t and LWP status flags, e.g. PR_STOPPED, in lwpstatus_t.
1192 The two sets of flags don't overlap. */ 1157 The two sets of flags don't overlap. */
1193 return pi->prstatus.pr_flags | pi->prstatus.pr_lwp.pr_flags; 1158 return pi->prstatus.pr_flags | pi->prstatus.pr_lwp.pr_flags;
1194 # else 1159 # else
1195 return pi->prstatus.pr_lwp.pr_flags; 1160 return pi->prstatus.pr_lwp.pr_flags;
1196 # endif 1161 # endif
1197 #else 1162 #else
1198 return pi->prstatus.pr_flags; 1163 return pi->prstatus.pr_flags;
1199 #endif 1164 #endif
1200 } 1165 }
1201 1166
1202 /* Returns the pr_why field (why the process stopped). */ 1167 /* Returns the pr_why field (why the process stopped). */
1203 1168
1204 int 1169 static int
1205 proc_why (procinfo *pi) 1170 proc_why (procinfo *pi)
1206 { 1171 {
1207 if (!pi->status_valid) 1172 if (!pi->status_valid)
1208 if (!proc_get_status (pi)) 1173 if (!proc_get_status (pi))
1209 return 0; /* FIXME: not a good failure value (but what is?) */ 1174 return 0; /* FIXME: not a good failure value (but what is?) */
1210 1175
1211 #ifdef NEW_PROC_API 1176 #ifdef NEW_PROC_API
1212 return pi->prstatus.pr_lwp.pr_why; 1177 return pi->prstatus.pr_lwp.pr_why;
1213 #else 1178 #else
1214 return pi->prstatus.pr_why; 1179 return pi->prstatus.pr_why;
1215 #endif 1180 #endif
1216 } 1181 }
1217 1182
1218 /* Returns the pr_what field (details of why the process stopped). */ 1183 /* Returns the pr_what field (details of why the process stopped). */
1219 1184
1220 int 1185 static int
1221 proc_what (procinfo *pi) 1186 proc_what (procinfo *pi)
1222 { 1187 {
1223 if (!pi->status_valid) 1188 if (!pi->status_valid)
1224 if (!proc_get_status (pi)) 1189 if (!proc_get_status (pi))
1225 return 0; /* FIXME: not a good failure value (but what is?) */ 1190 return 0; /* FIXME: not a good failure value (but what is?) */
1226 1191
1227 #ifdef NEW_PROC_API 1192 #ifdef NEW_PROC_API
1228 return pi->prstatus.pr_lwp.pr_what; 1193 return pi->prstatus.pr_lwp.pr_what;
1229 #else 1194 #else
1230 return pi->prstatus.pr_what; 1195 return pi->prstatus.pr_what;
(...skipping 22 matching lines...) Expand all
1253 (gdb_byte *) &pi->prstatus.pr_info.si_addr); 1218 (gdb_byte *) &pi->prstatus.pr_info.si_addr);
1254 #endif 1219 #endif
1255 return 1; 1220 return 1;
1256 } 1221 }
1257 1222
1258 #ifndef PIOCSSPCACT /* The following is not supported on OSF. */ 1223 #ifndef PIOCSSPCACT /* The following is not supported on OSF. */
1259 1224
1260 /* Returns the pr_nsysarg field (number of args to the current 1225 /* Returns the pr_nsysarg field (number of args to the current
1261 syscall). */ 1226 syscall). */
1262 1227
1263 int 1228 static int
1264 proc_nsysarg (procinfo *pi) 1229 proc_nsysarg (procinfo *pi)
1265 { 1230 {
1266 if (!pi->status_valid) 1231 if (!pi->status_valid)
1267 if (!proc_get_status (pi)) 1232 if (!proc_get_status (pi))
1268 return 0; 1233 return 0;
1269 1234
1270 #ifdef NEW_PROC_API 1235 #ifdef NEW_PROC_API
1271 return pi->prstatus.pr_lwp.pr_nsysarg; 1236 return pi->prstatus.pr_lwp.pr_nsysarg;
1272 #else 1237 #else
1273 return pi->prstatus.pr_nsysarg; 1238 return pi->prstatus.pr_nsysarg;
1274 #endif 1239 #endif
1275 } 1240 }
1276 1241
1277 /* Returns the pr_sysarg field (pointer to the arguments of current 1242 /* Returns the pr_sysarg field (pointer to the arguments of current
1278 syscall). */ 1243 syscall). */
1279 1244
1280 long * 1245 static long *
1281 proc_sysargs (procinfo *pi) 1246 proc_sysargs (procinfo *pi)
1282 { 1247 {
1283 if (!pi->status_valid) 1248 if (!pi->status_valid)
1284 if (!proc_get_status (pi)) 1249 if (!proc_get_status (pi))
1285 return NULL; 1250 return NULL;
1286 1251
1287 #ifdef NEW_PROC_API 1252 #ifdef NEW_PROC_API
1288 return (long *) &pi->prstatus.pr_lwp.pr_sysarg; 1253 return (long *) &pi->prstatus.pr_lwp.pr_sysarg;
1289 #else 1254 #else
1290 return (long *) &pi->prstatus.pr_sysarg; 1255 return (long *) &pi->prstatus.pr_sysarg;
1291 #endif 1256 #endif
1292 } 1257 }
1293
1294 /* Returns the pr_syscall field (id of current syscall if we are in
1295 one). */
1296
1297 int
1298 proc_syscall (procinfo *pi)
1299 {
1300 if (!pi->status_valid)
1301 if (!proc_get_status (pi))
1302 return 0;
1303
1304 #ifdef NEW_PROC_API
1305 return pi->prstatus.pr_lwp.pr_syscall;
1306 #else
1307 return pi->prstatus.pr_syscall;
1308 #endif
1309 }
1310 #endif /* PIOCSSPCACT */ 1258 #endif /* PIOCSSPCACT */
1311 1259
1260 #ifdef PROCFS_DONT_PIOCSSIG_CURSIG
1312 /* Returns the pr_cursig field (current signal). */ 1261 /* Returns the pr_cursig field (current signal). */
1313 1262
1314 long 1263 static long
1315 proc_cursig (struct procinfo *pi) 1264 proc_cursig (struct procinfo *pi)
1316 { 1265 {
1317 if (!pi->status_valid) 1266 if (!pi->status_valid)
1318 if (!proc_get_status (pi)) 1267 if (!proc_get_status (pi))
1319 return 0; /* FIXME: not a good failure value (but what is?) */ 1268 return 0; /* FIXME: not a good failure value (but what is?) */
1320 1269
1321 #ifdef NEW_PROC_API 1270 #ifdef NEW_PROC_API
1322 return pi->prstatus.pr_lwp.pr_cursig; 1271 return pi->prstatus.pr_lwp.pr_cursig;
1323 #else 1272 #else
1324 return pi->prstatus.pr_cursig; 1273 return pi->prstatus.pr_cursig;
1325 #endif 1274 #endif
1326 } 1275 }
1276 #endif /* PROCFS_DONT_PIOCSSIG_CURSIG */
1327 1277
1328 /* === I appologize for the messiness of this function. 1278 /* === I appologize for the messiness of this function.
1329 === This is an area where the different versions of 1279 === This is an area where the different versions of
1330 === /proc are more inconsistent than usual. 1280 === /proc are more inconsistent than usual.
1331 1281
1332 Set or reset any of the following process flags: 1282 Set or reset any of the following process flags:
1333 PR_FORK -- forked child will inherit trace flags 1283 PR_FORK -- forked child will inherit trace flags
1334 PR_RLC -- traced process runs when last /proc file closed. 1284 PR_RLC -- traced process runs when last /proc file closed.
1335 PR_KLC -- traced process is killed when last /proc file closed. 1285 PR_KLC -- traced process is killed when last /proc file closed.
1336 PR_ASYNC -- LWP's get to run/stop independently. 1286 PR_ASYNC -- LWP's get to run/stop independently.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 "<unknown flag>", 1401 "<unknown flag>",
1452 mode == FLAG_RESET ? "off" : "on"); 1402 mode == FLAG_RESET ? "off" : "on");
1453 1403
1454 return win; 1404 return win;
1455 } 1405 }
1456 1406
1457 /* Set the run_on_last_close flag. Process with all threads will 1407 /* Set the run_on_last_close flag. Process with all threads will
1458 become runnable when debugger closes all /proc fds. Returns 1408 become runnable when debugger closes all /proc fds. Returns
1459 non-zero for success, zero for failure. */ 1409 non-zero for success, zero for failure. */
1460 1410
1461 int 1411 static int
1462 proc_set_run_on_last_close (procinfo *pi) 1412 proc_set_run_on_last_close (procinfo *pi)
1463 { 1413 {
1464 return proc_modify_flag (pi, PR_RLC, FLAG_SET); 1414 return proc_modify_flag (pi, PR_RLC, FLAG_SET);
1465 } 1415 }
1466 1416
1467 /* Reset the run_on_last_close flag. The process will NOT become 1417 /* Reset the run_on_last_close flag. The process will NOT become
1468 runnable when debugger closes its file handles. Returns non-zero 1418 runnable when debugger closes its file handles. Returns non-zero
1469 for success, zero for failure. */ 1419 for success, zero for failure. */
1470 1420
1471 int 1421 static int
1472 proc_unset_run_on_last_close (procinfo *pi) 1422 proc_unset_run_on_last_close (procinfo *pi)
1473 { 1423 {
1474 return proc_modify_flag (pi, PR_RLC, FLAG_RESET); 1424 return proc_modify_flag (pi, PR_RLC, FLAG_RESET);
1475 } 1425 }
1476 1426
1477 #ifdef PR_KLC
1478 /* Set the kill_on_last_close flag. Process with all threads will be
1479 killed when debugger closes all /proc fds (or debugger exits or
1480 dies). Returns non-zero for success, zero for failure. */
1481
1482 int
1483 proc_set_kill_on_last_close (procinfo *pi)
1484 {
1485 return proc_modify_flag (pi, PR_KLC, FLAG_SET);
1486 }
1487
1488 /* Reset the kill_on_last_close flag. Process will NOT be killed when
1489 debugger closes its file handles (or exits or dies). Returns
1490 non-zero for success, zero for failure. */
1491
1492 int
1493 proc_unset_kill_on_last_close (procinfo *pi)
1494 {
1495 return proc_modify_flag (pi, PR_KLC, FLAG_RESET);
1496 }
1497 #endif /* PR_KLC */
1498
1499 /* Set inherit_on_fork flag. If the process forks a child while we
1500 are registered for events in the parent, then we will also recieve
1501 events from the child. Returns non-zero for success, zero for
1502 failure. */
1503
1504 int
1505 proc_set_inherit_on_fork (procinfo *pi)
1506 {
1507 return proc_modify_flag (pi, PR_FORK, FLAG_SET);
1508 }
1509
1510 /* Reset inherit_on_fork flag. If the process forks a child while we 1427 /* Reset inherit_on_fork flag. If the process forks a child while we
1511 are registered for events in the parent, then we will NOT recieve 1428 are registered for events in the parent, then we will NOT recieve
1512 events from the child. Returns non-zero for success, zero for 1429 events from the child. Returns non-zero for success, zero for
1513 failure. */ 1430 failure. */
1514 1431
1515 int 1432 static int
1516 proc_unset_inherit_on_fork (procinfo *pi) 1433 proc_unset_inherit_on_fork (procinfo *pi)
1517 { 1434 {
1518 return proc_modify_flag (pi, PR_FORK, FLAG_RESET); 1435 return proc_modify_flag (pi, PR_FORK, FLAG_RESET);
1519 } 1436 }
1520 1437
1521 #ifdef PR_ASYNC 1438 #ifdef PR_ASYNC
1522 /* Set PR_ASYNC flag. If one LWP stops because of a debug event 1439 /* Set PR_ASYNC flag. If one LWP stops because of a debug event
1523 (signal etc.), the remaining LWPs will continue to run. Returns 1440 (signal etc.), the remaining LWPs will continue to run. Returns
1524 non-zero for success, zero for failure. */ 1441 non-zero for success, zero for failure. */
1525 1442
1526 int 1443 static int
1527 proc_set_async (procinfo *pi) 1444 proc_set_async (procinfo *pi)
1528 { 1445 {
1529 return proc_modify_flag (pi, PR_ASYNC, FLAG_SET); 1446 return proc_modify_flag (pi, PR_ASYNC, FLAG_SET);
1530 } 1447 }
1531 1448
1532 /* Reset PR_ASYNC flag. If one LWP stops because of a debug event 1449 /* Reset PR_ASYNC flag. If one LWP stops because of a debug event
1533 (signal etc.), then all other LWPs will stop as well. Returns 1450 (signal etc.), then all other LWPs will stop as well. Returns
1534 non-zero for success, zero for failure. */ 1451 non-zero for success, zero for failure. */
1535 1452
1536 int 1453 static int
1537 proc_unset_async (procinfo *pi) 1454 proc_unset_async (procinfo *pi)
1538 { 1455 {
1539 return proc_modify_flag (pi, PR_ASYNC, FLAG_RESET); 1456 return proc_modify_flag (pi, PR_ASYNC, FLAG_RESET);
1540 } 1457 }
1541 #endif /* PR_ASYNC */ 1458 #endif /* PR_ASYNC */
1542 1459
1543 /* Request the process/LWP to stop. Does not wait. Returns non-zero 1460 /* Request the process/LWP to stop. Does not wait. Returns non-zero
1544 for success, zero for failure. */ 1461 for success, zero for failure. */
1545 1462
1546 int 1463 static int
1547 proc_stop_process (procinfo *pi) 1464 proc_stop_process (procinfo *pi)
1548 { 1465 {
1549 int win; 1466 int win;
1550 1467
1551 /* We might conceivably apply this operation to an LWP, and the 1468 /* We might conceivably apply this operation to an LWP, and the
1552 LWP's ctl file descriptor might not be open. */ 1469 LWP's ctl file descriptor might not be open. */
1553 1470
1554 if (pi->ctl_fd == 0 && 1471 if (pi->ctl_fd == 0 &&
1555 open_procinfo_files (pi, FD_CTL) == 0) 1472 open_procinfo_files (pi, FD_CTL) == 0)
1556 return 0; 1473 return 0;
(...skipping 16 matching lines...) Expand all
1573 } 1490 }
1574 #endif 1491 #endif
1575 } 1492 }
1576 1493
1577 return win; 1494 return win;
1578 } 1495 }
1579 1496
1580 /* Wait for the process or LWP to stop (block until it does). Returns 1497 /* Wait for the process or LWP to stop (block until it does). Returns
1581 non-zero for success, zero for failure. */ 1498 non-zero for success, zero for failure. */
1582 1499
1583 int 1500 static int
1584 proc_wait_for_stop (procinfo *pi) 1501 proc_wait_for_stop (procinfo *pi)
1585 { 1502 {
1586 int win; 1503 int win;
1587 1504
1588 /* We should never have to apply this operation to any procinfo 1505 /* We should never have to apply this operation to any procinfo
1589 except the one for the main process. If that ever changes for 1506 except the one for the main process. If that ever changes for
1590 any reason, then take out the following clause and replace it 1507 any reason, then take out the following clause and replace it
1591 with one that makes sure the ctl_fd is open. */ 1508 with one that makes sure the ctl_fd is open. */
1592 1509
1593 if (pi->tid != 0) 1510 if (pi->tid != 0)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 - (ioctl): set held signal set 1546 - (ioctl): set held signal set
1630 - (ioctl): set traced fault set 1547 - (ioctl): set traced fault set
1631 - (ioctl): set start pc (vaddr) 1548 - (ioctl): set start pc (vaddr)
1632 1549
1633 Always clears the current fault. PI is the process or LWP to 1550 Always clears the current fault. PI is the process or LWP to
1634 operate on. If STEP is true, set the process or LWP to trap after 1551 operate on. If STEP is true, set the process or LWP to trap after
1635 one instruction. If SIGNO is zero, clear the current signal if 1552 one instruction. If SIGNO is zero, clear the current signal if
1636 any; if non-zero, set the current signal to this one. Returns 1553 any; if non-zero, set the current signal to this one. Returns
1637 non-zero for success, zero for failure. */ 1554 non-zero for success, zero for failure. */
1638 1555
1639 int 1556 static int
1640 proc_run_process (procinfo *pi, int step, int signo) 1557 proc_run_process (procinfo *pi, int step, int signo)
1641 { 1558 {
1642 int win; 1559 int win;
1643 int runflags; 1560 int runflags;
1644 1561
1645 /* We will probably have to apply this operation to individual 1562 /* We will probably have to apply this operation to individual
1646 threads, so make sure the control file descriptor is open. */ 1563 threads, so make sure the control file descriptor is open. */
1647 1564
1648 if (pi->ctl_fd == 0 && 1565 if (pi->ctl_fd == 0 &&
1649 open_procinfo_files (pi, FD_CTL) == 0) 1566 open_procinfo_files (pi, FD_CTL) == 0)
(...skipping 26 matching lines...) Expand all
1676 win = (ioctl (pi->ctl_fd, PIOCRUN, &prrun) >= 0); 1593 win = (ioctl (pi->ctl_fd, PIOCRUN, &prrun) >= 0);
1677 } 1594 }
1678 #endif 1595 #endif
1679 1596
1680 return win; 1597 return win;
1681 } 1598 }
1682 1599
1683 /* Register to trace signals in the process or LWP. Returns non-zero 1600 /* Register to trace signals in the process or LWP. Returns non-zero
1684 for success, zero for failure. */ 1601 for success, zero for failure. */
1685 1602
1686 int 1603 static int
1687 proc_set_traced_signals (procinfo *pi, gdb_sigset_t *sigset) 1604 proc_set_traced_signals (procinfo *pi, gdb_sigset_t *sigset)
1688 { 1605 {
1689 int win; 1606 int win;
1690 1607
1691 /* We should never have to apply this operation to any procinfo 1608 /* We should never have to apply this operation to any procinfo
1692 except the one for the main process. If that ever changes for 1609 except the one for the main process. If that ever changes for
1693 any reason, then take out the following clause and replace it 1610 any reason, then take out the following clause and replace it
1694 with one that makes sure the ctl_fd is open. */ 1611 with one that makes sure the ctl_fd is open. */
1695 1612
1696 if (pi->tid != 0) 1613 if (pi->tid != 0)
(...skipping 19 matching lines...) Expand all
1716 pi->status_valid = 0; 1633 pi->status_valid = 0;
1717 1634
1718 if (!win) 1635 if (!win)
1719 warning (_("procfs: set_traced_signals failed")); 1636 warning (_("procfs: set_traced_signals failed"));
1720 return win; 1637 return win;
1721 } 1638 }
1722 1639
1723 /* Register to trace hardware faults in the process or LWP. Returns 1640 /* Register to trace hardware faults in the process or LWP. Returns
1724 non-zero for success, zero for failure. */ 1641 non-zero for success, zero for failure. */
1725 1642
1726 int 1643 static int
1727 proc_set_traced_faults (procinfo *pi, fltset_t *fltset) 1644 proc_set_traced_faults (procinfo *pi, fltset_t *fltset)
1728 { 1645 {
1729 int win; 1646 int win;
1730 1647
1731 /* We should never have to apply this operation to any procinfo 1648 /* We should never have to apply this operation to any procinfo
1732 except the one for the main process. If that ever changes for 1649 except the one for the main process. If that ever changes for
1733 any reason, then take out the following clause and replace it 1650 any reason, then take out the following clause and replace it
1734 with one that makes sure the ctl_fd is open. */ 1651 with one that makes sure the ctl_fd is open. */
1735 1652
1736 if (pi->tid != 0) 1653 if (pi->tid != 0)
(...skipping 17 matching lines...) Expand all
1754 #endif 1671 #endif
1755 /* The above operation renders the procinfo's cached pstatus obsolete. */ 1672 /* The above operation renders the procinfo's cached pstatus obsolete. */
1756 pi->status_valid = 0; 1673 pi->status_valid = 0;
1757 1674
1758 return win; 1675 return win;
1759 } 1676 }
1760 1677
1761 /* Register to trace entry to system calls in the process or LWP. 1678 /* Register to trace entry to system calls in the process or LWP.
1762 Returns non-zero for success, zero for failure. */ 1679 Returns non-zero for success, zero for failure. */
1763 1680
1764 int 1681 static int
1765 proc_set_traced_sysentry (procinfo *pi, sysset_t *sysset) 1682 proc_set_traced_sysentry (procinfo *pi, sysset_t *sysset)
1766 { 1683 {
1767 int win; 1684 int win;
1768 1685
1769 /* We should never have to apply this operation to any procinfo 1686 /* We should never have to apply this operation to any procinfo
1770 except the one for the main process. If that ever changes for 1687 except the one for the main process. If that ever changes for
1771 any reason, then take out the following clause and replace it 1688 any reason, then take out the following clause and replace it
1772 with one that makes sure the ctl_fd is open. */ 1689 with one that makes sure the ctl_fd is open. */
1773 1690
1774 if (pi->tid != 0) 1691 if (pi->tid != 0)
(...skipping 24 matching lines...) Expand all
1799 /* The above operation renders the procinfo's cached pstatus 1716 /* The above operation renders the procinfo's cached pstatus
1800 obsolete. */ 1717 obsolete. */
1801 pi->status_valid = 0; 1718 pi->status_valid = 0;
1802 1719
1803 return win; 1720 return win;
1804 } 1721 }
1805 1722
1806 /* Register to trace exit from system calls in the process or LWP. 1723 /* Register to trace exit from system calls in the process or LWP.
1807 Returns non-zero for success, zero for failure. */ 1724 Returns non-zero for success, zero for failure. */
1808 1725
1809 int 1726 static int
1810 proc_set_traced_sysexit (procinfo *pi, sysset_t *sysset) 1727 proc_set_traced_sysexit (procinfo *pi, sysset_t *sysset)
1811 { 1728 {
1812 int win; 1729 int win;
1813 1730
1814 /* We should never have to apply this operation to any procinfo 1731 /* We should never have to apply this operation to any procinfo
1815 except the one for the main process. If that ever changes for 1732 except the one for the main process. If that ever changes for
1816 any reason, then take out the following clause and replace it 1733 any reason, then take out the following clause and replace it
1817 with one that makes sure the ctl_fd is open. */ 1734 with one that makes sure the ctl_fd is open. */
1818 1735
1819 if (pi->tid != 0) 1736 if (pi->tid != 0)
(...skipping 24 matching lines...) Expand all
1844 /* The above operation renders the procinfo's cached pstatus 1761 /* The above operation renders the procinfo's cached pstatus
1845 obsolete. */ 1762 obsolete. */
1846 pi->status_valid = 0; 1763 pi->status_valid = 0;
1847 1764
1848 return win; 1765 return win;
1849 } 1766 }
1850 1767
1851 /* Specify the set of blocked / held signals in the process or LWP. 1768 /* Specify the set of blocked / held signals in the process or LWP.
1852 Returns non-zero for success, zero for failure. */ 1769 Returns non-zero for success, zero for failure. */
1853 1770
1854 int 1771 static int
1855 proc_set_held_signals (procinfo *pi, gdb_sigset_t *sighold) 1772 proc_set_held_signals (procinfo *pi, gdb_sigset_t *sighold)
1856 { 1773 {
1857 int win; 1774 int win;
1858 1775
1859 /* We should never have to apply this operation to any procinfo 1776 /* We should never have to apply this operation to any procinfo
1860 except the one for the main process. If that ever changes for 1777 except the one for the main process. If that ever changes for
1861 any reason, then take out the following clause and replace it 1778 any reason, then take out the following clause and replace it
1862 with one that makes sure the ctl_fd is open. */ 1779 with one that makes sure the ctl_fd is open. */
1863 1780
1864 if (pi->tid != 0) 1781 if (pi->tid != 0)
(...skipping 14 matching lines...) Expand all
1879 #else 1796 #else
1880 win = (ioctl (pi->ctl_fd, PIOCSHOLD, sighold) >= 0); 1797 win = (ioctl (pi->ctl_fd, PIOCSHOLD, sighold) >= 0);
1881 #endif 1798 #endif
1882 /* The above operation renders the procinfo's cached pstatus 1799 /* The above operation renders the procinfo's cached pstatus
1883 obsolete. */ 1800 obsolete. */
1884 pi->status_valid = 0; 1801 pi->status_valid = 0;
1885 1802
1886 return win; 1803 return win;
1887 } 1804 }
1888 1805
1889 /* Returns the set of signals that are pending in the process or LWP.
1890 Will also copy the sigset if SAVE is non-zero. */
1891
1892 gdb_sigset_t *
1893 proc_get_pending_signals (procinfo *pi, gdb_sigset_t *save)
1894 {
1895 gdb_sigset_t *ret = NULL;
1896
1897 /* We should never have to apply this operation to any procinfo
1898 except the one for the main process. If that ever changes for
1899 any reason, then take out the following clause and replace it
1900 with one that makes sure the ctl_fd is open. */
1901
1902 if (pi->tid != 0)
1903 pi = find_procinfo_or_die (pi->pid, 0);
1904
1905 if (!pi->status_valid)
1906 if (!proc_get_status (pi))
1907 return NULL;
1908
1909 #ifdef NEW_PROC_API
1910 ret = &pi->prstatus.pr_lwp.pr_lwppend;
1911 #else
1912 ret = &pi->prstatus.pr_sigpend;
1913 #endif
1914 if (save && ret)
1915 memcpy (save, ret, sizeof (gdb_sigset_t));
1916
1917 return ret;
1918 }
1919
1920 /* Returns the set of signal actions. Will also copy the sigactionset
1921 if SAVE is non-zero. */
1922
1923 gdb_sigaction_t *
1924 proc_get_signal_actions (procinfo *pi, gdb_sigaction_t *save)
1925 {
1926 gdb_sigaction_t *ret = NULL;
1927
1928 /* We should never have to apply this operation to any procinfo
1929 except the one for the main process. If that ever changes for
1930 any reason, then take out the following clause and replace it
1931 with one that makes sure the ctl_fd is open. */
1932
1933 if (pi->tid != 0)
1934 pi = find_procinfo_or_die (pi->pid, 0);
1935
1936 if (!pi->status_valid)
1937 if (!proc_get_status (pi))
1938 return NULL;
1939
1940 #ifdef NEW_PROC_API
1941 ret = &pi->prstatus.pr_lwp.pr_action;
1942 #else
1943 ret = &pi->prstatus.pr_action;
1944 #endif
1945 if (save && ret)
1946 memcpy (save, ret, sizeof (gdb_sigaction_t));
1947
1948 return ret;
1949 }
1950
1951 /* Returns the set of signals that are held / blocked. Will also copy 1806 /* Returns the set of signals that are held / blocked. Will also copy
1952 the sigset if SAVE is non-zero. */ 1807 the sigset if SAVE is non-zero. */
1953 1808
1954 gdb_sigset_t * 1809 static gdb_sigset_t *
1955 proc_get_held_signals (procinfo *pi, gdb_sigset_t *save) 1810 proc_get_held_signals (procinfo *pi, gdb_sigset_t *save)
1956 { 1811 {
1957 gdb_sigset_t *ret = NULL; 1812 gdb_sigset_t *ret = NULL;
1958 1813
1959 /* We should never have to apply this operation to any procinfo 1814 /* We should never have to apply this operation to any procinfo
1960 except the one for the main process. If that ever changes for 1815 except the one for the main process. If that ever changes for
1961 any reason, then take out the following clause and replace it 1816 any reason, then take out the following clause and replace it
1962 with one that makes sure the ctl_fd is open. */ 1817 with one that makes sure the ctl_fd is open. */
1963 1818
1964 if (pi->tid != 0) 1819 if (pi->tid != 0)
(...skipping 19 matching lines...) Expand all
1984 #endif /* NEW_PROC_API */ 1839 #endif /* NEW_PROC_API */
1985 if (save && ret) 1840 if (save && ret)
1986 memcpy (save, ret, sizeof (gdb_sigset_t)); 1841 memcpy (save, ret, sizeof (gdb_sigset_t));
1987 1842
1988 return ret; 1843 return ret;
1989 } 1844 }
1990 1845
1991 /* Returns the set of signals that are traced / debugged. Will also 1846 /* Returns the set of signals that are traced / debugged. Will also
1992 copy the sigset if SAVE is non-zero. */ 1847 copy the sigset if SAVE is non-zero. */
1993 1848
1994 gdb_sigset_t * 1849 static gdb_sigset_t *
1995 proc_get_traced_signals (procinfo *pi, gdb_sigset_t *save) 1850 proc_get_traced_signals (procinfo *pi, gdb_sigset_t *save)
1996 { 1851 {
1997 gdb_sigset_t *ret = NULL; 1852 gdb_sigset_t *ret = NULL;
1998 1853
1999 /* We should never have to apply this operation to any procinfo 1854 /* We should never have to apply this operation to any procinfo
2000 except the one for the main process. If that ever changes for 1855 except the one for the main process. If that ever changes for
2001 any reason, then take out the following clause and replace it 1856 any reason, then take out the following clause and replace it
2002 with one that makes sure the ctl_fd is open. */ 1857 with one that makes sure the ctl_fd is open. */
2003 1858
2004 if (pi->tid != 0) 1859 if (pi->tid != 0)
(...skipping 12 matching lines...) Expand all
2017 if (ioctl (pi->ctl_fd, PIOCGTRACE, &sigtrace) >= 0) 1872 if (ioctl (pi->ctl_fd, PIOCGTRACE, &sigtrace) >= 0)
2018 ret = &sigtrace; 1873 ret = &sigtrace;
2019 } 1874 }
2020 #endif 1875 #endif
2021 if (save && ret) 1876 if (save && ret)
2022 memcpy (save, ret, sizeof (gdb_sigset_t)); 1877 memcpy (save, ret, sizeof (gdb_sigset_t));
2023 1878
2024 return ret; 1879 return ret;
2025 } 1880 }
2026 1881
2027 /* Add SIGNO to the set of signals that are traced. Returns non-zero
2028 for success, zero for failure. */
2029
2030 int
2031 proc_trace_signal (procinfo *pi, int signo)
2032 {
2033 gdb_sigset_t temp;
2034
2035 /* We should never have to apply this operation to any procinfo
2036 except the one for the main process. If that ever changes for
2037 any reason, then take out the following clause and replace it
2038 with one that makes sure the ctl_fd is open. */
2039
2040 if (pi->tid != 0)
2041 pi = find_procinfo_or_die (pi->pid, 0);
2042
2043 if (pi)
2044 {
2045 if (proc_get_traced_signals (pi, &temp))
2046 {
2047 gdb_praddset (&temp, signo);
2048 return proc_set_traced_signals (pi, &temp);
2049 }
2050 }
2051
2052 return 0; /* failure */
2053 }
2054
2055 /* Remove SIGNO from the set of signals that are traced. Returns
2056 non-zero for success, zero for failure. */
2057
2058 int
2059 proc_ignore_signal (procinfo *pi, int signo)
2060 {
2061 gdb_sigset_t temp;
2062
2063 /* We should never have to apply this operation to any procinfo
2064 except the one for the main process. If that ever changes for
2065 any reason, then take out the following clause and replace it
2066 with one that makes sure the ctl_fd is open. */
2067
2068 if (pi->tid != 0)
2069 pi = find_procinfo_or_die (pi->pid, 0);
2070
2071 if (pi)
2072 {
2073 if (proc_get_traced_signals (pi, &temp))
2074 {
2075 gdb_prdelset (&temp, signo);
2076 return proc_set_traced_signals (pi, &temp);
2077 }
2078 }
2079
2080 return 0; /* failure */
2081 }
2082
2083 /* Returns the set of hardware faults that are traced /debugged. Will 1882 /* Returns the set of hardware faults that are traced /debugged. Will
2084 also copy the faultset if SAVE is non-zero. */ 1883 also copy the faultset if SAVE is non-zero. */
2085 1884
2086 fltset_t * 1885 static fltset_t *
2087 proc_get_traced_faults (procinfo *pi, fltset_t *save) 1886 proc_get_traced_faults (procinfo *pi, fltset_t *save)
2088 { 1887 {
2089 fltset_t *ret = NULL; 1888 fltset_t *ret = NULL;
2090 1889
2091 /* We should never have to apply this operation to any procinfo 1890 /* We should never have to apply this operation to any procinfo
2092 except the one for the main process. If that ever changes for 1891 except the one for the main process. If that ever changes for
2093 any reason, then take out the following clause and replace it 1892 any reason, then take out the following clause and replace it
2094 with one that makes sure the ctl_fd is open. */ 1893 with one that makes sure the ctl_fd is open. */
2095 1894
2096 if (pi->tid != 0) 1895 if (pi->tid != 0)
(...skipping 15 matching lines...) Expand all
2112 #endif 1911 #endif
2113 if (save && ret) 1912 if (save && ret)
2114 memcpy (save, ret, sizeof (fltset_t)); 1913 memcpy (save, ret, sizeof (fltset_t));
2115 1914
2116 return ret; 1915 return ret;
2117 } 1916 }
2118 1917
2119 /* Returns the set of syscalls that are traced /debugged on entry. 1918 /* Returns the set of syscalls that are traced /debugged on entry.
2120 Will also copy the syscall set if SAVE is non-zero. */ 1919 Will also copy the syscall set if SAVE is non-zero. */
2121 1920
2122 sysset_t * 1921 static sysset_t *
2123 proc_get_traced_sysentry (procinfo *pi, sysset_t *save) 1922 proc_get_traced_sysentry (procinfo *pi, sysset_t *save)
2124 { 1923 {
2125 sysset_t *ret = NULL; 1924 sysset_t *ret = NULL;
2126 1925
2127 /* We should never have to apply this operation to any procinfo 1926 /* We should never have to apply this operation to any procinfo
2128 except the one for the main process. If that ever changes for 1927 except the one for the main process. If that ever changes for
2129 any reason, then take out the following clause and replace it 1928 any reason, then take out the following clause and replace it
2130 with one that makes sure the ctl_fd is open. */ 1929 with one that makes sure the ctl_fd is open. */
2131 1930
2132 if (pi->tid != 0) 1931 if (pi->tid != 0)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 #endif /* NEW_PROC_API */ 1978 #endif /* NEW_PROC_API */
2180 if (save && ret) 1979 if (save && ret)
2181 memcpy (save, ret, sysset_t_size (pi)); 1980 memcpy (save, ret, sysset_t_size (pi));
2182 1981
2183 return ret; 1982 return ret;
2184 } 1983 }
2185 1984
2186 /* Returns the set of syscalls that are traced /debugged on exit. 1985 /* Returns the set of syscalls that are traced /debugged on exit.
2187 Will also copy the syscall set if SAVE is non-zero. */ 1986 Will also copy the syscall set if SAVE is non-zero. */
2188 1987
2189 sysset_t * 1988 static sysset_t *
2190 proc_get_traced_sysexit (procinfo *pi, sysset_t *save) 1989 proc_get_traced_sysexit (procinfo *pi, sysset_t *save)
2191 { 1990 {
2192 sysset_t * ret = NULL; 1991 sysset_t * ret = NULL;
2193 1992
2194 /* We should never have to apply this operation to any procinfo 1993 /* We should never have to apply this operation to any procinfo
2195 except the one for the main process. If that ever changes for 1994 except the one for the main process. If that ever changes for
2196 any reason, then take out the following clause and replace it 1995 any reason, then take out the following clause and replace it
2197 with one that makes sure the ctl_fd is open. */ 1996 with one that makes sure the ctl_fd is open. */
2198 1997
2199 if (pi->tid != 0) 1998 if (pi->tid != 0)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 if (save && ret) 2046 if (save && ret)
2248 memcpy (save, ret, sysset_t_size (pi)); 2047 memcpy (save, ret, sysset_t_size (pi));
2249 2048
2250 return ret; 2049 return ret;
2251 } 2050 }
2252 2051
2253 /* The current fault (if any) is cleared; the associated signal will 2052 /* The current fault (if any) is cleared; the associated signal will
2254 not be sent to the process or LWP when it resumes. Returns 2053 not be sent to the process or LWP when it resumes. Returns
2255 non-zero for success, zero for failure. */ 2054 non-zero for success, zero for failure. */
2256 2055
2257 int 2056 static int
2258 proc_clear_current_fault (procinfo *pi) 2057 proc_clear_current_fault (procinfo *pi)
2259 { 2058 {
2260 int win; 2059 int win;
2261 2060
2262 /* We should never have to apply this operation to any procinfo 2061 /* We should never have to apply this operation to any procinfo
2263 except the one for the main process. If that ever changes for 2062 except the one for the main process. If that ever changes for
2264 any reason, then take out the following clause and replace it 2063 any reason, then take out the following clause and replace it
2265 with one that makes sure the ctl_fd is open. */ 2064 with one that makes sure the ctl_fd is open. */
2266 2065
2267 if (pi->tid != 0) 2066 if (pi->tid != 0)
(...skipping 13 matching lines...) Expand all
2281 } 2080 }
2282 2081
2283 /* Set the "current signal" that will be delivered next to the 2082 /* Set the "current signal" that will be delivered next to the
2284 process. NOTE: semantics are different from those of KILL. This 2083 process. NOTE: semantics are different from those of KILL. This
2285 signal will be delivered to the process or LWP immediately when it 2084 signal will be delivered to the process or LWP immediately when it
2286 is resumed (even if the signal is held/blocked); it will NOT 2085 is resumed (even if the signal is held/blocked); it will NOT
2287 immediately cause another event of interest, and will NOT first 2086 immediately cause another event of interest, and will NOT first
2288 trap back to the debugger. Returns non-zero for success, zero for 2087 trap back to the debugger. Returns non-zero for success, zero for
2289 failure. */ 2088 failure. */
2290 2089
2291 int 2090 static int
2292 proc_set_current_signal (procinfo *pi, int signo) 2091 proc_set_current_signal (procinfo *pi, int signo)
2293 { 2092 {
2294 int win; 2093 int win;
2295 struct { 2094 struct {
2296 procfs_ctl_t cmd; 2095 procfs_ctl_t cmd;
2297 /* Use char array to avoid alignment issues. */ 2096 /* Use char array to avoid alignment issues. */
2298 char sinfo[sizeof (gdb_siginfo_t)]; 2097 char sinfo[sizeof (gdb_siginfo_t)];
2299 } arg; 2098 } arg;
2300 gdb_siginfo_t mysinfo; 2099 gdb_siginfo_t mysinfo;
2301 ptid_t wait_ptid; 2100 ptid_t wait_ptid;
(...skipping 14 matching lines...) Expand all
2316 bug. */ 2115 bug. */
2317 if (signo > 0 && 2116 if (signo > 0 &&
2318 signo == proc_cursig (pi)) 2117 signo == proc_cursig (pi))
2319 return 1; /* I assume this is a success? */ 2118 return 1; /* I assume this is a success? */
2320 #endif 2119 #endif
2321 2120
2322 /* The pointer is just a type alias. */ 2121 /* The pointer is just a type alias. */
2323 get_last_target_status (&wait_ptid, &wait_status); 2122 get_last_target_status (&wait_ptid, &wait_status);
2324 if (ptid_equal (wait_ptid, inferior_ptid) 2123 if (ptid_equal (wait_ptid, inferior_ptid)
2325 && wait_status.kind == TARGET_WAITKIND_STOPPED 2124 && wait_status.kind == TARGET_WAITKIND_STOPPED
2326 && wait_status.value.sig == target_signal_from_host (signo) 2125 && wait_status.value.sig == gdb_signal_from_host (signo)
2327 && proc_get_status (pi) 2126 && proc_get_status (pi)
2328 #ifdef NEW_PROC_API 2127 #ifdef NEW_PROC_API
2329 && pi->prstatus.pr_lwp.pr_info.si_signo == signo 2128 && pi->prstatus.pr_lwp.pr_info.si_signo == signo
2330 #else 2129 #else
2331 && pi->prstatus.pr_info.si_signo == signo 2130 && pi->prstatus.pr_info.si_signo == signo
2332 #endif 2131 #endif
2333 ) 2132 )
2334 /* Use the siginfo associated with the signal being 2133 /* Use the siginfo associated with the signal being
2335 redelivered. */ 2134 redelivered. */
2336 #ifdef NEW_PROC_API 2135 #ifdef NEW_PROC_API
(...skipping 17 matching lines...) Expand all
2354 win = (ioctl (pi->ctl_fd, PIOCSSIG, (void *) &arg.sinfo) >= 0); 2153 win = (ioctl (pi->ctl_fd, PIOCSSIG, (void *) &arg.sinfo) >= 0);
2355 #endif 2154 #endif
2356 2155
2357 return win; 2156 return win;
2358 } 2157 }
2359 2158
2360 /* The current signal (if any) is cleared, and is not sent to the 2159 /* The current signal (if any) is cleared, and is not sent to the
2361 process or LWP when it resumes. Returns non-zero for success, zero 2160 process or LWP when it resumes. Returns non-zero for success, zero
2362 for failure. */ 2161 for failure. */
2363 2162
2364 int 2163 static int
2365 proc_clear_current_signal (procinfo *pi) 2164 proc_clear_current_signal (procinfo *pi)
2366 { 2165 {
2367 int win; 2166 int win;
2368 2167
2369 /* We should never have to apply this operation to any procinfo 2168 /* We should never have to apply this operation to any procinfo
2370 except the one for the main process. If that ever changes for 2169 except the one for the main process. If that ever changes for
2371 any reason, then take out the following clause and replace it 2170 any reason, then take out the following clause and replace it
2372 with one that makes sure the ctl_fd is open. */ 2171 with one that makes sure the ctl_fd is open. */
2373 2172
2374 if (pi->tid != 0) 2173 if (pi->tid != 0)
(...skipping 22 matching lines...) Expand all
2397 #else 2196 #else
2398 win = (ioctl (pi->ctl_fd, PIOCSSIG, 0) >= 0); 2197 win = (ioctl (pi->ctl_fd, PIOCSSIG, 0) >= 0);
2399 #endif 2198 #endif
2400 2199
2401 return win; 2200 return win;
2402 } 2201 }
2403 2202
2404 /* Return the general-purpose registers for the process or LWP 2203 /* Return the general-purpose registers for the process or LWP
2405 corresponding to PI. Upon failure, return NULL. */ 2204 corresponding to PI. Upon failure, return NULL. */
2406 2205
2407 gdb_gregset_t * 2206 static gdb_gregset_t *
2408 proc_get_gregs (procinfo *pi) 2207 proc_get_gregs (procinfo *pi)
2409 { 2208 {
2410 if (!pi->status_valid || !pi->gregs_valid) 2209 if (!pi->status_valid || !pi->gregs_valid)
2411 if (!proc_get_status (pi)) 2210 if (!proc_get_status (pi))
2412 return NULL; 2211 return NULL;
2413 2212
2414 /* OK, sorry about the ifdef's. There's three cases instead of two, 2213 /* OK, sorry about the ifdef's. There's three cases instead of two,
2415 because in this case Unixware and Solaris/RW differ. */ 2214 because in this case Unixware and Solaris/RW differ. */
2416 2215
2417 #ifdef NEW_PROC_API 2216 #ifdef NEW_PROC_API
2418 # ifdef UNIXWARE /* FIXME: Should be autoconfigured. */ 2217 # ifdef UNIXWARE /* FIXME: Should be autoconfigured. */
2419 return &pi->prstatus.pr_lwp.pr_context.uc_mcontext.gregs; 2218 return &pi->prstatus.pr_lwp.pr_context.uc_mcontext.gregs;
2420 # else 2219 # else
2421 return &pi->prstatus.pr_lwp.pr_reg; 2220 return &pi->prstatus.pr_lwp.pr_reg;
2422 # endif 2221 # endif
2423 #else 2222 #else
2424 return &pi->prstatus.pr_reg; 2223 return &pi->prstatus.pr_reg;
2425 #endif 2224 #endif
2426 } 2225 }
2427 2226
2428 /* Return the general-purpose registers for the process or LWP 2227 /* Return the general-purpose registers for the process or LWP
2429 corresponding to PI. Upon failure, return NULL. */ 2228 corresponding to PI. Upon failure, return NULL. */
2430 2229
2431 gdb_fpregset_t * 2230 static gdb_fpregset_t *
2432 proc_get_fpregs (procinfo *pi) 2231 proc_get_fpregs (procinfo *pi)
2433 { 2232 {
2434 #ifdef NEW_PROC_API 2233 #ifdef NEW_PROC_API
2435 if (!pi->status_valid || !pi->fpregs_valid) 2234 if (!pi->status_valid || !pi->fpregs_valid)
2436 if (!proc_get_status (pi)) 2235 if (!proc_get_status (pi))
2437 return NULL; 2236 return NULL;
2438 2237
2439 # ifdef UNIXWARE /* FIXME: Should be autoconfigured. */ 2238 # ifdef UNIXWARE /* FIXME: Should be autoconfigured. */
2440 return &pi->prstatus.pr_lwp.pr_context.uc_mcontext.fpregs; 2239 return &pi->prstatus.pr_lwp.pr_context.uc_mcontext.fpregs;
2441 # else 2240 # else
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 # endif 2293 # endif
2495 } 2294 }
2496 } 2295 }
2497 #endif /* NEW_PROC_API */ 2296 #endif /* NEW_PROC_API */
2498 } 2297 }
2499 2298
2500 /* Write the general-purpose registers back to the process or LWP 2299 /* Write the general-purpose registers back to the process or LWP
2501 corresponding to PI. Return non-zero for success, zero for 2300 corresponding to PI. Return non-zero for success, zero for
2502 failure. */ 2301 failure. */
2503 2302
2504 int 2303 static int
2505 proc_set_gregs (procinfo *pi) 2304 proc_set_gregs (procinfo *pi)
2506 { 2305 {
2507 gdb_gregset_t *gregs; 2306 gdb_gregset_t *gregs;
2508 int win; 2307 int win;
2509 2308
2510 gregs = proc_get_gregs (pi); 2309 gregs = proc_get_gregs (pi);
2511 if (gregs == NULL) 2310 if (gregs == NULL)
2512 return 0; /* proc_get_regs has already warned. */ 2311 return 0; /* proc_get_regs has already warned. */
2513 2312
2514 if (pi->ctl_fd == 0 && open_procinfo_files (pi, FD_CTL) == 0) 2313 if (pi->ctl_fd == 0 && open_procinfo_files (pi, FD_CTL) == 0)
(...skipping 19 matching lines...) Expand all
2534 2333
2535 /* Policy: writing the registers invalidates our cache. */ 2334 /* Policy: writing the registers invalidates our cache. */
2536 pi->gregs_valid = 0; 2335 pi->gregs_valid = 0;
2537 return win; 2336 return win;
2538 } 2337 }
2539 2338
2540 /* Write the floating-pointer registers back to the process or LWP 2339 /* Write the floating-pointer registers back to the process or LWP
2541 corresponding to PI. Return non-zero for success, zero for 2340 corresponding to PI. Return non-zero for success, zero for
2542 failure. */ 2341 failure. */
2543 2342
2544 int 2343 static int
2545 proc_set_fpregs (procinfo *pi) 2344 proc_set_fpregs (procinfo *pi)
2546 { 2345 {
2547 gdb_fpregset_t *fpregs; 2346 gdb_fpregset_t *fpregs;
2548 int win; 2347 int win;
2549 2348
2550 fpregs = proc_get_fpregs (pi); 2349 fpregs = proc_get_fpregs (pi);
2551 if (fpregs == NULL) 2350 if (fpregs == NULL)
2552 return 0; /* proc_get_fpregs has already warned. */ 2351 return 0; /* proc_get_fpregs has already warned. */
2553 2352
2554 if (pi->ctl_fd == 0 && open_procinfo_files (pi, FD_CTL) == 0) 2353 if (pi->ctl_fd == 0 && open_procinfo_files (pi, FD_CTL) == 0)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 } 2391 }
2593 2392
2594 /* Policy: writing the registers invalidates our cache. */ 2393 /* Policy: writing the registers invalidates our cache. */
2595 pi->fpregs_valid = 0; 2394 pi->fpregs_valid = 0;
2596 return win; 2395 return win;
2597 } 2396 }
2598 2397
2599 /* Send a signal to the proc or lwp with the semantics of "kill()". 2398 /* Send a signal to the proc or lwp with the semantics of "kill()".
2600 Returns non-zero for success, zero for failure. */ 2399 Returns non-zero for success, zero for failure. */
2601 2400
2602 int 2401 static int
2603 proc_kill (procinfo *pi, int signo) 2402 proc_kill (procinfo *pi, int signo)
2604 { 2403 {
2605 int win; 2404 int win;
2606 2405
2607 /* We might conceivably apply this operation to an LWP, and the 2406 /* We might conceivably apply this operation to an LWP, and the
2608 LWP's ctl file descriptor might not be open. */ 2407 LWP's ctl file descriptor might not be open. */
2609 2408
2610 if (pi->ctl_fd == 0 && 2409 if (pi->ctl_fd == 0 &&
2611 open_procinfo_files (pi, FD_CTL) == 0) 2410 open_procinfo_files (pi, FD_CTL) == 0)
2612 { 2411 {
(...skipping 13 matching lines...) Expand all
2626 win = (ioctl (pi->ctl_fd, PIOCKILL, &signo) >= 0); 2425 win = (ioctl (pi->ctl_fd, PIOCKILL, &signo) >= 0);
2627 #endif 2426 #endif
2628 } 2427 }
2629 2428
2630 return win; 2429 return win;
2631 } 2430 }
2632 2431
2633 /* Find the pid of the process that started this one. Returns the 2432 /* Find the pid of the process that started this one. Returns the
2634 parent process pid, or zero. */ 2433 parent process pid, or zero. */
2635 2434
2636 int 2435 static int
2637 proc_parent_pid (procinfo *pi) 2436 proc_parent_pid (procinfo *pi)
2638 { 2437 {
2639 /* We should never have to apply this operation to any procinfo 2438 /* We should never have to apply this operation to any procinfo
2640 except the one for the main process. If that ever changes for 2439 except the one for the main process. If that ever changes for
2641 any reason, then take out the following clause and replace it 2440 any reason, then take out the following clause and replace it
2642 with one that makes sure the ctl_fd is open. */ 2441 with one that makes sure the ctl_fd is open. */
2643 2442
2644 if (pi->tid != 0) 2443 if (pi->tid != 0)
2645 pi = find_procinfo_or_die (pi->pid, 0); 2444 pi = find_procinfo_or_die (pi->pid, 0);
2646 2445
(...skipping 15 matching lines...) Expand all
2662 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; 2461 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
2663 void *ptr; 2462 void *ptr;
2664 2463
2665 gdb_assert (sizeof (ptr) == TYPE_LENGTH (ptr_type)); 2464 gdb_assert (sizeof (ptr) == TYPE_LENGTH (ptr_type));
2666 gdbarch_address_to_pointer (target_gdbarch, ptr_type, 2465 gdbarch_address_to_pointer (target_gdbarch, ptr_type,
2667 (gdb_byte *) &ptr, addr); 2466 (gdb_byte *) &ptr, addr);
2668 return ptr; 2467 return ptr;
2669 } 2468 }
2670 #endif 2469 #endif
2671 2470
2672 int 2471 static int
2673 proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags) 2472 proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags)
2674 { 2473 {
2675 #if !defined (PCWATCH) && !defined (PIOCSWATCH) 2474 #if !defined (PCWATCH) && !defined (PIOCSWATCH)
2676 /* If neither or these is defined, we can't support watchpoints. 2475 /* If neither or these is defined, we can't support watchpoints.
2677 This just avoids possibly failing to compile the below on such 2476 This just avoids possibly failing to compile the below on such
2678 systems. */ 2477 systems. */
2679 return 0; 2478 return 0;
2680 #else 2479 #else
2681 /* Horrible hack! Detect Solaris 2.5, because this doesn't work on 2.5. */ 2480 /* Horrible hack! Detect Solaris 2.5, because this doesn't work on 2.5. */
2682 #if defined (PIOCOPENLWP) || defined (UNIXWARE) /* Solaris 2.5: bail out. */ 2481 #if defined (PIOCOPENLWP) || defined (UNIXWARE) /* Solaris 2.5: bail out. */
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 2631
2833 /* =================== Thread "MODULE" =================== */ 2632 /* =================== Thread "MODULE" =================== */
2834 2633
2835 /* NOTE: you'll see more ifdefs and duplication of functions here, 2634 /* NOTE: you'll see more ifdefs and duplication of functions here,
2836 since there is a different way to do threads on every OS. */ 2635 since there is a different way to do threads on every OS. */
2837 2636
2838 /* Returns the number of threads for the process. */ 2637 /* Returns the number of threads for the process. */
2839 2638
2840 #if defined (PIOCNTHR) && defined (PIOCTLIST) 2639 #if defined (PIOCNTHR) && defined (PIOCTLIST)
2841 /* OSF version */ 2640 /* OSF version */
2842 int 2641 static int
2843 proc_get_nthreads (procinfo *pi) 2642 proc_get_nthreads (procinfo *pi)
2844 { 2643 {
2845 int nthreads = 0; 2644 int nthreads = 0;
2846 2645
2847 if (ioctl (pi->ctl_fd, PIOCNTHR, &nthreads) < 0) 2646 if (ioctl (pi->ctl_fd, PIOCNTHR, &nthreads) < 0)
2848 proc_warn (pi, "procfs: PIOCNTHR failed", __LINE__); 2647 proc_warn (pi, "procfs: PIOCNTHR failed", __LINE__);
2849 2648
2850 return nthreads; 2649 return nthreads;
2851 } 2650 }
2852 2651
2853 #else 2652 #else
2854 #if defined (SYS_lwpcreate) || defined (SYS_lwp_create) /* FIXME: multiple */ 2653 #if defined (SYS_lwpcreate) || defined (SYS_lwp_create) /* FIXME: multiple */
2855 /* Solaris and Unixware version */ 2654 /* Solaris and Unixware version */
2856 int 2655 static int
2857 proc_get_nthreads (procinfo *pi) 2656 proc_get_nthreads (procinfo *pi)
2858 { 2657 {
2859 if (!pi->status_valid) 2658 if (!pi->status_valid)
2860 if (!proc_get_status (pi)) 2659 if (!proc_get_status (pi))
2861 return 0; 2660 return 0;
2862 2661
2863 /* NEW_PROC_API: only works for the process procinfo, because the 2662 /* NEW_PROC_API: only works for the process procinfo, because the
2864 LWP procinfos do not get prstatus filled in. */ 2663 LWP procinfos do not get prstatus filled in. */
2865 #ifdef NEW_PROC_API 2664 #ifdef NEW_PROC_API
2866 if (pi->tid != 0) /* Find the parent process procinfo. */ 2665 if (pi->tid != 0) /* Find the parent process procinfo. */
2867 pi = find_procinfo_or_die (pi->pid, 0); 2666 pi = find_procinfo_or_die (pi->pid, 0);
2868 #endif 2667 #endif
2869 return pi->prstatus.pr_nlwp; 2668 return pi->prstatus.pr_nlwp;
2870 } 2669 }
2871 2670
2872 #else 2671 #else
2873 /* Default version */ 2672 /* Default version */
2874 int 2673 static int
2875 proc_get_nthreads (procinfo *pi) 2674 proc_get_nthreads (procinfo *pi)
2876 { 2675 {
2877 return 0; 2676 return 0;
2878 } 2677 }
2879 #endif 2678 #endif
2880 #endif 2679 #endif
2881 2680
2882 /* LWP version. 2681 /* LWP version.
2883 2682
2884 Return the ID of the thread that had an event of interest. 2683 Return the ID of the thread that had an event of interest.
2885 (ie. the one that hit a breakpoint or other traced event). All 2684 (ie. the one that hit a breakpoint or other traced event). All
2886 other things being equal, this should be the ID of a thread that is 2685 other things being equal, this should be the ID of a thread that is
2887 currently executing. */ 2686 currently executing. */
2888 2687
2889 #if defined (SYS_lwpcreate) || defined (SYS_lwp_create) /* FIXME: multiple */ 2688 #if defined (SYS_lwpcreate) || defined (SYS_lwp_create) /* FIXME: multiple */
2890 /* Solaris and Unixware version */ 2689 /* Solaris and Unixware version */
2891 int 2690 static int
2892 proc_get_current_thread (procinfo *pi) 2691 proc_get_current_thread (procinfo *pi)
2893 { 2692 {
2894 /* Note: this should be applied to the root procinfo for the 2693 /* Note: this should be applied to the root procinfo for the
2895 process, not to the procinfo for an LWP. If applied to the 2694 process, not to the procinfo for an LWP. If applied to the
2896 procinfo for an LWP, it will simply return that LWP's ID. In 2695 procinfo for an LWP, it will simply return that LWP's ID. In
2897 that case, find the parent process procinfo. */ 2696 that case, find the parent process procinfo. */
2898 2697
2899 if (pi->tid != 0) 2698 if (pi->tid != 0)
2900 pi = find_procinfo_or_die (pi->pid, 0); 2699 pi = find_procinfo_or_die (pi->pid, 0);
2901 2700
2902 if (!pi->status_valid) 2701 if (!pi->status_valid)
2903 if (!proc_get_status (pi)) 2702 if (!proc_get_status (pi))
2904 return 0; 2703 return 0;
2905 2704
2906 #ifdef NEW_PROC_API 2705 #ifdef NEW_PROC_API
2907 return pi->prstatus.pr_lwp.pr_lwpid; 2706 return pi->prstatus.pr_lwp.pr_lwpid;
2908 #else 2707 #else
2909 return pi->prstatus.pr_who; 2708 return pi->prstatus.pr_who;
2910 #endif 2709 #endif
2911 } 2710 }
2912 2711
2913 #else 2712 #else
2914 #if defined (PIOCNTHR) && defined (PIOCTLIST) 2713 #if defined (PIOCNTHR) && defined (PIOCTLIST)
2915 /* OSF version */ 2714 /* OSF version */
2916 int 2715 static int
2917 proc_get_current_thread (procinfo *pi) 2716 proc_get_current_thread (procinfo *pi)
2918 { 2717 {
2919 #if 0 /* FIXME: not ready for prime time? */ 2718 #if 0 /* FIXME: not ready for prime time? */
2920 return pi->prstatus.pr_tid; 2719 return pi->prstatus.pr_tid;
2921 #else 2720 #else
2922 return 0; 2721 return 0;
2923 #endif 2722 #endif
2924 } 2723 }
2925 2724
2926 #else 2725 #else
2927 /* Default version */ 2726 /* Default version */
2928 int 2727 static int
2929 proc_get_current_thread (procinfo *pi) 2728 proc_get_current_thread (procinfo *pi)
2930 { 2729 {
2931 return 0; 2730 return 0;
2932 } 2731 }
2933 2732
2934 #endif 2733 #endif
2935 #endif 2734 #endif
2936 2735
2937 /* Discover the IDs of all the threads within the process, and create 2736 /* Discover the IDs of all the threads within the process, and create
2938 a procinfo for each of them (chained to the parent). This 2737 a procinfo for each of them (chained to the parent). This
2939 unfortunately requires a different method on every OS. Returns 2738 unfortunately requires a different method on every OS. Returns
2940 non-zero for success, zero for failure. */ 2739 non-zero for success, zero for failure. */
2941 2740
2942 int 2741 static int
2943 proc_delete_dead_threads (procinfo *parent, procinfo *thread, void *ignore) 2742 proc_delete_dead_threads (procinfo *parent, procinfo *thread, void *ignore)
2944 { 2743 {
2945 if (thread && parent) /* sanity */ 2744 if (thread && parent) /* sanity */
2946 { 2745 {
2947 thread->status_valid = 0; 2746 thread->status_valid = 0;
2948 if (!proc_get_status (thread)) 2747 if (!proc_get_status (thread))
2949 destroy_one_procinfo (&parent->thread_list, thread); 2748 destroy_one_procinfo (&parent->thread_list, thread);
2950 } 2749 }
2951 return 0; /* keep iterating */ 2750 return 0; /* keep iterating */
2952 } 2751 }
2953 2752
2954 #if defined (PIOCLSTATUS) 2753 #if defined (PIOCLSTATUS)
2955 /* Solaris 2.5 (ioctl) version */ 2754 /* Solaris 2.5 (ioctl) version */
2956 int 2755 static int
2957 proc_update_threads (procinfo *pi) 2756 proc_update_threads (procinfo *pi)
2958 { 2757 {
2959 gdb_prstatus_t *prstatus; 2758 gdb_prstatus_t *prstatus;
2960 struct cleanup *old_chain = NULL; 2759 struct cleanup *old_chain = NULL;
2961 procinfo *thread; 2760 procinfo *thread;
2962 int nlwp, i; 2761 int nlwp, i;
2963 2762
2964 /* We should never have to apply this operation to any procinfo 2763 /* We should never have to apply this operation to any procinfo
2965 except the one for the main process. If that ever changes for 2764 except the one for the main process. If that ever changes for
2966 any reason, then take out the following clause and replace it 2765 any reason, then take out the following clause and replace it
(...skipping 28 matching lines...) Expand all
2995 } 2794 }
2996 #else 2795 #else
2997 #ifdef NEW_PROC_API 2796 #ifdef NEW_PROC_API
2998 /* Unixware and Solaris 6 (and later) version. */ 2797 /* Unixware and Solaris 6 (and later) version. */
2999 static void 2798 static void
3000 do_closedir_cleanup (void *dir) 2799 do_closedir_cleanup (void *dir)
3001 { 2800 {
3002 closedir (dir); 2801 closedir (dir);
3003 } 2802 }
3004 2803
3005 int 2804 static int
3006 proc_update_threads (procinfo *pi) 2805 proc_update_threads (procinfo *pi)
3007 { 2806 {
3008 char pathname[MAX_PROC_NAME_SIZE + 16]; 2807 char pathname[MAX_PROC_NAME_SIZE + 16];
3009 struct dirent *direntry; 2808 struct dirent *direntry;
3010 struct cleanup *old_chain = NULL; 2809 struct cleanup *old_chain = NULL;
3011 procinfo *thread; 2810 procinfo *thread;
3012 DIR *dirp; 2811 DIR *dirp;
3013 int lwpid; 2812 int lwpid;
3014 2813
3015 /* We should never have to apply this operation to any procinfo 2814 /* We should never have to apply this operation to any procinfo
(...skipping 27 matching lines...) Expand all
3043 if ((thread = create_procinfo (pi->pid, lwpid)) == NULL) 2842 if ((thread = create_procinfo (pi->pid, lwpid)) == NULL)
3044 proc_error (pi, "update_threads, create_procinfo", __LINE__); 2843 proc_error (pi, "update_threads, create_procinfo", __LINE__);
3045 } 2844 }
3046 pi->threads_valid = 1; 2845 pi->threads_valid = 1;
3047 do_cleanups (old_chain); 2846 do_cleanups (old_chain);
3048 return 1; 2847 return 1;
3049 } 2848 }
3050 #else 2849 #else
3051 #ifdef PIOCTLIST 2850 #ifdef PIOCTLIST
3052 /* OSF version */ 2851 /* OSF version */
3053 int 2852 static int
3054 proc_update_threads (procinfo *pi) 2853 proc_update_threads (procinfo *pi)
3055 { 2854 {
3056 int nthreads, i; 2855 int nthreads, i;
3057 tid_t *threads; 2856 tid_t *threads;
3058 2857
3059 /* We should never have to apply this operation to any procinfo 2858 /* We should never have to apply this operation to any procinfo
3060 except the one for the main process. If that ever changes for 2859 except the one for the main process. If that ever changes for
3061 any reason, then take out the following clause and replace it 2860 any reason, then take out the following clause and replace it
3062 with one that makes sure the ctl_fd is open. */ 2861 with one that makes sure the ctl_fd is open. */
3063 2862
(...skipping 15 matching lines...) Expand all
3079 { 2878 {
3080 if (!find_procinfo (pi->pid, threads[i])) 2879 if (!find_procinfo (pi->pid, threads[i]))
3081 if (!create_procinfo (pi->pid, threads[i])) 2880 if (!create_procinfo (pi->pid, threads[i]))
3082 proc_error (pi, "update_threads, create_procinfo", __LINE__); 2881 proc_error (pi, "update_threads, create_procinfo", __LINE__);
3083 } 2882 }
3084 pi->threads_valid = 1; 2883 pi->threads_valid = 1;
3085 return 1; 2884 return 1;
3086 } 2885 }
3087 #else 2886 #else
3088 /* Default version */ 2887 /* Default version */
3089 int 2888 static int
3090 proc_update_threads (procinfo *pi) 2889 proc_update_threads (procinfo *pi)
3091 { 2890 {
3092 return 0; 2891 return 0;
3093 } 2892 }
3094 #endif /* OSF PIOCTLIST */ 2893 #endif /* OSF PIOCTLIST */
3095 #endif /* NEW_PROC_API */ 2894 #endif /* NEW_PROC_API */
3096 #endif /* SOL 2.5 PIOCLSTATUS */ 2895 #endif /* SOL 2.5 PIOCLSTATUS */
3097 2896
3098 /* Given a pointer to a function, call that function once for each lwp 2897 /* Given a pointer to a function, call that function once for each lwp
3099 in the procinfo list, until the function returns non-zero, in which 2898 in the procinfo list, until the function returns non-zero, in which
3100 event return the value returned by the function. 2899 event return the value returned by the function.
3101 2900
3102 Note: this function does NOT call update_threads. If you want to 2901 Note: this function does NOT call update_threads. If you want to
3103 discover new threads first, you must call that function explicitly. 2902 discover new threads first, you must call that function explicitly.
3104 This function just makes a quick pass over the currently-known 2903 This function just makes a quick pass over the currently-known
3105 procinfos. 2904 procinfos.
3106 2905
3107 PI is the parent process procinfo. FUNC is the per-thread 2906 PI is the parent process procinfo. FUNC is the per-thread
3108 function. PTR is an opaque parameter for function. Returns the 2907 function. PTR is an opaque parameter for function. Returns the
3109 first non-zero return value from the callee, or zero. */ 2908 first non-zero return value from the callee, or zero. */
3110 2909
3111 int 2910 static int
3112 proc_iterate_over_threads (procinfo *pi, 2911 proc_iterate_over_threads (procinfo *pi,
3113 int (*func) (procinfo *, procinfo *, void *), 2912 int (*func) (procinfo *, procinfo *, void *),
3114 void *ptr) 2913 void *ptr)
3115 { 2914 {
3116 procinfo *thread, *next; 2915 procinfo *thread, *next;
3117 int retval = 0; 2916 int retval = 0;
3118 2917
3119 /* We should never have to apply this operation to any procinfo 2918 /* We should never have to apply this operation to any procinfo
3120 except the one for the main process. If that ever changes for 2919 except the one for the main process. If that ever changes for
3121 any reason, then take out the following clause and replace it 2920 any reason, then take out the following clause and replace it
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 if (status) 3779 if (status)
3981 { 3780 {
3982 /* How to exit gracefully, returning "unknown 3781 /* How to exit gracefully, returning "unknown
3983 event". */ 3782 event". */
3984 status->kind = TARGET_WAITKIND_SPURIOUS; 3783 status->kind = TARGET_WAITKIND_SPURIOUS;
3985 return inferior_ptid; 3784 return inferior_ptid;
3986 } 3785 }
3987 else 3786 else
3988 { 3787 {
3989 /* How to keep going without returning to wfi: */ 3788 /* How to keep going without returning to wfi: */
3990 » » » target_resume (ptid, 0, TARGET_SIGNAL_0); 3789 » » » target_resume (ptid, 0, GDB_SIGNAL_0);
3991 goto wait_again; 3790 goto wait_again;
3992 } 3791 }
3993 } 3792 }
3994 break; 3793 break;
3995 case PR_SYSEXIT: 3794 case PR_SYSEXIT:
3996 if (syscall_is_exec (pi, what)) 3795 if (syscall_is_exec (pi, what))
3997 { 3796 {
3998 /* Hopefully this is our own "fork-child" execing 3797 /* Hopefully this is our own "fork-child" execing
3999 the real child. Hoax this event into a trap, and 3798 the real child. Hoax this event into a trap, and
4000 GDB will see the child about to execute its start 3799 GDB will see the child about to execute its start
4001 address. */ 3800 address. */
4002 wstat = (SIGTRAP << 8) | 0177; 3801 wstat = (SIGTRAP << 8) | 0177;
4003 } 3802 }
4004 #ifdef SYS_syssgi 3803 #ifdef SYS_syssgi
4005 else if (what == SYS_syssgi) 3804 else if (what == SYS_syssgi)
4006 { 3805 {
4007 /* see if we can break on dbx_link(). If yes, then 3806 /* see if we can break on dbx_link(). If yes, then
4008 we no longer need the SYS_syssgi notifications. */ 3807 we no longer need the SYS_syssgi notifications. */
4009 if (insert_dbx_link_breakpoint (pi)) 3808 if (insert_dbx_link_breakpoint (pi))
4010 proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, 3809 proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT,
4011 FLAG_RESET, 0); 3810 FLAG_RESET, 0);
4012 3811
4013 /* This is an internal event and should be transparent 3812 /* This is an internal event and should be transparent
4014 to wfi, so resume the execution and wait again. See 3813 to wfi, so resume the execution and wait again. See
4015 comment in procfs_init_inferior() for more details. */ 3814 comment in procfs_init_inferior() for more details. */
4016 » » target_resume (ptid, 0, TARGET_SIGNAL_0); 3815 » » target_resume (ptid, 0, GDB_SIGNAL_0);
4017 goto wait_again; 3816 goto wait_again;
4018 } 3817 }
4019 #endif 3818 #endif
4020 else if (syscall_is_lwp_create (pi, what)) 3819 else if (syscall_is_lwp_create (pi, what))
4021 { 3820 {
4022 /* This syscall is somewhat like fork/exec. We 3821 /* This syscall is somewhat like fork/exec. We
4023 will get the event twice: once for the parent 3822 will get the event twice: once for the parent
4024 LWP, and once for the child. We should already 3823 LWP, and once for the child. We should already
4025 know about the parent LWP, but the child will 3824 know about the parent LWP, but the child will
4026 be new to us. So, whenever we get this event, 3825 be new to us. So, whenever we get this event,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
4376 4175
4377 If STEP is true, then arrange for the child to stop again after 4176 If STEP is true, then arrange for the child to stop again after
4378 executing a single instruction. If SIGNO is zero, then cancel any 4177 executing a single instruction. If SIGNO is zero, then cancel any
4379 pending signal; if non-zero, then arrange for the indicated signal 4178 pending signal; if non-zero, then arrange for the indicated signal
4380 to be delivered to the child when it runs. If PID is -1, then 4179 to be delivered to the child when it runs. If PID is -1, then
4381 allow any child thread to run; if non-zero, then allow only the 4180 allow any child thread to run; if non-zero, then allow only the
4382 indicated thread to run. (not implemented yet). */ 4181 indicated thread to run. (not implemented yet). */
4383 4182
4384 static void 4183 static void
4385 procfs_resume (struct target_ops *ops, 4184 procfs_resume (struct target_ops *ops,
4386 » ptid_t ptid, int step, enum target_signal signo) 4185 » ptid_t ptid, int step, enum gdb_signal signo)
4387 { 4186 {
4388 procinfo *pi, *thread; 4187 procinfo *pi, *thread;
4389 int native_signo; 4188 int native_signo;
4390 4189
4391 /* 2.1: 4190 /* 2.1:
4392 prrun.prflags |= PRSVADDR; 4191 prrun.prflags |= PRSVADDR;
4393 prrun.pr_vaddr = $PC; set resume address 4192 prrun.pr_vaddr = $PC; set resume address
4394 prrun.prflags |= PRSTRACE; trace signals in pr_trace (all) 4193 prrun.prflags |= PRSTRACE; trace signals in pr_trace (all)
4395 prrun.prflags |= PRSFAULT; trace faults in pr_fault (all but PAGE) 4194 prrun.prflags |= PRSFAULT; trace faults in pr_fault (all but PAGE)
4396 prrun.prflags |= PRCFAULT; clear current fault. 4195 prrun.prflags |= PRCFAULT; clear current fault.
4397 4196
4398 PRSTRACE and PRSFAULT can be done by other means 4197 PRSTRACE and PRSFAULT can be done by other means
4399 (proc_trace_signals, proc_trace_faults) 4198 (proc_trace_signals, proc_trace_faults)
4400 PRSVADDR is unnecessary. 4199 PRSVADDR is unnecessary.
4401 PRCFAULT may be replaced by a PIOCCFAULT call (proc_clear_current_fault) 4200 PRCFAULT may be replaced by a PIOCCFAULT call (proc_clear_current_fault)
4402 This basically leaves PRSTEP and PRCSIG. 4201 This basically leaves PRSTEP and PRCSIG.
4403 PRCSIG is like PIOCSSIG (proc_clear_current_signal). 4202 PRCSIG is like PIOCSSIG (proc_clear_current_signal).
4404 So basically PR_STEP is the sole argument that must be passed 4203 So basically PR_STEP is the sole argument that must be passed
4405 to proc_run_process (for use in the prrun struct by ioctl). */ 4204 to proc_run_process (for use in the prrun struct by ioctl). */
4406 4205
4407 /* Find procinfo for main process. */ 4206 /* Find procinfo for main process. */
4408 pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); 4207 pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
4409 4208
4410 /* First cut: ignore pid argument. */ 4209 /* First cut: ignore pid argument. */
4411 errno = 0; 4210 errno = 0;
4412 4211
4413 /* Convert signal to host numbering. */ 4212 /* Convert signal to host numbering. */
4414 if (signo == 0 || 4213 if (signo == 0 ||
4415 (signo == TARGET_SIGNAL_STOP && pi->ignore_next_sigstop)) 4214 (signo == GDB_SIGNAL_STOP && pi->ignore_next_sigstop))
4416 native_signo = 0; 4215 native_signo = 0;
4417 else 4216 else
4418 native_signo = target_signal_to_host (signo); 4217 native_signo = gdb_signal_to_host (signo);
4419 4218
4420 pi->ignore_next_sigstop = 0; 4219 pi->ignore_next_sigstop = 0;
4421 4220
4422 /* Running the process voids all cached registers and status. */ 4221 /* Running the process voids all cached registers and status. */
4423 /* Void the threads' caches first. */ 4222 /* Void the threads' caches first. */
4424 proc_iterate_over_threads (pi, invalidate_cache, NULL); 4223 proc_iterate_over_threads (pi, invalidate_cache, NULL);
4425 /* Void the process procinfo's caches. */ 4224 /* Void the process procinfo's caches. */
4426 invalidate_cache (NULL, pi, NULL); 4225 invalidate_cache (NULL, pi, NULL);
4427 4226
4428 if (PIDGET (ptid) != -1) 4227 if (PIDGET (ptid) != -1)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4467 procfs_pass_signals (int numsigs, unsigned char *pass_signals) 4266 procfs_pass_signals (int numsigs, unsigned char *pass_signals)
4468 { 4267 {
4469 gdb_sigset_t signals; 4268 gdb_sigset_t signals;
4470 procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); 4269 procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
4471 int signo; 4270 int signo;
4472 4271
4473 prfillset (&signals); 4272 prfillset (&signals);
4474 4273
4475 for (signo = 0; signo < NSIG; signo++) 4274 for (signo = 0; signo < NSIG; signo++)
4476 { 4275 {
4477 int target_signo = target_signal_from_host (signo); 4276 int target_signo = gdb_signal_from_host (signo);
4478 if (target_signo < numsigs && pass_signals[target_signo]) 4277 if (target_signo < numsigs && pass_signals[target_signo])
4479 gdb_prdelset (&signals, signo); 4278 gdb_prdelset (&signals, signo);
4480 } 4279 }
4481 4280
4482 if (!proc_set_traced_signals (pi, &signals)) 4281 if (!proc_set_traced_signals (pi, &signals))
4483 proc_error (pi, "pass_signals", __LINE__); 4282 proc_error (pi, "pass_signals", __LINE__);
4484 } 4283 }
4485 4284
4486 /* Print status information about the child process. */ 4285 /* Print status information about the child process. */
4487 4286
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
4951 4750
4952 if (!in_thread_list (gdb_threadid) || is_exited (gdb_threadid)) 4751 if (!in_thread_list (gdb_threadid) || is_exited (gdb_threadid))
4953 add_thread (gdb_threadid); 4752 add_thread (gdb_threadid);
4954 4753
4955 return 0; 4754 return 0;
4956 } 4755 }
4957 4756
4958 /* Query all the threads that the target knows about, and give them 4757 /* Query all the threads that the target knows about, and give them
4959 back to GDB to add to its list. */ 4758 back to GDB to add to its list. */
4960 4759
4961 void 4760 static void
4962 procfs_find_new_threads (struct target_ops *ops) 4761 procfs_find_new_threads (struct target_ops *ops)
4963 { 4762 {
4964 procinfo *pi; 4763 procinfo *pi;
4965 4764
4966 /* Find procinfo for main process. */ 4765 /* Find procinfo for main process. */
4967 pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); 4766 pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
4968 proc_update_threads (pi); 4767 proc_update_threads (pi);
4969 proc_iterate_over_threads (pi, procfs_notice_thread, NULL); 4768 proc_iterate_over_threads (pi, procfs_notice_thread, NULL);
4970 } 4769 }
4971 4770
(...skipping 21 matching lines...) Expand all
4993 return 0; 4792 return 0;
4994 } 4793 }
4995 /* I couldn't have got its status if it weren't alive, so it's 4794 /* I couldn't have got its status if it weren't alive, so it's
4996 alive. */ 4795 alive. */
4997 return 1; 4796 return 1;
4998 } 4797 }
4999 4798
5000 /* Convert PTID to a string. Returns the string in a static 4799 /* Convert PTID to a string. Returns the string in a static
5001 buffer. */ 4800 buffer. */
5002 4801
5003 char * 4802 static char *
5004 procfs_pid_to_str (struct target_ops *ops, ptid_t ptid) 4803 procfs_pid_to_str (struct target_ops *ops, ptid_t ptid)
5005 { 4804 {
5006 static char buf[80]; 4805 static char buf[80];
5007 4806
5008 if (TIDGET (ptid) == 0) 4807 if (TIDGET (ptid) == 0)
5009 sprintf (buf, "process %d", PIDGET (ptid)); 4808 sprintf (buf, "process %d", PIDGET (ptid));
5010 else 4809 else
5011 sprintf (buf, "LWP %ld", TIDGET (ptid)); 4810 sprintf (buf, "LWP %ld", TIDGET (ptid));
5012 4811
5013 return buf; 4812 return buf;
5014 } 4813 }
5015 4814
5016 /* Insert a watchpoint. */ 4815 /* Insert a watchpoint. */
5017 4816
5018 int 4817 static int
5019 procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag, 4818 procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag,
5020 int after) 4819 int after)
5021 { 4820 {
5022 #ifndef UNIXWARE 4821 #ifndef UNIXWARE
5023 #ifndef AIX5 4822 #ifndef AIX5
5024 int pflags = 0; 4823 int pflags = 0;
5025 procinfo *pi; 4824 procinfo *pi;
5026 4825
5027 pi = find_procinfo_or_die (PIDGET (ptid) == -1 ? 4826 pi = find_procinfo_or_die (PIDGET (ptid) == -1 ?
5028 PIDGET (inferior_ptid) : PIDGET (ptid), 0); 4827 PIDGET (inferior_ptid) : PIDGET (ptid), 0);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
5383 " Offset", 5182 " Offset",
5384 "Flags"); 5183 "Flags");
5385 5184
5386 iterate_over_mappings (pi, NULL, NULL, info_mappings_callback); 5185 iterate_over_mappings (pi, NULL, NULL, info_mappings_callback);
5387 printf_filtered ("\n"); 5186 printf_filtered ("\n");
5388 } 5187 }
5389 5188
5390 /* Implement the "info proc" command. */ 5189 /* Implement the "info proc" command. */
5391 5190
5392 static void 5191 static void
5393 info_proc_cmd (char *args, int from_tty) 5192 procfs_info_proc (struct target_ops *ops, char *args,
5193 » » enum info_proc_what what)
5394 { 5194 {
5395 struct cleanup *old_chain; 5195 struct cleanup *old_chain;
5396 procinfo *process = NULL; 5196 procinfo *process = NULL;
5397 procinfo *thread = NULL; 5197 procinfo *thread = NULL;
5398 char **argv = NULL; 5198 char **argv = NULL;
5399 char *tmp = NULL; 5199 char *tmp = NULL;
5400 int pid = 0; 5200 int pid = 0;
5401 int tid = 0; 5201 int tid = 0;
5402 int mappings = 0; 5202 int mappings = 0;
5403 5203
5204 switch (what)
5205 {
5206 case IP_MINIMAL:
5207 break;
5208
5209 case IP_MAPPINGS:
5210 case IP_ALL:
5211 mappings = 1;
5212 break;
5213
5214 default:
5215 error (_("Not supported on this target."));
5216 }
5217
5404 old_chain = make_cleanup (null_cleanup, 0); 5218 old_chain = make_cleanup (null_cleanup, 0);
5405 if (args) 5219 if (args)
5406 { 5220 {
5407 argv = gdb_buildargv (args); 5221 argv = gdb_buildargv (args);
5408 make_cleanup_freeargv (argv); 5222 make_cleanup_freeargv (argv);
5409 } 5223 }
5410 while (argv != NULL && *argv != NULL) 5224 while (argv != NULL && *argv != NULL)
5411 { 5225 {
5412 if (isdigit (argv[0][0])) 5226 if (isdigit (argv[0][0]))
5413 { 5227 {
5414 pid = strtoul (argv[0], &tmp, 10); 5228 pid = strtoul (argv[0], &tmp, 10);
5415 if (*tmp == '/') 5229 if (*tmp == '/')
5416 tid = strtoul (++tmp, NULL, 10); 5230 tid = strtoul (++tmp, NULL, 10);
5417 } 5231 }
5418 else if (argv[0][0] == '/') 5232 else if (argv[0][0] == '/')
5419 { 5233 {
5420 tid = strtoul (argv[0] + 1, NULL, 10); 5234 tid = strtoul (argv[0] + 1, NULL, 10);
5421 } 5235 }
5422 else if (strncmp (argv[0], "mappings", strlen (argv[0])) == 0)
5423 {
5424 mappings = 1;
5425 }
5426 else
5427 {
5428 /* [...] */
5429 }
5430 argv++; 5236 argv++;
5431 } 5237 }
5432 if (pid == 0) 5238 if (pid == 0)
5433 pid = PIDGET (inferior_ptid); 5239 pid = PIDGET (inferior_ptid);
5434 if (pid == 0) 5240 if (pid == 0)
5435 error (_("No current process: you must name one.")); 5241 error (_("No current process: you must name one."));
5436 else 5242 else
5437 { 5243 {
5438 /* Have pid, will travel. 5244 /* Have pid, will travel.
5439 First see if it's a process we're already debugging. */ 5245 First see if it's a process we're already debugging. */
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
5555 proc_trace_syscalls (args, from_tty, PR_SYSENTRY, FLAG_RESET); 5361 proc_trace_syscalls (args, from_tty, PR_SYSENTRY, FLAG_RESET);
5556 } 5362 }
5557 5363
5558 static void 5364 static void
5559 proc_untrace_sysexit_cmd (char *args, int from_tty) 5365 proc_untrace_sysexit_cmd (char *args, int from_tty)
5560 { 5366 {
5561 proc_trace_syscalls (args, from_tty, PR_SYSEXIT, FLAG_RESET); 5367 proc_trace_syscalls (args, from_tty, PR_SYSEXIT, FLAG_RESET);
5562 } 5368 }
5563 5369
5564 5370
5371 /* Provide a prototype to silence -Wmissing-prototypes. */
5372 extern void _initialize_procfs (void);
5373
5565 void 5374 void
5566 _initialize_procfs (void) 5375 _initialize_procfs (void)
5567 { 5376 {
5568 observer_attach_inferior_created (procfs_inferior_created); 5377 observer_attach_inferior_created (procfs_inferior_created);
5569 5378
5570 add_info ("proc", info_proc_cmd, _("\
5571 Show /proc process information about any running process.\n\
5572 Specify process id, or use the program being debugged by default.\n\
5573 Specify keyword 'mappings' for detailed info on memory mappings."));
5574 add_com ("proc-trace-entry", no_class, proc_trace_sysentry_cmd, 5379 add_com ("proc-trace-entry", no_class, proc_trace_sysentry_cmd,
5575 _("Give a trace of entries into the syscall.")); 5380 _("Give a trace of entries into the syscall."));
5576 add_com ("proc-trace-exit", no_class, proc_trace_sysexit_cmd, 5381 add_com ("proc-trace-exit", no_class, proc_trace_sysexit_cmd,
5577 _("Give a trace of exits from the syscall.")); 5382 _("Give a trace of exits from the syscall."));
5578 add_com ("proc-untrace-entry", no_class, proc_untrace_sysentry_cmd, 5383 add_com ("proc-untrace-entry", no_class, proc_untrace_sysentry_cmd,
5579 _("Cancel a trace of entries into the syscall.")); 5384 _("Cancel a trace of entries into the syscall."));
5580 add_com ("proc-untrace-exit", no_class, proc_untrace_sysexit_cmd, 5385 add_com ("proc-untrace-exit", no_class, proc_untrace_sysexit_cmd,
5581 _("Cancel a trace of exits from the syscall.")); 5386 _("Cancel a trace of exits from the syscall."));
5582 } 5387 }
5583 5388
(...skipping 15 matching lines...) Expand all
5599 return pid_to_ptid (procinfo_list ? procinfo_list->pid : -1); 5404 return pid_to_ptid (procinfo_list ? procinfo_list->pid : -1);
5600 } 5405 }
5601 5406
5602 /* =================== GCORE .NOTE "MODULE" =================== */ 5407 /* =================== GCORE .NOTE "MODULE" =================== */
5603 #if defined (UNIXWARE) || defined (PIOCOPENLWP) || defined (PCAGENT) 5408 #if defined (UNIXWARE) || defined (PIOCOPENLWP) || defined (PCAGENT)
5604 /* gcore only implemented on solaris and unixware (so far) */ 5409 /* gcore only implemented on solaris and unixware (so far) */
5605 5410
5606 static char * 5411 static char *
5607 procfs_do_thread_registers (bfd *obfd, ptid_t ptid, 5412 procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
5608 char *note_data, int *note_size, 5413 char *note_data, int *note_size,
5609 » » » enum target_signal stop_signal) 5414 » » » enum gdb_signal stop_signal)
5610 { 5415 {
5611 struct regcache *regcache = get_thread_regcache (ptid); 5416 struct regcache *regcache = get_thread_regcache (ptid);
5612 gdb_gregset_t gregs; 5417 gdb_gregset_t gregs;
5613 gdb_fpregset_t fpregs; 5418 gdb_fpregset_t fpregs;
5614 unsigned long merged_pid; 5419 unsigned long merged_pid;
5615 struct cleanup *old_chain; 5420 struct cleanup *old_chain;
5616 5421
5617 merged_pid = TIDGET (ptid) << 16 | PIDGET (ptid); 5422 merged_pid = TIDGET (ptid) << 16 | PIDGET (ptid);
5618 5423
5619 /* This part is the old method for fetching registers. 5424 /* This part is the old method for fetching registers.
(...skipping 30 matching lines...) Expand all
5650 5455
5651 do_cleanups (old_chain); 5456 do_cleanups (old_chain);
5652 5457
5653 return note_data; 5458 return note_data;
5654 } 5459 }
5655 5460
5656 struct procfs_corefile_thread_data { 5461 struct procfs_corefile_thread_data {
5657 bfd *obfd; 5462 bfd *obfd;
5658 char *note_data; 5463 char *note_data;
5659 int *note_size; 5464 int *note_size;
5660 enum target_signal stop_signal; 5465 enum gdb_signal stop_signal;
5661 }; 5466 };
5662 5467
5663 static int 5468 static int
5664 procfs_corefile_thread_callback (procinfo *pi, procinfo *thread, void *data) 5469 procfs_corefile_thread_callback (procinfo *pi, procinfo *thread, void *data)
5665 { 5470 {
5666 struct procfs_corefile_thread_data *args = data; 5471 struct procfs_corefile_thread_data *args = data;
5667 5472
5668 if (pi != NULL) 5473 if (pi != NULL)
5669 { 5474 {
5670 ptid_t ptid = MERGEPID (pi->pid, thread->tid); 5475 ptid_t ptid = MERGEPID (pi->pid, thread->tid);
5671 5476
5672 args->note_data = procfs_do_thread_registers (args->obfd, ptid, 5477 args->note_data = procfs_do_thread_registers (args->obfd, ptid,
5673 args->note_data, 5478 args->note_data,
5674 args->note_size, 5479 args->note_size,
5675 args->stop_signal); 5480 args->stop_signal);
5676 } 5481 }
5677 return 0; 5482 return 0;
5678 } 5483 }
5679 5484
5680 static int 5485 static int
5681 find_signalled_thread (struct thread_info *info, void *data) 5486 find_signalled_thread (struct thread_info *info, void *data)
5682 { 5487 {
5683 if (info->suspend.stop_signal != TARGET_SIGNAL_0 5488 if (info->suspend.stop_signal != GDB_SIGNAL_0
5684 && ptid_get_pid (info->ptid) == ptid_get_pid (inferior_ptid)) 5489 && ptid_get_pid (info->ptid) == ptid_get_pid (inferior_ptid))
5685 return 1; 5490 return 1;
5686 5491
5687 return 0; 5492 return 0;
5688 } 5493 }
5689 5494
5690 static enum target_signal 5495 static enum gdb_signal
5691 find_stop_signal (void) 5496 find_stop_signal (void)
5692 { 5497 {
5693 struct thread_info *info = 5498 struct thread_info *info =
5694 iterate_over_threads (find_signalled_thread, NULL); 5499 iterate_over_threads (find_signalled_thread, NULL);
5695 5500
5696 if (info) 5501 if (info)
5697 return info->suspend.stop_signal; 5502 return info->suspend.stop_signal;
5698 else 5503 else
5699 return TARGET_SIGNAL_0; 5504 return GDB_SIGNAL_0;
5700 } 5505 }
5701 5506
5702 static char * 5507 static char *
5703 procfs_make_note_section (bfd *obfd, int *note_size) 5508 procfs_make_note_section (bfd *obfd, int *note_size)
5704 { 5509 {
5705 struct cleanup *old_chain; 5510 struct cleanup *old_chain;
5706 gdb_gregset_t gregs; 5511 gdb_gregset_t gregs;
5707 gdb_fpregset_t fpregs; 5512 gdb_fpregset_t fpregs;
5708 char fname[16] = {'\0'}; 5513 char fname[16] = {'\0'};
5709 char psargs[80] = {'\0'}; 5514 char psargs[80] = {'\0'};
5710 procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); 5515 procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
5711 char *note_data = NULL; 5516 char *note_data = NULL;
5712 char *inf_args; 5517 char *inf_args;
5713 struct procfs_corefile_thread_data thread_args; 5518 struct procfs_corefile_thread_data thread_args;
5714 gdb_byte *auxv; 5519 gdb_byte *auxv;
5715 int auxv_len; 5520 int auxv_len;
5716 enum target_signal stop_signal; 5521 enum gdb_signal stop_signal;
5717 5522
5718 if (get_exec_file (0)) 5523 if (get_exec_file (0))
5719 { 5524 {
5720 strncpy (fname, lbasename (get_exec_file (0)), sizeof (fname)); 5525 strncpy (fname, lbasename (get_exec_file (0)), sizeof (fname));
5721 strncpy (psargs, get_exec_file (0), 5526 fname[sizeof (fname) - 1] = 0;
5722 » sizeof (psargs)); 5527 strncpy (psargs, get_exec_file (0), sizeof (psargs));
5528 psargs[sizeof (psargs) - 1] = 0;
5723 5529
5724 inf_args = get_inferior_args (); 5530 inf_args = get_inferior_args ();
5725 if (inf_args && *inf_args && 5531 if (inf_args && *inf_args &&
5726 strlen (inf_args) < ((int) sizeof (psargs) - (int) strlen (psargs))) 5532 strlen (inf_args) < ((int) sizeof (psargs) - (int) strlen (psargs)))
5727 { 5533 {
5728 strncat (psargs, " ", 5534 strncat (psargs, " ",
5729 sizeof (psargs) - strlen (psargs)); 5535 sizeof (psargs) - strlen (psargs));
5730 strncat (psargs, inf_args, 5536 strncat (psargs, inf_args,
5731 sizeof (psargs) - strlen (psargs)); 5537 sizeof (psargs) - strlen (psargs));
5732 } 5538 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5772 } 5578 }
5773 #else /* !(Solaris or Unixware) */ 5579 #else /* !(Solaris or Unixware) */
5774 static char * 5580 static char *
5775 procfs_make_note_section (bfd *obfd, int *note_size) 5581 procfs_make_note_section (bfd *obfd, int *note_size)
5776 { 5582 {
5777 error (_("gcore not implemented for this host.")); 5583 error (_("gcore not implemented for this host."));
5778 return NULL; /* lint */ 5584 return NULL; /* lint */
5779 } 5585 }
5780 #endif /* Solaris or Unixware */ 5586 #endif /* Solaris or Unixware */
5781 /* =================== END GCORE .NOTE "MODULE" =================== */ 5587 /* =================== END GCORE .NOTE "MODULE" =================== */
OLDNEW
« no previous file with comments | « gdb/proc-utils.h ('k') | gdb/progspace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698