This forces all tests that rely on stdio to be unbuffered, like
interrupt.exp was adjusted in
6f98576f.
To recap, in some scenarios, GDB or GDBserver can be spawned with
input _not_ connected to a tty, and then tests that rely on stdio fail
with timeouts, because the inferior's stdout and stderr streams end up
fully buffered. Calling gdb_unbuffer_output forces output to be
unbuffered.
See https://sourceware.org/ml/gdb-patches/2015-02/msg00809.html and
https://sourceware.org/ml/gdb-patches/2015-02/msg00819.html.
Tested on x86_64 Fedora 20, native, and against a remote gdbserver
board file that connects to the target with ssh, with and without -t
(create pty).
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/call-ar-st.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-rt-st.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-strs.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-strs.exp: Adjust to step over the
gdb_unbuffer_output call.
* gdb.base/catch-gdb-caused-signals.c: Include
"../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/dprintf.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/ending-run.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/run.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/shlib-call.exp: Adjust to step over the
gdb_unbuffer_output call.
* gdb.base/shmain.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/sizeof.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/varargs.c: Include "../lib/unbuffer_output.c".
(main): Rename to ...
(test): ... this.
(main): Reimplement.
* gdb.base/varargs.exp: Run to test instead of to main.
* gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
+2015-07-29 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/call-ar-st.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/call-rt-st.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/call-strs.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/call-strs.exp: Adjust to step over the
+ gdb_unbuffer_output call.
+ * gdb.base/catch-gdb-caused-signals.c: Include
+ "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/dprintf.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/ending-run.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/run.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/shlib-call.exp: Adjust to step over the
+ gdb_unbuffer_output call.
+ * gdb.base/shmain.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/sizeof.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+ * gdb.base/varargs.c: Include "../lib/unbuffer_output.c".
+ (main): Rename to ...
+ (test): ... this.
+ (main): Reimplement.
+ * gdb.base/varargs.exp: Run to test instead of to main.
+ * gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-dprintf.exp (mi_expect_dprintf): New procedure,
#include <stdlib.h>
#include <string.h>
+#include "../lib/unbuffer_output.c"
+
/**************************************************************************
* TESTS :
* -- function arguments that are enumerated types
static struct two_floats_t *f2;
static struct two_floats_t *f3;
+ gdb_unbuffer_output ();
+
/* Initialize arrays
*/
for (index = 0; index < 120; index++) {
#include <stdlib.h>
#include <string.h>
+#include "../lib/unbuffer_output.c"
+
/**************************************************************************
* TESTS :
* function returning large structures, which go on the stack
struct one_double_t *d1;
struct two_floats_t *f3;
+ gdb_unbuffer_output ();
/* Allocate space for large structures
*/
#include <stdlib.h>
#include <string.h>
+#include "../lib/unbuffer_output.c"
+
char buf[100];
char bigbuf[1000];
char * s;
int main()
{
+ gdb_unbuffer_output ();
+
s = &buf[0];
strcpy(buf, "test string");
str_func("abcd", "efgh", "ijkl", "mnop", "qrst", "uvwx", "yz12");
set prev_timeout $timeout
set timeout 120
-#step
-gdb_test "step" \
+gdb_test "next 2" \
"strcpy\\(buf, \"test string\"\\);" \
"step after assignment to s"
#include <unistd.h>
#include <stdio.h>
+#include "../lib/unbuffer_output.c"
+
int
main (void)
{
int i = 0;
+ gdb_unbuffer_output ();
+
i++; /* set dprintf here */
return 0; /* set breakpoint here */
}
#include <stdio.h>
+#include "../lib/unbuffer_output.c"
+
static int g;
void
{
int loc = 1234;
+ gdb_unbuffer_output ();
+
/* Ensure these functions are available. */
printf ("kickoff %d\n", loc);
fprintf (stderr, "also to stderr %d\n", loc);
#include <stdio.h>
#include <stdlib.h>
+#include "../lib/unbuffer_output.c"
+
int callee (int x)
{
int y = x * x; /* -break1- */
int *p;
int i;
+ gdb_unbuffer_output ();
+
p = (int *) malloc( 4 );
for (i = 1; i < 10; i++)
#include <stdio.h>
#include <stdlib.h>
+#include "../lib/unbuffer_output.c"
+
int factorial (int);
int
main (int argc, char **argv, char **envp)
{
+ gdb_unbuffer_output ();
+
#ifdef FAKEARGV
printf ("%d\n", factorial (1)); /* commands.exp: hw local_var out of scope */
#else
#step -over
-gdb_test "next" "g = shr1\\(g\\);" "next to shr1"
+gdb_test "next 2" "g = shr1\\(g\\);" "next to shr1"
#print g
#include "ss.h"
#include <stdio.h>
+#include "../lib/unbuffer_output.c"
+
extern int structarg(struct s);
extern int pstructarg(struct s*);
extern int shr1(int);
int main()
{
struct s y;
+
+ gdb_unbuffer_output ();
+
g = 1;
g = shr1(g);
g = shr2(g);
#include <stdio.h>
+#include "../lib/unbuffer_output.c"
+
typedef char padding[16];
struct {
int
main ()
{
+ gdb_unbuffer_output ();
+
fill_structs ();
printf ("sizeof (char) == %d\n", (int) sizeof (char));
# Query GDB for the size of various types
#
-gdb_test "next"
+gdb_test "next 2"
set sizeof_char [get_sizeof "char" 1]
set sizeof_short [get_sizeof "short" 2]
#include <stdio.h>
#include <stdarg.h>
+#include "../lib/unbuffer_output.c"
+
int find_max1(int, ...);
int find_max2(int, int, ...);
double find_max_double(int, double, ...);
#endif
-int main() {
+int
+test (void)
+{
c = -1;
uc = 1;
s = -2;
return 0;
}
+int
+main (void)
+{
+ gdb_unbuffer_output ();
+ test ();
+}
+
/* Integer varargs, 1 declared arg */
int find_max1(int num_vals, ...) {
return
}
-if ![runto_main] then {
+if ![runto test] then {
perror "couldn't run to breakpoint"
continue
}
#include <stdio.h>
#include <stdlib.h>
+#include "../lib/unbuffer_output.c"
+
static int g;
void
{
int loc = 1234;
+ gdb_unbuffer_output ();
+
/* Ensure these functions are available. */
printf ("kickoff %d\n", loc);
fprintf (stderr, "also to stderr %d\n", loc);