This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] prologue-single-line-func.exp


Hi.

This is a new testcase I wrote while debugging pr 17276.
It's standalone so I'm submitting it separately.

It tests whether gdb probably handles skipping passed the prologue
in a function that appears on a single line.
gcc still emits two line number entries for such functions,
one at the first instruction and one at the end of the prologue.

I tried to find an existing test for this, as I figured there
should be one.  Alas I couldn't find one.
If it turns out there is indeed an existing test,
I'd suggest either replacing it with this or making it easier to find. :-)

2014-08-15  Doug Evans  <dje@google.com>

	* gdb.base/prologue-single-line-func.exp: New file.
	* gdb.base/prologue-single-line-func.c: New file.

diff --git a/gdb/testsuite/gdb.base/prologue-single-line-func.c b/gdb/testsuite/gdb.base/prologue-single-line-func.c
new file mode 100644
index 0000000..4648112
--- /dev/null
+++ b/gdb/testsuite/gdb.base/prologue-single-line-func.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2014 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/>.  */
+
+int single_line_func (int x) { return x + 1; }
+
+int
+main (void)
+{
+  return single_line_func (-1);
+}
diff --git a/gdb/testsuite/gdb.base/prologue-single-line-func.exp b/gdb/testsuite/gdb.base/prologue-single-line-func.exp
new file mode 100644
index 0000000..e8f6b75
--- /dev/null
+++ b/gdb/testsuite/gdb.base/prologue-single-line-func.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 2014 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/>.
+
+standard_testfile
+
+if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+    return -1
+}
+
+if ![runto_main] {
+    fail "Cannot run to main."
+    continue
+}
+
+gdb_test "break single_line_func" \
+    "Breakpoint.*at.* file .*, line.*" \
+    "breakpoint on single line function"
+
+gdb_continue_to_breakpoint "single_line_func"
+
+# Verify we can read function arguments in the single line function,
+# and thus either that we properly skipped passed the prologue,
+# or that the debug info uses location lists for the arguments.
+gdb_test "p x" " = -1"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]