From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5407 invoked by alias); 15 Mar 2008 08:18:51 -0000 Received: (qmail 5399 invoked by uid 22791); 15 Mar 2008 08:18:51 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 15 Mar 2008 08:18:17 +0000 Received: from zps36.corp.google.com (zps36.corp.google.com [172.25.146.36]) by smtp-out.google.com with ESMTP id m2F8IA2Y005653 for ; Sat, 15 Mar 2008 08:18:11 GMT Received: from rv-out-0910.google.com (rvfb22.prod.google.com [10.140.179.22]) by zps36.corp.google.com with ESMTP id m2F8I9iE001601 for ; Sat, 15 Mar 2008 01:18:10 -0700 Received: by rv-out-0910.google.com with SMTP id b22so2829677rvf.55 for ; Sat, 15 Mar 2008 01:18:09 -0700 (PDT) Received: by 10.140.133.16 with SMTP id g16mr6944438rvd.231.1205569089674; Sat, 15 Mar 2008 01:18:09 -0700 (PDT) Received: by 10.141.113.18 with HTTP; Sat, 15 Mar 2008 01:18:09 -0700 (PDT) Message-ID: <2e7be40c0803150118x58bf76c7r4bf67fc61d07c26a@mail.gmail.com> Date: Sat, 15 Mar 2008 08:18:00 -0000 From: "Chris Demetriou" To: gdb-patches@sources.redhat.com Subject: [RFA] fix for rbreak issue w/ "Junk at end of arguments" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_3622_19174285.1205569089687" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00212.txt.bz2 ------=_Part_3622_19174285.1205569089687 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 3414 Hi folks, When you 'rbreak' a pattern that matches certain symbols (e.g., those containing "@plt"), you will get a "Junk at end of arguments" error when applying the breakpoints. For instance, given the example program: #include int foo() { return 37; } int main() { printf("%d\n", foo()); } compiled with gcc -g and run under a clean build of gdb as of last night (on a 'clean' CentOS 5 system, as well as an modded Debian-derivative system): [cgd@blue tmp]$ gdb/bld.clean/gdb/gdb a.out GNU gdb 6.8.50.20080315-cvs Copyright (C) 2008 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-unknown-linux-gnu"... (gdb) rbreak printf Function "printf" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (printf@plt) pending. printf@plt; (gdb) run Starting program: /tmp/a.out Error in re-setting breakpoint 1: Junk at end of arguments. 37 Program exited with code 03. (gdb) Note the pending breakpoint query, the error setting the breakpoint, and the fact that the breakpoint wasn't hit. What seems to be happening is that when setting the breakpoint, breakpoint_re_set_one is called. This calls decode_line_1 which in turn calls skip_quoted, which ultimately leaves "@plt" as something to be left over after stopping the symbol name at "printf". (My analysis may be a bit off, I actually debugged this using an optimized gdb binary, stupid me.) The attached patch fixes this by quoting the symbol name. (The symbol name is actually quoted in one case in rbreak_command already, this gets the other.) With the patch, as expected: [cgd@blue tmp]$ gdb/bld.dirty/gdb/gdb a.out GNU gdb 6.8.50.20080315-cvs Copyright (C) 2008 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-unknown-linux-gnu"... (gdb) rbreak printf Breakpoint 1 at 0x400398 printf@plt; (gdb) run Starting program: /tmp/a.out Breakpoint 1, 0x0000000000400398 in printf@plt () (gdb) No pending breakpoint query, no breakpoint-setting error, and breakpoint is hit as expected. (FWIW, i originally tripped over this on a symbol other than printf. That was just something easy for the example. And, others out in the world have seen this too, e.g., http://community.livejournal.com/evan_tech .) Tested manually as shown above, plus by running gdb 'make check' before/after symtab.c patch. Only change is that the new test goes from FAIL to PASS. If this patch is acceptable, please apply it. (I don't have write access.) chris --- [gdb/ChangeLog] 2008-03-15 Chris Demetriou * symtab.c (rbreak_command): Quote symbol name before passing it to break_command. [gdb/testsuite/ChangeLog] 2008-03-15 Chris Demetriou * gdb.base/break.exp (rbreak junk): New test for rbreak "Junk at end of arguments" issue. ------=_Part_3622_19174285.1205569089687 Content-Type: text/x-patch; name=gdb-rbreak.patch Content-Transfer-Encoding: base64 X-Attachment-Id: f_fdtwhsvn0 Content-Disposition: attachment; filename=gdb-rbreak.patch Content-length: 3103 W2dkYi9DaGFuZ2VMb2ddCjIwMDgtMDMtMTUgIENocmlzIERlbWV0cmlvdSAg PGNnZEBnb29nbGUuY29tPgoKICAgICAgICAqIHN5bXRhYi5jIChyYnJlYWtf Y29tbWFuZCk6IFF1b3RlIHN5bWJvbCBuYW1lIGJlZm9yZSBwYXNzaW5nCglp dCB0byBicmVha19jb21tYW5kLgoKW2dkYi90ZXN0c3VpdGUvQ2hhbmdlTG9n XQoyMDA4LTAzLTE1ICBDaHJpcyBEZW1ldHJpb3UgIDxjZ2RAZ29vZ2xlLmNv bT4KCiAgICAgICAgKiBnZGIuYmFzZS9icmVhay5leHAgKHJicmVhayBqdW5r KTogTmV3IHRlc3QgZm9yIHJicmVhawoJIkp1bmsgYXQgZW5kIG9mIGFyZ3Vt ZW50cyIgaXNzdWUuCgoKLS0tIGdkYi9zeW10YWIuYwkyMDA4LTAzLTE1IDAw OjEyOjM4LjAwMDAwMDAwMCAtMDcwMAorKysgZ2RiL3N5bXRhYi5jCTIwMDgt MDMtMTUgMDA6MzA6MDcuNTQ1OTQzMDAwIC0wNzAwCkBAIC0zMzQ1LDcgKzMz NDUsMTIgQEAgcmJyZWFrX2NvbW1hbmQgKGNoYXIgKnJlZ2V4cCwgaW50IGZy b21fdAogCX0KICAgICAgIGVsc2UKIAl7Ci0JICBicmVha19jb21tYW5kIChT WU1CT0xfTElOS0FHR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5rICh0aW1lb3V0KSIKKyAgICB9Cit9CisKKwogIyBSZXNldCB0aGUg ZGVmYXVsdCBhcmd1bWVudHMgZm9yIFZ4V29ya3MKIGlmIFtpc3RhcmdldCAi Ki0qLXZ4d29ya3MqIl0gewogICAgIHNldCB0aW1lb3V0IDEwCg== ------=_Part_3622_19174285.1205569089687--