|
51 | 51 | #include "inflow.h"
|
52 | 52 | #include "auxv.h"
|
53 | 53 | #include "procfs.h"
|
| 54 | +#include "observer.h" |
54 | 55 |
|
55 | 56 | /*
|
56 | 57 | * PROCFS.C
|
@@ -5146,13 +5147,27 @@ procfs_create_inferior (struct target_ops *ops, char *exec_file,
|
5146 | 5147 | NULL, NULL, shell_file);
|
5147 | 5148 |
|
5148 | 5149 | procfs_init_inferior (ops, pid);
|
| 5150 | +} |
| 5151 | + |
| 5152 | +/* An observer for the "inferior_created" event. */ |
5149 | 5153 |
|
| 5154 | +static void |
| 5155 | +procfs_inferior_created (struct target_ops *ops, int from_tty) |
| 5156 | +{ |
5150 | 5157 | #ifdef SYS_syssgi
|
5151 | 5158 | /* Make sure to cancel the syssgi() syscall-exit notifications.
|
5152 | 5159 | They should normally have been removed by now, but they may still
|
5153 | 5160 | be activated if the inferior doesn't use shared libraries, or if
|
5154 | 5161 | we didn't locate __dbx_link, or if we never stopped in __dbx_link.
|
5155 |
| - See procfs_init_inferior() for more details. */ |
| 5162 | + See procfs_init_inferior() for more details. |
| 5163 | +
|
| 5164 | + Since these notifications are only ever enabled when we spawned |
| 5165 | + the inferior ourselves, there is nothing to do when the inferior |
| 5166 | + was created by attaching to an already running process, or when |
| 5167 | + debugging a core file. */ |
| 5168 | + if (current_inferior ()->attach_flag || !target_can_run (¤t_target)) |
| 5169 | + return; |
| 5170 | + |
5156 | 5171 | proc_trace_syscalls_1 (find_procinfo_or_die (PIDGET (inferior_ptid), 0),
|
5157 | 5172 | SYS_syssgi, PR_SYSEXIT, FLAG_RESET, 0);
|
5158 | 5173 | #endif
|
@@ -6000,6 +6015,8 @@ proc_untrace_sysexit_cmd (char *args, int from_tty)
|
6000 | 6015 | void
|
6001 | 6016 | _initialize_procfs (void)
|
6002 | 6017 | {
|
| 6018 | + observer_attach_inferior_created (procfs_inferior_created); |
| 6019 | + |
6003 | 6020 | add_info ("proc", info_proc_cmd, _("\
|
6004 | 6021 | Show /proc process information about any running process.\n\
|
6005 | 6022 | Specify process id, or use the program being debugged by default.\n\
|
|
0 commit comments