From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13057 invoked by alias); 6 Dec 2007 16:27:32 -0000 Received: (qmail 13043 invoked by uid 22791); 6 Dec 2007 16:27:29 -0000 X-Spam-Check-By: sourceware.org Received: from ics.u-strasbg.fr (HELO ics.u-strasbg.fr) (130.79.112.250) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 06 Dec 2007 16:27:22 +0000 Received: from ICSMULLER (laocoon.u-strasbg.fr [130.79.112.72]) by ics.u-strasbg.fr (Postfix) with ESMTP id C4D7C18701E; Thu, 6 Dec 2007 17:31:40 +0100 (CET) From: "Pierre Muller" To: "'Pedro Alves'" Cc: References: <47112285.2080100@portugalmail.pt> <001601c83720$5a6ccca0$0f4665e0$@u-strasbg.fr> <47572C3C.70000@portugalmail.pt> In-Reply-To: <47572C3C.70000@portugalmail.pt> Subject: RE: [RFC] testsuite: Skip over function prologue in runto and runto_main Date: Thu, 06 Dec 2007 16:34:00 -0000 Message-ID: <002a01c83824$dc461e20$94d25a60$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Content-Language: en-us Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00107.txt.bz2 > > Here is the proposed patch: > > > > It basically defines two new globals variables in gdb.exp: > > 1) skip_function_prologue > > that should be "yes" if gdb should execute a 'next' statement > > if after the 'runto' procedure it arrives at a line that contains > > only an opening brace. > > > > 2) skip_main_function_prologue > > Which does the same, but only within runto_main procedure. > > This variable is set to "yes" if EXEEXT env is different from "". > > But this is probably not the right condition. > > I have no good idea how to set that variable, but > > maybe setting it unconditionally would be OK too. > > > > > > What problem is 1) trying to solve? It is mainly because runto_main is calling runto procedure, and that the patterns are only inside runto procedure. But as said, this would probably allow to skip implicit code that is not recognized as part of the prologue. As programmer of the Free Pascal Compiler, I know that there is quite some implicit code hidden inside the 'begin' pascal statement (equivalent of the C open brace), like exception stack setup, win32 special call to avoid stack faults for big local stack areas, implicit class initialization... To handle this we would just need to replace the open brace by a variable possibly named 'function_start_token' defaulting to '{' but that would be changed into 'begin' for pascal, and probably also for 'ada' or ''. > Just a nit, but __main call is not really considered part > of the prologue. It's emitted as the first statement > of the body of main. But this is the main problem here: many testsuite expect files do assume that by using runto_main you arrive on the first explicit statement in the main function. Thus if the call to __main is implicit, we need to decide if gdb should place the breakpoint past that implicit call, which is what your patch does, but to me this is the same as saying that the call to main is part of the prologue. But you just said the opposite. My patch would rather be something like, for the main function: a call to __main is the first statement on some targets, but we do not what to make any differences between those targets and others (which call __main before main, or not at all) and thus we skip any implicit code, which would be better found by the fact that the open brace is the last part of the line where we stop. I think that the pattern that I used should also find lines that contain both the main and the open brace; possible errors would be something like main (int argc; char** argv) { if (argc >0) { ... where my patch would go too far, but that is probably easy to correct with a pattern allowing only a single open brace. The call to mcount in case of profiling could be handled with the same logic, no? So finally the main question remains to decide whether the call to __main (in main) (or mcount in profiled function) should be considered as part of the prologue or handled a real statements, even though they are implicit. Pierre