You are not logged in.
Pages: 1
Hey,
I installed arch on my notebook. I'm quite familiar with gdb.
Problem is that gdb is not breaking at breakpoints set before.
I would guess something is wrong with the config of gdb for my user. But I have
no idea how to debug this.
Anybody an idea?
So a simple example.c
int main(void)
{
int a = 0;
int b = 3;
int c;
c = a + b;
return 1;
}
compile it with gcc -g -o example example.c
when debugging with ~>gdb example and setting a break at e.g. line 6 it does not
break.
GNU gdb (GDB) 7.12
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-pc-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 example...done.
(gdb) break 6
Breakpoint 1 at 0x4004b8: file example.c, line 6.
(gdb) r
Starting program: /tmp/example
[Inferior 1 (process 1921) exited with code 01]
(gdb)
But if it run as root #> gdb example
...output as before
(gdb) break 6
Breakpoint 1 at 0x4004b8: file example.c, line 6.
(gdb) r
Starting program: /tmp/example
Breakpoint 1, main () at example.c:6
warning: Source file is more recent than executable.
6 c = a + b;
(gdb)
thanks
blablubs82352
Offline
I would venture that those statements were optimized out. That program returns 1. There is no output. There is no storage. a, b and c have no purpose.
Try printing c before you exit.
Edit: I stopped reading before you introduced root. Now I've no idea
Edit 2: Um, "warning: Source file is more recent than executable."
Last edited by ewaller (2016-12-20 16:12:48)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Huh, when I do exactly what you did, I have the following results:
[jbs@dmb-gaming-laptop example_debug]$ pwd
/home/jbs/cpp/tests/example_debug
[jbs@dmb-gaming-laptop example_debug]$ ls
example.c
[jbs@dmb-gaming-laptop example_debug]$ gcc -g -o example example.c
[jbs@dmb-gaming-laptop example_debug]$ ls
example example.c
[jbs@dmb-gaming-laptop example_debug]$ gdb example
GNU gdb (GDB) 7.12
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-pc-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 example...done.
(gdb) break 6
Breakpoint 1 at 0x4004b8: file example.c, line 6.
(gdb) r
Starting program: /home/jbs/cpp/tests/example_debug/example
Breakpoint 1, main () at example.c:6
6 c = a + b;
(gdb) quit
A debugging session is active.
Inferior 1 [process 1300] will be killed.
Quit anyway? (y or n) y
[jbs@dmb-gaming-laptop example_debug]$ whoami
jbs
[jbs@dmb-gaming-laptop example_debug]$
Contents of example.c:
[jbs@dmb-gaming-laptop example_debug]$ cat example.c
int main(void)
{
int a = 0;
int b = 3;
int c;
c = a + b;
return 1;
}
[jbs@dmb-gaming-laptop example_debug]$
So it worked for me, as a standard user. Is your executable owned by root by chance?? Or is /tmp owned by root in your case? It shouldn't be, AFAIK, but you wont know until you check. The "source is more recent then executable" warning, as ewaller pointed out, would also be worth investigating. I'm not sure why this worked for me but not for you.
I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.
Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...
Offline
Hi,
Recompiling doesn't make anything better. It doesn't matter where or as who the code is compiled.
I know my other netbook with similar arch setup has the same problem. But as for you, at a friend of mine it works perfectly.
I checked show configuration is the same for root and my user.
configure --host=x86_64-pc-linux-gnu --target=x86_64-pc-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)
--with-guile
--with-separate-debug-dir=/usr/lib/debug (relocatable)
--with-system-gdbinit=/etc/gdb/gdbinit
--without-babeltrace
Offline
[dimich@dimich tmp]$ cat > example.c
int main(void)
{
int a = 0;
int b = 3;
int c;
c = a + b;
return 1;
}
[dimich@dimich tmp]$ gcc -g -o example example.c
[dimich@dimich tmp]$
[dimich@dimich tmp]$ gdb ./example
GNU gdb (GDB) 7.12
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-pc-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 ./example...done.
(gdb) break 6
Breakpoint 1 at 0x4004b8: file example.c, line 6.
(gdb) r
Starting program: /home/dimich/tmp/example
Breakpoint 1, main () at example.c:6
6 c = a + b;
(gdb)
¯\_(ツ)_/¯
Offline
Hi,
mysteriously with one of the latest updates this issue disappeared.
I have no idea, what was the issue which caused this problem.
/blablubs82352
Offline
Pages: 1