Article View: gnu.gdb.bug
Article #1282gdb and catching SIGINT
From: Brian Eaton
Date: Wed, 15 Jun 2005 19:25
Date: Wed, 15 Jun 2005 19:25
115 lines
5839 bytes
5839 bytes
--0-1880632445-1118863539=:30651 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Id: Content-Disposition: inline Hello all - I'm working on debugging a program that uses sigwait() to wait for SIGINT to catch ctrl-C. I normally use "ctrl-C" in gdb to interrupt execution so I can set breakpoints, examine variables, etc... but when I attach to this program and use ctrl-C, the signal gets passed to the program instead of being intercepted by gdb. This is somewhat bothersome. Is what I am seeing "as-designed" behavior for gdb? Is there some configuration option I can set to avoid it? I have a test program that shows what happens. Here's an example of what I'm doing: In one terminal window, I start up my test program: $ ./int Program started, waiting for signal Then, in another terminal, I attach to the program with gdb and use "cont" to allow it to continue executing: $ gdb --pid=6814 GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu". Attaching to process 6814 Reading symbols from /home/beaton/ctrlc/int...done. Using host libthread_db library "/lib/tls/libthread_db.so.1". Reading symbols from /lib/tls/libpthread.so.0...done. [Thread debugging using libthread_db enabled] [New Thread 1075093632 (LWP 6814)] Loaded symbols for /lib/tls/libpthread.so.0 Reading symbols from /lib/tls/libc.so.6...done. Loaded symbols for /lib/tls/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 0xffffe410 in ?? () (gdb) cont Meanwhile, my test program logs this message: Wokeup, err = 4, sig = 0 Finally, I hit ctrl-C in the gdb terminal window. When that happens, my test program logs these messages and exits: Wokeup, err = 0, sig = 2 Got signal 2, exiting. And then gdb prints Program exited normally. (gdb) The "handle SIGINT" command reports that gdb is set to stop and print that signal, but not to pass it to the program. I'm attaching the test program to this message. Regards, Brian __________________________________ Discover Yahoo! Stay in touch with email, IM, photo sharing and more. Check it out! http://discover.yahoo.com/stayintouch.html --0-1880632445-1118863539=:30651 Content-Type: application/octet-stream; name="int.c" Content-Transfer-Encoding: base64 Content-Description: 1602041336-int.c Content-Disposition: attachment; filename="int.c" Ci8qIGdjYyAtZyAtV2FsbCBpbnQuYyAtbHB0aHJlYWQgLW8gaW50ICovCgoj aW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVk ZSA8c2lnbmFsLmg+CiNpbmNsdWRlIDxlcnJuby5oPgojaW5jbHVkZSA8cHRo cmVhZC5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDx1bmlzdGQu aD4KCmludAptYWluKGludCBhcmdjLCBjaGFyICoqYXJndikKewogICAgaW50 IGVycjsKICAgIHNpZ3NldF90IHNldDsKICAgIGludCBzaWc7CgogICAgcHJp bnRmKCJQcm9ncmFtIHN0YXJ0ZWQsIHdhaXRpbmcgZm9yIHNpZ25hbC5cbiIp OwogICAgaWYgKHNpZ2VtcHR5c2V0KCZzZXQpKSB7CiAgICAgICAgcHJpbnRm KCJzaWdlbXB0eXNldCBmYWlsZWQ6ICVzXG4iLCBzdHJlcnJvcihlcnJubykp OwogICAgICAgIGV4aXQoMSk7CiAgICB9CiAgICBpZiAoc2lnYWRkc2V0KCZz ZXQsIFNJR0lOVCkpIHsKICAgICAgICBwcmludGYoInNpZ2FkZHNldCBmb3Ig U0lHSU5UIGZhaWxlZDogJXNcbiIsIHN0cmVycm9yKGVycm5vKSk7CiAgICAg ICAgZXhpdCgxKTsKICAgIH0KICAgIGVyciA9IHB0aHJlYWRfc2lnbWFzayhT SUdfQkxPQ0ssICZzZXQsIE5VTEwpOwogICAgaWYgKDAgIT0gZXJyKSB7CiAg ICAgICAgcHJpbnRmKCJwdGhyZWFkX3NpZ21hc2sgZmFpbGVkOiAlc1xuIiwg c3RyZXJyb3IoZXJyKSk7CiAgICAgICAgZXhpdCgxKTsKICAgIH0KICAgIGRv IHsKICAgICAgICBzaWcgPSAwOwogICAgICAgIGVyciA9IHNpZ3dhaXQoJnNl dCwgJnNpZyk7CglwcmludGYoIldva2V1cCwgZXJyID0gJWQsIHNpZyA9ICVk XG4iLCBlcnIsIHNpZyk7CiAgICB9IHdoaWxlIChFSU5UUiA9PSBlcnIpOwog ICAgcHJpbnRmKCJHb3Qgc2lnbmFsICVkLCBleGl0aW5nLlxuIiwgc2lnKTsK ICAgIGV4aXQoMCk7Cn0K --0-1880632445-1118863539=:30651--
Technical Details
Message-ID:
<mailman.100.1118863598.2857.bug-gdb@gnu.org>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f5053,841770da7276c57c,start X-Google-Attributes: gidf5053,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail From: Brian Eaton <brian95060@yahoo.com> Newsgroups: gnu.gdb.bug Subject: gdb and catching SIGINT Date: Wed, 15 Jun 2005 12:25:39 -0700 (PDT) Lines: 117 Approved: bug-gdb@gnu.org Message-ID: <mailman.100.1118863598.2857.bug-gdb@gnu.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0-1880632445-1118863539=:30651" Content-Transfer-Encoding: 8bit X-Trace: news.Stanford.EDU 1118863582 15509 199.232.76.165 (15 Jun 2005 19:26:22 GMT) X-Complaints-To: news@news.stanford.edu To: bug-gdb@gnu.org Envelope-to: bug-gdb@gnu.org DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Jk8HYDAe8OXdHU9WsU7dFHg+Lv5r+c8wbreuxNzecefuLZPGkiAyW0vtpKt/chmmqLUD3VfCgf+ABuYn4lxF/4s3YxUeOsOtsJpeoEREzltLKIiDt3hlV7B1Dr1MtMXPNSnJxeFDzrP944pQ7chAgQE3Nz0goZXENiAfTqSDv0U= ; X-BeenThere: bug-gdb@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GDB, the GNU debugger" <bug-gdb.gnu.org> List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-gdb>, <mailto:bug-gdb-request@gnu.org?subject=unsubscribe> List-Archive: <http://lists.gnu.org/pipermail/bug-gdb> List-Post: <mailto:bug-gdb@gnu.org> List-Help: <mailto:bug-gdb-request@gnu.org?subject=help> List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-gdb>, <mailto:bug-gdb-request@gnu.org?subject=subscribe>