GDB的問題在Ubuntu 13.04版本泊塢窗Docker version 1.1.0, build 79812e3
,並使用創建的泊塢窗容器:內搬運工人
# docker build -t gdb_problem_testing - < THIS_FILE
FROM ubuntu
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y build-essential gdb
這樣做:
[email protected] $ sudo docker run --rm -it --user=root gdb_problem_testing su root -c bash
[email protected]:/# cat <<EOF > test.c && gcc -ggdb test.c -o test && gdb -ex run test
> #include <stdio.h>
>
> int main(int argc, char **argv) {
> printf("Hello\n!");
> }
> EOF
GNU gdb (Ubuntu/Linaro 7.4-2012.02-0ubuntu2) 7.4-2012.02
Copyright (C) 2012 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-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /test...done.
Starting program: /test
[email protected] $
不運行程序。 gdb剛起來並退出。在最後一行(su <some_user> -c bash
等),請注意,我甚至得到了來自泊塢窗容器啓動並沒有返回到bash提示符(!)
我一直無法重現這在非泊塢窗環境。
如果我不su <some_user> -c bash
而不是使用bash
,則不會發生此問題。由於各種原因,必須使用su
,主要是因爲這是我發現能夠對碼頭集裝箱中的特定用戶執行ulimits的唯一方式。
爲什麼gdb不能在這種情況下工作?
編輯
複製pastable命令,在泊塢窗容器中運行:下面
cat <<EOF > test.c && gcc -ggdb test.c -o test && gdb -ex run test
#include <stdio.h>
int main(int argc, char **argv) {
printf("Hello\n!");
}
EOF
UPDATE
只是爲了表明它是在真實搞亂事情泊塢窗容器su
命令,是用bash
代替su root -c bash
做同樣的事情:
[email protected] $ sudo docker run --rm -it --user=root gdb_problem_testing bash
[email protected]:/# cat <<EOF > test.c && gcc -ggdb test.c -o test && gdb -ex run test
> #include <stdio.h>
>
> int main(int argc, char **argv) {
> printf("Hello\n!");
> }
> EOF
GNU gdb (Ubuntu/Linaro 7.4-2012.02-0ubuntu2) 7.4-2012.02
Copyright (C) 2012 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-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /test...done.
Starting program: /test
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
Hello
![Inferior 1 (process 17) exited with code 07]
(gdb)
請注意程序實際上是如何運行的(打印出「Hello」),並且我呆在gdb和docker容器中。
出於拼命亂事,我碰巧找到解決辦法。做'sudo -u root su root -c'。我沒有想法爲什麼這應該是不同的,但它是。 gdb將運行,並且所有ulimits仍然適用 –