GNU Binutils with patches for OS216
Révision | 56514b062a732f83b76053db6c1189d80291f659 (tree) |
---|---|
l'heure | 2018-10-01 19:14:57 |
Auteur | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Avoid find_thread_ptid with null_ptid
With a following patch, find_thread_ptid will first find the inferior
for the passed-in ptid, using find_inferior_pid, and then look for the
thread in that inferior's thread list. If we pass down null_ptid to
find_thread_ptid then that means we'll end up passing 0 to
find_inferior_pid, which hits this assertion:
struct inferior *
find_inferior_pid (int pid)
{
struct inferior *inf;
>
/* Looking for inferior pid == 0 is always wrong, and indicative of
> a bug somewhere else. There may be more than one with pid == 0,
> for instance. */
gdb_assert (pid != 0);
This patch prepares for the change, by avoiding passing down null_ptid
to find_thread_ptid or to functions that naturally use it, such as the
target_pid_to_str call in inferior.c:add_inferior. In that latter
case, the patch changes GDB output,
from:
to:
which seems like a good change to me. It might not even make sense to
talk about "process" for the current target, for example.
The python_on_normal_stop change ends up avoiding looking up the
same thread twice (inferior_thread also does a look up).
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* cli/cli-interp.c (cli_on_user_selected_context_changed): Use
inferior_thread instead of find_thread_ptid, and only when
inferior_ptid is not null_ptid.
* inferior.c (add_inferior): Don't include target_pid_to_str
output when the inferior is not started.
* python/py-inferior.c (python_on_normal_stop): Don't use
find_thread_ptid.
(tui_on_user_selected_context_changed): Use inferior_thread
instead of find_thread_ptid, and only when inferior_ptid is not
null_ptid.
@@ -251,13 +251,11 @@ cli_on_command_error (void) | ||
251 | 251 | static void |
252 | 252 | cli_on_user_selected_context_changed (user_selected_what selection) |
253 | 253 | { |
254 | - struct thread_info *tp; | |
255 | - | |
256 | 254 | /* This event is suppressed. */ |
257 | 255 | if (cli_suppress_notification.user_selected_context) |
258 | 256 | return; |
259 | 257 | |
260 | - tp = find_thread_ptid (inferior_ptid); | |
258 | + thread_info *tp = inferior_ptid != null_ptid ? inferior_thread () : NULL; | |
261 | 259 | |
262 | 260 | SWITCH_THRU_ALL_UIS () |
263 | 261 | { |
@@ -122,9 +122,14 @@ add_inferior (int pid) | ||
122 | 122 | struct inferior *inf = add_inferior_silent (pid); |
123 | 123 | |
124 | 124 | if (print_inferior_events) |
125 | - printf_unfiltered (_("[New inferior %d (%s)]\n"), | |
126 | - inf->num, | |
127 | - target_pid_to_str (ptid_t (pid))); | |
125 | + { | |
126 | + if (pid != 0) | |
127 | + printf_unfiltered (_("[New inferior %d (%s)]\n"), | |
128 | + inf->num, | |
129 | + target_pid_to_str (ptid_t (pid))); | |
130 | + else | |
131 | + printf_unfiltered (_("[New inferior %d]\n"), inf->num); | |
132 | + } | |
128 | 133 | |
129 | 134 | return inf; |
130 | 135 | } |
@@ -86,8 +86,8 @@ python_on_normal_stop (struct bpstats *bs, int print_frame) | ||
86 | 86 | if (!gdb_python_initialized) |
87 | 87 | return; |
88 | 88 | |
89 | - if (!find_thread_ptid (inferior_ptid)) | |
90 | - return; | |
89 | + if (inferior_ptid == null_ptid) | |
90 | + return; | |
91 | 91 | |
92 | 92 | stop_signal = inferior_thread ()->suspend.stop_signal; |
93 | 93 |
@@ -210,13 +210,11 @@ tui_on_command_error (void) | ||
210 | 210 | static void |
211 | 211 | tui_on_user_selected_context_changed (user_selected_what selection) |
212 | 212 | { |
213 | - struct thread_info *tp; | |
214 | - | |
215 | 213 | /* This event is suppressed. */ |
216 | 214 | if (cli_suppress_notification.user_selected_context) |
217 | 215 | return; |
218 | 216 | |
219 | - tp = find_thread_ptid (inferior_ptid); | |
217 | + thread_info *tp = inferior_ptid != null_ptid ? inferior_thread () : NULL; | |
220 | 218 | |
221 | 219 | SWITCH_THRU_ALL_UIS () |
222 | 220 | { |