From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18445 invoked by alias); 7 Jan 2007 12:03:24 -0000 Received: (qmail 18434 invoked by uid 22791); 7 Jan 2007 12:03:23 -0000 X-Spam-Check-By: sourceware.org Received: from nile.gnat.com (HELO nile.gnat.com) (205.232.38.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 07 Jan 2007 12:03:17 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-nile.gnat.com (Postfix) with ESMTP id 6F10348CBE9 for ; Sun, 7 Jan 2007 07:03:15 -0500 (EST) Received: from nile.gnat.com ([127.0.0.1]) by localhost (nile.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 23606-01-10 for ; Sun, 7 Jan 2007 07:03:15 -0500 (EST) Received: from takamaka.act-europe.fr (AStDenis-105-1-33-164.w80-8.abo.wanadoo.fr [80.8.163.164]) by nile.gnat.com (Postfix) with ESMTP id AD8FF48CC21 for ; Sun, 7 Jan 2007 07:03:13 -0500 (EST) Received: by takamaka.act-europe.fr (Postfix, from userid 1000) id 235B834C099; Sun, 7 Jan 2007 16:04:02 +0400 (RET) Date: Sun, 07 Jan 2007 12:03:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA/ada] cleanup a bit is_known_support_routine Message-ID: <20070107120401.GA17004@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i 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-01/txt/msg00209.txt.bz2 --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 450 As said before, this relatively old code could uses some cleanup. This patch depends on another earlier patch being applied: [RFA/ada] Improve is_known_support_routine http://www.sourceware.org/ml/gdb-patches/2007-01/msg00208.html 2007-01-07 Joel Brobecker * ada-lang.c (is_known_support_routine): Improve the implementation. Tested on x86-linux. No regression. Ok to apply? Thank you, -- Joel --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="cleanup.diff" Content-length: 3621 --- ada-lang.c.orig 2007-01-07 16:03:25.000000000 +0400 +++ ada-lang.c 2007-01-07 15:46:31.000000000 +0400 @@ -9042,65 +9042,44 @@ function_name_from_pc (CORE_ADDR pc) static int is_known_support_routine (struct frame_info *frame) { - struct frame_info *next_frame = get_next_frame (frame); - /* If frame is not innermost, that normally means that frame->pc - points to *after* the call instruction, and we want to get the line - containing the call, never the next line. But if the next frame is - a signal_handler_caller or a dummy frame, then the next frame was - not entered as the result of a call, and we want to get the line - containing frame->pc. */ - const int pc_is_after_call = - next_frame != NULL - && get_frame_type (next_frame) != SIGTRAMP_FRAME - && get_frame_type (next_frame) != DUMMY_FRAME; - struct symtab_and_line sal - = find_pc_line (get_frame_pc (frame), pc_is_after_call); + struct symtab_and_line sal; char *func_name; int i; - /* The heuristic: - 1. The symtab is null (indicating no debugging symbols) - 2. The symtab's filename does not exist. - 3. The object file's name is one of the standard libraries. - 4. The symtab's file name has the form of an Ada library source file. - 5. The function at frame's PC has a GNAT-compiler-generated name. */ + /* If this code does not have any debugging information (no symtab), + This cannot be any user code. */ + find_frame_sal (frame, &sal); if (sal.symtab == NULL) return 1; - /* On some systems (e.g. VxWorks), the kernel contains debugging - symbols; in this case, the filename referenced by these symbols - does not exists. */ + /* If there is a symtab, but the associated source file cannot be + located, then assume this is not user code: Selecting a frame + for which we cannot display the code would not be very helpful + for the user. This should also take care of case such as VxWorks + where the kernel has some debugging info provided for a few units. */ if (symtab_to_fullname (sal.symtab) == NULL) return 1; + /* Check the unit filename againt the Ada runtime file naming. + We also check the name of the objfile against the name of some + known system libraries that sometimes come with debugging info + too. */ + for (i = 0; known_runtime_file_name_patterns[i] != NULL; i += 1) { re_comp (known_runtime_file_name_patterns[i]); if (re_exec (sal.symtab->filename)) return 1; - } - if (sal.symtab->objfile != NULL) - { - for (i = 0; known_runtime_file_name_patterns[i] != NULL; i += 1) - { - re_comp (known_runtime_file_name_patterns[i]); - if (re_exec (sal.symtab->objfile->name)) - return 1; - } + if (sal.symtab->objfile != NULL + && re_exec (sal.symtab->objfile->name)) + return 1; } - /* If the frame PC points after the call instruction, then we need to - decrement it in order to search for the function associated to this - PC. Otherwise, if the associated call was the last instruction of - the function, we might either find the wrong function or even fail - during the function name lookup. */ - if (pc_is_after_call) - func_name = function_name_from_pc (get_frame_pc (frame) - 1); - else - func_name = function_name_from_pc (get_frame_pc (frame)); + /* Check whether the function is a GNAT-generated entity. */ + func_name = function_name_from_pc (get_frame_address_in_block (frame)); if (func_name == NULL) return 1; --qMm9M+Fa2AknHoGS--