From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17859 invoked by alias); 6 Apr 2004 21:40:52 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 17837 invoked from network); 6 Apr 2004 21:40:49 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 6 Apr 2004 21:40:49 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i36Lencu026137 for ; Tue, 6 Apr 2004 17:40:49 -0400 Received: from localhost.redhat.com (to-dhcp51.toronto.redhat.com [172.16.14.151]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i36Lemj01799; Tue, 6 Apr 2004 17:40:48 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 642B12B9C; Tue, 6 Apr 2004 17:40:51 -0400 (EDT) Message-ID: <407323E3.6010801@gnu.org> Date: Tue, 06 Apr 2004 21:40:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Joel Brobecker Cc: gdb@sources.redhat.com Subject: Re: Proposal: New command "begin" References: <20040401203716.GX888@gnat.com> In-Reply-To: <20040401203716.GX888@gnat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-04/txt/msg00043.txt.bz2 > 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