From patchwork Tue Aug 26 21:33:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 2544 Received: (qmail 21832 invoked by alias); 26 Aug 2014 21:34:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 21814 invoked by uid 89); 26 Aug 2014 21:34:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ob0-f201.google.com Received: from mail-ob0-f201.google.com (HELO mail-ob0-f201.google.com) (209.85.214.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 26 Aug 2014 21:34:00 +0000 Received: by mail-ob0-f201.google.com with SMTP id va2so2467528obc.0 for ; Tue, 26 Aug 2014 14:33:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type; bh=i8mXknnGSoP5XOgKJbUrussMlW2Swll7Z9yOZPktVgg=; b=RXlA0XFkgq9eBghKvwBXF1WpxDn1gnymcMs6o3HeaQ0R2/YJXtL0XcwRJsdLXtcFPf gJBppHgWn2KkRZfOqFNL/cAJzPmqSKq7aNlGPVz/RMuB2v6zeO+NGmfdp2b6PkvrwchB l3WZzEcAmc83gpAuzBrGEEwZuyW3xemdvjvGTYZ9RxhyozbEH7xyftIPyAr92+9olRRL QHLjH5WsR3x1UcpxhiiEAOSCbNjQbPy7loKX0Q3vgteCpveeg8aXZw17p86FNmbuaJss y/YuiqNRkVzu1HijjZXQdEpkD3ygG72cUrdegYmbtLD1RZZEd376lVvIpSFqnuYpp8CP vd+A== X-Gm-Message-State: ALoCoQn1nIJh8mS+UOM68xdUkWiPweJDfb+cQueXtAdwxs/Z0OBBlkV/DBZqVENlqUAEhXqCweVSroAs3sssk5lGcZQa934vtkGpxXVirK4EjHPZiUwwjRSboZxmGFsAwvpKehUl1IXJ X-Received: by 10.182.251.135 with SMTP id zk7mr19756534obc.14.1409088838923; Tue, 26 Aug 2014 14:33:58 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id c77si294417yha.5.2014.08.26.14.33.58 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Aug 2014 14:33:58 -0700 (PDT) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTPS id 8D0E231C42C for ; Tue, 26 Aug 2014 14:33:58 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH 1/2] symtab.c cleanup Date: Tue, 26 Aug 2014 14:33:57 -0700 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. While fixing some clang-related failures in assembler-based tests (*-tdep.c clang support has the same bug in three places - time for some consolidation) I ran across this in symtab.c. This part of symtab.c has a bunch of find_* functions (find_line_pc, find_line_pc_range, etc.) followed by a bunch of prologue related functions (skip_prologue_using_lineinfo, skip_prologue_sal, etc.). This patch moves find_function_start_sal into the find_* set of functions. 2014-08-26 Doug Evans * symtab.c (find_function_start_sal): Move definition to better spot. diff --git a/gdb/symtab.c b/gdb/symtab.c index ab56892..c530d50 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2787,6 +2787,38 @@ find_pc_line_pc_range (CORE_ADDR pc, CORE_ADDR *startptr, CORE_ADDR *endptr) return sal.symtab != 0; } +/* Given a function symbol SYM, find the symtab and line for the start + of the function. + If the argument FUNFIRSTLINE is nonzero, we want the first line + of real code inside the function. */ + +struct symtab_and_line +find_function_start_sal (struct symbol *sym, int funfirstline) +{ + struct symtab_and_line sal; + + fixup_symbol_section (sym, NULL); + sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), + SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym), 0); + + /* We always should have a line for the function start address. + If we don't, something is odd. Create a plain SAL refering + just the PC and hope that skip_prologue_sal (if requested) + can find a line number for after the prologue. */ + if (sal.pc < BLOCK_START (SYMBOL_BLOCK_VALUE (sym))) + { + init_sal (&sal); + sal.pspace = current_program_space; + sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); + sal.section = SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym); + } + + if (funfirstline) + skip_prologue_sal (&sal); + + return sal; +} + /* Given a function start address FUNC_ADDR and SYMTAB, find the first address for that function that has an entry in SYMTAB's line info table. If such an entry cannot be found, return FUNC_ADDR @@ -2827,38 +2859,6 @@ skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab) return func_addr; } -/* Given a function symbol SYM, find the symtab and line for the start - of the function. - If the argument FUNFIRSTLINE is nonzero, we want the first line - of real code inside the function. */ - -struct symtab_and_line -find_function_start_sal (struct symbol *sym, int funfirstline) -{ - struct symtab_and_line sal; - - fixup_symbol_section (sym, NULL); - sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), - SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym), 0); - - /* We always should have a line for the function start address. - If we don't, something is odd. Create a plain SAL refering - just the PC and hope that skip_prologue_sal (if requested) - can find a line number for after the prologue. */ - if (sal.pc < BLOCK_START (SYMBOL_BLOCK_VALUE (sym))) - { - init_sal (&sal); - sal.pspace = current_program_space; - sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); - sal.section = SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym); - } - - if (funfirstline) - skip_prologue_sal (&sal); - - return sal; -} - /* Adjust SAL to the first instruction past the function prologue. If the PC was explicitly specified, the SAL is not changed. If the line number was explicitly specified, at most the SAL's PC