This is the mail archive of the gdb-patches@sources.redhat.com 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: Add support for target switches in simulator


Nick Clifton wrote:
> 
> Hi Guys,
> 
>   I would like permission to apply the following patch.  It adds the
>   ability for simulator backends to parse their own command line
>   switches, thus creating target specific simulator options.
> 
>   I would like this facility in order to be able to add a new switch
>   to the ARM simulator - a switch to select which set(s) of SWI
>   emulations it should perform.
> 
>   I have not worked out how this feature would be accessed from GDB.
>   My guess is that the switches could be added to the arguments passed
>   via sim_open(), but how would a GDB user tell GDB to add these
>   switches ?

>From memory, don't you do something like:

	(gdb) target sim xxx=yyy


> 
> Cheers
>         Nick
> 
> sim/common/ChangeLog
> 2002-05-16  Nick Clifton  <nickc@cambridge.redhat.com>
> 
>         * run.c (main): Call sim_target_parse_command_line if
>         SIM_TARGET_SWITCHES is defined.
>         (usage): Call sim_target_display_usage if SIM_TARGET_SWITCHES
>         is defined.
> 
> include/ChangeLog
> 2002-05-16  Nick Clifton  <nickc@cambridge.redhat.com>
> 
>         * remote-sim.h: Provide prototypes for
>         sim_target_parse_command_line and sim_target_display_usage
>         if SIM_TARGET_SWITCHES is defined.
> 
> Index: sim/common/run.c
> ===================================================================
> RCS file: /cvs/src/src/sim/common/run.c,v
> retrieving revision 1.7
> diff -c -3 -p -w -r1.7 run.c
> *** sim/common/run.c    21 Dec 2001 00:47:18 -0000      1.7
> --- sim/common/run.c    16 May 2002 16:04:36 -0000
> *************** main (ac, av)
> *** 111,116 ****
> --- 111,120 ----
>     default_callback.init (&default_callback);
>     sim_set_callbacks (&default_callback);
> 
> + #ifdef SIM_TARGET_SWITCHES
> +   ac = sim_target_parse_command_line (ac, av);
> + #endif
> +
>     /* FIXME: This is currently being rewritten to have each simulator
>        do all argv processing.  */
> 
> *************** usage ()
> *** 334,338 ****
> --- 338,346 ----
>     fprintf (stderr, "\n");
>     fprintf (stderr, "program args    Arguments to pass to simulated program.\n");
>     fprintf (stderr, "                Note: Very few simulators support this.\n");
> + #ifdef SIM_TARGET_SWITCHES
> +   fprintf (stderr, "\nTarget specific options:\n");
> +   sim_target_display_usage ();
> + #endif
>     exit (1);
>   }
> 
> Index: include/remote-sim.h
> ===================================================================
> RCS file: /cvs/src/src/include/remote-sim.h,v
> retrieving revision 1.4
> diff -c -3 -p -w -r1.4 remote-sim.h
> *** include/remote-sim.h        14 Mar 2001 02:27:43 -0000      1.4
> --- include/remote-sim.h        16 May 2002 16:07:49 -0000
> *************** void sim_set_profile_size PARAMS ((int n
> *** 346,351 ****
> --- 346,362 ----
>      multi-cpu simulators. */
> 
>   void sim_kill PARAMS ((SIM_DESC sd));
> +
> + #ifdef SIM_TARGET_SWITCHES
> +   /* Parse the command line, extracting any target specific switches
> +      before the generic simulator code gets a chance to complain
> +      about them.  Returns the adjusted value of argc.  */
> + int sim_target_parse_command_line PARAMS ((int, char **));
> +
> +   /* Display a list of target specific switches supported by this
> +      target.  */
> + void sim_target_display_usage PARAMS ((void));
> + #endif
> 
>   #ifdef __cplusplus
>   }


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