Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: [RFA/commit/testcase] "info line" should not skip prologues (was: "Re: GDB 7.4 branching status? (2011-11-23)")
Date: Tue, 29 Nov 2011 03:19:00 -0000	[thread overview]
Message-ID: <20111129031915.GP24943@adacore.com> (raw)
In-Reply-To: <m31ussq6o2.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]

This is an issue that I discovered in your previous set of patches, but
got fixed in this iteration :-). Nonetheless, I wrote a testcase,
so I'm sending it here.  I think I should commit it independenly
of your series.

I had described the problem as follow:

>     The "info line" command skips function prologues, but it shouldn't.
>     Consider for instance the new testcase provided with this patch.
>     The code looks like this:
>     
>         17
>         18  int twice (int i) { /* THIS LINE */
>         19    /* We purposefully put the return type, function prototype and
>         20       opening curly brace on the same line, in an effort to make sure
>         21       that the function prologue would be associated to that line.  */
>         22    return 2 * i;
>         23  }
>     
>     Without this patch, GDB would report the following address range
>     for line 18:
>     
>         (gdb) info line 18
>         Line 18 of "[...]/infoline.c" is at address 0x40049b <twice+7>
>             but contains no code.
>     
>     The indicator that the prologue was skipped comes from the fact that
>     the address chosen is at twice+7, not twice+0.

-- 
Joel

[-- Attachment #2: 0003-decode_all_digits-Skip-prologue-only-if-self-funfirs.patch --]
[-- Type: text/x-diff, Size: 3376 bytes --]

From c21988ba1e257d0f20f2bdaf9677b867bfa0aeb0 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Fri, 25 Nov 2011 11:42:26 -0800
Subject: info line should not skip function prologues.

gdb/testsuite/ChangeLog:

        * gdb.base/infoline.c, gdb.base/infoline.exp: New files.
---
 gdb/testsuite/gdb.base/infoline.c   |   30 ++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/infoline.exp |   30 ++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/infoline.c
 create mode 100644 gdb/testsuite/gdb.base/infoline.exp

diff --git a/gdb/testsuite/gdb.base/infoline.c b/gdb/testsuite/gdb.base/infoline.c
new file mode 100644
index 0000000..7b0da2b
--- /dev/null
+++ b/gdb/testsuite/gdb.base/infoline.c
@@ -0,0 +1,30 @@
+/* Copyright 2011 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int twice (int i) { /* THIS LINE */
+  /* We purposefully put the return type, function prototype and
+     opening curly brace on the same line, in an effort to make sure
+     that the function prologue would be associated to that line.  */
+  return 2 * i;
+}
+
+int
+main (void)
+{
+  int t = twice (1);
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/infoline.exp b/gdb/testsuite/gdb.base/infoline.exp
new file mode 100644
index 0000000..41ff894
--- /dev/null
+++ b/gdb/testsuite/gdb.base/infoline.exp
@@ -0,0 +1,30 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set testfile infoline
+set srcfile ${testfile}.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+    return -1
+}
+
+clean_restart ${testfile}
+
+# Verify that the "info line" command does not skip function prologues.
+# If it did, GDB would tell us that the line we're interested in starts
+# at <twice+N> where N is different from zero.
+set fun_decl_line [gdb_get_line_number "THIS LINE"]
+gdb_test "info line ${srcfile}:${fun_decl_line}" \
+         "Line ${fun_decl_line} of \".*${testfile}\.c\" starts at address 0x\[0-9a-f\]+ <twice> and ends at .*"
-- 
1.7.1


  parent reply	other threads:[~2011-11-29  3:19 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23 16:39 GDB 7.4 branching status? (2011-11-23) Joel Brobecker
2011-11-23 16:56 ` Tristan Gingold
2011-11-23 18:47 ` Tom Tromey
2011-11-23 23:24   ` Joel Brobecker
2011-11-24 10:56     ` Jerome Guitton
2011-11-24 16:33       ` Joel Brobecker
2011-11-28 16:17         ` Tom Tromey
2011-11-28 21:29         ` Tom Tromey
2011-11-29  2:28           ` Joel Brobecker
2011-11-29  2:49           ` iterate_over_symbols should be a wrapper? (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 15:27             ` iterate_over_symbols should be a wrapper? Tom Tromey
2011-11-29  3:07           ` partial-symtab symbol sorting (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29  8:41             ` Pierre Muller
2011-11-29 14:51             ` partial-symtab symbol sorting Tom Tromey
     [not found]             ` <47228.5772244961$1322556128@news.gmane.org>
2011-11-29 14:55               ` Tom Tromey
2011-11-29  3:11           ` multiple-location breakpoint output (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 15:06             ` multiple-location breakpoint output Tom Tromey
2011-11-29  3:14           ` decode_digits_line_mode (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 14:56             ` decode_digits_line_mode Tom Tromey
2011-11-29  3:19           ` Joel Brobecker [this message]
2011-11-29 15:03             ` [RFA/commit/testcase] "info line" should not skip prologues Tom Tromey
2011-11-29 17:00               ` Joel Brobecker
2011-11-29  3:22           ` GDB 7.4 branching status? (2011-11-23) Joel Brobecker
2011-11-29 15:38             ` Tom Tromey
2011-11-29  3:29           ` set multiple-symbol ask/cancel not working (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 16:14             ` set multiple-symbol ask/cancel not working Tom Tromey
2011-11-29 16:57               ` Tom Tromey
2011-11-29 17:06                 ` Joel Brobecker
2011-11-30 16:41                   ` Tom Tromey
2011-11-29  3:33           ` one-too-many location in breakpoint (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 16:15             ` one-too-many location in breakpoint Tom Tromey
2011-11-29 16:59               ` Tom Tromey
2011-11-30  5:59                 ` Joel Brobecker
2011-11-30 16:41                   ` Tom Tromey
2011-12-05 12:04                 ` Pedro Alves
2011-12-05 12:17                   ` Pedro Alves
2011-12-08 18:56                 ` Maciej W. Rozycki
2011-12-09  8:47                   ` Joel Brobecker
2011-11-24  0:58 ` GDB 7.4 branching status? (2011-11-23) Yao Qi
2011-11-24 17:17 ` Maciej W. Rozycki
2011-11-24 17:27   ` Joel Brobecker
2011-12-03  1:19     ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111129031915.GP24943@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox