Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用GDB附加到分叉子进程_Gdb_Fork_Remote Debugging_Gdbserver - Fatal编程技术网

无法使用GDB附加到分叉子进程

无法使用GDB附加到分叉子进程,gdb,fork,remote-debugging,gdbserver,Gdb,Fork,Remote Debugging,Gdbserver,我有 在远程系统上运行 从myfile.c中摘录的代码如下: gdbserver --multi :2345 那我就接通了 159: mppts_number = index; //-------------------------- FORK------------------------------------- pid = fork(); if (pid == -1) { //syslog(LOG_INFO,"Erro

我有

在远程系统上运行

myfile.c
中摘录的代码如下:

gdbserver --multi :2345
那我就接通了

    159: mppts_number = index;

    //-------------------------- FORK-------------------------------------

    pid = fork();
    if (pid == -1)
    {
        //syslog(LOG_INFO,"Error: Start Daemon failed (%s)\n");

        return -1;
    }
    else if (!pid)
    {
        sleep(30);
        ...
    }
    else
    {
        return 0;
    }
如果我这样做了

(gdb) target extended-remote 192.168.10.248:2345
Remote debugging using 192.168.10.248:2345
(gdb) set remote exec-file a.out
(gdb) file a.out
Reading symbols from a.out...done.
(gdb) b 159
Breakpoint 1 at 0x11384: file myfile.c, line 159.
(gdb) r
Starting program: MYPATH/a.out
Reading ...
...
Breakpoint 1, main (argc=1, argv=0x7efff7c4) at myfile.c:159
159         mppts_number = index;
(gdb) n
163         pid = fork();
(gdb) n
164         if (pid == -1)
(gdb) p pid
$1 = 10459
我在
ps
中没有看到任何进程。在中间我可以看到

(gdb) attach 10459
A program is being debugged already.  Kill it? (y or n) n
Not killed.
(gdb) continue
Continuing.
[Inferior 1 (process 10458) exited normally]
(gdb) attach 10459
Attaching to program: MYPATH, process 10459
Attaching to process 10459 failed
#ps auxf | grep a.out
根10458 0.0 0.1 1824 984分/0 t+22:28 0:00 | \\uuA.out
根10459 0.0.0点/0 Z+22:28 0:00 | \[a.out]

所以,我无法附加到子项目。我还可以这样做吗?

啊,我需要在
fork
之前执行
continue
,这样过程就不会停止

# ps auxf | grep a.out
root     10458  0.0  0.1   1824   984 pts/0    t+   22:28   0:00  |           \_ a.out
root     10459  0.0  0.0      0     0 pts/0    Z+   22:28   0:00  |               \_ [a.out] <defunct>