public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Proposal: New command "begin"
@ 2004-04-01 20:37 Joel Brobecker
  2004-04-06 21:40 ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2004-04-01 20:37 UTC (permalink / raw)
  To: gdb

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.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proposal: New command "begin"
  2004-04-01 20:37 Proposal: New command "begin" Joel Brobecker
@ 2004-04-06 21:40 ` Andrew Cagney
  2004-04-07  7:40   ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Cagney @ 2004-04-06 21:40 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb

> 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 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proposal: New command "begin"
  2004-04-06 21:40 ` Andrew Cagney
@ 2004-04-07  7:40   ` Joel Brobecker
  2004-04-16  3:44     ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2004-04-07  7:40 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb

> - 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.

Hmmm, could be nice.

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

(frown) I am not too keen on this one.

> - 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.

I like "begin", but I'm not that attached to this name. If we can agree
on a better command name, I'll take care of sending an implementation
plan on gdb-patches.

> Is this mainly for GUI, or the user?

Both, actually. We have a button for it in our GUI, but I use it all the
time, and never use a GUI.

-- 
Joel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proposal: New command "begin"
  2004-04-07  7:40   ` Joel Brobecker
@ 2004-04-16  3:44     ` Joel Brobecker
  0 siblings, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2004-04-16  3:44 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb

> > 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.
> 
> I like "begin", but I'm not that attached to this name. If we can agree
> on a better command name, I'll take care of sending an implementation
> plan on gdb-patches.

Any suggestion for a better command name, instead of "begin"?

-- 
Joel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proposal: New command "begin"
@ 2004-04-16 15:12 Michael Elizabeth Chastain
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Elizabeth Chastain @ 2004-04-16 15:12 UTC (permalink / raw)
  To: brobecker, cagney; +Cc: gdb

Joel> Any suggestion for a better command name, instead of "begin"?

"start" ?

Michael C

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proposal: New command "begin"
@ 2004-04-07  2:23 Michael Elizabeth Chastain
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Elizabeth Chastain @ 2004-04-07  2:23 UTC (permalink / raw)
  To: brobecker, cagney; +Cc: gdb

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

I agree with this.

> 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.

I agree with this too.

Perhaps 'start' ?

Overall I think this would be a useful new command.

Michael C

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-04-16  3:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-01 20:37 Proposal: New command "begin" Joel Brobecker
2004-04-06 21:40 ` Andrew Cagney
2004-04-07  7:40   ` Joel Brobecker
2004-04-16  3:44     ` Joel Brobecker
2004-04-07  2:23 Michael Elizabeth Chastain
2004-04-16 15:12 Michael Elizabeth Chastain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).