import gdb-1999-11-08 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / condbreak.exp
index ae0858bf52bcf2e76dcf155f1ada321390858d09..e73f2ab14295271e5f376788d8e8900fc82f2c59 100644 (file)
@@ -143,8 +143,58 @@ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.
 #
 # run until the breakpoint at marker1
 #
-gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*" \
-                       "run until breakpoint at marker1"
+# If the inferior stops at the first instruction of a source line, GDB
+# won't print the actual PC value; the source line is enough to
+# exactly specify the PC.  But if the inferior is instead stopped in
+# the midst of a source line, GDB will include the PC in the
+# breakpoint hit message.  This way, GDB always provides the exact
+# stop location, but avoids clutter when possible.
+#
+# Suppose you have a function written completely on one source line, like:
+#    int foo (int x) { return 0; }
+# Setting a breakpoint at `foo' actually places the breakpoint after
+# foo's prologue.
+#
+# GCC's STABS writer always emits a line entry attributing the
+# prologue instructions to the line containing the function's open
+# brace, even if the first user instruction is also on that line.
+# This means that, in the case of a one-line function, you will get
+# two line entries in the debug info for the same line: one at the
+# function's entry point, and another at the first user instruction.
+# GDB preserves these duplicated line entries, and prefers the later
+# one; thus, when the program stops after the prologue, at the first
+# user instruction, GDB's search finds the second line entry, decides
+# that the PC is indeed at the beginning of a source line, and doesn't
+# print an address in the breakpoint hit message.
+# 
+# GCC's Dwarf2 writer, on the other hand, squeezes out duplicate line
+# entries, so GDB considers the source line to begin at the start of
+# the function's prologue.  Thus, if the program stops at the
+# breakpoint, GDB will decide that the PC is not at the beginning of a
+# source line, and will print an address.
+#
+# I think the Dwarf2 writer's behavior is arguably correct, but not
+# helpful.  If the user sets a breakpoint at that source line, they
+# want that breakpoint to fall after the prologue.  Identifying the
+# prologue's code with the opening brace is nice, but it shouldn't
+# take precedence over real code.
+#
+# Until the Dwarf2 writer gets fixed, I'm going to XFAIL its behavior.
+send_gdb "continue\n"
+gdb_expect {
+    -re  "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*" {
+       pass "run until breakpoint at marker1"
+    }
+    -re  "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*" {
+       xfail "run until breakpoint at marker1"
+    }
+    -re "$gdb_prompt $" {
+       fail "run until breakpoint at marker1"
+    }
+    timeout {
+       fail "(timeout) run until breakpoint at marker1"
+    }
+}
 
 #
 # run until the breakpoint at marker2
This page took 0.034173 seconds and 4 git commands to generate.