binutils-gdb/gdb/python
Pedro Alves 151bb4a505 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.
2018-11-22 16:09:12 +00:00
..
lib/gdb Fix output indentation for "info pretty-printers" 2018-11-08 16:17:01 -07:00
py-all-events.def Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-arch.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-auto-load.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-block.c Return gdbpy_ref from gdb_py_object_from_*longest 2018-11-04 08:01:00 -07:00
py-bpevent.c gdb/python: Use copy-initialization more when possible 2018-08-24 22:57:16 +01:00
py-breakpoint.c Return gdbpy_ref from some Python string functions 2018-11-04 08:01:01 -07:00
py-cmd.c gdb/python: Make cmdpy_completer_helper return gdbpy_ref<> 2018-10-25 12:20:18 +01:00
py-continueevent.c Change thread_to_thread_object to return a new reference 2018-09-16 07:25:57 -06:00
py-event-types.def Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-event.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-event.h Change thread_to_thread_object to return a new reference 2018-09-16 07:25:57 -06:00
py-events.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-evtregistry.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-evts.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-exitedevent.c gdb/python: Use copy-initialization more when possible 2018-08-24 22:57:16 +01:00
py-finishbreakpoint.c Use thread_info and inferior pointers more throughout 2018-06-21 17:09:31 +01:00
py-frame.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-framefilter.c MI: Fix printing of frame architecture with Python frame filters enabled 2018-08-27 17:12:41 -04:00
py-function.c gdb/python: Make convert_values_to_python return gdbpy_ref<> 2018-10-25 12:20:18 +01:00
py-gdb-readline.c Remove "repeat" argument from command_line_input 2018-08-17 16:39:06 -06:00
py-inferior.c Avoid find_thread_ptid with null_ptid 2018-11-22 16:09:12 +00:00
py-infevents.c gdb/python: Use copy-initialization more when possible 2018-08-24 22:57:16 +01:00
py-infthread.c Change thread_to_thread_object to return a new reference 2018-09-16 07:25:57 -06:00
py-instruction.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-instruction.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-lazy-string.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-linetable.c Return gdbpy_ref from gdb_py_object_from_*longest 2018-11-04 08:01:00 -07:00
py-newobjfileevent.c Change objfile_to_objfile_object to return a new reference 2018-09-16 07:25:56 -06:00
py-objfile.c Return gdbpy_ref from some Python string functions 2018-11-04 08:01:01 -07:00
py-param.c Allow setting a parameter to raise gdb.GdbError 2018-09-23 23:15:12 -06:00
py-prettyprint.c Return gdbpy_ref from gdbpy_get_varobj_pretty_printer 2018-11-04 08:01:01 -07:00
py-progspace.c Return gdbpy_ref from some Python string functions 2018-11-04 08:01:01 -07:00
py-record-btrace.c [gdb/python] Fix cpychecker error in recpy_bt_goto 2018-10-05 00:20:07 +02:00
py-record-btrace.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-record-full.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-record-full.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-record.c Use thread_info and inferior pointers more throughout 2018-06-21 17:09:31 +01:00
py-record.h Use thread_info and inferior pointers more throughout 2018-06-21 17:09:31 +01:00
py-ref.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-signalevent.c gdb/python: Use copy-initialization more when possible 2018-08-24 22:57:16 +01:00
py-stopevent.c Change thread_to_thread_object to return a new reference 2018-09-16 07:25:57 -06:00
py-stopevent.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
py-symbol.c Update symbol domain and location values for Python 2018-10-06 23:20:55 -06:00
py-symtab.c Return gdbpy_ref from some Python string functions 2018-11-04 08:01:01 -07:00
py-threadevent.c Simplify uses of thread_to_thread_object 2018-09-16 23:36:54 -06:00
py-type.c Return gdbpy_ref from gdb_py_object_from_*longest 2018-11-04 08:01:00 -07:00
py-unwind.c Simple unused variable removals 2018-07-22 13:20:01 -06:00
py-utils.c Return gdbpy_ref from some Python string functions 2018-11-04 08:01:01 -07:00
py-value.c Use gdb:array_view in call_function_by_hand & friends 2018-11-21 11:55:11 +00:00
py-varobj.c Don't steal references in the gdb Python code 2018-09-16 23:48:21 -06:00
py-xmethods.c invoke_xmethod & array_view 2018-11-21 12:06:20 +00:00
python-config.py configure uses incorrect link order when testing libpython 2018-05-04 10:08:09 -04:00
python-internal.h Return gdbpy_ref from gdbpy_get_varobj_pretty_printer 2018-11-04 08:01:01 -07:00
python.c Make command-repeat work after gdb.execute 2018-11-21 17:06:05 +00:00
python.h python: Make gdb.execute("show commands") work (PR 23669) 2018-09-17 08:26:24 -04:00