2017-08-24 56 views
0

我想使用eclipse IDE作爲前端GUI來調試另一個在我的主機中停泊的OS的核心文件。通過Docker中的'gdbserver',我只能調試正在運行的進程。但是我需要對核心文件進行驗屍調試。使用eclipse進行遠程核心文件分析

我嘗試使用

docker exec -it $DOCKER_CONTAINER bash -c "gdb /usr/bin/executable /opt/crash/executable.core 

這個工程使用的外殼部分的/ home/ME /斌/ remote_gdb包裝。因爲

Could not determine GDB version using command: remote_gdb --version 

即使「remote_gdb --version」打印出完全一樣的原始「的gdb --version」,但它沒有使用「日蝕」。

我可以做一些工作, 'DDD' 作爲前端 - 讓我練習:

> cd $HOME/SRC 
> ls -l 
total 4 
-rw-rw-r-- 1 frank frank 96 Aug 24 18:04 test.c 

> cat test.c 
#include <stdio.h> 

int main(int argc, char** argv) 
{ 
    printf("hello, world!\n"); 
    return 0; 
} 

> docker run -v $HOME/SRC:/SRC -t fedora /bin/bash 
// IN DOCKER NOW: 
>> yum install gcc 
[...] 
>> yum install gdb 
[...] 
>> cd /SRC 
>> gcc -g3 -O0 -o test test.c 
>> ls -l 
total 40 
-rwxr-xr-x 1 root root 34864 Aug 24 16:26 test 
-rw-rw-r-- 1 1000 1000 96 Aug 24 16:04 test.c 

回到主持人:

> docker ps 
CONTAINER ID  IMAGE    COMMAND    CREATED    STATUS    PORTS    NAMES 
e501d8384060  fedora    "/bin/bash"   4 minutes ago  Up 4 minutes       stupefied_murdock 
> cat $HOME/bin/remote_gdb 
#!/bin/bash 
docker exec -it e501d8384060 gdb /SRC/test 

> remote_gdb # $HOME/bin/ is in $PATH 
GNU gdb (GDB) Fedora 8.0-20.fc26 
Copyright (C) 2017 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "x86_64-redhat-linux-gnu". 
Type "show configuration" for configuration details. 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>. 
Find the GDB manual and other documentation resources online at: 
<http://www.gnu.org/software/gdb/documentation/>. 
For help, type "help". 
Type "apropos word" to search for commands related to "word"... 
Reading symbols from /SRC/test...done. 
(gdb) list 
1 #include <stdio.h> 
2 
3 int main(int argc, char** argv) 
4 { 
5  printf("hello, world!\n"); 
6  return 0; 
7 } 
8 
(gdb) 

切換回外殼,我在碼頭 - 看到'gdb'正在運行:

>> yum install procps-ng 
[...] 
>> ps -ef 
UID  PID PPID C STIME TTY   TIME CMD 
root   1  0 0 16:22 ?  00:00:00 /bin/bash 
root  16  0 0 16:23 ?  00:00:00 bash 
root  116  0 0 16:28 ?  00:00:00 gdb /SRC/test 
root  131 16 0 16:30 ?  00:00:00 ps -ef 

再次打開主機外殼(在泊塢窗後退出GDB會話):

> ddd --debugger remote_gdb 

的 'DDD' 很好用gdb扮演碼頭工人開始。 它也適用於核心文件(添加「睡眠(100);」並殺死進程)。 但是'ddd'沒有一個非常好的GUI。 那麼用'eclipse'做這種工作的方式是什麼? 我也不能使它與其他選項的工作: 'qtcreator', 'KDevelop的', 'nemiver', '工具KDbg' 等

附錄:

它也不會一起工作「 ssh'進入容器。 但是,當我執行相同的'remote_gdb'包裝腳本作爲'外部工具'它可以執行(?!)

回答

0

我部分可以解決這個問題。
主要問題是:我的docker命令不提供eclipse的tty。
作爲一種解決方法,我將「ssh」切換到泊塢窗圖像中。
此外,我必須在主機和docker映像之間對齊文件位置(可執行文件,核心文件和源文件)。由於使用'gdb'包裝腳本,'eclipse'不知道我正在遠程調試並驗證所有文件的本地可用性。

這適用於驗屍調試(核心文件分析)並將運行的進程附加在docker中(通常在遠程系統上)。
但是,它的確不是而是通過eclipse在gdb中啓動進程。

所以用'strace'來檢查'eclipse'和'gdb'之間的活動,並發現,爲了在'gdb'中啓動一個新進程,'eclipse'嘗試應用一些'--interpreter mi2 -nx」命令:

遜色-TTY設置--thread組I1的/ dev/PTS/27

這是否意味着它試圖綁定本地TTY入庫?
這當然不能遠程工作。

'eclipse'使用「inferior-tty-set」的原因是什麼?
它不使用此命令進行驗屍調試或附加正在運行的進程 - 雖然我甚至有一個可在'eclipse'中使用的gdb控制檯