Commit c29705b
Philippe Waroquiers
Fix internal error and improve 'set debug infrun 1'/target wait kind trace
The test gdb.threads/watchthreads-reorder.exp verifies that the
'set debug infrun 1' debug output does not crash GDB.
Under high load, the test can still cause a GDB internal error (see details
below).
This patch fixes this crash, and improves/factorises some wait kind traces.
Tested on debian/amd64 + run one test with 'set debug infrun 1'.
Changes compared to the first version:
* Handles the suggestions of Kevin to trace the relevant elements
of the wait status (this is done by calling target_waitstatus_to_string).
* Some other changes to factorise wait status tracing.
Note that using target_waitstatus_to_string instead of the 'locally printed'
status kind strings means that debug trace that was using strings such as:
"EXITED" or "TARGET_WAITKIND_EXITED"
will now use what is printed by target_waitstatus_to_string e.g.
"exited".
gdb/ChangeLog
2019-04-01 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* infrun.c (stop_all_threads): If debug_infrun, always
trace the wait status after wait_one, using
target_waitstatus_to_string and target_pid_to_str.
(handle_inferior_event): Replace various trace of
wait status kind by a single trace.
* gdb/gnu-nat.c (gnu_nat_target::wait): Replace local
wait status kind image by target_waitstatus_to_string.
* target/waitstatus.c (target_waitstatus_to_string): Fix
obsolete comment.
(top-gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007f3d54a0642a in __GI_abort () at abort.c:89
#2 0x0000555c24c60e66 in dump_core () at ../../fixleaks/gdb/utils.c:201
#3 0x0000555c24c63d49 in internal_vproblem(internal_problem *, const char *, int, const char *, typedef __va_list_tag __va_list_tag *) (problem=problem@entry=0x555c25338d40 <internal_error_problem>, file=<optimized out>, line=287,
fmt=<optimized out>, ap=<optimized out>) at ../../fixleaks/gdb/utils.c:411
#4 0x0000555c24c63eab in internal_verror (file=<optimized out>, line=<optimized out>, fmt=<optimized out>,
ap=<optimized out>) at ../../fixleaks/gdb/utils.c:436
#5 0x0000555c249e8c22 in internal_error (file=file@entry=0x555c24e0f2ad "../../fixleaks/gdb/inferior.c",
line=line@entry=287, fmt=<optimized out>) at ../../fixleaks/gdb/common/errors.c:55
#6 0x0000555c247d3f5c in find_inferior_pid (pid=<optimized out>) at ../../fixleaks/gdb/inferior.c:287
#7 0x0000555c24ad2248 in find_inferior_pid (pid=<optimized out>) at ../../fixleaks/gdb/inferior.c:302
#8 find_inferior_ptid (ptid=...) at ../../fixleaks/gdb/inferior.c:301
#9 0x0000555c24c35f25 in find_thread_ptid (ptid=...) at ../../fixleaks/gdb/thread.c:522
#10 0x0000555c24b0ab4d in thread_db_target::pid_to_str[abi:cxx11](ptid_t) (
this=0x555c2532e3e0 <the_thread_db_target>, ptid=...) at ../../fixleaks/gdb/linux-thread-db.c:1637
#11 0x0000555c24c2f420 in target_pid_to_str[abi:cxx11](ptid_t) (ptid=...) at ../../fixleaks/gdb/target.c:2083
#12 0x0000555c24ad9cab in stop_all_threads () at ../../fixleaks/gdb/infrun.c:4373
#13 0x0000555c24ada00f in stop_waiting (ecs=<optimized out>) at ../../fixleaks/gdb/infrun.c:7464
#14 0x0000555c24adc401 in process_event_stop_test (ecs=ecs@entry=0x7ffc9402d9d0) at ../../fixleaks/gdb/infrun.c:6181
...
(top-gdb) fr 12
#12 0x0000555c24ad9cab in stop_all_threads () at ../../fixleaks/gdb/infrun.c:4373
(top-gdb) p event_ptid
$5 = {m_pid = 25419, m_lwp = 25427, m_tid = 0}
(top-gdb) p ptid
$6 = {m_pid = 0, m_lwp = 0, m_tid = 0}
(top-gdb) p ws
$7 = {kind = TARGET_WAITKIND_THREAD_EXITED, value = {integer = 0, sig = GDB_SIGNAL_0, related_pid = {m_pid = 0,
m_lwp = 0, m_tid = 0}, execd_pathname = 0x0, syscall_number = 0}}
(top-gdb)
The gdb.log corresponding to the above crash is:
(gdb) PASS: gdb.threads/watchthreads-reorder.exp: reorder1: set debug infrun 1
continue
Continuing.
infrun: clear_proceed_status_thread (Thread 0x7ffff7fcfb40 (LWP 25419))
infrun: clear_proceed_status_thread (Thread 0x7ffff7310700 (LWP 25427))
infrun: clear_proceed_status_thread (Thread 0x7ffff6b0f700 (LWP 25428))
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming Thread 0x7ffff7fcfb40 (LWP 25419)
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7fcfb40 (LWP 25419)] at 0x7ffff7344317
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: proceed: resuming Thread 0x7ffff7310700 (LWP 25427)
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7310700 (LWP 25427)] at 0x5555555553d7
infrun: prepare_to_wait
infrun: proceed: resuming Thread 0x7ffff6b0f700 (LWP 25428)
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff6b0f700 (LWP 25428)] at 0x5555555554c8
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: -1.0.0 [process -1],
infrun: status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Joining the threads.
[Thread 0x7ffff6b0f700 (LWP 25428) exited]
infrun: target_wait (-1.0.0, status) =
infrun: -1.0.0 [process -1],
infrun: status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 25419.25419.0 [Thread 0x7ffff7fcfb40 (LWP 25419)],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x555555555e50
infrun: context switch
infrun: Switching context from Thread 0x7ffff6b0f700 (LWP 25428) to Thread 0x7ffff7fcfb40 (LWP 25419)
infrun: BPSTAT_WHAT_STOP_NOISY
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun: Thread 0x7ffff7fcfb40 (LWP 25419) not executing
infrun: Thread 0x7ffff7310700 (LWP 25427) executing, need stop
[Thread 0x7ffff7310700 (LWP 25427) exited]
infrun: target_wait (-1.0.0, status) =
infrun: 25419.25427.0 [LWP 25427],
infrun: status->kind = thread exited, status = 0
infrun: infrun_async(0)
../../fixleaks/gdb/inferior.c:287: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/watchthreads-reorder.exp: reorder1: continue to breakpoint: break-at-exit (GDB internal error)
Resyncing due to internal error.
n
infrun: infrun_async(1)
This is a bug, please report it. For instructions, see:
<http://www.gnu.org/software/gdb/bugs/>.
infrun: infrun_async(0)
../../fixleaks/gdb/inferior.c:287: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) y1 parent 05caa1d commit c29705b
4 files changed
+31
-72
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
1 | 13 | | |
2 | 14 | | |
3 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1647 | 1647 | | |
1648 | 1648 | | |
1649 | 1649 | | |
1650 | | - | |
| 1650 | + | |
1651 | 1651 | | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
| 1652 | + | |
1659 | 1653 | | |
1660 | 1654 | | |
1661 | 1655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4358 | 4358 | | |
4359 | 4359 | | |
4360 | 4360 | | |
4361 | | - | |
4362 | | - | |
| 4361 | + | |
4363 | 4362 | | |
4364 | | - | |
| 4363 | + | |
| 4364 | + | |
| 4365 | + | |
| 4366 | + | |
4365 | 4367 | | |
4366 | | - | |
4367 | | - | |
4368 | | - | |
4369 | | - | |
4370 | | - | |
4371 | | - | |
4372 | | - | |
4373 | 4368 | | |
4374 | | - | |
4375 | | - | |
4376 | | - | |
4377 | | - | |
4378 | | - | |
| 4369 | + | |
| 4370 | + | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
| 4375 | + | |
4379 | 4376 | | |
4380 | 4377 | | |
4381 | 4378 | | |
| |||
4604 | 4601 | | |
4605 | 4602 | | |
4606 | 4603 | | |
| 4604 | + | |
| 4605 | + | |
| 4606 | + | |
| 4607 | + | |
4607 | 4608 | | |
4608 | 4609 | | |
4609 | 4610 | | |
| |||
4615 | 4616 | | |
4616 | 4617 | | |
4617 | 4618 | | |
4618 | | - | |
4619 | | - | |
4620 | 4619 | | |
4621 | 4620 | | |
4622 | 4621 | | |
4623 | 4622 | | |
4624 | 4623 | | |
4625 | 4624 | | |
4626 | | - | |
4627 | | - | |
4628 | 4625 | | |
4629 | 4626 | | |
4630 | 4627 | | |
| |||
4643 | 4640 | | |
4644 | 4641 | | |
4645 | 4642 | | |
4646 | | - | |
4647 | | - | |
4648 | | - | |
4649 | 4643 | | |
4650 | 4644 | | |
4651 | 4645 | | |
| |||
4738 | 4732 | | |
4739 | 4733 | | |
4740 | 4734 | | |
4741 | | - | |
4742 | | - | |
4743 | 4735 | | |
4744 | 4736 | | |
4745 | 4737 | | |
| |||
4817 | 4809 | | |
4818 | 4810 | | |
4819 | 4811 | | |
4820 | | - | |
4821 | | - | |
4822 | 4812 | | |
4823 | 4813 | | |
4824 | 4814 | | |
| |||
4827 | 4817 | | |
4828 | 4818 | | |
4829 | 4819 | | |
4830 | | - | |
4831 | | - | |
4832 | 4820 | | |
4833 | 4821 | | |
4834 | 4822 | | |
| |||
4838 | 4826 | | |
4839 | 4827 | | |
4840 | 4828 | | |
4841 | | - | |
4842 | | - | |
4843 | | - | |
4844 | | - | |
4845 | | - | |
4846 | | - | |
4847 | | - | |
4848 | | - | |
4849 | | - | |
4850 | | - | |
4851 | 4829 | | |
4852 | 4830 | | |
4853 | 4831 | | |
| |||
4912 | 4890 | | |
4913 | 4891 | | |
4914 | 4892 | | |
4915 | | - | |
4916 | | - | |
4917 | | - | |
4918 | | - | |
4919 | | - | |
4920 | | - | |
4921 | | - | |
4922 | | - | |
4923 | 4893 | | |
4924 | 4894 | | |
4925 | 4895 | | |
| |||
5080 | 5050 | | |
5081 | 5051 | | |
5082 | 5052 | | |
5083 | | - | |
5084 | | - | |
5085 | | - | |
5086 | | - | |
5087 | 5053 | | |
5088 | 5054 | | |
5089 | 5055 | | |
| |||
5098 | 5064 | | |
5099 | 5065 | | |
5100 | 5066 | | |
5101 | | - | |
5102 | | - | |
5103 | 5067 | | |
5104 | 5068 | | |
5105 | 5069 | | |
| |||
5148 | 5112 | | |
5149 | 5113 | | |
5150 | 5114 | | |
5151 | | - | |
5152 | | - | |
5153 | | - | |
5154 | 5115 | | |
5155 | 5116 | | |
5156 | 5117 | | |
| |||
5162 | 5123 | | |
5163 | 5124 | | |
5164 | 5125 | | |
5165 | | - | |
5166 | | - | |
5167 | | - | |
5168 | 5126 | | |
5169 | 5127 | | |
5170 | 5128 | | |
5171 | 5129 | | |
5172 | 5130 | | |
5173 | | - | |
5174 | | - | |
5175 | 5131 | | |
5176 | 5132 | | |
5177 | 5133 | | |
5178 | 5134 | | |
5179 | | - | |
5180 | | - | |
5181 | 5135 | | |
5182 | 5136 | | |
5183 | 5137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
0 commit comments