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: (gdb) add-inferior [New inferior 2 (process 0)] to: (gdb) add-inferior [New inferior 2] 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: 2018-11-22 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.
This commit is contained in:
parent
79a9468c70
commit
151bb4a505
5 changed files with 25 additions and 11 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2018-11-22 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.
|
||||||
|
|
||||||
2018-11-21 Benno Fünfstück <benno.fuenfstueck@gmail.com>
|
2018-11-21 Benno Fünfstück <benno.fuenfstueck@gmail.com>
|
||||||
|
|
||||||
PR python/23714
|
PR python/23714
|
||||||
|
|
|
@ -257,13 +257,11 @@ cli_on_command_error (void)
|
||||||
static void
|
static void
|
||||||
cli_on_user_selected_context_changed (user_selected_what selection)
|
cli_on_user_selected_context_changed (user_selected_what selection)
|
||||||
{
|
{
|
||||||
struct thread_info *tp;
|
|
||||||
|
|
||||||
/* This event is suppressed. */
|
/* This event is suppressed. */
|
||||||
if (cli_suppress_notification.user_selected_context)
|
if (cli_suppress_notification.user_selected_context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tp = find_thread_ptid (inferior_ptid);
|
thread_info *tp = inferior_ptid != null_ptid ? inferior_thread () : NULL;
|
||||||
|
|
||||||
SWITCH_THRU_ALL_UIS ()
|
SWITCH_THRU_ALL_UIS ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,9 +122,14 @@ add_inferior (int pid)
|
||||||
struct inferior *inf = add_inferior_silent (pid);
|
struct inferior *inf = add_inferior_silent (pid);
|
||||||
|
|
||||||
if (print_inferior_events)
|
if (print_inferior_events)
|
||||||
printf_unfiltered (_("[New inferior %d (%s)]\n"),
|
{
|
||||||
inf->num,
|
if (pid != 0)
|
||||||
target_pid_to_str (ptid_t (pid)));
|
printf_unfiltered (_("[New inferior %d (%s)]\n"),
|
||||||
|
inf->num,
|
||||||
|
target_pid_to_str (ptid_t (pid)));
|
||||||
|
else
|
||||||
|
printf_unfiltered (_("[New inferior %d]\n"), inf->num);
|
||||||
|
}
|
||||||
|
|
||||||
return inf;
|
return inf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,8 +86,8 @@ python_on_normal_stop (struct bpstats *bs, int print_frame)
|
||||||
if (!gdb_python_initialized)
|
if (!gdb_python_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!find_thread_ptid (inferior_ptid))
|
if (inferior_ptid == null_ptid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stop_signal = inferior_thread ()->suspend.stop_signal;
|
stop_signal = inferior_thread ()->suspend.stop_signal;
|
||||||
|
|
||||||
|
|
|
@ -210,13 +210,11 @@ tui_on_command_error (void)
|
||||||
static void
|
static void
|
||||||
tui_on_user_selected_context_changed (user_selected_what selection)
|
tui_on_user_selected_context_changed (user_selected_what selection)
|
||||||
{
|
{
|
||||||
struct thread_info *tp;
|
|
||||||
|
|
||||||
/* This event is suppressed. */
|
/* This event is suppressed. */
|
||||||
if (cli_suppress_notification.user_selected_context)
|
if (cli_suppress_notification.user_selected_context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tp = find_thread_ptid (inferior_ptid);
|
thread_info *tp = inferior_ptid != null_ptid ? inferior_thread () : NULL;
|
||||||
|
|
||||||
SWITCH_THRU_ALL_UIS ()
|
SWITCH_THRU_ALL_UIS ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue