Я пытаюсь отладить простую программу с 8 строками с gdb:
$ g++ -g 1.cpp
$ gdb a.out
(gdb) break 5
Breakpoint 1 at 0x40089e: file 1.cpp, line 5.
(gdb) run
Однако gdb просто перескочит через точку останова, и процесс просто выполняется и обычно выходит.
Но, если я работаю sudo gdb a.out
, затем это остановится на точке останова как ожидалось. Я даже пытался установить setuid, обдумал gdb исполняемый файл, но даже который не помог.
Дополнительная информация:
$ 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
Я вне идей. Что я делаю неправильно?
По неясным для меня причинам GDB использует переменную окружения SHELL. Если я запускаю это так:
$ env SHELL=/bin/bash gdb a.out
GDB останавливается на точках останова, как и ожидалось.