[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. --- gdb/symtab.c 2008-03-15 00:12:38.000000000 -0700 +++ gdb/symtab.c 2008-03-15 00:30:07.545943000 -0700 @@ -3345,7 +3345,12 @@ rbreak_command (char *regexp, int from_t } else { - break_command (SYMBOL_LINKAGE_NAME (p->msymbol), from_tty); + char *string = alloca (strlen (SYMBOL_LINKAGE_NAME(p->msymbol)) + 3); + strcpy (string, "'"); + strcat (string, SYMBOL_LINKAGE_NAME(p->msymbol)); + strcat (string, "'"); + + break_command (string, from_tty); printf_filtered (" %s;\n", SYMBOL_PRINT_NAME (p->msymbol)); } --- gdb/testsuite/gdb.base/break.exp 2008-03-15 00:12:38.000000000 -0700 +++ gdb/testsuite/gdb.base/break.exp 2008-03-15 00:29:15.680217000 -0700 @@ -944,6 +944,48 @@ gdb_expect { } +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} + +# +# test that 'rbreak' on a symbol that may be from a shared library doesn't +# cause a "Junk at end of arguments." error. +# +# On x86 GNU/Linux, this test will choke on e.g. __libc_start_main@plt. +# +# Note that this test won't necessarily choke on all targets even if +# all the rbreak issue is present. rbreak needs to match and set a +# breakpoint on a symbol causes 'break' to choke. +# + +gdb_test "set breakpoint pending on" "" "rbreak junk pending setup" + +# We expect at least one breakpoint to be set when we "rbreak main". +gdb_test "rbreak main" \ + ".*Breakpoint.*at.* file .*$srcfile, line.*" \ + "rbreak junk set breakpoint" + +# Run to a breakpoint. Fail if we see "Junk at end of arguments". +gdb_run_cmd +gdb_expect { + -re "Junk at end of arguments" { + fail "rbreak junk" + } + -re ".*Breakpoint \[0-9\]+,.*$gdb_prompt $" { + pass "rbreak junk" + } + timeout { + fail "rbreak junk (timeout)" + } +} + + # Reset the default arguments for VxWorks if [istarget "*-*-vxworks*"] { set timeout 10