GNU Binutils with patches for OS216
修订版 | 975f8708de015fb2b813edbf8b714f4777c57a41 (tree) |
---|---|
时间 | 2020-06-19 07:11:23 |
作者 | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Don't write to inferior_ptid in gnu-nat.c
Untested.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* gnu-nat.c (gnu_nat_target::create_inferior): Switch to the added
thread.
(gnu_nat_target::attach): Don't write to inferior_ptid directly.
Instead use switch_to_thread.
(gnu_nat_target::detach): Use switch_to_no_thread
instead of writing to inferior_ptid directly. Used passed-in
inferior instead of looking up the inferior by pid.
@@ -1,5 +1,15 @@ | ||
1 | 1 | 2020-06-18 Pedro Alves <palves@redhat.com> |
2 | 2 | |
3 | + * gnu-nat.c (gnu_nat_target::create_inferior): Switch to the added | |
4 | + thread. | |
5 | + (gnu_nat_target::attach): Don't write to inferior_ptid directly. | |
6 | + Instead use switch_to_thread. | |
7 | + (gnu_nat_target::detach): Use switch_to_no_thread | |
8 | + instead of writing to inferior_ptid directly. Used passed-in | |
9 | + inferior instead of looking up the inferior by pid. | |
10 | + | |
11 | +2020-06-18 Pedro Alves <palves@redhat.com> | |
12 | + | |
3 | 13 | * go32-nat.c (go32_nat_target::create_inferior): Don't write to |
4 | 14 | inferior_ptid. |
5 | 15 |
@@ -2121,7 +2121,8 @@ gnu_nat_target::create_inferior (const char *exec_file, | ||
2121 | 2121 | /* We have something that executes now. We'll be running through |
2122 | 2122 | the shell at this point (if startup-with-shell is true), but the |
2123 | 2123 | pid shouldn't change. */ |
2124 | - add_thread_silent (this, ptid_t (pid)); | |
2124 | + thread_info *thr = add_thread_silent (this, ptid_t (pid)); | |
2125 | + switch_to_thread (thr); | |
2125 | 2126 | |
2126 | 2127 | /* Attach to the now stopped child, which is actually a shell... */ |
2127 | 2128 | inf_debug (inf, "attaching to child: %d", pid); |
@@ -2196,7 +2197,9 @@ gnu_nat_target::attach (const char *args, int from_tty) | ||
2196 | 2197 | |
2197 | 2198 | inf_update_procs (inf); |
2198 | 2199 | |
2199 | - inferior_ptid = ptid_t (pid, inf_pick_first_thread (), 0); | |
2200 | + thread_info *thr | |
2201 | + = find_thread_ptid (this, ptid_t (pid, inf_pick_first_thread ())); | |
2202 | + switch_to_thread (thr); | |
2200 | 2203 | |
2201 | 2204 | /* We have to initialize the terminal settings now, since the code |
2202 | 2205 | below might try to restore them. */ |
@@ -2225,8 +2228,6 @@ gnu_nat_target::attach (const char *args, int from_tty) | ||
2225 | 2228 | void |
2226 | 2229 | gnu_nat_target::detach (inferior *inf, int from_tty) |
2227 | 2230 | { |
2228 | - int pid; | |
2229 | - | |
2230 | 2231 | if (from_tty) |
2231 | 2232 | { |
2232 | 2233 | const char *exec_file = get_exec_file (0); |
@@ -2238,12 +2239,10 @@ gnu_nat_target::detach (inferior *inf, int from_tty) | ||
2238 | 2239 | printf_unfiltered ("Detaching from pid %d\n", gnu_current_inf->pid); |
2239 | 2240 | } |
2240 | 2241 | |
2241 | - pid = gnu_current_inf->pid; | |
2242 | - | |
2243 | 2242 | inf_detach (gnu_current_inf); |
2244 | 2243 | |
2245 | - inferior_ptid = null_ptid; | |
2246 | - detach_inferior (find_inferior_pid (this, pid)); | |
2244 | + switch_to_no_thread (); | |
2245 | + detach_inferior (inf); | |
2247 | 2246 | |
2248 | 2247 | maybe_unpush_target (); |
2249 | 2248 | } |