aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.trace
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2010-03-26 01:46:29 +0000
committerStan Shebs <shebs@codesourcery.com>2010-03-26 01:46:29 +0000
commit6c28cbf2b6beb56c99ec084b9bc5adc8d4813894 (patch)
tree1a4837c78b049a3c055de85cba991b2030200ee1 /gdb/testsuite/gdb.trace
parenta45fc99392bdce4c67b43b1a0a05c77e7112afab (diff)
downloadgdb-6c28cbf2b6beb56c99ec084b9bc5adc8d4813894.zip
gdb-6c28cbf2b6beb56c99ec084b9bc5adc8d4813894.tar.gz
gdb-6c28cbf2b6beb56c99ec084b9bc5adc8d4813894.tar.bz2
2010-03-25 Stan Shebs <stan@codesourcery.com>
* tracepoint.h (trace_stop_reason): Add tracepoint_error. (struct trace_status): New field error_desc. * tracepoint.c (stop_reason_names): Add terror. (current_trace_status): Ensure non-NULL error description. (trace_status_command): Add error report. (trace_status_mi): Ditto. (trace_save): Add special case for error description. (parse_trace_status): Add case for errors. * gdb.texinfo (Tracepoint Packets): Document trace error status. * gdb.trace/tfile.c: Generate an additional trace file, improve portability. * gdb.trace/tfile.exp: Test trace file with an error stop, delete files in a better way.
Diffstat (limited to 'gdb/testsuite/gdb.trace')
-rw-r--r--gdb/testsuite/gdb.trace/tfile.c80
-rw-r--r--gdb/testsuite/gdb.trace/tfile.exp15
2 files changed, 79 insertions, 16 deletions
diff --git a/gdb/testsuite/gdb.trace/tfile.c b/gdb/testsuite/gdb.trace/tfile.c
index 9ffc371..5d4c797 100644
--- a/gdb/testsuite/gdb.trace/tfile.c
+++ b/gdb/testsuite/gdb.trace/tfile.c
@@ -41,9 +41,11 @@ finish_trace_file (int fd)
}
void
-write_basic_trace_file ()
+write_basic_trace_file (void)
{
- int fd;
+ int fd, int_x;
+ short short_x;
+ long long ll_x;
fd = start_trace_file ("basic.tf");
@@ -61,6 +63,7 @@ write_basic_trace_file ()
/* Dump tracepoint definitions, in syntax similar to that used
for reconnection uploads. */
+ /* FIXME need a portable way to print function address in hex */
snprintf (spbuf, sizeof spbuf, "tp T1:%lx:E:0:0\n",
(long) &write_basic_trace_file);
write (fd, spbuf, strlen (spbuf));
@@ -71,28 +74,73 @@ write_basic_trace_file ()
write (fd, "\n", 1);
/* Make up a simulated trace buffer. */
- /* (Encapsulate better if we're going to do lots of this.) */
+ /* (Encapsulate better if we're going to do lots of this; note that
+ buffer endianness is the target program's enddianness.) */
trptr = trbuf;
- *((short *) trptr) = 1;
- trptr += sizeof (short);
+ short_x = 1;
+ memcpy (trptr, &short_x, 2);
+ trptr += 2;
tfsizeptr = trptr;
- trptr += sizeof (int);
+ trptr += 4;
*((char *) trptr) = 'M';
trptr += 1;
- *((long long *) trptr) = (long) &testglob;
+ ll_x = (long) &testglob;
+ memcpy (trptr, &ll_x, sizeof (long long));
trptr += sizeof (long long);
- *((short *) trptr) = sizeof (testglob);
- trptr += sizeof (short);
- *((int *) trptr) = testglob;
+ short_x = sizeof (testglob);
+ memcpy (trptr, &short_x, 2);
+ trptr += 2;
+ memcpy (trptr, &testglob, sizeof (testglob));
trptr += sizeof (testglob);
/* Go back and patch in the frame size. */
- *((int *) tfsizeptr) = trptr - tfsizeptr - sizeof (int);
+ int_x = trptr - tfsizeptr - sizeof (int);
+ memcpy (tfsizeptr, &int_x, 4);
+
+ /* Write end of tracebuffer marker. */
+ memset (trptr, 0, 6);
+ trptr += 6;
+
+ write (fd, trbuf, trptr - trbuf);
+
+ finish_trace_file (fd);
+}
+
+void
+write_error_trace_file (void)
+{
+ int fd;
+
+ fd = start_trace_file ("error.tf");
+
+ /* The next part of the file consists of newline-separated lines
+ defining status, tracepoints, etc. The section is terminated by
+ an empty line. */
+
+ /* Dump the size of the R (register) blocks in traceframes. */
+ snprintf (spbuf, sizeof spbuf, "R %x\n", 500 /* FIXME get from arch */);
+ write (fd, spbuf, strlen (spbuf));
+
+ /* Dump trace status, in the general form of the qTstatus reply. */
+ snprintf (spbuf, sizeof spbuf, "status 0;terror:made-up error:1;tframes:0;tcreated:0;tfree:100;tsize:1000\n");
+ write (fd, spbuf, strlen (spbuf));
+
+ /* Dump tracepoint definitions, in syntax similar to that used
+ for reconnection uploads. */
+ /* FIXME need a portable way to print function address in hex */
+ snprintf (spbuf, sizeof spbuf, "tp T1:%lx:E:0:0\n",
+ (long) &write_basic_trace_file);
+ write (fd, spbuf, strlen (spbuf));
+ /* (Note that we would only need actions defined if we wanted to
+ test tdump.) */
+
+ /* Empty line marks the end of the definition section. */
+ write (fd, "\n", 1);
+
+ trptr = trbuf;
/* Write end of tracebuffer marker. */
- *((short *) trptr) = 0;
- trptr += sizeof (short);
- *((int *) trptr) = 0;
- trptr += sizeof (int);
+ memset (trptr, 0, 6);
+ trptr += 6;
write (fd, trbuf, trptr - trbuf);
@@ -109,6 +157,8 @@ main (int argc, char **argv, char **envp)
{
write_basic_trace_file ();
+ write_error_trace_file ();
+
done_making_trace_files ();
return 0;
diff --git a/gdb/testsuite/gdb.trace/tfile.exp b/gdb/testsuite/gdb.trace/tfile.exp
index 20af854..a3adfcc 100644
--- a/gdb/testsuite/gdb.trace/tfile.exp
+++ b/gdb/testsuite/gdb.trace/tfile.exp
@@ -47,7 +47,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
gdb_reinitialize_dir $srcdir/$subdir
# Make sure we are starting fresh.
-remote_exec build {sh -xc rm\ -f\ basic.tf}
+remote_file host delete basic.tf
+remote_file host delete error.tf
gdb_load $binfile
@@ -83,7 +84,19 @@ Trace buffer has 256 bytes of 4096 bytes free \\(93% full\\).*
Looking at trace frame 0, tracepoint .*" \
"tstatus on trace file"
+# Now start afresh, using only a trace file.
+gdb_exit
+gdb_start
+gdb_load $binfile
+gdb_test "target tfile error.tf" "Created tracepoint.*" "target tfile"
+gdb_test "tstatus" \
+ "Using a trace file.*
+Trace stopped by an error \\(made-up error, tracepoint 1\\).*
+Collected 0 trace frame.*
+Trace buffer has 256 bytes of 4096 bytes free \\(93% full\\).*
+Not looking at any trace frame.*" \
+ "tstatus on error trace file"