From: Ender Dai <xdai@uoregon.edu>
To: gdb@sourceware.org
Subject: gdb behavior on tight loop
Date: Wed, 24 Jul 2013 03:51:00 -0000 [thread overview]
Message-ID: <87r4eopqdb.fsf@cortana.d.cs.uoregon.edu> (raw)
Hi,
I just find some counterintuitive (to me) behavior of gdb on tight
loop. Please see the gdb session below. When I run "next" on line 5, the
tight loop, it will take several seconds before gdb stop on line 6 and I
regain control. Strace shows that it looks like gdb is doing some magic
in every iteration.
If I set an additional breackpoint on line 6, and "continue" on line 5
instead of "next", everything looks good.
Is this supposed behavior? What is gdb doing undercover?
(There is a warning message about vdso, but google tell me that it
should be fine...)
Thanks,
Ender
$ gdb a.out
GNU gdb (GDB) 7.6 (Debian 7.6-5)
Copyright (C) 2013 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://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ender/src/tmp/a.out...done.
(gdb) l
1 int
2 main(void)
3 {
4 int i;
5 for (i=0; i<100000; i++);
6 return 0;
7 }
(gdb) b 5
Breakpoint 1 at 0x4004b1: file loop.c, line 5.
(gdb) r
Starting program: /home/xdai/src/tmp/a.out
warning: no loadable sections found in added symbol-file system-supplied
DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Breakpoint 1, main () at loop.c:5
5 for (i=0; i<100000; i++);
(gdb) n
6 return 0;
(gdb)
$ uname -a
Linux cortana 3.9-1-amd64 #1 SMP Debian 3.9.8-1 x86_64 GNU/Linux
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.8.1-7'
--with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib
--enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc
--enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Debian 4.8.1-7)
next reply other threads:[~2013-07-24 3:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 3:51 Ender Dai [this message]
2013-07-24 12:23 ` Abid, Hafiz
2013-07-24 17:25 ` Ender Dai
2013-07-24 21:17 ` John Gilmore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r4eopqdb.fsf@cortana.d.cs.uoregon.edu \
--to=xdai@uoregon.edu \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox