GNU Binutils with patches for OS216
修訂 | cf6f3e86ded2cd950f59a0f2c164f2c953ef534b (tree) |
---|---|
時間 | 2020-06-22 01:32:27 |
作者 | Rainer Orth <ro@CeBi...> |
Commiter | Rainer Orth |
[PR gdb/25939] Move push_target call earlier in procfs.c
Since the multi-target patch, the run command fails on Solaris with an
assertion failure even for a trivial program:
$ ./gdb -D ./data-directory ./hello
GNU gdb (GDB) 10.0.50.20200106-git
[...]
Reading symbols from ./hello...
(gdb) run
Starting program: /vol/obj/gnu/gdb/gdb/reghunt/no-resync/122448/gdb/hello
/vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:336: internal-error:
thread_info::thread_info(inferior*, ptid_t): Assertion inf_ != NULL'
failed.
Here's the start of the corresponding stack trace:
#0 internal_error (
"/vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c", line=line@entry=336,
fmt=0x9ddb94 "%s: Assertion %s' failed.")
#1 0x0000000000ef81f4 in thread_info::thread_info (this=0x1212020,
#2 0x0000000000ef82cd in new_thread (inf=inf@entry=0x0, ptid=...)
#3 0x0000000000efac3c in add_thread_silent (
#4 0x0000000000d90692 in procfs_target::create_inferior (
"/vol/obj/gnu/gdb/gdb/reghunt/no-resync/122448/gdb/hello", allargs="",
env=0x13c48f0, from_tty=<optimized out>)
#5 0x0000000000c84e64 in run_command_1 (args=<optimized out>, from_tty=1,
#6 0x0000000000c85007 in run_command (args=<optimized out>,
Looking closer, I found that in add_thread_silent as called from
procfs.c (procfs_target::create_inferior) find_inferior_ptid returns
NULL. The all_inferiors (targ) iterator comes up empty.
Going from there, I see that in add_thread_silent
m_target_stack = {m_top = file_stratum, m_stack = {0x20190e0
<the_dummy_target>, 0x200b8c0 <exec_ops>, 0x0, 0x0, 0x0, 0x0, 0x0}}}
i.e. the_procfs_target is missing compared to the_amd64_linux_nat_target
on Linux/x86_64.
Moving the push_target call earlier allows debugging to get over the
initial assertion failure. I run instead into
procfs: couldn't find pid 0 in procinfo list.
which is fixed by
https://sourceware.org/pipermail/gdb-patches/2020-June/169674.html
Both patches tested together on amd64-pc-solaris2.11.
PR gdb/25939
* procfs.c (procfs_target::procfs_init_inferior): Move push_target
call ...
(procfs_target::create_inferior): ... here.
@@ -1,3 +1,10 @@ | ||
1 | +2020-06-21 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> | |
2 | + | |
3 | + PR gdb/25939 | |
4 | + * procfs.c (procfs_target::procfs_init_inferior): Move push_target | |
5 | + call ... | |
6 | + (procfs_target::create_inferior): ... here. | |
7 | + | |
1 | 8 | 2020-06-21 Philippe Waroquiers <philippe.waroquiers@skynet.be> |
2 | 9 | |
3 | 10 | * exec.c (validate_exec_file): Ensure the build-id is up to |
@@ -2781,11 +2781,6 @@ procfs_target::procfs_init_inferior (int pid) | ||
2781 | 2781 | int fail; |
2782 | 2782 | int lwpid; |
2783 | 2783 | |
2784 | - /* This routine called on the parent side (GDB side) | |
2785 | - after GDB forks the inferior. */ | |
2786 | - if (!target_is_pushed (this)) | |
2787 | - push_target (this); | |
2788 | - | |
2789 | 2784 | pi = create_procinfo (pid, 0); |
2790 | 2785 | if (pi == NULL) |
2791 | 2786 | perror (_("procfs: out of memory in 'init_inferior'")); |
@@ -3006,6 +3001,9 @@ procfs_target::create_inferior (const char *exec_file, | ||
3006 | 3001 | shell_file = tryname; |
3007 | 3002 | } |
3008 | 3003 | |
3004 | + if (!target_is_pushed (this)) | |
3005 | + push_target (this); | |
3006 | + | |
3009 | 3007 | pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap, |
3010 | 3008 | NULL, NULL, shell_file, NULL); |
3011 | 3009 |