• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Révision56514b062a732f83b76053db6c1189d80291f659 (tree)
l'heure2018-10-01 19:14:57
AuteurPedro Alves <palves@redh...>
CommiterPedro Alves

Message de Log

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:
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.

Change Summary

Modification

--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -251,13 +251,11 @@ cli_on_command_error (void)
251251 static void
252252 cli_on_user_selected_context_changed (user_selected_what selection)
253253 {
254- struct thread_info *tp;
255-
256254 /* This event is suppressed. */
257255 if (cli_suppress_notification.user_selected_context)
258256 return;
259257
260- tp = find_thread_ptid (inferior_ptid);
258+ thread_info *tp = inferior_ptid != null_ptid ? inferior_thread () : NULL;
261259
262260 SWITCH_THRU_ALL_UIS ()
263261 {
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -122,9 +122,14 @@ add_inferior (int pid)
122122 struct inferior *inf = add_inferior_silent (pid);
123123
124124 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+ }
128133
129134 return inf;
130135 }
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -86,8 +86,8 @@ python_on_normal_stop (struct bpstats *bs, int print_frame)
8686 if (!gdb_python_initialized)
8787 return;
8888
89- if (!find_thread_ptid (inferior_ptid))
90- return;
89+ if (inferior_ptid == null_ptid)
90+ return;
9191
9292 stop_signal = inferior_thread ()->suspend.stop_signal;
9393
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -210,13 +210,11 @@ tui_on_command_error (void)
210210 static void
211211 tui_on_user_selected_context_changed (user_selected_what selection)
212212 {
213- struct thread_info *tp;
214-
215213 /* This event is suppressed. */
216214 if (cli_suppress_notification.user_selected_context)
217215 return;
218216
219- tp = find_thread_ptid (inferior_ptid);
217+ thread_info *tp = inferior_ptid != null_ptid ? inferior_thread () : NULL;
220218
221219 SWITCH_THRU_ALL_UIS ()
222220 {