Por razões não claras para mim, o gdb usa a variável de ambiente SHELL. Se eu correr assim:
$ env SHELL=/bin/bash gdb a.out
O gdb pára nos pontos de interrupção conforme esperado.
Estou tentando depurar um programa simples de 8 linhas com o gdb:
$ g++ -g 1.cpp
$ gdb a.out
(gdb) break 5
Breakpoint 1 at 0x40089e: file 1.cpp, line 5.
(gdb) run
No entanto, o gdb apenas pula o ponto de interrupção e o processo simplesmente executa e sai normalmente.
Mas, se eu executar sudo gdb a.out
, ele será interrompido no ponto de interrupção conforme o esperado. Eu até tentei definir setuid bit no executável gdb, mas mesmo isso não ajudou.
Informação adicional:
$ sudo sysctl --all | grep yama
kernel.yama.ptrace_scope = 0
$ stat 'which gdb'
File: '/usr/bin/gdb'
Size: 6546408 Blocks: 12792 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 19136921 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-05-05 16:04:28.364144348 +0300
Modify: 2016-06-23 22:55:06.000000000 +0300
Change: 2017-05-05 16:04:16.771898651 +0300
Birth: -
$ gdb
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 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".
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".
(gdb) show config
This GDB was configured as follows:
configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-auto-load-dir=$debugdir:$datadir/auto-load
--with-auto-load-safe-path=$debugdir:$datadir/auto-load
--with-expat
--with-gdb-datadir=/usr/share/gdb (relocatable)
--with-jit-reader-dir=/usr/lib/gdb (relocatable)
--without-libunwind-ia64
--with-lzma
--with-python=/usr (relocatable)
--without-guile
--with-separate-debug-dir=/usr/lib/debug (relocatable)
--with-system-gdbinit=/etc/gdb/gdbinit
--with-babeltrace
Estou sem ideias. O que estou fazendo errado?
Por razões não claras para mim, o gdb usa a variável de ambiente SHELL. Se eu correr assim:
$ env SHELL=/bin/bash gdb a.out
O gdb pára nos pontos de interrupção conforme esperado.