Proposal: New command "begin"

Andrew Cagney cagney@gnu.org
Tue Apr 6 21:40:00 GMT 2004


> Hello,
> 
> There is a command that we have been using for quite a while for Ada,
> which could be useful to all languages, so I am proposing the addition
> of this command for all languages. The purpose of this message is to
> start a discussion regarding this command, whether it would be desirable
> as a command available for all language, and if yes, then what its
> user interface and effect (semantics) should be. The actual
> implementation will be discussed separately.

This one is many layered.

- I think GDB's current source-and-line, should be initialized to 
"main", as defined by the language.  That way operations such as:
   $ gdb java-program
   (gdb) break
   Breakpoint 1 at foo.java:14 Foo::Main(...)
   (gdb) run
   Hit breakpoint 1 foo.java:14
   (gdb)
work.

- Perhaphs a GDB variable ($main?) that points to the program entry point.

- And yes, some sort of command to perform a "runto_main".  It's a 
sufficiently standard GUI operation to justify its presence.

I'm just not sure about "begin" as a good choice of command name - 
begin goes better with end, and that's a compound command terminator.

Is this mainly for GUI, or the user?

Andrew

> New command: ``begin''
> ======================
> 
> <<
> Depending on the language, the name of the main procedure can vary.
> With languages such as C or C++, the main procedure name is always
> main(), but other languages such as Ada do not require a specific
> name for their main procedure. The debugger provides a convenient
> way to begin the execution of the program and to stop at the beginning
> of the main procedure, depending on the language used.
> 
> begin
> 
>     Does the equivalent of setting a temporary breakpoint at the
>     beginning of the main procedure and then performing run. Some
>     programs contain an elaboration phase that will be performed before
>     the main procedure is reached, and it is possible that the debugger
>     will stop before reaching the main procedure. However, the temporary
>     breakpoint will remain to halt execution.
> 
> It is sometimes necessary to debug the program during elaboration. In
> these cases, using the begin command would stop the execution of your
> program too late, as the program would have already completed the
> elaboration phase. Under these circumstances, insert breakpoints in
> your elaboration code before running your program.
> 
>>>>>
> 
> 
> So, for a language such as C, this command would only be a shortcut
> for "tbreak main; run". I am not completely sure on how elaboration
> is performed in C++, but I think it's done before procedure main()
> is called, so "begin" would also be the equivalent of "tbreak main;
> run" as well. How about Objective-C? Fortran? What should we do
> for Asm? For Ada, we use that command to search the executable for
> the name of the main program name, and then insert a breakpoint
> there.
> 
> For the "minimal" language and "asm", I would suggest that we do the
> same as in C, which is to tbreak on main and then run.
> 
> Opinions?
> -- Joel 




More information about the Gdb mailing list