M BUZZ CRAZE NEWS
// general

gdb skips breakpoints without sudo

By Sarah Rodriguez

I'm trying to debug simple 8-line program with gdb:

$ g++ -g 1.cpp
$ gdb a.out
(gdb) break 5
Breakpoint 1 at 0x40089e: file 1.cpp, line 5.
(gdb) run

However, gdb will just skip over the breakpoint and process just executes and exits normally.

But, if I run sudo gdb a.out, then it will stop on breakpoint as expected. I even tried setting setuid bit on gdb executable, but even that didn't help.

Additional info:

$ 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 <
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:
<
Find the GDB manual and other documentation resources online at:
<
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

I'm out of ideas. What I am doing wrong?

7

1 Answer

For reasons unclear to me gdb uses SHELL environment variable. If I run it like this:

$ env SHELL=/bin/bash gdb a.out

gdb stops at breakpoints as expected.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy