[RFA] [PATCH] gdb.base/break.exp

Michael Snyder msnyder@redhat.com
Sat Nov 25 12:24:00 GMT 2000


Michael Elizabeth Chastain wrote:
> 
> On Red Hat Linux 6.2 native, I see these test failures:
> 
>   FAIL: gdb.base/break.exp: break main #1
>   FAIL: gdb.base/break.exp: break main #2
>   FAIL: gdb.base/break.exp: clear main
> 
> I have an analysis and a patch.
> 
> First, the analysis.  This test case sets multiple breakpoints on a single
> location and then clears all of them at once.  The location for the test
> is the well-known function 'main'.
> 
> Unfortunately, at that point of the test execution, the program counter
> is in a library function __libc_start_main which has a parameter named
> 'main'.  This parameter name shadows the global function name 'main',
> so that gdb-under-test resolves the name 'main' to this parameter, not
> to the global function 'main'.  This is normal C scoping.  And of course,
> it is illegal to set a breakpoint on a parameter.
[...]

Good analysis.

> My fix is trivial: use a different function name for the
> set-multiple-breakpoints-and-clear-them-all test.

Not to be too picky, but how do you know this problem will not
crop up again with a shadowing symbol called "factorial"?

Would it be worth the effort to define a symbol in the testcase
that would be unlikely to be duplicated?  Such as maybe
"gdb_break_test_unique_symbol"?


> Michael Chastain
> chastain@redhat.com
> "love without fear"
> 
> ---
> 
> 2000-11-23  Michael Chastain  <chastain@redhat.com>
> 
>         * break.exp (test_clear_command): use a different function
>         than 'main' for the test function.  On glibc based systems,
>         __libc_start_main is the current function at this point in
>         execution, and __libc_start_main has a parameter named 'main'.
> 
> Index: gdb/testsuite/gdb.base/break.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/break.exp,v
> retrieving revision 1.6
> diff -c -3 -p -r1.6 break.exp
> *** gdb/testsuite/gdb.base/break.exp    2000/11/17 16:24:48     1.6
> --- gdb/testsuite/gdb.base/break.exp    2000/11/23 18:45:14
> *************** if [istarget "hppa*-*-hpux*"] then {
> *** 707,718 ****
> 
> 
>   proc test_clear_command {} {
> !     gdb_test "break main" "Breakpoint.*at.*" "break main #1"
> !     gdb_test "break main" "Breakpoint.*at.*" "break main #2"
> 
>       # We don't test that it deletes the correct breakpoints.  We do at
>       # least test that it deletes more than one breakpoint.
> !     gdb_test "clear main" {Deleted breakpoints [0-9]+ [0-9]+.*}
>   }
> 
>   #
> --- 707,718 ----
> 
> 
>   proc test_clear_command {} {
> !     gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #1"
> !     gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #2"
> 
>       # We don't test that it deletes the correct breakpoints.  We do at
>       # least test that it deletes more than one breakpoint.
> !     gdb_test "clear factorial" {Deleted breakpoints [0-9]+ [0-9]+.*}
>   }
> 
>   #


More information about the Gdb-patches mailing list