From patchwork Wed Sep 3 00:15:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 2633 Received: (qmail 21621 invoked by alias); 3 Sep 2014 00:15:22 -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 21609 invoked by uid 89); 3 Sep 2014 00:15:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f202.google.com Received: from mail-qc0-f202.google.com (HELO mail-qc0-f202.google.com) (209.85.216.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 03 Sep 2014 00:15:20 +0000 Received: by mail-qc0-f202.google.com with SMTP id r5so878203qcx.3 for ; Tue, 02 Sep 2014 17:15:18 -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=+Eyw/JPjzJ/96aTeVH82hFydR2Mr51uOWpQCOvk1GCA=; b=dSVu8l9iJkfXQ8FwnCs5yuWT5NgdFAfwvPBsQpN/GWuil0/4suOhoJMM2/tS1ig9LS 0FvSD2xmS2HInuE888jerzr+6XNnmACZ5DGBLsscV4zA+leFUVLXzrXJyEvRgt8tzBm/ ZvVz9jIOR4QwWJaHSQRok+Rkbs91khlmY0SpLg+KA63MTKMnDPF80qg6/2OzQ5NICX1v 1SkeM5fcSFJxjkpXX6Cc5Pw3DaX3n74G7NYCqWqSZCdIFK3HnvATstTEb+KmrOXz28CU rjM58Go1mwuJKw8Agk1J9KGQq0HYQulmcmzrOrQyh4kB6g0zQRof8061ht7VWSG77MGL wraQ== X-Gm-Message-State: ALoCoQnv1IWF0KEalOtdhcjXyjmUCjf4xbNSC5CEX5VIaDwZ7ILQasc4qw4Ym7RxYqDEnA69dBADmYCKAqyJPrZKiB38Yf0g5OeHaReyt9YQucWfdeOSpBW9Oulp+2rBxuS2qIymbkzxxSeThjVrUI6rZ07D+kZHjWPkZwaFzMIs8wDhmIwEt6M= X-Received: by 10.236.87.46 with SMTP id x34mr2953565yhe.49.1409703318773; Tue, 02 Sep 2014 17:15:18 -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 e55si742507yhb.3.2014.09.02.17.15.18 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Sep 2014 17:15:18 -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 63B0531CE01 for ; Tue, 2 Sep 2014 17:15:18 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH] skip_prologue_using_sal: early exit if assembler Date: Tue, 02 Sep 2014 17:15:17 -0700 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. This patch is part of the discussion I started here: https://sourceware.org/ml/gdb-patches/2014-08/msg00539.html The prologue parsing aspect of that discussion is submitted as a patch here: https://sourceware.org/ml/gdb-patches/2014-09/msg00079.html This patch fixes a few failures when tested with clang, e.g. amd64-disp-step.exp. There's no point in trying to use source line info to parse prologues in assembler code. Regression tested on amd64, i386, aarch64, ppc64 [all linux]. Note: Most of the patch is due to re-indentation. 2014-09-02 Doug Evans * symtab.c (skip_prologue_using_sal): Return zero if called for assembler code. diff --git a/gdb/symtab.c b/gdb/symtab.c index c530d50..a2b051b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3139,27 +3139,33 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) prologue_sal = find_pc_line (start_pc, 0); if (prologue_sal.line != 0) { + struct linetable *linetable = LINETABLE (prologue_sal.symtab); + int idx = 0; + + /* If this is assembler just punt. + While the assembler code could be implementing a higher level + language and thus could have a logical prologue, we can't really + know what is prologue and what is not using sals (short of using + something like DWARF's DW_LNS_set_prologue_end). */ + if (prologue_sal.symtab->language == language_asm) + return 0; + /* For languages other than assembly, treat two consecutive line entries at the same address as a zero-instruction prologue. The GNU assembler emits separate line notes for each instruction in a multi-instruction macro, but compilers generally will not do this. */ - if (prologue_sal.symtab->language != language_asm) - { - struct linetable *linetable = LINETABLE (prologue_sal.symtab); - int idx = 0; - - /* Skip any earlier lines, and any end-of-sequence marker - from a previous function. */ - while (linetable->item[idx].pc != prologue_sal.pc - || linetable->item[idx].line == 0) - idx++; - - if (idx+1 < linetable->nitems - && linetable->item[idx+1].line != 0 - && linetable->item[idx+1].pc == start_pc) - return start_pc; - } + + /* Skip any earlier lines, and any end-of-sequence marker + from a previous function. */ + while (linetable->item[idx].pc != prologue_sal.pc + || linetable->item[idx].line == 0) + idx++; + + if (idx+1 < linetable->nitems + && linetable->item[idx+1].line != 0 + && linetable->item[idx+1].pc == start_pc) + return start_pc; /* If there is only one sal that covers the entire function, then it is probably a single line function, like