This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [commit] add some comments to testsuite/lib/gdb.exp


On Saturday 03 December 2011 18:07:50, Doug Evans wrote:

>  #
> -# runto_main -- ask gdb to run until we hit a breakpoint at main.
> -#              The case where the target uses stubs has to be handled
> -#              specially--if it uses stubs, assuming we hit
> -#              breakpoint() and just step out of the function.
> -#
> +# N.B. This function deletes all existing breakpoints.
> +# If you don't want that, use gdb_start_cmd.

"() use gdb_start_cmd.  Note that gdb_start_cmd doesn't work with
remote targets, so you will consequently need to skip your
test accordingly".


> +
>  proc runto_main { } {
>      global gdb_prompt
>      global decimal
> @@ -472,7 +478,6 @@ proc runto_main { } {
>      return 1
>  }
>  
> -
>  ### Continue, and expect to hit a breakpoint.
>  ### Report a pass or fail, depending on whether it seems to have
>  ### worked.  Use NAME as part of the test name; each call to
> @@ -3142,6 +3147,32 @@ proc setup_kfail_for_target { PR target 
>      }
>  }
>  
> +# Test programs for embedded (often "bare board") systems sometimes use a
> +# "stub" either embedded in the test program itself or in the boot rom.
> +# The job of the stub is to implement the remote protocol to communicate
> +# with gdb and control the inferior.  To initiate the remote protocol
> +# session with gdb the stub needs to be given control by the inferior.
> +# They do this by calling a function that typically triggers a trap
> +# from main that transfers control to the stub.
> +# The purpose of this function, gdb_step_for_stub, is to step out of
> +# that function ("breakpoint" in the example below) and back into main.
> +#
> +# Example:
> +#
> +# int
> +# main ()
> +# {
> +# #ifdef usestubs
> +#  set_debug_traps (); /* install trap handlers for stub */
> +#  breakpoint (); /* trigger a trap to give the stub control */
> +# #endif
> +#  /* test program begins here */
> +# }
> +#
> +# Note that one consequence of this design is that a breakpoint on "main"
> +# does not Just Work (because if the target could stop there you still have
> +# to step past the calls to set_debug_traps,breakpoint).
> +

I think your patch is fine.  Okay with me.

But I do wonder whether there is still anyone making use of this.
Can't we just zap all of the #ifdef usestubs bits?
There are zillions of tests that don't make have usestubs support
in their main.  It must be pretty broken?
All the stubs I've seen thus far that needed to do something magical,
did it transparently, before main is reached, e.g., with extra startup
glue, and board file magic, which IMO is the Right Way.

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]